@@ -35,38 +35,38 @@ discard block |
||
35 | 35 | |
36 | 36 | class FbApplicationController extends Controller { |
37 | 37 | |
38 | - private FormFactoryInterface $formFactory; |
|
39 | - private RepositoryInterface $facebookAppRepository; |
|
40 | - private RepositoryInterface $facebookPageRepository; |
|
41 | - private Factory $facebookAppFactory; |
|
42 | - private EventDispatcherInterface $eventDispatcher; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param FormFactoryInterface $formFactory |
|
46 | - * @param RepositoryInterface $facebookAppRepository |
|
47 | - * @param RepositoryInterface $facebookPageRepository |
|
48 | - * @param Factory $facebookAppFactory |
|
49 | - * @param EventDispatcherInterface $eventDispatcher |
|
50 | - */ |
|
51 | - public function __construct(FormFactoryInterface $formFactory, RepositoryInterface $facebookAppRepository, |
|
52 | - RepositoryInterface $facebookPageRepository, Factory $facebookAppFactory, |
|
53 | - EventDispatcherInterface $eventDispatcher) { |
|
38 | + private FormFactoryInterface $formFactory; |
|
39 | + private RepositoryInterface $facebookAppRepository; |
|
40 | + private RepositoryInterface $facebookPageRepository; |
|
41 | + private Factory $facebookAppFactory; |
|
42 | + private EventDispatcherInterface $eventDispatcher; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param FormFactoryInterface $formFactory |
|
46 | + * @param RepositoryInterface $facebookAppRepository |
|
47 | + * @param RepositoryInterface $facebookPageRepository |
|
48 | + * @param Factory $facebookAppFactory |
|
49 | + * @param EventDispatcherInterface $eventDispatcher |
|
50 | + */ |
|
51 | + public function __construct(FormFactoryInterface $formFactory, RepositoryInterface $facebookAppRepository, |
|
52 | + RepositoryInterface $facebookPageRepository, Factory $facebookAppFactory, |
|
53 | + EventDispatcherInterface $eventDispatcher) { |
|
54 | 54 | $this->formFactory = $formFactory; |
55 | 55 | $this->facebookAppRepository = $facebookAppRepository; |
56 | 56 | $this->facebookPageRepository = $facebookPageRepository; |
57 | 57 | $this->facebookAppFactory = $facebookAppFactory; |
58 | 58 | $this->eventDispatcher = $eventDispatcher; |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @Route("/api/{version}/facebook/applications/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_applications") |
|
64 | - */ |
|
65 | - public function listAction(Request $request): ResourcesListResponseInterface { |
|
62 | + /** |
|
63 | + * @Route("/api/{version}/facebook/applications/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_applications") |
|
64 | + */ |
|
65 | + public function listAction(Request $request): ResourcesListResponseInterface { |
|
66 | 66 | $repository = $this->facebookAppRepository; |
67 | 67 | $sort = $request->query->all('sorting'); |
68 | 68 | if (empty($sort)) { |
69 | - $sort = ['id' => 'asc']; |
|
69 | + $sort = ['id' => 'asc']; |
|
70 | 70 | } |
71 | 71 | $items = $repository->getPaginatedByCriteria( |
72 | 72 | $this->eventDispatcher, |
@@ -76,51 +76,51 @@ discard block |
||
76 | 76 | ); |
77 | 77 | |
78 | 78 | return new ResourcesListResponse($items); |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @Route("/api/{version}/facebook/applications/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_create_facebook_applications") |
|
83 | - */ |
|
84 | - public function createAction(Request $request) { |
|
81 | + /** |
|
82 | + * @Route("/api/{version}/facebook/applications/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_create_facebook_applications") |
|
83 | + */ |
|
84 | + public function createAction(Request $request) { |
|
85 | 85 | /* @var FacebookApplication $feed */ |
86 | 86 | $application = $this->facebookAppFactory->create(); |
87 | 87 | $form = $this->formFactory->createNamed('', FacebookApplicationType::class, $application, ['method' => $request->getMethod()]); |
88 | 88 | |
89 | 89 | $form->handleRequest($request); |
90 | 90 | if ($form->isSubmitted() && $form->isValid()) { |
91 | - $this->checkIfApplicationExists($application); |
|
92 | - $this->facebookAppRepository->add($application); |
|
91 | + $this->checkIfApplicationExists($application); |
|
92 | + $this->facebookAppRepository->add($application); |
|
93 | 93 | |
94 | - return new SingleResourceResponse($application, new ResponseContext(201)); |
|
94 | + return new SingleResourceResponse($application, new ResponseContext(201)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return new SingleResourceResponse($form, new ResponseContext(400)); |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @Route("/api/{version}/facebook/applications/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_delete_facebook_applications") |
|
102 | - */ |
|
103 | - public function deleteAction($id) { |
|
100 | + /** |
|
101 | + * @Route("/api/{version}/facebook/applications/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_delete_facebook_applications") |
|
102 | + */ |
|
103 | + public function deleteAction($id) { |
|
104 | 104 | $repository = $this->facebookAppRepository; |
105 | 105 | if (null === $application = $repository->findOneBy(['id' => $id])) { |
106 | - throw new NotFoundHttpException('There is no Application with provided id!'); |
|
106 | + throw new NotFoundHttpException('There is no Application with provided id!'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | if (null !== $page = $this->facebookPageRepository->findOneBy(['id' => $id])) { |
110 | - throw new ConflictHttpException(sprintf('This Application is used by page with id: %s!', $page->getId())); |
|
110 | + throw new ConflictHttpException(sprintf('This Application is used by page with id: %s!', $page->getId())); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $repository->remove($application); |
114 | 114 | |
115 | 115 | return new SingleResourceResponse(null, new ResponseContext(204)); |
116 | - } |
|
116 | + } |
|
117 | 117 | |
118 | - private function checkIfApplicationExists(ApplicationInterface $application) { |
|
118 | + private function checkIfApplicationExists(ApplicationInterface $application) { |
|
119 | 119 | if (null !== $this->facebookAppRepository->findOneBy([ |
120 | 120 | 'appId' => $application->getAppId(), |
121 | 121 | ]) |
122 | 122 | ) { |
123 | - throw new ConflictHttpException('This Application already exists!'); |
|
123 | + throw new ConflictHttpException('This Application already exists!'); |
|
124 | + } |
|
124 | 125 | } |
125 | - } |
|
126 | 126 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $tenantCode = $tenant->getCode(); |
84 | 84 | $themes = array_filter( |
85 | 85 | $themeRepository->findAll(), |
86 | - static function ($element) use (&$tenantCode) { |
|
87 | - if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR . $tenantCode)) { |
|
86 | + static function($element) use (&$tenantCode) { |
|
87 | + if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR.$tenantCode)) { |
|
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } catch (\Exception $e) { |
113 | 113 | return new SingleResourceResponse(['message' => $e->getMessage()], new ResponseContext(400)); |
114 | 114 | } |
115 | - $themeConfig = json_decode(file_get_contents($themePath . DIRECTORY_SEPARATOR . 'theme.json'), true); |
|
115 | + $themeConfig = json_decode(file_get_contents($themePath.DIRECTORY_SEPARATOR.'theme.json'), true); |
|
116 | 116 | |
117 | 117 | return new SingleResourceResponse($themeConfig, new ResponseContext(201)); |
118 | 118 | } |
@@ -36,34 +36,34 @@ discard block |
||
36 | 36 | |
37 | 37 | class ThemesController extends Controller { |
38 | 38 | |
39 | - private CachedTenantContextInterface $cachedTenantContext; |
|
40 | - private FormFactoryInterface $formFactory; |
|
41 | - private ThemeLoader $themeLoader; |
|
42 | - private ThemeServiceInterface $themeService; |
|
43 | - private ThemeUploaderInterface $themeUploader; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param CachedTenantContextInterface $cachedTenantContext |
|
47 | - * @param FormFactoryInterface $formFactory |
|
48 | - * @param ThemeLoader $themeLoader |
|
49 | - * @param ThemeServiceInterface $themeService |
|
50 | - * @param ThemeUploaderInterface $themeUploader |
|
51 | - */ |
|
52 | - public function __construct(CachedTenantContextInterface $cachedTenantContext, FormFactoryInterface $formFactory, |
|
53 | - ThemeLoader $themeLoader, ThemeServiceInterface $themeService, |
|
54 | - ThemeUploaderInterface $themeUploader) { |
|
39 | + private CachedTenantContextInterface $cachedTenantContext; |
|
40 | + private FormFactoryInterface $formFactory; |
|
41 | + private ThemeLoader $themeLoader; |
|
42 | + private ThemeServiceInterface $themeService; |
|
43 | + private ThemeUploaderInterface $themeUploader; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param CachedTenantContextInterface $cachedTenantContext |
|
47 | + * @param FormFactoryInterface $formFactory |
|
48 | + * @param ThemeLoader $themeLoader |
|
49 | + * @param ThemeServiceInterface $themeService |
|
50 | + * @param ThemeUploaderInterface $themeUploader |
|
51 | + */ |
|
52 | + public function __construct(CachedTenantContextInterface $cachedTenantContext, FormFactoryInterface $formFactory, |
|
53 | + ThemeLoader $themeLoader, ThemeServiceInterface $themeService, |
|
54 | + ThemeUploaderInterface $themeUploader) { |
|
55 | 55 | $this->cachedTenantContext = $cachedTenantContext; |
56 | 56 | $this->formFactory = $formFactory; |
57 | 57 | $this->themeLoader = $themeLoader; |
58 | 58 | $this->themeService = $themeService; |
59 | 59 | $this->themeUploader = $themeUploader; |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_available_themes") |
|
65 | - */ |
|
66 | - public function listAvailableAction(): ResourcesListResponseInterface { |
|
63 | + /** |
|
64 | + * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_available_themes") |
|
65 | + */ |
|
66 | + public function listAvailableAction(): ResourcesListResponseInterface { |
|
67 | 67 | $themeLoader = $this->themeLoader; |
68 | 68 | $themes = $themeLoader->load(); |
69 | 69 | $pagination = new SlidingPagination(); |
@@ -73,21 +73,21 @@ discard block |
||
73 | 73 | $pagination->setTotalItemCount(count($themes)); |
74 | 74 | |
75 | 75 | return new ResourcesListResponse($pagination); |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_tenant_themes") |
|
80 | - */ |
|
81 | - public function listInstalledAction(ThemeRepositoryInterface $themeRepository): ResourcesListResponseInterface { |
|
78 | + /** |
|
79 | + * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_tenant_themes") |
|
80 | + */ |
|
81 | + public function listInstalledAction(ThemeRepositoryInterface $themeRepository): ResourcesListResponseInterface { |
|
82 | 82 | /** @var TenantInterface $tenant */ |
83 | 83 | $tenant = $this->cachedTenantContext->getTenant(); |
84 | 84 | $tenantCode = $tenant->getCode(); |
85 | 85 | $themes = array_filter( |
86 | 86 | $themeRepository->findAll(), |
87 | 87 | static function ($element) use (&$tenantCode) { |
88 | - if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR . $tenantCode)) { |
|
88 | + if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR . $tenantCode)) { |
|
89 | 89 | return true; |
90 | - } |
|
90 | + } |
|
91 | 91 | } |
92 | 92 | ); |
93 | 93 | |
@@ -98,46 +98,46 @@ discard block |
||
98 | 98 | $pagination->setTotalItemCount(count($themes)); |
99 | 99 | |
100 | 100 | return new ResourcesListResponse($pagination); |
101 | - } |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme") |
|
105 | - */ |
|
106 | - public function uploadThemeAction(Request $request): SingleResourceResponseInterface { |
|
103 | + /** |
|
104 | + * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme") |
|
105 | + */ |
|
106 | + public function uploadThemeAction(Request $request): SingleResourceResponseInterface { |
|
107 | 107 | $form = $this->formFactory->createNamed('', ThemeUploadType::class, []); |
108 | 108 | $form->handleRequest($request); |
109 | 109 | if ($form->isSubmitted() && $form->isValid()) { |
110 | - $formData = $form->getData(); |
|
111 | - $themeUploader = $this->themeUploader; |
|
110 | + $formData = $form->getData(); |
|
111 | + $themeUploader = $this->themeUploader; |
|
112 | 112 | |
113 | - try { |
|
113 | + try { |
|
114 | 114 | $themePath = $themeUploader->upload($formData['file']); |
115 | - } catch (\Exception $e) { |
|
115 | + } catch (\Exception $e) { |
|
116 | 116 | return new SingleResourceResponse(['message' => $e->getMessage()], new ResponseContext(400)); |
117 | - } |
|
118 | - $themeConfig = json_decode(file_get_contents($themePath . DIRECTORY_SEPARATOR . 'theme.json'), true); |
|
117 | + } |
|
118 | + $themeConfig = json_decode(file_get_contents($themePath . DIRECTORY_SEPARATOR . 'theme.json'), true); |
|
119 | 119 | |
120 | - return new SingleResourceResponse($themeConfig, new ResponseContext(201)); |
|
120 | + return new SingleResourceResponse($themeConfig, new ResponseContext(201)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return new SingleResourceResponse($form, new ResponseContext(400)); |
124 | - } |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_install_theme") |
|
128 | - */ |
|
129 | - public function installThemeAction(Request $request): SingleResourceResponseInterface { |
|
126 | + /** |
|
127 | + * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_install_theme") |
|
128 | + */ |
|
129 | + public function installThemeAction(Request $request): SingleResourceResponseInterface { |
|
130 | 130 | $form = $this->formFactory->createNamed('', ThemeInstallType::class, []); |
131 | 131 | $form->handleRequest($request); |
132 | 132 | if ($form->isSubmitted() && $form->isValid()) { |
133 | - $formData = $form->getData(); |
|
134 | - $themeService = $this->themeService; |
|
135 | - [$sourceDir, $themeDir] = $themeService->getDirectoriesForTheme($formData['name']); |
|
136 | - $themeService->installAndProcessGeneratedData($sourceDir, $themeDir, $formData['processGeneratedData']); |
|
133 | + $formData = $form->getData(); |
|
134 | + $themeService = $this->themeService; |
|
135 | + [$sourceDir, $themeDir] = $themeService->getDirectoriesForTheme($formData['name']); |
|
136 | + $themeService->installAndProcessGeneratedData($sourceDir, $themeDir, $formData['processGeneratedData']); |
|
137 | 137 | |
138 | - return new SingleResourceResponse(['status' => 'installed'], new ResponseContext(201)); |
|
138 | + return new SingleResourceResponse(['status' => 'installed'], new ResponseContext(201)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return new SingleResourceResponse($form, new ResponseContext(400)); |
142 | - } |
|
142 | + } |
|
143 | 143 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | */ |
51 | 51 | public function getLogoAction(string $id) { |
52 | 52 | $cacheKey = md5(serialize(['upload', $id])); |
53 | - return $this->cacheInterface->get($cacheKey, function (CacheItemInterface $item, &$save) use ($id) { |
|
53 | + return $this->cacheInterface->get($cacheKey, function(CacheItemInterface $item, &$save) use ($id) { |
|
54 | 54 | $item->expiresAfter(63072000); |
55 | 55 | |
56 | 56 | $fileSystem = $this->filesystem; |
@@ -29,50 +29,50 @@ |
||
29 | 29 | |
30 | 30 | class ThemeLogoController extends Controller { |
31 | 31 | |
32 | - private Filesystem $filesystem; |
|
33 | - private ThemeLogoUploaderInterface $themeLogoUploader; |
|
34 | - private CacheInterface $cacheInterface; |
|
32 | + private Filesystem $filesystem; |
|
33 | + private ThemeLogoUploaderInterface $themeLogoUploader; |
|
34 | + private CacheInterface $cacheInterface; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param Filesystem $filesystem |
|
38 | - * @param ThemeLogoUploaderInterface $themeLogoUploader |
|
39 | - * @param CacheInterface $cacheInterface |
|
40 | - */ |
|
41 | - public function __construct(Filesystem $filesystem, ThemeLogoUploaderInterface $themeLogoUploader, |
|
42 | - CacheInterface $cacheInterface) { |
|
36 | + /** |
|
37 | + * @param Filesystem $filesystem |
|
38 | + * @param ThemeLogoUploaderInterface $themeLogoUploader |
|
39 | + * @param CacheInterface $cacheInterface |
|
40 | + */ |
|
41 | + public function __construct(Filesystem $filesystem, ThemeLogoUploaderInterface $themeLogoUploader, |
|
42 | + CacheInterface $cacheInterface) { |
|
43 | 43 | $this->filesystem = $filesystem; |
44 | 44 | $this->themeLogoUploader = $themeLogoUploader; |
45 | 45 | $this->cacheInterface = $cacheInterface; |
46 | - } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @Route("/theme_logo/{id}", options={"expose"=true}, requirements={"id"=".+"}, methods={"GET"}, name="swp_theme_logo_get") |
|
50 | - */ |
|
51 | - public function getLogoAction(string $id) { |
|
48 | + /** |
|
49 | + * @Route("/theme_logo/{id}", options={"expose"=true}, requirements={"id"=".+"}, methods={"GET"}, name="swp_theme_logo_get") |
|
50 | + */ |
|
51 | + public function getLogoAction(string $id) { |
|
52 | 52 | $cacheKey = md5(serialize(['upload', $id])); |
53 | 53 | return $this->cacheInterface->get($cacheKey, function (CacheItemInterface $item, &$save) use ($id) { |
54 | - $item->expiresAfter(63072000); |
|
54 | + $item->expiresAfter(63072000); |
|
55 | 55 | |
56 | - $fileSystem = $this->filesystem; |
|
57 | - $themeLogoUploader = $this->themeLogoUploader; |
|
58 | - $id = $themeLogoUploader->getThemeLogoUploadPath($id); |
|
59 | - $file = $fileSystem->has($id); |
|
60 | - if (!$file) { |
|
56 | + $fileSystem = $this->filesystem; |
|
57 | + $themeLogoUploader = $this->themeLogoUploader; |
|
58 | + $id = $themeLogoUploader->getThemeLogoUploadPath($id); |
|
59 | + $file = $fileSystem->has($id); |
|
60 | + if (!$file) { |
|
61 | 61 | $save = false; |
62 | 62 | throw new NotFoundHttpException('File was not found.'); |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - $path = $fileSystem->get($id)->getPath(); |
|
66 | - $response = new Response(); |
|
67 | - $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE, pathinfo($path, PATHINFO_BASENAME)); |
|
68 | - $response->headers->set('Content-Disposition', $disposition); |
|
69 | - $response->headers->set('Content-Type', MimeTypeHelper::getByPath($path)); |
|
70 | - $response->setPublic(); |
|
71 | - $response->setMaxAge(63072000); |
|
72 | - $response->setSharedMaxAge(63072000); |
|
73 | - $response->setContent($fileSystem->read($path)); |
|
65 | + $path = $fileSystem->get($id)->getPath(); |
|
66 | + $response = new Response(); |
|
67 | + $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE, pathinfo($path, PATHINFO_BASENAME)); |
|
68 | + $response->headers->set('Content-Disposition', $disposition); |
|
69 | + $response->headers->set('Content-Type', MimeTypeHelper::getByPath($path)); |
|
70 | + $response->setPublic(); |
|
71 | + $response->setMaxAge(63072000); |
|
72 | + $response->setSharedMaxAge(63072000); |
|
73 | + $response->setContent($fileSystem->read($path)); |
|
74 | 74 | |
75 | - return $response; |
|
75 | + return $response; |
|
76 | 76 | }); |
77 | - } |
|
77 | + } |
|
78 | 78 | } |
@@ -29,32 +29,32 @@ discard block |
||
29 | 29 | |
30 | 30 | class FbiaArticleController extends Controller { |
31 | 31 | |
32 | - private FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository; |
|
33 | - private FacebookInstantArticlesService $facebookInstantArticlesService; |
|
34 | - private EventDispatcherInterface $eventDispatcher; |
|
32 | + private FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository; |
|
33 | + private FacebookInstantArticlesService $facebookInstantArticlesService; |
|
34 | + private EventDispatcherInterface $eventDispatcher; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository |
|
38 | - * @param FacebookInstantArticlesService $facebookInstantArticlesService |
|
39 | - * @param EventDispatcherInterface $eventDispatcher |
|
40 | - */ |
|
41 | - public function __construct(FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository, |
|
42 | - FacebookInstantArticlesService $facebookInstantArticlesService, |
|
43 | - EventDispatcherInterface $eventDispatcher) { |
|
36 | + /** |
|
37 | + * @param FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository |
|
38 | + * @param FacebookInstantArticlesService $facebookInstantArticlesService |
|
39 | + * @param EventDispatcherInterface $eventDispatcher |
|
40 | + */ |
|
41 | + public function __construct(FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository, |
|
42 | + FacebookInstantArticlesService $facebookInstantArticlesService, |
|
43 | + EventDispatcherInterface $eventDispatcher) { |
|
44 | 44 | $this->facebookInstantArticlesArticleRepository = $facebookInstantArticlesArticleRepository; |
45 | 45 | $this->facebookInstantArticlesService = $facebookInstantArticlesService; |
46 | 46 | $this->eventDispatcher = $eventDispatcher; |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @Route("/api/{version}/facebook/instantarticles/articles/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_instant_articles_articles") |
|
52 | - */ |
|
53 | - public function listAction(Request $request): ResourcesListResponseInterface { |
|
50 | + /** |
|
51 | + * @Route("/api/{version}/facebook/instantarticles/articles/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_instant_articles_articles") |
|
52 | + */ |
|
53 | + public function listAction(Request $request): ResourcesListResponseInterface { |
|
54 | 54 | $repository = $this->facebookInstantArticlesArticleRepository; |
55 | 55 | $sort = $request->query->all('sorting'); |
56 | 56 | if (empty($sort)) { |
57 | - $sort = ['createdAt' => 'desc']; |
|
57 | + $sort = ['createdAt' => 'desc']; |
|
58 | 58 | } |
59 | 59 | $items = $repository->getPaginatedByCriteria( |
60 | 60 | $this->eventDispatcher, |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | return new ResourcesListResponse($items); |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @Route("/api/{version}/facebook/instantarticles/articles/{submissionId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_facebook_instant_articles_articles_update") |
|
71 | - */ |
|
72 | - public function updateSubmissionAction(string $submissionId): SingleResourceResponseInterface { |
|
69 | + /** |
|
70 | + * @Route("/api/{version}/facebook/instantarticles/articles/{submissionId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_facebook_instant_articles_articles_update") |
|
71 | + */ |
|
72 | + public function updateSubmissionAction(string $submissionId): SingleResourceResponseInterface { |
|
73 | 73 | $instantArticlesService = $this->facebookInstantArticlesService; |
74 | 74 | $instantArticle = $instantArticlesService->updateSubmissionStatus($submissionId); |
75 | 75 | |
76 | 76 | return new SingleResourceResponse($instantArticle); |
77 | - } |
|
77 | + } |
|
78 | 78 | } |
@@ -43,29 +43,29 @@ |
||
43 | 43 | { |
44 | 44 | $collectionRouteCacheKey = md5('route_'.$url); |
45 | 45 | return $this->cacheProvider->get($collectionRouteCacheKey, function (ItemInterface $item, &$save) use ($url) { |
46 | - try { |
|
46 | + try { |
|
47 | 47 | $route = $this->matcher->match($this->getFragmentFromUrl($url, 'path')); |
48 | - } catch(ResourceNotFoundException $e) { |
|
48 | + } catch(ResourceNotFoundException $e) { |
|
49 | 49 | $save = false; |
50 | 50 | return null; |
51 | - } |
|
52 | - if(!isset($route['_article_meta'])) { |
|
51 | + } |
|
52 | + if(!isset($route['_article_meta'])) { |
|
53 | 53 | $save = false; |
54 | 54 | return null; |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | - if(!($route['_article_meta'] instanceof Meta)) { |
|
57 | + if(!($route['_article_meta'] instanceof Meta)) { |
|
58 | 58 | $save = false; |
59 | 59 | return null; |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | - $values = $route['_article_meta']->getValues(); |
|
63 | - if(!($values instanceof ArticleInterface)) { |
|
62 | + $values = $route['_article_meta']->getValues(); |
|
63 | + if(!($values instanceof ArticleInterface)) { |
|
64 | 64 | $save = false; |
65 | 65 | return null; |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - return $values; |
|
68 | + return $values; |
|
69 | 69 | }); |
70 | 70 | } |
71 | 71 |
@@ -42,25 +42,25 @@ |
||
42 | 42 | public function resolve(string $url): ?ArticleInterface |
43 | 43 | { |
44 | 44 | $collectionRouteCacheKey = md5('route_'.$url); |
45 | - return $this->cacheProvider->get($collectionRouteCacheKey, function (ItemInterface $item, &$save) use ($url) { |
|
45 | + return $this->cacheProvider->get($collectionRouteCacheKey, function(ItemInterface $item, &$save) use ($url) { |
|
46 | 46 | try { |
47 | 47 | $route = $this->matcher->match($this->getFragmentFromUrl($url, 'path')); |
48 | - } catch(ResourceNotFoundException $e) { |
|
48 | + } catch (ResourceNotFoundException $e) { |
|
49 | 49 | $save = false; |
50 | 50 | return null; |
51 | 51 | } |
52 | - if(!isset($route['_article_meta'])) { |
|
52 | + if (!isset($route['_article_meta'])) { |
|
53 | 53 | $save = false; |
54 | 54 | return null; |
55 | 55 | } |
56 | 56 | |
57 | - if(!($route['_article_meta'] instanceof Meta)) { |
|
57 | + if (!($route['_article_meta'] instanceof Meta)) { |
|
58 | 58 | $save = false; |
59 | 59 | return null; |
60 | 60 | } |
61 | 61 | |
62 | 62 | $values = $route['_article_meta']->getValues(); |
63 | - if(!($values instanceof ArticleInterface)) { |
|
63 | + if (!($values instanceof ArticleInterface)) { |
|
64 | 64 | $save = false; |
65 | 65 | return null; |
66 | 66 | } |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | if (null !== $existingPackage) { |
126 | 126 | $existingPackage = $this->packageHydrator->hydrate($package, $existingPackage); |
127 | 127 | |
128 | - $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PRE_UPDATE]), Events::PACKAGE_PRE_UPDATE); |
|
128 | + $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PRE_UPDATE]), Events::PACKAGE_PRE_UPDATE); |
|
129 | 129 | $this->packageObjectManager->flush(); |
130 | - $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_POST_UPDATE]), Events::PACKAGE_POST_UPDATE); |
|
131 | - $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
130 | + $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_POST_UPDATE]), Events::PACKAGE_POST_UPDATE); |
|
131 | + $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
132 | 132 | $this->packageObjectManager->flush(); |
133 | 133 | |
134 | 134 | $this->reset(); |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | - $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_PRE_CREATE]), Events::PACKAGE_PRE_CREATE); |
|
140 | + $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_PRE_CREATE]), Events::PACKAGE_PRE_CREATE); |
|
141 | 141 | $this->packageRepository->add($package); |
142 | - $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_POST_CREATE]), Events::PACKAGE_POST_CREATE); |
|
143 | - $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
142 | + $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_POST_CREATE]), Events::PACKAGE_POST_CREATE); |
|
143 | + $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED); |
|
144 | 144 | $this->packageObjectManager->flush(); |
145 | 145 | |
146 | 146 | $this->logger->info(sprintf('Package %s was created', $package->getGuid())); |
@@ -52,7 +52,7 @@ |
||
52 | 52 | |
53 | 53 | if ($isPublishedToAppleNews = (bool) $configuration[$this->supportedKeys[0]]) { |
54 | 54 | $subject->setPublishedToAppleNews($isPublishedToAppleNews); |
55 | - $this->eventDispatcher->dispatch( new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH); |
|
55 | + $this->eventDispatcher->dispatch(new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH); |
|
56 | 56 | |
57 | 57 | $this->logger->info(sprintf( |
58 | 58 | 'Configuration: "%s" for "%s" rule has been applied!', |
@@ -60,7 +60,7 @@ |
||
60 | 60 | |
61 | 61 | if ($isPublishedFBIA = (bool) $configuration['isPublishedFbia']) { |
62 | 62 | $subject->setPublishedFBIA($isPublishedFBIA); |
63 | - $this->eventDispatcher->dispatch( new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH); |
|
63 | + $this->eventDispatcher->dispatch(new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH); |
|
64 | 64 | |
65 | 65 | $this->logger->info(sprintf( |
66 | 66 | 'Configuration: "%s" for "%s" rule has been applied!', |
@@ -101,14 +101,14 @@ |
||
101 | 101 | |
102 | 102 | $this->articleRepository->persist($articleStatistics); |
103 | 103 | |
104 | - $this->eventDispatcher->dispatch( new GenericEvent($article), Events::SWP_VALIDATION); |
|
104 | + $this->eventDispatcher->dispatch(new GenericEvent($article), Events::SWP_VALIDATION); |
|
105 | 105 | |
106 | 106 | $article->setPackage($package); |
107 | 107 | $article->setArticleStatistics($articleStatistics); |
108 | 108 | $this->articleRepository->persist($article); |
109 | - $this->eventDispatcher->dispatch( new ArticleEvent($article, $package, ArticleEvents::PRE_CREATE), ArticleEvents::PRE_CREATE); |
|
109 | + $this->eventDispatcher->dispatch(new ArticleEvent($article, $package, ArticleEvents::PRE_CREATE), ArticleEvents::PRE_CREATE); |
|
110 | 110 | $this->articleRepository->flush(); |
111 | - $this->eventDispatcher->dispatch( new ArticleEvent($article, $package, ArticleEvents::POST_CREATE),ArticleEvents::POST_CREATE); |
|
111 | + $this->eventDispatcher->dispatch(new ArticleEvent($article, $package, ArticleEvents::POST_CREATE), ArticleEvents::POST_CREATE); |
|
112 | 112 | $this->entityManager->flush($article); |
113 | 113 | } |
114 | 114 | $this->tenantContext->setTenant($originalTenant); |