diff --git a/config/documents.yaml b/config/documents.yaml index 9e073012..f198214c 100644 --- a/config/documents.yaml +++ b/config/documents.yaml @@ -27,4 +27,12 @@ services: # Pimcore\Bundle\StudioBackendBundle\Document\Repository\SiteRepositoryInterface: - class: Pimcore\Bundle\StudioBackendBundle\Document\Repository\SiteRepository \ No newline at end of file + class: Pimcore\Bundle\StudioBackendBundle\Document\Repository\SiteRepository + + + # + # Hydrators + # + + Pimcore\Bundle\StudioBackendBundle\Document\Hydrator\SiteHydratorInterface: + class: Pimcore\Bundle\StudioBackendBundle\Document\Hydrator\SiteHydrator \ No newline at end of file diff --git a/src/Class/Service/FieldCollection/LayoutDefinitionService.php b/src/Class/Service/FieldCollection/LayoutDefinitionService.php index 7aa5b9ad..be1907e4 100644 --- a/src/Class/Service/FieldCollection/LayoutDefinitionService.php +++ b/src/Class/Service/FieldCollection/LayoutDefinitionService.php @@ -21,7 +21,7 @@ use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\DataObjectResolverInterface; use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\FieldCollection\DefinitionResolverInterface; use Pimcore\Bundle\StudioBackendBundle\Class\Event\FieldCollection\LayoutDefinitionEvent; -use Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\FieldCollection\LayoutDefinitionHydratorInterface; +use Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\FieldCollection\SiteHydratorInterface; use Pimcore\Bundle\StudioBackendBundle\Class\Schema\LayoutDefinition; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; use Pimcore\Model\DataObject; @@ -34,11 +34,11 @@ final class LayoutDefinitionService implements LayoutDefinitionServiceInterface { public function __construct( - private readonly DataObjectResolverInterface $dataObjectResolver, + private readonly DataObjectResolverInterface $dataObjectResolver, private readonly ClassDefinitionResolverInterface $classDefinitionResolver, - private readonly DefinitionResolverInterface $definitionResolver, - private readonly LayoutDefinitionHydratorInterface $layoutDefinitionHydrator, - private readonly EventDispatcherInterface $eventDispatcher, + private readonly DefinitionResolverInterface $definitionResolver, + private readonly SiteHydratorInterface $layoutDefinitionHydrator, + private readonly EventDispatcherInterface $eventDispatcher, ) { } diff --git a/src/Document/Hydrator/SiteHydrator.php b/src/Document/Hydrator/SiteHydrator.php new file mode 100644 index 00000000..577d1337 --- /dev/null +++ b/src/Document/Hydrator/SiteHydrator.php @@ -0,0 +1,37 @@ +getId(), + $siteModel->getDomains(), + $siteModel->getMainDomain(), + $siteModel->getRootId(), + $siteModel->getRootPath(), + ); + } +} diff --git a/src/Document/Hydrator/SiteHydratorInterface.php b/src/Document/Hydrator/SiteHydratorInterface.php new file mode 100644 index 00000000..5c456805 --- /dev/null +++ b/src/Document/Hydrator/SiteHydratorInterface.php @@ -0,0 +1,28 @@ +siteRepository->listSites(); foreach ($siteList as $siteEntry) { - $site = new Site( - $siteEntry->getId(), - $siteEntry->getDomains(), - $siteEntry->getMainDomain(), - $siteEntry->getRootId(), - $siteEntry->getRootPath(), - ); + $site = $this->siteHydrator->hydrate($siteEntry); $this->eventDispatcher->dispatch(new SiteEvent($site), SiteEvent::EVENT_NAME); $sites[] = $site;