@@ -26,27 +26,27 @@ discard block |
||
| 26 | 26 | use FOS\RestBundle\Controller\Annotations\Route; |
| 27 | 27 | |
| 28 | 28 | class AuthorSearchController extends AbstractController { |
| 29 | - private RepositoryManagerInterface $repositoryManager; |
|
| 30 | - private PaginatorInterface $paginator; |
|
| 31 | - private string $authorClassName; |
|
| 29 | + private RepositoryManagerInterface $repositoryManager; |
|
| 30 | + private PaginatorInterface $paginator; |
|
| 31 | + private string $authorClassName; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @param RepositoryManagerInterface $repositoryManager |
|
| 35 | - * @param PaginatorInterface $paginator |
|
| 36 | - * @param string $authorClassName |
|
| 37 | - */ |
|
| 38 | - public function __construct(RepositoryManagerInterface $repositoryManager, PaginatorInterface $paginator, |
|
| 39 | - string $authorClassName) { |
|
| 33 | + /** |
|
| 34 | + * @param RepositoryManagerInterface $repositoryManager |
|
| 35 | + * @param PaginatorInterface $paginator |
|
| 36 | + * @param string $authorClassName |
|
| 37 | + */ |
|
| 38 | + public function __construct(RepositoryManagerInterface $repositoryManager, PaginatorInterface $paginator, |
|
| 39 | + string $authorClassName) { |
|
| 40 | 40 | $this->repositoryManager = $repositoryManager; |
| 41 | 41 | $this->paginator = $paginator; |
| 42 | 42 | $this->authorClassName = $authorClassName; |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @Route("/api/{version}/authors/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_authors") |
|
| 48 | - */ |
|
| 49 | - public function searchAction(Request $request): ResourcesListResponse { |
|
| 46 | + /** |
|
| 47 | + * @Route("/api/{version}/authors/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_authors") |
|
| 48 | + */ |
|
| 49 | + public function searchAction(Request $request): ResourcesListResponse { |
|
| 50 | 50 | $criteria = Criteria::fromQueryParameters( |
| 51 | 51 | $request->query->get('term', ''), |
| 52 | 52 | [ |
@@ -87,5 +87,5 @@ discard block |
||
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | return new ResourcesListResponse($pagination, $responseContext); |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -51,33 +51,33 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | class AnalyticsExportController extends AbstractController { |
| 53 | 53 | |
| 54 | - protected CacheInterface $cacheProvider; |
|
| 55 | - protected RepositoryInterface $analyticsReportRepository; |
|
| 56 | - protected Filesystem $filesystem; |
|
| 57 | - protected CsvReportFileLocationResolver $csvReportFileLocationResolver; |
|
| 58 | - protected CachedTenantContextInterface $cachedTenantContext; |
|
| 59 | - protected RouteRepositoryInterface $routeRepository; |
|
| 60 | - private MessageBusInterface $messageBus; |
|
| 61 | - private FormFactoryInterface $formFactory; |
|
| 62 | - private EventDispatcherInterface $eventDispatcher; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @param CacheInterface $cacheProvider |
|
| 66 | - * @param RepositoryInterface $analyticsReportRepository |
|
| 67 | - * @param Filesystem $filesystem |
|
| 68 | - * @param CsvReportFileLocationResolver $csvReportFileLocationResolver |
|
| 69 | - * @param CachedTenantContextInterface $cachedTenantContext |
|
| 70 | - * @param RouteRepositoryInterface $routeRepository |
|
| 71 | - * @param MessageBusInterface $messageBus |
|
| 72 | - * @param FormFactoryInterface $formFactory |
|
| 73 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 74 | - */ |
|
| 75 | - public function __construct(CacheInterface $cacheProvider, |
|
| 76 | - RepositoryInterface $analyticsReportRepository, Filesystem $filesystem, |
|
| 77 | - CsvReportFileLocationResolver $csvReportFileLocationResolver, |
|
| 78 | - CachedTenantContextInterface $cachedTenantContext, |
|
| 79 | - RouteRepositoryInterface $routeRepository, MessageBusInterface $messageBus, |
|
| 80 | - FormFactoryInterface $formFactory, EventDispatcherInterface $eventDispatcher) { |
|
| 54 | + protected CacheInterface $cacheProvider; |
|
| 55 | + protected RepositoryInterface $analyticsReportRepository; |
|
| 56 | + protected Filesystem $filesystem; |
|
| 57 | + protected CsvReportFileLocationResolver $csvReportFileLocationResolver; |
|
| 58 | + protected CachedTenantContextInterface $cachedTenantContext; |
|
| 59 | + protected RouteRepositoryInterface $routeRepository; |
|
| 60 | + private MessageBusInterface $messageBus; |
|
| 61 | + private FormFactoryInterface $formFactory; |
|
| 62 | + private EventDispatcherInterface $eventDispatcher; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @param CacheInterface $cacheProvider |
|
| 66 | + * @param RepositoryInterface $analyticsReportRepository |
|
| 67 | + * @param Filesystem $filesystem |
|
| 68 | + * @param CsvReportFileLocationResolver $csvReportFileLocationResolver |
|
| 69 | + * @param CachedTenantContextInterface $cachedTenantContext |
|
| 70 | + * @param RouteRepositoryInterface $routeRepository |
|
| 71 | + * @param MessageBusInterface $messageBus |
|
| 72 | + * @param FormFactoryInterface $formFactory |
|
| 73 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 74 | + */ |
|
| 75 | + public function __construct(CacheInterface $cacheProvider, |
|
| 76 | + RepositoryInterface $analyticsReportRepository, Filesystem $filesystem, |
|
| 77 | + CsvReportFileLocationResolver $csvReportFileLocationResolver, |
|
| 78 | + CachedTenantContextInterface $cachedTenantContext, |
|
| 79 | + RouteRepositoryInterface $routeRepository, MessageBusInterface $messageBus, |
|
| 80 | + FormFactoryInterface $formFactory, EventDispatcherInterface $eventDispatcher) { |
|
| 81 | 81 | $this->cacheProvider = $cacheProvider; |
| 82 | 82 | $this->analyticsReportRepository = $analyticsReportRepository; |
| 83 | 83 | $this->filesystem = $filesystem; |
@@ -87,15 +87,15 @@ discard block |
||
| 87 | 87 | $this->messageBus = $messageBus; |
| 88 | 88 | $this->formFactory = $formFactory; |
| 89 | 89 | $this->eventDispatcher = $eventDispatcher; |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @FosRoute("/api/{version}/export/analytics/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_analytics_export_post") |
|
| 95 | - * |
|
| 96 | - * @throws \Exception |
|
| 97 | - */ |
|
| 98 | - public function post(Request $request): SingleResourceResponseInterface { |
|
| 93 | + /** |
|
| 94 | + * @FosRoute("/api/{version}/export/analytics/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_analytics_export_post") |
|
| 95 | + * |
|
| 96 | + * @throws \Exception |
|
| 97 | + */ |
|
| 98 | + public function post(Request $request): SingleResourceResponseInterface { |
|
| 99 | 99 | /** @var UserInterface $currentlyLoggedInUser */ |
| 100 | 100 | $currentlyLoggedInUser = $this->getUser(); |
| 101 | 101 | |
@@ -106,46 +106,46 @@ discard block |
||
| 106 | 106 | $form->handleRequest($request); |
| 107 | 107 | |
| 108 | 108 | if ($form->isSubmitted() && $form->isValid()) { |
| 109 | - $data = $form->getData(); |
|
| 109 | + $data = $form->getData(); |
|
| 110 | 110 | |
| 111 | - $analyticsReport = new AnalyticsReport(); |
|
| 112 | - $analyticsReport->setAssetId($fileName); |
|
| 113 | - $analyticsReport->setFileExtension('csv'); |
|
| 114 | - $analyticsReport->setUser($currentlyLoggedInUser); |
|
| 111 | + $analyticsReport = new AnalyticsReport(); |
|
| 112 | + $analyticsReport->setAssetId($fileName); |
|
| 113 | + $analyticsReport->setFileExtension('csv'); |
|
| 114 | + $analyticsReport->setUser($currentlyLoggedInUser); |
|
| 115 | 115 | |
| 116 | - $exportAnalytics = new ExportAnalytics( |
|
| 117 | - $data['start'], |
|
| 118 | - $data['end'], |
|
| 119 | - $this->cachedTenantContext->getTenant()->getCode(), |
|
| 120 | - $fileName, |
|
| 121 | - $currentlyLoggedInUser->getEmail(), |
|
| 122 | - !empty($data['routes']) ? $this->toIds($data['routes']) : [], |
|
| 123 | - !empty($data['authors']) ? $this->toIds($data['authors']) : [], |
|
| 124 | - $data['term'] ?? '' |
|
| 125 | - ); |
|
| 116 | + $exportAnalytics = new ExportAnalytics( |
|
| 117 | + $data['start'], |
|
| 118 | + $data['end'], |
|
| 119 | + $this->cachedTenantContext->getTenant()->getCode(), |
|
| 120 | + $fileName, |
|
| 121 | + $currentlyLoggedInUser->getEmail(), |
|
| 122 | + !empty($data['routes']) ? $this->toIds($data['routes']) : [], |
|
| 123 | + !empty($data['authors']) ? $this->toIds($data['authors']) : [], |
|
| 124 | + $data['term'] ?? '' |
|
| 125 | + ); |
|
| 126 | 126 | |
| 127 | - $filters = $this->processFilters( |
|
| 128 | - $exportAnalytics->getFilters(), |
|
| 129 | - !empty($data['routes']) ? $data['routes'] : [], |
|
| 130 | - !empty($data['authors']) ? $data['authors'] : [] |
|
| 131 | - ); |
|
| 127 | + $filters = $this->processFilters( |
|
| 128 | + $exportAnalytics->getFilters(), |
|
| 129 | + !empty($data['routes']) ? $data['routes'] : [], |
|
| 130 | + !empty($data['authors']) ? $data['authors'] : [] |
|
| 131 | + ); |
|
| 132 | 132 | |
| 133 | - $analyticsReport->setFilters($filters); |
|
| 133 | + $analyticsReport->setFilters($filters); |
|
| 134 | 134 | |
| 135 | - $this->analyticsReportRepository->add($analyticsReport); |
|
| 135 | + $this->analyticsReportRepository->add($analyticsReport); |
|
| 136 | 136 | |
| 137 | - $this->messageBus->dispatch($exportAnalytics); |
|
| 137 | + $this->messageBus->dispatch($exportAnalytics); |
|
| 138 | 138 | |
| 139 | - return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201)); |
|
| 139 | + return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201)); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 143 | - } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * @FosRoute("/api/{version}/export/analytics/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_analytics_reports") |
|
| 147 | - */ |
|
| 148 | - public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 145 | + /** |
|
| 146 | + * @FosRoute("/api/{version}/export/analytics/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_analytics_reports") |
|
| 147 | + */ |
|
| 148 | + public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 149 | 149 | $sorting = $request->query->all('sorting'); |
| 150 | 150 | $reports = $this->analyticsReportRepository->getPaginatedByCriteria( |
| 151 | 151 | $this->eventDispatcher, |
@@ -155,21 +155,21 @@ discard block |
||
| 155 | 155 | ); |
| 156 | 156 | |
| 157 | 157 | return new ResourcesListResponse($reports); |
| 158 | - } |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * @Route("/analytics/export/{fileName}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_export_analytics_download") |
|
| 162 | - */ |
|
| 163 | - public function downloadFile(string $fileName): Response { |
|
| 160 | + /** |
|
| 161 | + * @Route("/analytics/export/{fileName}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_export_analytics_download") |
|
| 162 | + */ |
|
| 163 | + public function downloadFile(string $fileName): Response { |
|
| 164 | 164 | $cacheKey = md5(serialize(['analytics_report', $fileName])); |
| 165 | 165 | |
| 166 | 166 | $analyticsReport = $this->cacheProvider->get($cacheKey, function () use ($fileName) { |
| 167 | - /* @var AnalyticsReportInterface|null $analyticsReport */ |
|
| 168 | - return $this->analyticsReportRepository->findOneBy(['assetId' => $fileName]); |
|
| 167 | + /* @var AnalyticsReportInterface|null $analyticsReport */ |
|
| 168 | + return $this->analyticsReportRepository->findOneBy(['assetId' => $fileName]); |
|
| 169 | 169 | }); |
| 170 | 170 | |
| 171 | 171 | if (null === $analyticsReport) { |
| 172 | - throw new NotFoundHttpException('Report file was not found.'); |
|
| 172 | + throw new NotFoundHttpException('Report file was not found.'); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $response = new Response(); |
@@ -188,30 +188,30 @@ discard block |
||
| 188 | 188 | $response->setContent($this->filesystem->read($this->csvReportFileLocationResolver->getMediaBasePath() . '/' . $analyticsReport->getAssetId())); |
| 189 | 189 | |
| 190 | 190 | return $response; |
| 191 | - } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - private function toIds(array $items): array { |
|
| 193 | + private function toIds(array $items): array { |
|
| 194 | 194 | $ids = []; |
| 195 | 195 | foreach ($items as $item) { |
| 196 | - foreach ($item as $entity) { |
|
| 196 | + foreach ($item as $entity) { |
|
| 197 | 197 | if (!$entity instanceof PersistableInterface) { |
| 198 | - continue; |
|
| 198 | + continue; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $ids[] = $entity->getId(); |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | return $ids; |
| 206 | - } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - private function processFilters(array $filters, array $routes, array $authors): array { |
|
| 208 | + private function processFilters(array $filters, array $routes, array $authors): array { |
|
| 209 | 209 | $routeNames = []; |
| 210 | 210 | |
| 211 | 211 | foreach ($routes as $route) { |
| 212 | - foreach ($route as $entity) { |
|
| 212 | + foreach ($route as $entity) { |
|
| 213 | 213 | $routeNames[] = $entity->getName(); |
| 214 | - } |
|
| 214 | + } |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | $filters['routes'] = $routeNames; |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | $authorNames = []; |
| 220 | 220 | /** @var ArticleAuthorInterface $author */ |
| 221 | 221 | foreach ($authors as $author) { |
| 222 | - foreach ($author as $entity) { |
|
| 222 | + foreach ($author as $entity) { |
|
| 223 | 223 | $authorNames[] = $entity->getName(); |
| 224 | - } |
|
| 224 | + } |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $filters['authors'] = $authorNames; |
| 228 | 228 | |
| 229 | 229 | return $filters; |
| 230 | - } |
|
| 230 | + } |
|
| 231 | 231 | } |
@@ -29,28 +29,28 @@ discard block |
||
| 29 | 29 | use FOS\RestBundle\Controller\Annotations\Route; |
| 30 | 30 | |
| 31 | 31 | class SlideshowController extends Controller { |
| 32 | - private ArticleRepositoryInterface $articleRepository; |
|
| 33 | - private SlideshowRepositoryInterface $slideshowRepository; |
|
| 34 | - private EventDispatcherInterface $eventDispatcher; |
|
| 32 | + private ArticleRepositoryInterface $articleRepository; |
|
| 33 | + private SlideshowRepositoryInterface $slideshowRepository; |
|
| 34 | + private EventDispatcherInterface $eventDispatcher; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param ArticleRepositoryInterface $articleRepository |
|
| 38 | - * @param SlideshowRepositoryInterface $slideshowRepository |
|
| 39 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 40 | - */ |
|
| 41 | - public function __construct(ArticleRepositoryInterface $articleRepository, |
|
| 42 | - SlideshowRepositoryInterface $slideshowRepository, |
|
| 43 | - EventDispatcherInterface $eventDispatcher) { |
|
| 36 | + /** |
|
| 37 | + * @param ArticleRepositoryInterface $articleRepository |
|
| 38 | + * @param SlideshowRepositoryInterface $slideshowRepository |
|
| 39 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 40 | + */ |
|
| 41 | + public function __construct(ArticleRepositoryInterface $articleRepository, |
|
| 42 | + SlideshowRepositoryInterface $slideshowRepository, |
|
| 43 | + EventDispatcherInterface $eventDispatcher) { |
|
| 44 | 44 | $this->articleRepository = $articleRepository; |
| 45 | 45 | $this->slideshowRepository = $slideshowRepository; |
| 46 | 46 | $this->eventDispatcher = $eventDispatcher; |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @Route("/api/{version}/content/slideshows/{articleId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_slideshows_list") |
|
| 52 | - */ |
|
| 53 | - public function listAction(Request $request, string $articleId): ResourcesListResponseInterface { |
|
| 50 | + /** |
|
| 51 | + * @Route("/api/{version}/content/slideshows/{articleId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_slideshows_list") |
|
| 52 | + */ |
|
| 53 | + public function listAction(Request $request, string $articleId): ResourcesListResponseInterface { |
|
| 54 | 54 | $repository = $this->slideshowRepository; |
| 55 | 55 | |
| 56 | 56 | $article = $this->findArticleOr404($articleId); |
@@ -60,29 +60,29 @@ discard block |
||
| 60 | 60 | ]), $request->query->all('sorting'), new PaginationData($request)); |
| 61 | 61 | |
| 62 | 62 | return new ResourcesListResponse($slideshows); |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @Route("/api/{version}/content/slideshows/{articleId}/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_get_slideshow", requirements={"id"="\d+"}) |
|
| 67 | - */ |
|
| 68 | - public function getAction($id, string $articleId): SingleResourceResponseInterface { |
|
| 65 | + /** |
|
| 66 | + * @Route("/api/{version}/content/slideshows/{articleId}/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_get_slideshow", requirements={"id"="\d+"}) |
|
| 67 | + */ |
|
| 68 | + public function getAction($id, string $articleId): SingleResourceResponseInterface { |
|
| 69 | 69 | $article = $this->findArticleOr404($articleId); |
| 70 | 70 | |
| 71 | 71 | if (null === $list = $this->slideshowRepository->findOneBy([ |
| 72 | 72 | 'id' => $id, |
| 73 | 73 | 'article' => $article, |
| 74 | 74 | ])) { |
| 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 new SingleResourceResponse($list); |
| 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 | } |
@@ -28,50 +28,50 @@ |
||
| 28 | 28 | use FOS\RestBundle\Controller\Annotations\Route; |
| 29 | 29 | |
| 30 | 30 | class PackageSeoMediaUploadController extends AbstractController { |
| 31 | - private FactoryInterface $seoMetadataFactory; |
|
| 32 | - private RepositoryInterface $seoMetadataRepository; |
|
| 33 | - private FormFactoryInterface $formFactory; |
|
| 31 | + private FactoryInterface $seoMetadataFactory; |
|
| 32 | + private RepositoryInterface $seoMetadataRepository; |
|
| 33 | + private FormFactoryInterface $formFactory; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param FactoryInterface $seoMetadataFactory |
|
| 37 | - * @param RepositoryInterface $seoMetadataRepository |
|
| 38 | - * @param FormFactoryInterface $formFactory |
|
| 39 | - */ |
|
| 40 | - public function __construct(FactoryInterface $seoMetadataFactory, RepositoryInterface $seoMetadataRepository, |
|
| 41 | - FormFactoryInterface $formFactory) { |
|
| 35 | + /** |
|
| 36 | + * @param FactoryInterface $seoMetadataFactory |
|
| 37 | + * @param RepositoryInterface $seoMetadataRepository |
|
| 38 | + * @param FormFactoryInterface $formFactory |
|
| 39 | + */ |
|
| 40 | + public function __construct(FactoryInterface $seoMetadataFactory, RepositoryInterface $seoMetadataRepository, |
|
| 41 | + FormFactoryInterface $formFactory) { |
|
| 42 | 42 | $this->seoMetadataFactory = $seoMetadataFactory; |
| 43 | 43 | $this->seoMetadataRepository = $seoMetadataRepository; |
| 44 | 44 | $this->formFactory = $formFactory; |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @Route("/api/{version}/packages/seo/upload/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_package_seo_image") |
|
| 50 | - */ |
|
| 51 | - public function uploadAction(Request $request, string $packageGuid, |
|
| 52 | - SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse { |
|
| 48 | + /** |
|
| 49 | + * @Route("/api/{version}/packages/seo/upload/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_package_seo_image") |
|
| 50 | + */ |
|
| 51 | + public function uploadAction(Request $request, string $packageGuid, |
|
| 52 | + SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse { |
|
| 53 | 53 | $seoMetadata = $this->seoMetadataRepository->findOneByPackageGuid($packageGuid); |
| 54 | 54 | |
| 55 | 55 | if (null === $seoMetadata) { |
| 56 | - $seoMetadata = $this->seoMetadataFactory->create(); |
|
| 56 | + $seoMetadata = $this->seoMetadataFactory->create(); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $form = $this->formFactory->createNamed('', SeoImageType::class, $seoMetadata); |
| 60 | 60 | $form->handleRequest($request); |
| 61 | 61 | |
| 62 | 62 | if ($form->isSubmitted() && $form->isValid()) { |
| 63 | - try { |
|
| 63 | + try { |
|
| 64 | 64 | $seoMetadata->setPackageGuid($packageGuid); |
| 65 | 65 | $seoImageUploader->handleUpload($seoMetadata); |
| 66 | 66 | |
| 67 | 67 | $this->seoMetadataRepository->add($seoMetadata); |
| 68 | - } catch (\Exception $e) { |
|
| 68 | + } catch (\Exception $e) { |
|
| 69 | 69 | return new SingleResourceResponse(['message' => 'Could not upload an image.'], new ResponseContext(400)); |
| 70 | - } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return new SingleResourceResponse($seoMetadata, new ResponseContext(201)); |
|
| 72 | + return new SingleResourceResponse($seoMetadata, new ResponseContext(201)); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -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 | } |
@@ -35,102 +35,102 @@ |
||
| 35 | 35 | use FOS\RestBundle\Controller\Annotations\Route; |
| 36 | 36 | |
| 37 | 37 | class RelatedArticleOrganizationController extends Controller { |
| 38 | - private EventDispatcherInterface $eventDispatcher; |
|
| 39 | - private DataTransformerInterface $dataTransformer; |
|
| 40 | - private CachedTenantContextInterface $cachedTenantContext; |
|
| 41 | - private PackageRepositoryInterface $packageRepository; |
|
| 42 | - private ArticleRepositoryInterface $articleRepository; |
|
| 43 | - private TenantRepositoryInterface $tenantRepository; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 47 | - * @param DataTransformerInterface $dataTransformer |
|
| 48 | - * @param CachedTenantContextInterface $cachedTenantContext |
|
| 49 | - * @param PackageRepositoryInterface $packageRepository |
|
| 50 | - * @param ArticleRepositoryInterface $articleRepository |
|
| 51 | - * @param TenantRepositoryInterface $tenantRepository |
|
| 52 | - */ |
|
| 53 | - public function __construct(EventDispatcherInterface $eventDispatcher, |
|
| 54 | - DataTransformerInterface $dataTransformer, |
|
| 55 | - CachedTenantContextInterface $cachedTenantContext, |
|
| 56 | - PackageRepositoryInterface $packageRepository, |
|
| 57 | - ArticleRepositoryInterface $articleRepository, |
|
| 58 | - TenantRepositoryInterface $tenantRepository) { |
|
| 38 | + private EventDispatcherInterface $eventDispatcher; |
|
| 39 | + private DataTransformerInterface $dataTransformer; |
|
| 40 | + private CachedTenantContextInterface $cachedTenantContext; |
|
| 41 | + private PackageRepositoryInterface $packageRepository; |
|
| 42 | + private ArticleRepositoryInterface $articleRepository; |
|
| 43 | + private TenantRepositoryInterface $tenantRepository; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 47 | + * @param DataTransformerInterface $dataTransformer |
|
| 48 | + * @param CachedTenantContextInterface $cachedTenantContext |
|
| 49 | + * @param PackageRepositoryInterface $packageRepository |
|
| 50 | + * @param ArticleRepositoryInterface $articleRepository |
|
| 51 | + * @param TenantRepositoryInterface $tenantRepository |
|
| 52 | + */ |
|
| 53 | + public function __construct(EventDispatcherInterface $eventDispatcher, |
|
| 54 | + DataTransformerInterface $dataTransformer, |
|
| 55 | + CachedTenantContextInterface $cachedTenantContext, |
|
| 56 | + PackageRepositoryInterface $packageRepository, |
|
| 57 | + ArticleRepositoryInterface $articleRepository, |
|
| 58 | + TenantRepositoryInterface $tenantRepository) { |
|
| 59 | 59 | $this->eventDispatcher = $eventDispatcher; |
| 60 | 60 | $this->dataTransformer = $dataTransformer; |
| 61 | 61 | $this->cachedTenantContext = $cachedTenantContext; |
| 62 | 62 | $this->packageRepository = $packageRepository; |
| 63 | 63 | $this->articleRepository = $articleRepository; |
| 64 | 64 | $this->tenantRepository = $tenantRepository; |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @Route("/api/{version}/organization/articles/related/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_organization_related_articles") |
|
| 70 | - */ |
|
| 71 | - public function postAction(Request $request) { |
|
| 68 | + /** |
|
| 69 | + * @Route("/api/{version}/organization/articles/related/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_organization_related_articles") |
|
| 70 | + */ |
|
| 71 | + public function postAction(Request $request) { |
|
| 72 | 72 | $content = $request->getContent(); |
| 73 | 73 | $package = $this->dataTransformer->transform($content); |
| 74 | 74 | $relatedArticlesList = $this->getRelated($package); |
| 75 | 75 | |
| 76 | 76 | return new SingleResourceResponse($relatedArticlesList); |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @Route("/api/{version}/packages/{id}/related/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_packages_related_articles", requirements={"id"="\d+"}) |
|
| 81 | - */ |
|
| 82 | - public function getRelatedAction(string $id) { |
|
| 79 | + /** |
|
| 80 | + * @Route("/api/{version}/packages/{id}/related/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_packages_related_articles", requirements={"id"="\d+"}) |
|
| 81 | + */ |
|
| 82 | + public function getRelatedAction(string $id) { |
|
| 83 | 83 | $package = $this->findOr404((int)$id); |
| 84 | 84 | |
| 85 | 85 | $relatedArticlesList = $this->getRelated($package); |
| 86 | 86 | |
| 87 | 87 | return new SingleResourceResponse($relatedArticlesList); |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - private function getRelated(PackageInterface $package): RelatedArticleList { |
|
| 90 | + private function getRelated(PackageInterface $package): RelatedArticleList { |
|
| 91 | 91 | $relatedItemsGroups = $package->getItems()->filter(static function ($group) { |
| 92 | - return ItemInterface::TYPE_TEXT === $group->getType(); |
|
| 92 | + return ItemInterface::TYPE_TEXT === $group->getType(); |
|
| 93 | 93 | }); |
| 94 | 94 | |
| 95 | 95 | $relatedArticlesList = new RelatedArticleList(); |
| 96 | 96 | |
| 97 | 97 | if (null === $package || (null !== $package && 0 === \count($relatedItemsGroups))) { |
| 98 | - return $relatedArticlesList; |
|
| 98 | + return $relatedArticlesList; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE); |
| 102 | 102 | $articleRepository = $this->articleRepository; |
| 103 | 103 | |
| 104 | 104 | foreach ($relatedItemsGroups as $item) { |
| 105 | - if (null === ($existingArticles = $articleRepository->findBy(['code' => $item->getGuid()]))) { |
|
| 105 | + if (null === ($existingArticles = $articleRepository->findBy(['code' => $item->getGuid()]))) { |
|
| 106 | 106 | continue; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - $tenants = []; |
|
| 110 | - foreach ($existingArticles as $existingArticle) { |
|
| 109 | + $tenants = []; |
|
| 110 | + foreach ($existingArticles as $existingArticle) { |
|
| 111 | 111 | $tenantCode = $existingArticle->getTenantCode(); |
| 112 | 112 | $tenant = $this->tenantRepository->findOneByCode($tenantCode); |
| 113 | 113 | |
| 114 | 114 | $tenants[] = $tenant; |
| 115 | - } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - $relatedArticleListItem = new RelatedArticleListItem(); |
|
| 118 | - $relatedArticleListItem->setTenants($tenants); |
|
| 119 | - $relatedArticleListItem->setTitle($item->getHeadline()); |
|
| 117 | + $relatedArticleListItem = new RelatedArticleListItem(); |
|
| 118 | + $relatedArticleListItem->setTenants($tenants); |
|
| 119 | + $relatedArticleListItem->setTitle($item->getHeadline()); |
|
| 120 | 120 | |
| 121 | - $relatedArticlesList->addRelatedArticleItem($relatedArticleListItem); |
|
| 121 | + $relatedArticlesList->addRelatedArticleItem($relatedArticleListItem); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return $relatedArticlesList; |
| 125 | - } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - private function findOr404(int $id): PackageInterface { |
|
| 127 | + private function findOr404(int $id): PackageInterface { |
|
| 128 | 128 | $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE); |
| 129 | 129 | $tenantContext = $this->cachedTenantContext; |
| 130 | 130 | if (null === $package = $this->packageRepository->findOneBy(['id' => $id, 'organization' => $tenantContext->getTenant()->getOrganization()])) { |
| 131 | - throw new NotFoundHttpException('Package was not found.'); |
|
| 131 | + throw new NotFoundHttpException('Package was not found.'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | return $package; |
| 135 | - } |
|
| 135 | + } |
|
| 136 | 136 | } |
@@ -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 | } |
@@ -28,77 +28,77 @@ |
||
| 28 | 28 | use FOS\RestBundle\Controller\Annotations\Route; |
| 29 | 29 | |
| 30 | 30 | class WebhookController extends AbstractAPIController { |
| 31 | - private WebhookRepositoryInterface $webhookRepository; |
|
| 32 | - private FormFactoryInterface $formFactory; |
|
| 33 | - private FactoryInterface $webhookFactory; |
|
| 34 | - private EntityManagerInterface $entityManager; |
|
| 35 | - private EventDispatcherInterface $eventDispatcher; |
|
| 31 | + private WebhookRepositoryInterface $webhookRepository; |
|
| 32 | + private FormFactoryInterface $formFactory; |
|
| 33 | + private FactoryInterface $webhookFactory; |
|
| 34 | + private EntityManagerInterface $entityManager; |
|
| 35 | + private EventDispatcherInterface $eventDispatcher; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param WebhookRepositoryInterface $webhookRepository |
|
| 39 | - * @param FormFactoryInterface $formFactory |
|
| 40 | - * @param FactoryInterface $webhookFactory |
|
| 41 | - * @param EntityManagerInterface $entityManager |
|
| 42 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 43 | - */ |
|
| 44 | - public function __construct(WebhookRepositoryInterface $webhookRepository, FormFactoryInterface $formFactory, |
|
| 45 | - FactoryInterface $webhookFactory, EntityManagerInterface $entityManager, |
|
| 46 | - EventDispatcherInterface $eventDispatcher) { |
|
| 37 | + /** |
|
| 38 | + * @param WebhookRepositoryInterface $webhookRepository |
|
| 39 | + * @param FormFactoryInterface $formFactory |
|
| 40 | + * @param FactoryInterface $webhookFactory |
|
| 41 | + * @param EntityManagerInterface $entityManager |
|
| 42 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 43 | + */ |
|
| 44 | + public function __construct(WebhookRepositoryInterface $webhookRepository, FormFactoryInterface $formFactory, |
|
| 45 | + FactoryInterface $webhookFactory, EntityManagerInterface $entityManager, |
|
| 46 | + EventDispatcherInterface $eventDispatcher) { |
|
| 47 | 47 | $this->webhookRepository = $webhookRepository; |
| 48 | 48 | $this->formFactory = $formFactory; |
| 49 | 49 | $this->webhookFactory = $webhookFactory; |
| 50 | 50 | $this->entityManager = $entityManager; |
| 51 | 51 | $this->eventDispatcher = $eventDispatcher; |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_webhook") |
|
| 57 | - */ |
|
| 58 | - public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 55 | + /** |
|
| 56 | + * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_webhook") |
|
| 57 | + */ |
|
| 58 | + public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 59 | 59 | return $this->listWebhooks($this->eventDispatcher,$this->webhookRepository, $request); |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @Route("/api/{version}/webhooks/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_webhook") |
|
| 64 | - * |
|
| 65 | - * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook") |
|
| 66 | - */ |
|
| 67 | - public function getAction(WebhookInterface $webhook): SingleResourceResponseInterface { |
|
| 62 | + /** |
|
| 63 | + * @Route("/api/{version}/webhooks/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_webhook") |
|
| 64 | + * |
|
| 65 | + * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook") |
|
| 66 | + */ |
|
| 67 | + public function getAction(WebhookInterface $webhook): SingleResourceResponseInterface { |
|
| 68 | 68 | return $this->getSingleWebhook($webhook); |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_webhook") |
|
| 73 | - */ |
|
| 74 | - public function createAction(Request $request): SingleResourceResponseInterface { |
|
| 71 | + /** |
|
| 72 | + * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_webhook") |
|
| 73 | + */ |
|
| 74 | + public function createAction(Request $request): SingleResourceResponseInterface { |
|
| 75 | 75 | $ruleRepository = $this->webhookRepository; |
| 76 | 76 | $ruleFactory = $this->webhookFactory; |
| 77 | 77 | $formFactory = $this->formFactory; |
| 78 | 78 | |
| 79 | 79 | return $this->createWebhook($ruleRepository, $ruleFactory, $request, $formFactory); |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_webhook", requirements={"id"="\d+"}) |
|
| 84 | - * |
|
| 85 | - * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook") |
|
| 86 | - */ |
|
| 87 | - public function deleteAction(WebhookInterface $webhook): SingleResourceResponseInterface { |
|
| 82 | + /** |
|
| 83 | + * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_webhook", requirements={"id"="\d+"}) |
|
| 84 | + * |
|
| 85 | + * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook") |
|
| 86 | + */ |
|
| 87 | + public function deleteAction(WebhookInterface $webhook): SingleResourceResponseInterface { |
|
| 88 | 88 | $webhookRepository = $this->webhookRepository; |
| 89 | 89 | |
| 90 | 90 | return $this->deleteWebhook($webhookRepository, $webhook); |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_webhook", requirements={"id"="\d+"}) |
|
| 95 | - * |
|
| 96 | - * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook") |
|
| 97 | - */ |
|
| 98 | - public function updateAction(Request $request, WebhookInterface $webhook): SingleResourceResponseInterface { |
|
| 93 | + /** |
|
| 94 | + * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_webhook", requirements={"id"="\d+"}) |
|
| 95 | + * |
|
| 96 | + * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook") |
|
| 97 | + */ |
|
| 98 | + public function updateAction(Request $request, WebhookInterface $webhook): SingleResourceResponseInterface { |
|
| 99 | 99 | $objectManager = $this->entityManager; |
| 100 | 100 | $formFactory = $this->formFactory; |
| 101 | 101 | |
| 102 | 102 | return $this->updateWebhook($objectManager, $request, $webhook, $formFactory); |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -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 | } |