Total Complexity | 3 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | class HasStatusModel extends MyActiveRecord |
||
16 | { |
||
17 | public $parentClassName; |
||
18 | public $parentIdColumn; |
||
19 | |||
20 | /** @var string */ |
||
21 | public $statusModelClass = StatusModel::class; |
||
22 | |||
23 | |||
24 | /** |
||
25 | * @throws InvalidConfigException |
||
26 | */ |
||
27 | public function init() |
||
28 | { |
||
29 | if (!$this->parentClassName) { |
||
30 | throw new InvalidConfigException('parentClassName must be set for ' . static::class); |
||
31 | } |
||
32 | |||
33 | /** @var MyActiveRecord $parent */ |
||
34 | $parent = new $this->parentClassName; |
||
35 | $this->parentIdColumn = $parent::primaryKey()[0]; |
||
36 | |||
37 | |||
38 | parent::init(); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @return StatusModel |
||
43 | */ |
||
44 | public function getStatusModel() |
||
49 | } |
||
50 | |||
51 | } |