| @@ 10-52 (lines=43) @@ | ||
| 7 | use Sylius\Component\Resource\Factory\FactoryInterface; |
|
| 8 | use Webmozart\Assert\Assert; |
|
| 9 | ||
| 10 | final class RouteFactory implements FactoryInterface |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * @var FactoryInterface |
|
| 14 | */ |
|
| 15 | private $decoratedFactory; |
|
| 16 | ||
| 17 | /** |
|
| 18 | * @var ObjectManager |
|
| 19 | */ |
|
| 20 | private $documentManager; |
|
| 21 | ||
| 22 | /** |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | private $routeParentPath; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param FactoryInterface $decoratedFactory |
|
| 29 | * @param ObjectManager $documentManager |
|
| 30 | * @param array $routeParentsPaths |
|
| 31 | */ |
|
| 32 | public function __construct(FactoryInterface $decoratedFactory, ObjectManager $documentManager, $routeParentsPaths) |
|
| 33 | { |
|
| 34 | $this->decoratedFactory = $decoratedFactory; |
|
| 35 | $this->documentManager = $documentManager; |
|
| 36 | ||
| 37 | Assert::notEmpty($routeParentsPaths); |
|
| 38 | $this->routeParentPath = current($routeParentsPaths); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | public function createNew() |
|
| 45 | { |
|
| 46 | /** @var Route $route */ |
|
| 47 | $route = $this->decoratedFactory->createNew(); |
|
| 48 | $route->setParentDocument($this->documentManager->find(null, $this->routeParentPath)); |
|
| 49 | ||
| 50 | return $route; |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 9-49 (lines=41) @@ | ||
| 6 | use Lakion\SyliusCmsBundle\Document\StaticContent; |
|
| 7 | use Sylius\Component\Resource\Factory\FactoryInterface; |
|
| 8 | ||
| 9 | final class StaticContentFactory implements FactoryInterface |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var FactoryInterface |
|
| 13 | */ |
|
| 14 | private $decoratedFactory; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @var ObjectManager |
|
| 18 | */ |
|
| 19 | private $documentManager; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var string |
|
| 23 | */ |
|
| 24 | private $staticContentParentPath; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param FactoryInterface $decoratedFactory |
|
| 28 | * @param ObjectManager $documentManager |
|
| 29 | * @param string $staticContentParentPath |
|
| 30 | */ |
|
| 31 | public function __construct(FactoryInterface $decoratedFactory, ObjectManager $documentManager, $staticContentParentPath) |
|
| 32 | { |
|
| 33 | $this->decoratedFactory = $decoratedFactory; |
|
| 34 | $this->documentManager = $documentManager; |
|
| 35 | $this->staticContentParentPath = $staticContentParentPath; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * {@inheritdoc} |
|
| 40 | */ |
|
| 41 | public function createNew() |
|
| 42 | { |
|
| 43 | /** @var StaticContent $staticContent */ |
|
| 44 | $staticContent = $this->decoratedFactory->createNew(); |
|
| 45 | $staticContent->setParentDocument($this->documentManager->find(null, $this->staticContentParentPath)); |
|
| 46 | ||
| 47 | return $staticContent; |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| @@ 9-49 (lines=41) @@ | ||
| 6 | use Lakion\SyliusCmsBundle\Document\StringBlock; |
|
| 7 | use Sylius\Component\Resource\Factory\FactoryInterface; |
|
| 8 | ||
| 9 | final class StringBlockFactory implements FactoryInterface |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var FactoryInterface |
|
| 13 | */ |
|
| 14 | private $decoratedFactory; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * @var ObjectManager |
|
| 18 | */ |
|
| 19 | private $documentManager; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var string |
|
| 23 | */ |
|
| 24 | private $stringBlockParentPath; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param FactoryInterface $decoratedFactory |
|
| 28 | * @param ObjectManager $documentManager |
|
| 29 | * @param string $stringBlockParentPath |
|
| 30 | */ |
|
| 31 | public function __construct(FactoryInterface $decoratedFactory, ObjectManager $documentManager, $stringBlockParentPath) |
|
| 32 | { |
|
| 33 | $this->decoratedFactory = $decoratedFactory; |
|
| 34 | $this->documentManager = $documentManager; |
|
| 35 | $this->stringBlockParentPath = $stringBlockParentPath; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * {@inheritdoc} |
|
| 40 | */ |
|
| 41 | public function createNew() |
|
| 42 | { |
|
| 43 | /** @var StringBlock $stringBlock */ |
|
| 44 | $stringBlock = $this->decoratedFactory->createNew(); |
|
| 45 | $stringBlock->setParentDocument($this->documentManager->find(null, $this->stringBlockParentPath)); |
|
| 46 | ||
| 47 | return $stringBlock; |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||