| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 62.5% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | abstract class AbstractComponentFactory extends AbstractFactory |
||
| 10 | { |
||
| 11 | public const COMPONENT_OPS = [ |
||
| 12 | 'className' => null, |
||
| 13 | 'parentComponent' => null, |
||
| 14 | 'parentContent' => null, |
||
| 15 | 'componentGroup' => null, |
||
| 16 | 'dynamicPage' => null |
||
| 17 | ]; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param AbstractComponent $component |
||
| 21 | * @param array|null $ops |
||
| 22 | */ |
||
| 23 | 22 | protected function init($component, ?array $ops = null): void |
|
| 24 | { |
||
| 25 | 22 | parent::init($component, $ops); |
|
| 26 | if ( |
||
| 27 | 22 | $this->ops['parentContent'] && |
|
| 28 | 22 | !$component->hasParentContent($this->ops['parentContent']) |
|
| 29 | ) { |
||
| 30 | $location = new ComponentLocation($this->ops['parentContent'], $component); |
||
| 31 | $component->addLocation($location); |
||
| 32 | $this->manager->persist($location); |
||
| 33 | } |
||
| 34 | if ( |
||
| 35 | 22 | $this->ops['dynamicPage'] |
|
| 36 | ) { |
||
| 37 | $location = new ComponentLocation(null, $component); |
||
| 38 | $location->setDynamicPageClass($this->ops['dynamicPage']); |
||
| 39 | $this->manager->persist($location); |
||
| 40 | } |
||
| 41 | 22 | } |
|
| 42 | |||
| 43 | 18 | protected static function getIgnoreOps(): array |
|
| 48 | ]; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @inheritdoc |
||
| 53 | */ |
||
| 54 | 43 | protected static function defaultOps(): array |
|
| 57 | } |
||
| 58 | } |
||
| 59 |