@@ -28,32 +28,32 @@ discard block |
||
| 28 | 28 | use FOS\RestBundle\Controller\Annotations\Route; |
| 29 | 29 | |
| 30 | 30 | class SlideshowItemController extends Controller { |
| 31 | - private ArticleRepositoryInterface $articleRepository; |
|
| 32 | - private SlideshowRepositoryInterface $slideshowRepository; |
|
| 33 | - private SlideshowItemRepositoryInterface $slideshowItemRepository; |
|
| 34 | - private EventDispatcherInterface $eventDispatcher; |
|
| 31 | + private ArticleRepositoryInterface $articleRepository; |
|
| 32 | + private SlideshowRepositoryInterface $slideshowRepository; |
|
| 33 | + private SlideshowItemRepositoryInterface $slideshowItemRepository; |
|
| 34 | + private EventDispatcherInterface $eventDispatcher; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param ArticleRepositoryInterface $articleRepository |
|
| 38 | - * @param SlideshowRepositoryInterface $slideshowRepository |
|
| 39 | - * @param SlideshowItemRepositoryInterface $slideshowItemRepository |
|
| 40 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 41 | - */ |
|
| 42 | - public function __construct(ArticleRepositoryInterface $articleRepository, |
|
| 43 | - SlideshowRepositoryInterface $slideshowRepository, |
|
| 44 | - SlideshowItemRepositoryInterface $slideshowItemRepository, |
|
| 45 | - EventDispatcherInterface $eventDispatcher) { |
|
| 36 | + /** |
|
| 37 | + * @param ArticleRepositoryInterface $articleRepository |
|
| 38 | + * @param SlideshowRepositoryInterface $slideshowRepository |
|
| 39 | + * @param SlideshowItemRepositoryInterface $slideshowItemRepository |
|
| 40 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 41 | + */ |
|
| 42 | + public function __construct(ArticleRepositoryInterface $articleRepository, |
|
| 43 | + SlideshowRepositoryInterface $slideshowRepository, |
|
| 44 | + SlideshowItemRepositoryInterface $slideshowItemRepository, |
|
| 45 | + EventDispatcherInterface $eventDispatcher) { |
|
| 46 | 46 | $this->articleRepository = $articleRepository; |
| 47 | 47 | $this->slideshowRepository = $slideshowRepository; |
| 48 | 48 | $this->slideshowItemRepository = $slideshowItemRepository; |
| 49 | 49 | $this->eventDispatcher = $eventDispatcher; |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @Route("/api/{version}/content/slideshows/{articleId}/{id}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_slideshow_items", requirements={"id"="\d+"}) |
|
| 55 | - */ |
|
| 56 | - public function listAction(Request $request, string $articleId, string $id) { |
|
| 53 | + /** |
|
| 54 | + * @Route("/api/{version}/content/slideshows/{articleId}/{id}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_slideshow_items", requirements={"id"="\d+"}) |
|
| 55 | + */ |
|
| 56 | + public function listAction(Request $request, string $articleId, string $id) { |
|
| 57 | 57 | $article = $this->findArticleOr404($articleId); |
| 58 | 58 | $repository = $this->slideshowItemRepository; |
| 59 | 59 | |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | return new ResourcesListResponse($items); |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - private function findOr404($id): ?SlideshowInterface { |
|
| 73 | + private function findOr404($id): ?SlideshowInterface { |
|
| 74 | 74 | if (null === $slideshow = $this->slideshowRepository->findOneById($id)) { |
| 75 | - throw new NotFoundHttpException(sprintf('Slideshow with id "%s" was not found.', $id)); |
|
| 75 | + throw new NotFoundHttpException(sprintf('Slideshow with id "%s" was not found.', $id)); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return $slideshow; |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - private function findArticleOr404($id) { |
|
| 81 | + private function findArticleOr404($id) { |
|
| 82 | 82 | if (null === $article = $this->articleRepository->findOneById($id)) { |
| 83 | - throw new NotFoundHttpException(sprintf('Article with id "%s" was not found.', $id)); |
|
| 83 | + throw new NotFoundHttpException(sprintf('Article with id "%s" was not found.', $id)); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $article; |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | } |
@@ -37,75 +37,75 @@ |
||
| 37 | 37 | use FOS\RestBundle\Controller\Annotations\Route as FOSRoute; |
| 38 | 38 | |
| 39 | 39 | class SeoMediaController extends AbstractMediaController { |
| 40 | - private FactoryInterface $seoMetadataFactory; |
|
| 41 | - private ArticleProviderInterface $articleProvider; |
|
| 42 | - private EntityManagerInterface $seoObjectManager; |
|
| 43 | - private FormFactoryInterface $formFactory; |
|
| 44 | - |
|
| 45 | - public function __construct( |
|
| 46 | - FactoryInterface $seoMetadataFactory, |
|
| 47 | - ArticleProviderInterface $articleProvider, |
|
| 48 | - FormFactoryInterface $formFactory, |
|
| 49 | - EntityManagerInterface $seoObjectManager, |
|
| 50 | - MediaManagerInterface $seoMediaManager, |
|
| 51 | - CacheInterface $cacheProvider, |
|
| 52 | - FileProviderInterface $fileProvider, |
|
| 53 | - FileExtensionCheckerInterface $fileExtensionChecker |
|
| 54 | - ) { |
|
| 40 | + private FactoryInterface $seoMetadataFactory; |
|
| 41 | + private ArticleProviderInterface $articleProvider; |
|
| 42 | + private EntityManagerInterface $seoObjectManager; |
|
| 43 | + private FormFactoryInterface $formFactory; |
|
| 44 | + |
|
| 45 | + public function __construct( |
|
| 46 | + FactoryInterface $seoMetadataFactory, |
|
| 47 | + ArticleProviderInterface $articleProvider, |
|
| 48 | + FormFactoryInterface $formFactory, |
|
| 49 | + EntityManagerInterface $seoObjectManager, |
|
| 50 | + MediaManagerInterface $seoMediaManager, |
|
| 51 | + CacheInterface $cacheProvider, |
|
| 52 | + FileProviderInterface $fileProvider, |
|
| 53 | + FileExtensionCheckerInterface $fileExtensionChecker |
|
| 54 | + ) { |
|
| 55 | 55 | $this->seoMetadataFactory = $seoMetadataFactory; |
| 56 | 56 | $this->formFactory = $formFactory; |
| 57 | 57 | $this->articleProvider = $articleProvider; |
| 58 | 58 | $this->seoObjectManager = $seoObjectManager; |
| 59 | 59 | |
| 60 | 60 | parent::__construct($seoMediaManager, $cacheProvider, $fileProvider, $fileExtensionChecker); |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @Route("/seo/media/{mediaId}.{extension}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_seo_media_get") |
|
| 65 | - */ |
|
| 66 | - public function getAction(string $mediaId, string $extension): Response { |
|
| 63 | + /** |
|
| 64 | + * @Route("/seo/media/{mediaId}.{extension}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_seo_media_get") |
|
| 65 | + */ |
|
| 66 | + public function getAction(string $mediaId, string $extension): Response { |
|
| 67 | 67 | return $this->getMedia($mediaId, $extension); |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @FOSRoute("/api/{version}/upload/seo_image/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_seo_image") |
|
| 72 | - */ |
|
| 73 | - public function uploadSeoImageAction(Request $request, string $id, |
|
| 74 | - SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse { |
|
| 70 | + /** |
|
| 71 | + * @FOSRoute("/api/{version}/upload/seo_image/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_seo_image") |
|
| 72 | + */ |
|
| 73 | + public function uploadSeoImageAction(Request $request, string $id, |
|
| 74 | + SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse { |
|
| 75 | 75 | $article = $this->findOr404($id); |
| 76 | 76 | $seoMetadata = $article->getSeoMetadata(); |
| 77 | 77 | |
| 78 | 78 | if (null === $seoMetadata) { |
| 79 | - $seoMetadata = $this->seoMetadataFactory->create(); |
|
| 79 | + $seoMetadata = $this->seoMetadataFactory->create(); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | $form = $this->formFactory->createNamed('', SeoImageType::class, $seoMetadata); |
| 83 | 83 | $form->handleRequest($request); |
| 84 | 84 | |
| 85 | 85 | if ($form->isSubmitted() && $form->isValid()) { |
| 86 | - try { |
|
| 86 | + try { |
|
| 87 | 87 | $seoImageUploader->handleUpload($seoMetadata); |
| 88 | 88 | |
| 89 | 89 | if (null === $article->getSeoMetadata()) { |
| 90 | - $article->setSeoMetadata($seoMetadata); |
|
| 90 | + $article->setSeoMetadata($seoMetadata); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $this->seoObjectManager->flush(); |
| 94 | - } catch (\Exception $e) { |
|
| 94 | + } catch (\Exception $e) { |
|
| 95 | 95 | return new SingleResourceResponse(['message' => 'Could not upload an image.'], new ResponseContext(400)); |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - return new SingleResourceResponse($seoMetadata, new ResponseContext(201)); |
|
| 98 | + return new SingleResourceResponse($seoMetadata, new ResponseContext(201)); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - private function findOr404(string $id): ArticleInterface { |
|
| 104 | + private function findOr404(string $id): ArticleInterface { |
|
| 105 | 105 | if (null === $article = $this->articleProvider->getOneById($id)) { |
| 106 | - throw new NotFoundHttpException('Article was not found.'); |
|
| 106 | + throw new NotFoundHttpException('Article was not found.'); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | return $article; |
| 110 | - } |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -23,12 +23,12 @@ |
||
| 23 | 23 | use FOS\RestBundle\Controller\Annotations\Route; |
| 24 | 24 | |
| 25 | 25 | class FailedQueueController extends AbstractController { |
| 26 | - /** |
|
| 27 | - * @Route("/api/{version}/failed_queue/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_failed_queue") |
|
| 28 | - */ |
|
| 29 | - public function listAction(Request $request, FailedEntriesProvider $failedEntriesProvider) { |
|
| 26 | + /** |
|
| 27 | + * @Route("/api/{version}/failed_queue/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_failed_queue") |
|
| 28 | + */ |
|
| 29 | + public function listAction(Request $request, FailedEntriesProvider $failedEntriesProvider) { |
|
| 30 | 30 | $max = $request->query->getInt('limit', 50); |
| 31 | 31 | |
| 32 | 32 | return new SingleResourceResponse($failedEntriesProvider->getFailedEntries($max)); |
| 33 | - } |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -19,34 +19,34 @@ discard block |
||
| 19 | 19 | use FOS\RestBundle\Controller\Annotations\Route; |
| 20 | 20 | |
| 21 | 21 | class SeoMetadataController extends AbstractController { |
| 22 | - private FormFactoryInterface $formFactory; |
|
| 23 | - private FactoryInterface $seoMetadataFactory; |
|
| 24 | - private RepositoryInterface $seoMetadataRepository; |
|
| 25 | - private EventDispatcherInterface $eventDispatcher; |
|
| 22 | + private FormFactoryInterface $formFactory; |
|
| 23 | + private FactoryInterface $seoMetadataFactory; |
|
| 24 | + private RepositoryInterface $seoMetadataRepository; |
|
| 25 | + private EventDispatcherInterface $eventDispatcher; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param FormFactoryInterface $formFactory |
|
| 29 | - * @param FactoryInterface $seoMetadataFactory |
|
| 30 | - * @param RepositoryInterface $seoMetadataRepository |
|
| 31 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 32 | - */ |
|
| 33 | - public function __construct(FormFactoryInterface $formFactory, FactoryInterface $seoMetadataFactory, |
|
| 34 | - RepositoryInterface $seoMetadataRepository, EventDispatcherInterface $eventDispatcher) { |
|
| 27 | + /** |
|
| 28 | + * @param FormFactoryInterface $formFactory |
|
| 29 | + * @param FactoryInterface $seoMetadataFactory |
|
| 30 | + * @param RepositoryInterface $seoMetadataRepository |
|
| 31 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 32 | + */ |
|
| 33 | + public function __construct(FormFactoryInterface $formFactory, FactoryInterface $seoMetadataFactory, |
|
| 34 | + RepositoryInterface $seoMetadataRepository, EventDispatcherInterface $eventDispatcher) { |
|
| 35 | 35 | $this->formFactory = $formFactory; |
| 36 | 36 | $this->seoMetadataFactory = $seoMetadataFactory; |
| 37 | 37 | $this->seoMetadataRepository = $seoMetadataRepository; |
| 38 | 38 | $this->eventDispatcher = $eventDispatcher; |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @Route("/api/{version}/packages/seo/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PUT"}, name="swp_api_core_seo_metadata_put") |
|
| 43 | - */ |
|
| 44 | - public function put(Request $request, string $packageGuid): SingleResourceResponse { |
|
| 41 | + /** |
|
| 42 | + * @Route("/api/{version}/packages/seo/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PUT"}, name="swp_api_core_seo_metadata_put") |
|
| 43 | + */ |
|
| 44 | + public function put(Request $request, string $packageGuid): SingleResourceResponse { |
|
| 45 | 45 | $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE); |
| 46 | 46 | |
| 47 | 47 | $seoMetadata = $this->seoMetadataRepository->findOneByPackageGuid($packageGuid); |
| 48 | 48 | if (null === $seoMetadata) { |
| 49 | - $seoMetadata = $this->seoMetadataFactory->create(); |
|
| 49 | + $seoMetadata = $this->seoMetadataFactory->create(); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $form = $this->formFactory->createNamed('', SeoMetadataType::class, $seoMetadata, ['method' => $request->getMethod()]); |
@@ -54,26 +54,26 @@ discard block |
||
| 54 | 54 | $form->handleRequest($request); |
| 55 | 55 | |
| 56 | 56 | if ($form->isSubmitted() && $form->isValid()) { |
| 57 | - $seoMetadata->setPackageGuid($packageGuid); |
|
| 58 | - $this->seoMetadataRepository->add($seoMetadata); |
|
| 57 | + $seoMetadata->setPackageGuid($packageGuid); |
|
| 58 | + $this->seoMetadataRepository->add($seoMetadata); |
|
| 59 | 59 | |
| 60 | - return new SingleResourceResponse($seoMetadata, new ResponseContext(200)); |
|
| 60 | + return new SingleResourceResponse($seoMetadata, new ResponseContext(200)); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @Route("/api/{version}/packages/seo/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_seo_metadata_get") |
|
| 68 | - */ |
|
| 69 | - public function getAction(string $packageGuid): SingleResourceResponse { |
|
| 66 | + /** |
|
| 67 | + * @Route("/api/{version}/packages/seo/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_seo_metadata_get") |
|
| 68 | + */ |
|
| 69 | + public function getAction(string $packageGuid): SingleResourceResponse { |
|
| 70 | 70 | $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE); |
| 71 | 71 | |
| 72 | 72 | $existingSeoMetadata = $this->seoMetadataRepository->findOneByPackageGuid($packageGuid); |
| 73 | 73 | if (null === $existingSeoMetadata) { |
| 74 | - throw new NotFoundHttpException('SEO metadata not found!'); |
|
| 74 | + throw new NotFoundHttpException('SEO metadata not found!'); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return new SingleResourceResponse($existingSeoMetadata, new ResponseContext(200)); |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -44,35 +44,35 @@ discard block |
||
| 44 | 44 | use FOS\RestBundle\Controller\Annotations\Route; |
| 45 | 45 | |
| 46 | 46 | class ContentListItemController extends AbstractController { |
| 47 | - private ContentListItemRepositoryInterface $contentListItemRepository; |
|
| 48 | - private EntityManagerInterface $entityManager; |
|
| 49 | - private ContentListServiceInterface $contentListService; |
|
| 50 | - private EventDispatcherInterface $eventDispatcher; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @param ContentListItemRepositoryInterface $contentListItemRepository |
|
| 54 | - * @param EntityManagerInterface $entityManager |
|
| 55 | - * @param ContentListServiceInterface $contentListService |
|
| 56 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 57 | - */ |
|
| 58 | - public function __construct(ContentListItemRepositoryInterface $contentListItemRepository, |
|
| 59 | - EntityManagerInterface $entityManager, |
|
| 60 | - ContentListServiceInterface $contentListService, |
|
| 61 | - EventDispatcherInterface $eventDispatcher) { |
|
| 47 | + private ContentListItemRepositoryInterface $contentListItemRepository; |
|
| 48 | + private EntityManagerInterface $entityManager; |
|
| 49 | + private ContentListServiceInterface $contentListService; |
|
| 50 | + private EventDispatcherInterface $eventDispatcher; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @param ContentListItemRepositoryInterface $contentListItemRepository |
|
| 54 | + * @param EntityManagerInterface $entityManager |
|
| 55 | + * @param ContentListServiceInterface $contentListService |
|
| 56 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 57 | + */ |
|
| 58 | + public function __construct(ContentListItemRepositoryInterface $contentListItemRepository, |
|
| 59 | + EntityManagerInterface $entityManager, |
|
| 60 | + ContentListServiceInterface $contentListService, |
|
| 61 | + EventDispatcherInterface $eventDispatcher) { |
|
| 62 | 62 | $this->contentListItemRepository = $contentListItemRepository; |
| 63 | 63 | $this->entityManager = $entityManager; |
| 64 | 64 | $this->contentListService = $contentListService; |
| 65 | 65 | $this->eventDispatcher = $eventDispatcher; |
| 66 | - } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @Route("/api/{version}/content/lists/{id}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_items", requirements={"id"="\d+"}) |
|
| 71 | - */ |
|
| 72 | - public function listAction(Request $request, int $id): ResourcesListResponseInterface { |
|
| 69 | + /** |
|
| 70 | + * @Route("/api/{version}/content/lists/{id}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_items", requirements={"id"="\d+"}) |
|
| 71 | + */ |
|
| 72 | + public function listAction(Request $request, int $id): ResourcesListResponseInterface { |
|
| 73 | 73 | $sort = $request->query->all('sorting'); |
| 74 | 74 | if (empty($sort)) { |
| 75 | - $sort = ['sticky' => 'desc']; |
|
| 75 | + $sort = ['sticky' => 'desc']; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $items = $this->contentListItemRepository->getPaginatedByCriteria( |
@@ -105,20 +105,20 @@ discard block |
||
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | return new ResourcesListResponse($items, $responseContext); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * @Route("/api/{version}/content/lists/{listId}/items/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_show_lists_item", requirements={"id"="\d+"}) |
|
| 112 | - */ |
|
| 113 | - public function getAction($listId, $id) { |
|
| 110 | + /** |
|
| 111 | + * @Route("/api/{version}/content/lists/{listId}/items/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_show_lists_item", requirements={"id"="\d+"}) |
|
| 112 | + */ |
|
| 113 | + public function getAction($listId, $id) { |
|
| 114 | 114 | return new SingleResourceResponse($this->findOr404($listId, $id)); |
| 115 | - } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * @Route("/api/{version}/content/lists/{listId}/items/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_lists_item", requirements={"id"="\d+", "listId"="\d+"}) |
|
| 119 | - */ |
|
| 120 | - public function updateAction(Request $request, FormFactoryInterface $formFactory, $listId, |
|
| 121 | - $id): SingleResourceResponseInterface { |
|
| 117 | + /** |
|
| 118 | + * @Route("/api/{version}/content/lists/{listId}/items/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_lists_item", requirements={"id"="\d+", "listId"="\d+"}) |
|
| 119 | + */ |
|
| 120 | + public function updateAction(Request $request, FormFactoryInterface $formFactory, $listId, |
|
| 121 | + $id): SingleResourceResponseInterface { |
|
| 122 | 122 | $contentListItem = $this->findOr404($listId, $id); |
| 123 | 123 | $form = $formFactory->createNamed( |
| 124 | 124 | '', |
@@ -130,59 +130,59 @@ discard block |
||
| 130 | 130 | $form->handleRequest($request); |
| 131 | 131 | |
| 132 | 132 | if ($form->isSubmitted() && $form->isValid()) { |
| 133 | - $contentListItem->getContentList()->setUpdatedAt(new DateTime()); |
|
| 133 | + $contentListItem->getContentList()->setUpdatedAt(new DateTime()); |
|
| 134 | 134 | |
| 135 | - if (null !== $contentListItem->getStickyPosition()) { |
|
| 135 | + if (null !== $contentListItem->getStickyPosition()) { |
|
| 136 | 136 | $contentListItem->setPosition($contentListItem->getStickyPosition()); |
| 137 | - } |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - $this->entityManager->flush(); |
|
| 139 | + $this->entityManager->flush(); |
|
| 140 | 140 | |
| 141 | - return new SingleResourceResponse($contentListItem); |
|
| 141 | + return new SingleResourceResponse($contentListItem); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @Route("/api/{version}/content/lists/{listId}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_batch_update_lists_item", requirements={"listId"="\d+"}) |
|
| 149 | - */ |
|
| 150 | - public function batchUpdateAction( |
|
| 151 | - Request $request, |
|
| 152 | - FormFactoryInterface $formFactory, |
|
| 153 | - ContentListRepositoryInterface $contentListRepository, |
|
| 154 | - ArticleRepositoryInterface $articleRepository, |
|
| 155 | - EventDispatcherInterface $eventDispatcher, |
|
| 156 | - int $listId |
|
| 157 | - ): SingleResourceResponseInterface { |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @Route("/api/{version}/content/lists/{listId}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_batch_update_lists_item", requirements={"listId"="\d+"}) |
|
| 149 | + */ |
|
| 150 | + public function batchUpdateAction( |
|
| 151 | + Request $request, |
|
| 152 | + FormFactoryInterface $formFactory, |
|
| 153 | + ContentListRepositoryInterface $contentListRepository, |
|
| 154 | + ArticleRepositoryInterface $articleRepository, |
|
| 155 | + EventDispatcherInterface $eventDispatcher, |
|
| 156 | + int $listId |
|
| 157 | + ): SingleResourceResponseInterface { |
|
| 158 | 158 | /** @var ContentListInterface $list */ |
| 159 | 159 | $list = $contentListRepository->findOneBy(['id' => $listId]); |
| 160 | 160 | if (null === $list) { |
| 161 | - throw new NotFoundHttpException(sprintf('Content list with id "%s" was not found.', $list)); |
|
| 161 | + throw new NotFoundHttpException(sprintf('Content list with id "%s" was not found.', $list)); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $form = $formFactory->createNamed('', ContentListItemsType::class, [], ['method' => $request->getMethod()]); |
| 165 | 165 | |
| 166 | 166 | $form->handleRequest($request); |
| 167 | 167 | if ($form->isSubmitted() && $form->isValid()) { |
| 168 | - $data = $form->getData(); |
|
| 169 | - $updatedAt = DateTime::createFromFormat(DateTime::RFC3339, $data['updatedAt'], new DateTimeZone('UTC')); |
|
| 170 | - $updatedAt->setTimezone(new DateTimeZone('UTC')); |
|
| 171 | - $listUpdatedAt = $list->getUpdatedAt(); |
|
| 172 | - $listUpdatedAt->setTimezone(new DateTimeZone('UTC')); |
|
| 173 | - if ($updatedAt < $listUpdatedAt) { |
|
| 168 | + $data = $form->getData(); |
|
| 169 | + $updatedAt = DateTime::createFromFormat(DateTime::RFC3339, $data['updatedAt'], new DateTimeZone('UTC')); |
|
| 170 | + $updatedAt->setTimezone(new DateTimeZone('UTC')); |
|
| 171 | + $listUpdatedAt = $list->getUpdatedAt(); |
|
| 172 | + $listUpdatedAt->setTimezone(new DateTimeZone('UTC')); |
|
| 173 | + if ($updatedAt < $listUpdatedAt) { |
|
| 174 | 174 | throw new ConflictHttpException('List was already updated'); |
| 175 | - } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - $updatedArticles = []; |
|
| 178 | - /** @var ContentListAction $item */ |
|
| 179 | - foreach ($data['items'] as $item) { |
|
| 177 | + $updatedArticles = []; |
|
| 178 | + /** @var ContentListAction $item */ |
|
| 179 | + foreach ($data['items'] as $item) { |
|
| 180 | 180 | $position = $item->getPosition(); |
| 181 | 181 | $isSticky = $item->isSticky(); |
| 182 | 182 | $contentId = $item->getContentId(); |
| 183 | 183 | |
| 184 | 184 | switch ($item->getAction()) { |
| 185 | - case ContentListAction::ACTION_MOVE: |
|
| 185 | + case ContentListAction::ACTION_MOVE: |
|
| 186 | 186 | $contentListItem = $this->findByContentOr404($list, $contentId); |
| 187 | 187 | |
| 188 | 188 | $this->ensureThereIsNoItemOnPositionOrThrow409($listId, $position, $isSticky); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $updatedArticles[$contentId] = $contentListItem->getContent(); |
| 196 | 196 | |
| 197 | 197 | break; |
| 198 | - case ContentListAction::ACTION_ADD: |
|
| 198 | + case ContentListAction::ACTION_ADD: |
|
| 199 | 199 | $this->ensureThereIsNoItemOnPositionOrThrow409($listId, $position, $isSticky); |
| 200 | 200 | |
| 201 | 201 | $object = $articleRepository->findOneById($contentId); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $updatedArticles[$contentId] = $contentListItem->getContent(); |
| 205 | 205 | |
| 206 | 206 | break; |
| 207 | - case ContentListAction::ACTION_DELETE: |
|
| 207 | + case ContentListAction::ACTION_DELETE: |
|
| 208 | 208 | $contentListItem = $this->findByContentOr404($list, $contentId); |
| 209 | 209 | $this->entityManager->remove($contentListItem); |
| 210 | 210 | $list->setUpdatedAt(new DateTime('now')); |
@@ -213,25 +213,25 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | break; |
| 215 | 215 | } |
| 216 | - } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - $this->contentListService->repositionStickyItems($list); |
|
| 218 | + $this->contentListService->repositionStickyItems($list); |
|
| 219 | 219 | |
| 220 | - foreach ($updatedArticles as $updatedArticle) { |
|
| 220 | + foreach ($updatedArticles as $updatedArticle) { |
|
| 221 | 221 | $eventDispatcher->dispatch(new ArticleEvent( |
| 222 | 222 | $updatedArticle, |
| 223 | 223 | $updatedArticle->getPackage(), |
| 224 | 224 | ArticleEvents::POST_UPDATE |
| 225 | 225 | ), ArticleEvents::POST_UPDATE); |
| 226 | - } |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - return new SingleResourceResponse($list, new ResponseContext(201)); |
|
| 228 | + return new SingleResourceResponse($list, new ResponseContext(201)); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 232 | - } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - private function findByContentOr404($listId, $contentId): ContentListItemInterface { |
|
| 234 | + private function findByContentOr404($listId, $contentId): ContentListItemInterface { |
|
| 235 | 235 | /** @var ContentListItemInterface $listItem */ |
| 236 | 236 | $listItem = $this->contentListItemRepository->findOneBy([ |
| 237 | 237 | 'contentList' => $listId, |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | ]); |
| 240 | 240 | |
| 241 | 241 | if (null === $listItem) { |
| 242 | - throw new NotFoundHttpException(sprintf('Content list item with content_id "%s" was not found on that list. If You want to add new item - use action type "add".', $contentId)); |
|
| 242 | + throw new NotFoundHttpException(sprintf('Content list item with content_id "%s" was not found on that list. If You want to add new item - use action type "add".', $contentId)); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | return $listItem; |
| 246 | - } |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - private function findOr404($listId, $id): ContentListItemInterface { |
|
| 248 | + private function findOr404($listId, $id): ContentListItemInterface { |
|
| 249 | 249 | /** @var ContentListItemInterface $listItem */ |
| 250 | 250 | $listItem = $this->contentListItemRepository->findOneBy([ |
| 251 | 251 | 'contentList' => $listId, |
@@ -253,17 +253,17 @@ discard block |
||
| 253 | 253 | ]); |
| 254 | 254 | |
| 255 | 255 | if (null === $listItem) { |
| 256 | - throw new NotFoundHttpException(sprintf('Content list item with id "%s" was not found.', $id)); |
|
| 256 | + throw new NotFoundHttpException(sprintf('Content list item with id "%s" was not found.', $id)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | return $listItem; |
| 260 | - } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - private function ensureThereIsNoItemOnPositionOrThrow409(int $listId, int $position, bool $isSticky): void { |
|
| 262 | + private function ensureThereIsNoItemOnPositionOrThrow409(int $listId, int $position, bool $isSticky): void { |
|
| 263 | 263 | $existingContentListItem = $this->contentListService->isAnyItemPinnedOnPosition($listId, $position); |
| 264 | 264 | |
| 265 | 265 | if (null !== $existingContentListItem && $isSticky && $existingContentListItem->isSticky()) { |
| 266 | - throw new ConflictHttpException('There is already an item pinned on that position. Unpin it first.'); |
|
| 266 | + throw new ConflictHttpException('There is already an item pinned on that position. Unpin it first.'); |
|
| 267 | + } |
|
| 267 | 268 | } |
| 268 | - } |
|
| 269 | 269 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | public function viewAction(AmpInterface $object): Response { |
| 47 | - return $this->cacheService->get($this->getCacheKey($object), function () use ($object) { |
|
| 47 | + return $this->cacheService->get($this->getCacheKey($object), function() use ($object) { |
|
| 48 | 48 | $this->themeLoader->load(); |
| 49 | 49 | $content = $this->twig->render(sprintf('@%s/index.html.twig', ThemeLoaderInterface::THEME_NAMESPACE), [ |
| 50 | 50 | 'object' => $object, |
@@ -26,46 +26,46 @@ |
||
| 26 | 26 | |
| 27 | 27 | final class AmpController extends AbstractController { |
| 28 | 28 | |
| 29 | - private Environment $twig; |
|
| 30 | - private AmpConverterInterface $converter; |
|
| 31 | - private ThemeLoaderInterface $themeLoader; |
|
| 32 | - private CacheInterface $cacheService; |
|
| 29 | + private Environment $twig; |
|
| 30 | + private AmpConverterInterface $converter; |
|
| 31 | + private ThemeLoaderInterface $themeLoader; |
|
| 32 | + private CacheInterface $cacheService; |
|
| 33 | 33 | |
| 34 | - public function __construct( |
|
| 35 | - Environment $twig, |
|
| 36 | - AmpConverterInterface $ampConverter, |
|
| 37 | - ThemeLoaderInterface $ampThemeLoader, |
|
| 38 | - CacheInterface $cacheService |
|
| 39 | - ) { |
|
| 34 | + public function __construct( |
|
| 35 | + Environment $twig, |
|
| 36 | + AmpConverterInterface $ampConverter, |
|
| 37 | + ThemeLoaderInterface $ampThemeLoader, |
|
| 38 | + CacheInterface $cacheService |
|
| 39 | + ) { |
|
| 40 | 40 | $this->twig = $twig; |
| 41 | 41 | $this->converter = $ampConverter; |
| 42 | 42 | $this->themeLoader = $ampThemeLoader; |
| 43 | 43 | $this->cacheService = $cacheService; |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function viewAction(AmpInterface $object): Response { |
|
| 46 | + public function viewAction(AmpInterface $object): Response { |
|
| 47 | 47 | return $this->cacheService->get($this->getCacheKey($object), function () use ($object) { |
| 48 | - $this->themeLoader->load(); |
|
| 49 | - $content = $this->twig->render(sprintf('@%s/index.html.twig', ThemeLoaderInterface::THEME_NAMESPACE), [ |
|
| 50 | - 'object' => $object, |
|
| 51 | - ]); |
|
| 48 | + $this->themeLoader->load(); |
|
| 49 | + $content = $this->twig->render(sprintf('@%s/index.html.twig', ThemeLoaderInterface::THEME_NAMESPACE), [ |
|
| 50 | + 'object' => $object, |
|
| 51 | + ]); |
|
| 52 | 52 | |
| 53 | - $response = new Response(); |
|
| 54 | - $response->setContent($this->converter->convertToAmp($content)); |
|
| 55 | - return $response; |
|
| 53 | + $response = new Response(); |
|
| 54 | + $response->setContent($this->converter->convertToAmp($content)); |
|
| 55 | + return $response; |
|
| 56 | 56 | }); |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - private function getCacheKey(AmpInterface $object): string { |
|
| 59 | + private function getCacheKey(AmpInterface $object): string { |
|
| 60 | 60 | $elements = ['amp_article']; |
| 61 | 61 | if ($object instanceof PersistableInterface) { |
| 62 | - $elements[] = $object->getId(); |
|
| 62 | + $elements[] = $object->getId(); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | if ($object instanceof TimestampableInterface && null !== $object->getUpdatedAt()) { |
| 66 | - $elements[] = $object->getUpdatedAt()->getTimestamp(); |
|
| 66 | + $elements[] = $object->getUpdatedAt()->getTimestamp(); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | return md5(implode('__', $elements)); |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $redirectRoute = $this->redirectRouteRepository->findOneBy(['staticPrefix' => $candidates[0]]); |
| 73 | 73 | |
| 74 | 74 | if (null !== $redirectRoute) { |
| 75 | - $collection->add($redirectRoute->getRouteName() ?? '', $redirectRoute); |
|
| 75 | + $collection->add($redirectRoute->getRouteName() ?? '', $redirectRoute); |
|
| 76 | 76 | |
| 77 | 77 | return $collection; |
| 78 | 78 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | private function getArrayOfIdsFromRoutesArray(array $routes): array |
| 251 | 251 | { |
| 252 | - return array_map(function ($route) { |
|
| 252 | + return array_map(function($route) { |
|
| 253 | 253 | return $route->getId(); |
| 254 | 254 | }, $routes); |
| 255 | 255 | } |
@@ -50,6 +50,6 @@ |
||
| 50 | 50 | unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - return 'Route for media ' . $name->getValues()->getId() . ' not found'; |
|
| 53 | + return 'Route for media '.$name->getValues()->getId().' not found'; |
|
| 54 | 54 | } |
| 55 | 55 | } |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | class SeoMediaRouter extends Router implements VersatileGeneratorInterface { |
| 28 | 28 | |
| 29 | - const OBJECT_BASED_ROUTE_NAME = "__seo_media_router_route_name__"; |
|
| 29 | + const OBJECT_BASED_ROUTE_NAME = "__seo_media_router_route_name__"; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * {@inheritdoc} |
|
| 33 | - */ |
|
| 34 | - public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { |
|
| 31 | + /** |
|
| 32 | + * {@inheritdoc} |
|
| 33 | + */ |
|
| 34 | + public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { |
|
| 35 | 35 | if (self::OBJECT_BASED_ROUTE_NAME === $name && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)) { |
| 36 | - $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 37 | - unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 36 | + $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 37 | + unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $item = $name->getValues()->getImage(); |
@@ -43,18 +43,18 @@ discard block |
||
| 43 | 43 | $parameters['extension'] = $item->getFileExtension(); |
| 44 | 44 | |
| 45 | 45 | return parent::generate('swp_seo_media_get', $parameters, $referenceType); |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function supports($name): bool { |
|
| 48 | + public function supports($name): bool { |
|
| 49 | 49 | return (is_string($name) && $name == self::OBJECT_BASED_ROUTE_NAME) || ($name instanceof Meta && $name->getValues() instanceof ArticleSeoMediaInterface); |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function getRouteDebugMessage($name, array $parameters = array()): string { |
|
| 52 | + public function getRouteDebugMessage($name, array $parameters = array()): string { |
|
| 53 | 53 | if (self::OBJECT_BASED_ROUTE_NAME === $name && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)) { |
| 54 | - $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 55 | - unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 54 | + $name = $parameters[RouteObjectInterface::ROUTE_OBJECT]; |
|
| 55 | + unset($parameters[RouteObjectInterface::ROUTE_OBJECT]); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | return 'Route for media ' . $name->getValues()->getId() . ' not found'; |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | try { |
| 46 | 46 | return $this->routingExtension->getPath($name, $parameters, $relative); |
| 47 | - } catch (RouteNotFoundException|MissingMandatoryParametersException|InvalidParameterException $e) { |
|
| 47 | + } catch (RouteNotFoundException | MissingMandatoryParametersException | InvalidParameterException $e) { |
|
| 48 | 48 | // allow empty path |
| 49 | 49 | } |
| 50 | 50 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | try { |
| 66 | 66 | return $this->routingExtension->getUrl($name, $parameters, $schemeRelative); |
| 67 | - } catch (RouteNotFoundException|MissingMandatoryParametersException|InvalidParameterException $e) { |
|
| 67 | + } catch (RouteNotFoundException | MissingMandatoryParametersException | InvalidParameterException $e) { |
|
| 68 | 68 | // allow empty url |
| 69 | 69 | } |
| 70 | 70 | |
@@ -36,88 +36,88 @@ |
||
| 36 | 36 | use Twig\TwigFunction; |
| 37 | 37 | |
| 38 | 38 | final class DecoratingRoutingExtension extends AbstractExtension { |
| 39 | - private RoutingExtension $routingExtension; |
|
| 39 | + private RoutingExtension $routingExtension; |
|
| 40 | 40 | |
| 41 | - public function __construct(RoutingExtension $routingExtension) { |
|
| 41 | + public function __construct(RoutingExtension $routingExtension) { |
|
| 42 | 42 | $this->routingExtension = $routingExtension; |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function getPath($name, $parameters = [], $relative = false): ?string { |
|
| 45 | + public function getPath($name, $parameters = [], $relative = false): ?string { |
|
| 46 | 46 | if ($name == null) { |
| 47 | - return null; |
|
| 47 | + return null; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | if (is_object($name)) { |
| 51 | - $object = $name; |
|
| 52 | - $name = null; |
|
| 53 | - self::setupParams($object, $name, $parameters); |
|
| 51 | + $object = $name; |
|
| 52 | + $name = null; |
|
| 53 | + self::setupParams($object, $name, $parameters); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | try { |
| 57 | - return $this->routingExtension->getPath($name, $parameters, $relative); |
|
| 57 | + return $this->routingExtension->getPath($name, $parameters, $relative); |
|
| 58 | 58 | } catch (RouteNotFoundException|MissingMandatoryParametersException|InvalidParameterException $e) { |
| 59 | - // allow empty path |
|
| 59 | + // allow empty path |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return null; |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function getUrl($name, $parameters = [], $schemeRelative = false): ?string { |
|
| 65 | + public function getUrl($name, $parameters = [], $schemeRelative = false): ?string { |
|
| 66 | 66 | if ($name == null) { |
| 67 | - return null; |
|
| 67 | + return null; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | if (is_object($name)) { |
| 71 | - $object = $name; |
|
| 72 | - $name = null; |
|
| 73 | - self::setupParams($object, $name, $parameters); |
|
| 71 | + $object = $name; |
|
| 72 | + $name = null; |
|
| 73 | + self::setupParams($object, $name, $parameters); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | try { |
| 77 | - return $this->routingExtension->getUrl($name, $parameters, $schemeRelative); |
|
| 77 | + return $this->routingExtension->getUrl($name, $parameters, $schemeRelative); |
|
| 78 | 78 | } catch (RouteNotFoundException|MissingMandatoryParametersException|InvalidParameterException $e) { |
| 79 | - // allow empty url |
|
| 79 | + // allow empty url |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return null; |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - public static function setupParams(object $object, &$name, &$parameters) { |
|
| 85 | + public static function setupParams(object $object, &$name, &$parameters) { |
|
| 86 | 86 | $name = RouteObjectInterface::OBJECT_BASED_ROUTE_NAME; |
| 87 | 87 | $parameters[RouteObjectInterface::ROUTE_OBJECT] = $object; |
| 88 | 88 | |
| 89 | 89 | if ($object instanceof Meta) { |
| 90 | - $values = $object->getValues(); |
|
| 91 | - if (($values instanceof ArticleMediaInterface || $values instanceof ImageRenditionInterface)) { |
|
| 90 | + $values = $object->getValues(); |
|
| 91 | + if (($values instanceof ArticleMediaInterface || $values instanceof ImageRenditionInterface)) { |
|
| 92 | 92 | $name = MediaRouter::OBJECT_BASED_ROUTE_NAME; |
| 93 | 93 | return; |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - if ($values instanceof ArticleSeoMediaInterface) { |
|
| 96 | + if ($values instanceof ArticleSeoMediaInterface) { |
|
| 97 | 97 | $name = SeoMediaRouter::OBJECT_BASED_ROUTE_NAME; |
| 98 | 98 | return; |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - if ($values instanceof AuthorMediaInterface) { |
|
| 101 | + if ($values instanceof AuthorMediaInterface) { |
|
| 102 | 102 | $name = ArticleAuthorMediaRouter::OBJECT_BASED_ROUTE_NAME; |
| 103 | 103 | return; |
| 104 | - } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - if ($values instanceof ArticleInterface || $values instanceof RouteInterface) { |
|
| 106 | + if ($values instanceof ArticleInterface || $values instanceof RouteInterface) { |
|
| 107 | 107 | $name = MetaRouter::OBJECT_BASED_ROUTE_NAME; |
| 108 | 108 | return; |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | if ($object instanceof RouteInterface || $object instanceof ArticleInterface) { |
| 113 | - $name = MetaRouter::OBJECT_BASED_ROUTE_NAME; |
|
| 113 | + $name = MetaRouter::OBJECT_BASED_ROUTE_NAME; |
|
| 114 | + } |
|
| 114 | 115 | } |
| 115 | - } |
|
| 116 | 116 | |
| 117 | - public function getFunctions(): array { |
|
| 117 | + public function getFunctions(): array { |
|
| 118 | 118 | return [ |
| 119 | 119 | new TwigFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this->routingExtension, 'isUrlGenerationSafe']]), |
| 120 | 120 | new TwigFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this->routingExtension, 'isUrlGenerationSafe']]), |
| 121 | 121 | ]; |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | } |