@@ -22,10 +22,10 @@ |
||
22 | 22 | class ContentController extends AbstractController |
23 | 23 | { |
24 | 24 | |
25 | - public function __construct() { |
|
26 | - } |
|
25 | + public function __construct() { |
|
26 | + } |
|
27 | 27 | |
28 | - public function renderPageAction(string $contentTemplate): Response |
|
28 | + public function renderPageAction(string $contentTemplate): Response |
|
29 | 29 | { |
30 | 30 | $response = new Response(); |
31 | 31 | $response->headers->set('Content-Type', 'text/html; charset=UTF-8'); |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -41,29 +41,29 @@ discard block |
||
41 | 41 | use FOS\RestBundle\Controller\Annotations\Route; |
42 | 42 | |
43 | 43 | class OrganizationRuleController extends AbstractController { |
44 | - private FormFactoryInterface $formFactory; |
|
45 | - private EventDispatcherInterface $eventDispatcher; |
|
46 | - private CachedTenantContextInterface $cachedTenantContext; |
|
47 | - private EntityManagerInterface $entityManager; |
|
48 | - private RuleRepositoryInterface $ruleRepository; |
|
49 | - private RulesMatcherInterface $rulesMatcher; |
|
50 | - private FactoryInterface $ruleFactory; |
|
51 | - private DataTransformerInterface $dataTransformer; |
|
52 | - |
|
53 | - /** |
|
54 | - * @param FormFactoryInterface $formFactory |
|
55 | - * @param EventDispatcherInterface $eventDispatcher |
|
56 | - * @param CachedTenantContextInterface $cachedTenantContext |
|
57 | - * @param EntityManagerInterface $entityManager |
|
58 | - * @param RuleRepositoryInterface $ruleRepository |
|
59 | - * @param RulesMatcherInterface $rulesMatcher |
|
60 | - * @param FactoryInterface $ruleFactory |
|
61 | - * @param DataTransformerInterface $dataTransformer |
|
62 | - */ |
|
63 | - public function __construct(FormFactoryInterface $formFactory, EventDispatcherInterface $eventDispatcher, |
|
64 | - CachedTenantContextInterface $cachedTenantContext, EntityManagerInterface $entityManager, |
|
65 | - RuleRepositoryInterface $ruleRepository, RulesMatcherInterface $rulesMatcher, |
|
66 | - FactoryInterface $ruleFactory, DataTransformerInterface $dataTransformer) { |
|
44 | + private FormFactoryInterface $formFactory; |
|
45 | + private EventDispatcherInterface $eventDispatcher; |
|
46 | + private CachedTenantContextInterface $cachedTenantContext; |
|
47 | + private EntityManagerInterface $entityManager; |
|
48 | + private RuleRepositoryInterface $ruleRepository; |
|
49 | + private RulesMatcherInterface $rulesMatcher; |
|
50 | + private FactoryInterface $ruleFactory; |
|
51 | + private DataTransformerInterface $dataTransformer; |
|
52 | + |
|
53 | + /** |
|
54 | + * @param FormFactoryInterface $formFactory |
|
55 | + * @param EventDispatcherInterface $eventDispatcher |
|
56 | + * @param CachedTenantContextInterface $cachedTenantContext |
|
57 | + * @param EntityManagerInterface $entityManager |
|
58 | + * @param RuleRepositoryInterface $ruleRepository |
|
59 | + * @param RulesMatcherInterface $rulesMatcher |
|
60 | + * @param FactoryInterface $ruleFactory |
|
61 | + * @param DataTransformerInterface $dataTransformer |
|
62 | + */ |
|
63 | + public function __construct(FormFactoryInterface $formFactory, EventDispatcherInterface $eventDispatcher, |
|
64 | + CachedTenantContextInterface $cachedTenantContext, EntityManagerInterface $entityManager, |
|
65 | + RuleRepositoryInterface $ruleRepository, RulesMatcherInterface $rulesMatcher, |
|
66 | + FactoryInterface $ruleFactory, DataTransformerInterface $dataTransformer) { |
|
67 | 67 | $this->formFactory = $formFactory; |
68 | 68 | $this->eventDispatcher = $eventDispatcher; |
69 | 69 | $this->cachedTenantContext = $cachedTenantContext; |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | $this->rulesMatcher = $rulesMatcher; |
73 | 73 | $this->ruleFactory = $ruleFactory; |
74 | 74 | $this->dataTransformer = $dataTransformer; |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * @Route("/api/{version}/organization/rules/evaluate", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_organization_rules_evaluate") |
|
80 | - */ |
|
81 | - public function rulesEvaluationAction(Request $request): SingleResourceResponseInterface { |
|
78 | + /** |
|
79 | + * @Route("/api/{version}/organization/rules/evaluate", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_organization_rules_evaluate") |
|
80 | + */ |
|
81 | + public function rulesEvaluationAction(Request $request): SingleResourceResponseInterface { |
|
82 | 82 | $content = $request->getContent(); |
83 | 83 | $dispatcher = $this->eventDispatcher; |
84 | 84 | $package = $this->dataTransformer->transform($content); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | $rules = $this->rulesMatcher->getMatchedRules($package); |
88 | 88 | |
89 | 89 | return new SingleResourceResponse($rules); |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * @Route("/api/{version}/organization/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_organization_rules") |
|
94 | - */ |
|
95 | - public function rulesAction(Request $request): ResourcesListResponseInterface { |
|
92 | + /** |
|
93 | + * @Route("/api/{version}/organization/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_organization_rules") |
|
94 | + */ |
|
95 | + public function rulesAction(Request $request): ResourcesListResponseInterface { |
|
96 | 96 | $tenantContext = $this->cachedTenantContext; |
97 | 97 | |
98 | 98 | $this->getEventDispatcher()->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE); |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | return new ResourcesListResponse($rules); |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @Route("/api/{version}/organization/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_organization_rule") |
|
116 | - */ |
|
117 | - public function createAction(Request $request): SingleResourceResponseInterface { |
|
114 | + /** |
|
115 | + * @Route("/api/{version}/organization/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_organization_rule") |
|
116 | + */ |
|
117 | + public function createAction(Request $request): SingleResourceResponseInterface { |
|
118 | 118 | $ruleRepository = $this->getRuleRepository(); |
119 | 119 | |
120 | 120 | $rule = $this->ruleFactory->create(); |
@@ -122,54 +122,54 @@ discard block |
||
122 | 122 | $form->handleRequest($request); |
123 | 123 | |
124 | 124 | if ($form->isSubmitted() && $form->isValid()) { |
125 | - $ruleRepository->add($rule); |
|
126 | - $rule->setTenantCode(null); |
|
127 | - $ruleRepository->flush(); |
|
125 | + $ruleRepository->add($rule); |
|
126 | + $rule->setTenantCode(null); |
|
127 | + $ruleRepository->flush(); |
|
128 | 128 | |
129 | - return new SingleResourceResponse($rule, new ResponseContext(201)); |
|
129 | + return new SingleResourceResponse($rule, new ResponseContext(201)); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return new SingleResourceResponse($form, new ResponseContext(400)); |
133 | - } |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * @Route("/api/{version}/organization/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_show_organization_rule", requirements={"id"="\d+"}) |
|
137 | - */ |
|
138 | - public function getAction(int $id): SingleResourceResponseInterface { |
|
135 | + /** |
|
136 | + * @Route("/api/{version}/organization/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_show_organization_rule", requirements={"id"="\d+"}) |
|
137 | + */ |
|
138 | + public function getAction(int $id): SingleResourceResponseInterface { |
|
139 | 139 | return new SingleResourceResponse($this->findOr404($id)); |
140 | - } |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * @Route("/api/{version}/organization/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_organization_rule", requirements={"id"="\d+"}) |
|
144 | - */ |
|
145 | - public function updateRuleAction(Request $request, int $id) { |
|
142 | + /** |
|
143 | + * @Route("/api/{version}/organization/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_organization_rule", requirements={"id"="\d+"}) |
|
144 | + */ |
|
145 | + public function updateRuleAction(Request $request, int $id) { |
|
146 | 146 | $objectManager = $this->entityManager; |
147 | 147 | $rule = $this->findOr404($id); |
148 | 148 | $form = $this->formFactory->createNamed('', RuleType::class, $rule, ['method' => $request->getMethod()]); |
149 | 149 | |
150 | 150 | $form->handleRequest($request); |
151 | 151 | if ($form->isSubmitted() && $form->isValid()) { |
152 | - $objectManager->flush(); |
|
153 | - $objectManager->refresh($rule); |
|
152 | + $objectManager->flush(); |
|
153 | + $objectManager->refresh($rule); |
|
154 | 154 | |
155 | - return new SingleResourceResponse($rule); |
|
155 | + return new SingleResourceResponse($rule); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return new SingleResourceResponse($form, new ResponseContext(500)); |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * @Route("/api/{version}/organization/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_organization_rule", requirements={"id"="\d+"}) |
|
163 | - */ |
|
164 | - public function deleteAction(int $id) { |
|
161 | + /** |
|
162 | + * @Route("/api/{version}/organization/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_organization_rule", requirements={"id"="\d+"}) |
|
163 | + */ |
|
164 | + public function deleteAction(int $id) { |
|
165 | 165 | $rule = $this->findOr404($id); |
166 | 166 | $ruleRepository = $this->ruleRepository; |
167 | 167 | $ruleRepository->remove($rule); |
168 | 168 | |
169 | 169 | return new SingleResourceResponse(null, new ResponseContext(204)); |
170 | - } |
|
170 | + } |
|
171 | 171 | |
172 | - private function findOr404(int $id) { |
|
172 | + private function findOr404(int $id) { |
|
173 | 173 | $tenantContext = $this->cachedTenantContext; |
174 | 174 | $this->getEventDispatcher()->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE); |
175 | 175 | |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | 'organization' => $tenantContext->getTenant()->getOrganization(), |
179 | 179 | 'tenantCode' => null, |
180 | 180 | ]))) { |
181 | - throw new NotFoundHttpException('Organization rule was not found.'); |
|
181 | + throw new NotFoundHttpException('Organization rule was not found.'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | return $rule; |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - private function getRuleRepository() { |
|
187 | + private function getRuleRepository() { |
|
188 | 188 | return $this->ruleRepository; |
189 | - } |
|
189 | + } |
|
190 | 190 | |
191 | - private function getEventDispatcher() { |
|
191 | + private function getEventDispatcher() { |
|
192 | 192 | return $this->eventDispatcher; |
193 | - } |
|
193 | + } |
|
194 | 194 | } |
@@ -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 | } |