diff --git a/src/Controller/PageAdminController.php b/src/Controller/PageAdminController.php index a5c460552..173613995 100644 --- a/src/Controller/PageAdminController.php +++ b/src/Controller/PageAdminController.php @@ -13,6 +13,7 @@ namespace Sonata\PageBundle\Controller; +use Sonata\AdminBundle\Admin\AdminInterface; use Sonata\AdminBundle\Controller\CRUDController; use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; use Sonata\BlockBundle\Block\BlockServiceManagerInterface; @@ -20,10 +21,12 @@ use Sonata\PageBundle\Admin\BlockAdmin; use Sonata\PageBundle\Admin\SnapshotAdmin; use Sonata\PageBundle\Model\BlockInteractorInterface; +use Sonata\PageBundle\Model\PageBlockInterface; use Sonata\PageBundle\Model\PageInterface; use Sonata\PageBundle\Model\PageManagerInterface; use Sonata\PageBundle\Model\SiteManagerInterface; use Sonata\PageBundle\Page\TemplateManagerInterface; +use Sonata\PageBundle\Service\Contract\CreateSnapshotByPageInterface; use Sonata\PageBundle\Service\CreateSnapshotService; use Sonata\PageBundle\Site\SiteSelectorInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -62,11 +65,11 @@ public static function getSubscribedServices(): array public function batchActionSnapshot(ProxyQueryInterface $query): RedirectResponse { $snapShotAdmin = $this->container->get('sonata.page.admin.snapshot'); - \assert($snapShotAdmin instanceof SnapshotAdmin); + \assert($snapShotAdmin instanceof AdminInterface); $snapShotAdmin->checkAccess('create'); $createSnapshot = $this->container->get('sonata.page.service.create_snapshot'); - \assert($createSnapshot instanceof CreateSnapshotService); + \assert($createSnapshot instanceof CreateSnapshotByPageInterface); foreach ($query->execute() as $page) { $createSnapshot->createByPage($page); } @@ -171,7 +174,7 @@ public function composeAction(Request $request): Response $this->admin->checkAccess('compose'); $blockAdmin = $this->container->get('sonata.page.admin.block'); - \assert($blockAdmin instanceof BlockAdmin); + \assert($blockAdmin instanceof AdminInterface); if (false === $blockAdmin->isGranted('LIST')) { throw new AccessDeniedException(); @@ -258,7 +261,7 @@ public function composeAction(Request $request): Response public function composeContainerShowAction(Request $request): Response { $blockAdmin = $this->container->get('sonata.page.admin.block'); - \assert($blockAdmin instanceof BlockAdmin); + \assert($blockAdmin instanceof AdminInterface); if (false === $blockAdmin->isGranted('LIST')) { throw new AccessDeniedException(); @@ -266,7 +269,7 @@ public function composeContainerShowAction(Request $request): Response $id = $request->get($this->admin->getIdParameter()); $block = $blockAdmin->getObject($id); - if (null === $block) { + if (!$block instanceof PageBlockInterface) { throw new NotFoundHttpException(sprintf('Unable to find the block with id : %s', $id)); } diff --git a/src/Controller/SiteAdminController.php b/src/Controller/SiteAdminController.php index 2f4ee3130..7c52261c9 100644 --- a/src/Controller/SiteAdminController.php +++ b/src/Controller/SiteAdminController.php @@ -13,9 +13,11 @@ namespace Sonata\PageBundle\Controller; +use Sonata\AdminBundle\Admin\AdminInterface; use Sonata\AdminBundle\Controller\CRUDController; use Sonata\PageBundle\Admin\SnapshotAdmin; use Sonata\PageBundle\Model\SiteInterface; +use Sonata\PageBundle\Service\Contract\CreateSnapshotBySiteInterface; use Sonata\PageBundle\Service\CreateSnapshotService; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; @@ -45,7 +47,7 @@ public static function getSubscribedServices(): array public function snapshotsAction(Request $request): Response { $adminSnapshot = $this->container->get('sonata.page.admin.snapshot'); - \assert($adminSnapshot instanceof SnapshotAdmin); + \assert($adminSnapshot instanceof AdminInterface); if (false === $adminSnapshot->isGranted('CREATE')) { throw new AccessDeniedException(); } @@ -62,7 +64,7 @@ public function snapshotsAction(Request $request): Response if ('POST' === $request->getMethod()) { $createSnapshot = $this->container->get('sonata.page.service.create_snapshot'); - \assert($createSnapshot instanceof CreateSnapshotService); + \assert($createSnapshot instanceof CreateSnapshotBySiteInterface); $createSnapshot->createBySite($object); $this->addFlash(