Conditions | 4 |
Paths | 5 |
Total Lines | 22 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function run($id, $name) |
||
30 | { |
||
31 | /* @var $model \yii\db\ActiveRecord */ |
||
32 | $model = $this->findModel($id); |
||
33 | |||
34 | if (!$related = $model->getRelation($name, false)) { |
||
35 | throw new NotFoundHttpException('Relationship does not exist'); |
||
36 | } |
||
37 | |||
38 | if ($this->checkAccess) { |
||
39 | call_user_func($this->checkAccess, $this->id, $model, $name); |
||
40 | } |
||
41 | |||
42 | $relationship = new Relationship([ |
||
43 | 'multiple' => $related->multiple |
||
44 | ]); |
||
45 | |||
46 | if ($related->multiple) { |
||
47 | return $relationship->addRelated($related->all()); |
||
48 | } |
||
49 | |||
50 | return $relationship->addRelated($related->one()); |
||
51 | } |
||
52 | } |