@@ -34,36 +34,36 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | class FbiaFeedController extends AbstractController { |
| 36 | 36 | |
| 37 | - private FormFactoryInterface $formFactory; |
|
| 38 | - private RepositoryInterface $facebookInstantArticlesFeedRepository; |
|
| 39 | - private FactoryInterface $facebookInstantArticlesFeedFactory; |
|
| 40 | - private EventDispatcherInterface $eventDispatcher; |
|
| 37 | + private FormFactoryInterface $formFactory; |
|
| 38 | + private RepositoryInterface $facebookInstantArticlesFeedRepository; |
|
| 39 | + private FactoryInterface $facebookInstantArticlesFeedFactory; |
|
| 40 | + private EventDispatcherInterface $eventDispatcher; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @param FormFactoryInterface $formFactory |
|
| 44 | - * @param RepositoryInterface $facebookInstantArticlesFeedRepository |
|
| 45 | - * @param FactoryInterface $facebookInstantArticlesFeedFactory |
|
| 46 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 47 | - */ |
|
| 48 | - public function __construct(FormFactoryInterface $formFactory, |
|
| 49 | - RepositoryInterface $facebookInstantArticlesFeedRepository, |
|
| 50 | - FactoryInterface $facebookInstantArticlesFeedFactory, |
|
| 51 | - EventDispatcherInterface $eventDispatcher) { |
|
| 42 | + /** |
|
| 43 | + * @param FormFactoryInterface $formFactory |
|
| 44 | + * @param RepositoryInterface $facebookInstantArticlesFeedRepository |
|
| 45 | + * @param FactoryInterface $facebookInstantArticlesFeedFactory |
|
| 46 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 47 | + */ |
|
| 48 | + public function __construct(FormFactoryInterface $formFactory, |
|
| 49 | + RepositoryInterface $facebookInstantArticlesFeedRepository, |
|
| 50 | + FactoryInterface $facebookInstantArticlesFeedFactory, |
|
| 51 | + EventDispatcherInterface $eventDispatcher) { |
|
| 52 | 52 | $this->formFactory = $formFactory; |
| 53 | 53 | $this->facebookInstantArticlesFeedRepository = $facebookInstantArticlesFeedRepository; |
| 54 | 54 | $this->facebookInstantArticlesFeedFactory = $facebookInstantArticlesFeedFactory; |
| 55 | 55 | $this->eventDispatcher = $eventDispatcher; |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @Route("/api/{version}/facebook/instantarticles/feed/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_instant_articles_feed") |
|
| 61 | - */ |
|
| 62 | - public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 59 | + /** |
|
| 60 | + * @Route("/api/{version}/facebook/instantarticles/feed/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_instant_articles_feed") |
|
| 61 | + */ |
|
| 62 | + public function listAction(Request $request): ResourcesListResponseInterface { |
|
| 63 | 63 | $repository = $this->facebookInstantArticlesFeedRepository; |
| 64 | 64 | $sort = $request->query->all('sorting'); |
| 65 | 65 | if (empty($sort)) { |
| 66 | - $sort = ['createdAt' => 'desc']; |
|
| 66 | + $sort = ['createdAt' => 'desc']; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $items = $repository->getPaginatedByCriteria( |
@@ -74,33 +74,33 @@ discard block |
||
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | return new ResourcesListResponse($items); |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @Route("/api/{version}/facebook/instantarticles/feed/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_create_facebook_instant_articles_feed") |
|
| 81 | - */ |
|
| 82 | - public function createAction(Request $request): SingleResourceResponseInterface { |
|
| 79 | + /** |
|
| 80 | + * @Route("/api/{version}/facebook/instantarticles/feed/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_create_facebook_instant_articles_feed") |
|
| 81 | + */ |
|
| 82 | + public function createAction(Request $request): SingleResourceResponseInterface { |
|
| 83 | 83 | /* @var FacebookInstantArticlesFeedInterface $feed */ |
| 84 | 84 | $feed = $this->facebookInstantArticlesFeedFactory->create(); |
| 85 | 85 | $form = $this->formFactory->createNamed('', FacebookInstantArticlesFeedType::class, $feed, ['method' => $request->getMethod()]); |
| 86 | 86 | |
| 87 | 87 | $form->handleRequest($request); |
| 88 | 88 | if ($form->isSubmitted() && $form->isValid()) { |
| 89 | - $this->checkIfFeedExists($feed->getContentBucket(), $feed->getFacebookPage()); |
|
| 90 | - $this->facebookInstantArticlesFeedRepository->add($feed); |
|
| 89 | + $this->checkIfFeedExists($feed->getContentBucket(), $feed->getFacebookPage()); |
|
| 90 | + $this->facebookInstantArticlesFeedRepository->add($feed); |
|
| 91 | 91 | |
| 92 | - return new SingleResourceResponse($feed, new ResponseContext(201)); |
|
| 92 | + return new SingleResourceResponse($feed, new ResponseContext(201)); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - private function checkIfFeedExists($contentBucket, $facebookPage) { |
|
| 98 | + private function checkIfFeedExists($contentBucket, $facebookPage) { |
|
| 99 | 99 | if (null !== $this->facebookInstantArticlesFeedRepository->findOneBy([ |
| 100 | 100 | 'contentBucket' => $contentBucket, |
| 101 | 101 | 'facebookPage' => $facebookPage, |
| 102 | 102 | ])) { |
| 103 | - throw new ConflictHttpException('Feed for that page and content bucket already exists!'); |
|
| 103 | + throw new ConflictHttpException('Feed for that page and content bucket already exists!'); |
|
| 104 | + } |
|
| 104 | 105 | } |
| 105 | - } |
|
| 106 | 106 | } |
@@ -34,86 +34,86 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | class RuleController extends FOSRestController { |
| 36 | 36 | |
| 37 | - private FormFactoryInterface $formFactory; |
|
| 38 | - private EntityManagerInterface $entityManager; |
|
| 39 | - private RuleRepositoryInterface $ruleRepository; |
|
| 40 | - private FactoryInterface $ruleFactory; |
|
| 41 | - private EventDispatcherInterface $eventDispatcher; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @param FormFactoryInterface $formFactory |
|
| 45 | - * @param EntityManagerInterface $entityManager |
|
| 46 | - * @param RuleRepositoryInterface $ruleRepository |
|
| 47 | - * @param FactoryInterface $ruleFactory |
|
| 48 | - * @param EventDispatcherInterface $eventDispatcher |
|
| 49 | - */ |
|
| 50 | - public function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, |
|
| 51 | - RuleRepositoryInterface $ruleRepository, FactoryInterface $ruleFactory, |
|
| 52 | - EventDispatcherInterface $eventDispatcher) { |
|
| 37 | + private FormFactoryInterface $formFactory; |
|
| 38 | + private EntityManagerInterface $entityManager; |
|
| 39 | + private RuleRepositoryInterface $ruleRepository; |
|
| 40 | + private FactoryInterface $ruleFactory; |
|
| 41 | + private EventDispatcherInterface $eventDispatcher; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @param FormFactoryInterface $formFactory |
|
| 45 | + * @param EntityManagerInterface $entityManager |
|
| 46 | + * @param RuleRepositoryInterface $ruleRepository |
|
| 47 | + * @param FactoryInterface $ruleFactory |
|
| 48 | + * @param EventDispatcherInterface $eventDispatcher |
|
| 49 | + */ |
|
| 50 | + public function __construct(FormFactoryInterface $formFactory, EntityManagerInterface $entityManager, |
|
| 51 | + RuleRepositoryInterface $ruleRepository, FactoryInterface $ruleFactory, |
|
| 52 | + EventDispatcherInterface $eventDispatcher) { |
|
| 53 | 53 | $this->formFactory = $formFactory; |
| 54 | 54 | $this->entityManager = $entityManager; |
| 55 | 55 | $this->ruleRepository = $ruleRepository; |
| 56 | 56 | $this->ruleFactory = $ruleFactory; |
| 57 | 57 | $this->eventDispatcher = $eventDispatcher; |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_rule") |
|
| 63 | - */ |
|
| 64 | - public function listAction(Request $request) { |
|
| 61 | + /** |
|
| 62 | + * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_rule") |
|
| 63 | + */ |
|
| 64 | + public function listAction(Request $request) { |
|
| 65 | 65 | $rules = $this->ruleRepository |
| 66 | 66 | ->getPaginatedByCriteria($this->eventDispatcher, new Criteria(), $request->query->all('sorting'), new PaginationData($request)); |
| 67 | 67 | |
| 68 | 68 | if (0 === $rules->count()) { |
| 69 | - throw new NotFoundHttpException('No rules were found.'); |
|
| 69 | + throw new NotFoundHttpException('No rules were found.'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return new ResourcesListResponse($rules); |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @Route("/api/{version}/rules/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_rule") |
|
| 77 | - * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule") |
|
| 78 | - */ |
|
| 79 | - public function getAction(RuleInterface $rule) { |
|
| 75 | + /** |
|
| 76 | + * @Route("/api/{version}/rules/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_rule") |
|
| 77 | + * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule") |
|
| 78 | + */ |
|
| 79 | + public function getAction(RuleInterface $rule) { |
|
| 80 | 80 | return new SingleResourceResponse($rule); |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_rule") |
|
| 85 | - */ |
|
| 86 | - public function createAction(Request $request) { |
|
| 83 | + /** |
|
| 84 | + * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_rule") |
|
| 85 | + */ |
|
| 86 | + public function createAction(Request $request) { |
|
| 87 | 87 | $ruleRepository = $this->ruleRepository; |
| 88 | 88 | $rule = $this->ruleFactory->create(); |
| 89 | 89 | $form = $this->formFactory->createNamed('', RuleType::class, $rule); |
| 90 | 90 | $form->handleRequest($request); |
| 91 | 91 | |
| 92 | 92 | if ($form->isSubmitted() && $form->isValid()) { |
| 93 | - $ruleRepository->add($rule); |
|
| 93 | + $ruleRepository->add($rule); |
|
| 94 | 94 | |
| 95 | - return new SingleResourceResponse($rule, new ResponseContext(201)); |
|
| 95 | + return new SingleResourceResponse($rule, new ResponseContext(201)); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_rule", methods={"DELETE"}, requirements={"id"="\d+"}) |
|
| 103 | - * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule") |
|
| 104 | - */ |
|
| 105 | - public function deleteAction(RuleInterface $rule) { |
|
| 101 | + /** |
|
| 102 | + * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_rule", methods={"DELETE"}, requirements={"id"="\d+"}) |
|
| 103 | + * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule") |
|
| 104 | + */ |
|
| 105 | + public function deleteAction(RuleInterface $rule) { |
|
| 106 | 106 | $ruleRepository = $this->ruleRepository; |
| 107 | 107 | $ruleRepository->remove($rule); |
| 108 | 108 | |
| 109 | 109 | return new SingleResourceResponse(null, new ResponseContext(204)); |
| 110 | - } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_rule", requirements={"id"="\d+"}) |
|
| 114 | - * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule") |
|
| 115 | - */ |
|
| 116 | - public function updateAction(Request $request, RuleInterface $rule) { |
|
| 112 | + /** |
|
| 113 | + * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_rule", requirements={"id"="\d+"}) |
|
| 114 | + * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule") |
|
| 115 | + */ |
|
| 116 | + public function updateAction(Request $request, RuleInterface $rule) { |
|
| 117 | 117 | $objectManager = $this->entityManager; |
| 118 | 118 | |
| 119 | 119 | $form = $this->formFactory->createNamed('', RuleType::class, $rule, [ |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $form->handleRequest($request); |
| 124 | 124 | if ($form->isSubmitted() && $form->isValid()) { |
| 125 | - $objectManager->flush(); |
|
| 126 | - $objectManager->refresh($rule); |
|
| 125 | + $objectManager->flush(); |
|
| 126 | + $objectManager->refresh($rule); |
|
| 127 | 127 | |
| 128 | - return new SingleResourceResponse($rule); |
|
| 128 | + return new SingleResourceResponse($rule); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return new SingleResourceResponse($form, new ResponseContext(400)); |
| 132 | - } |
|
| 132 | + } |
|
| 133 | 133 | } |
@@ -13,21 +13,21 @@ discard block |
||
| 13 | 13 | use Symfony\Component\Routing\Annotation\Route; |
| 14 | 14 | |
| 15 | 15 | class ExternalOauthController extends Controller { |
| 16 | - public const PUBLISHER_JWT_COOKIE = 'publisher_jwt'; |
|
| 16 | + public const PUBLISHER_JWT_COOKIE = 'publisher_jwt'; |
|
| 17 | 17 | |
| 18 | - private ClientRegistry $clientRegistry; |
|
| 18 | + private ClientRegistry $clientRegistry; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param ClientRegistry $clientRegistry |
|
| 22 | - */ |
|
| 23 | - public function __construct(ClientRegistry $clientRegistry) { |
|
| 20 | + /** |
|
| 21 | + * @param ClientRegistry $clientRegistry |
|
| 22 | + */ |
|
| 23 | + public function __construct(ClientRegistry $clientRegistry) { |
|
| 24 | 24 | $this->clientRegistry = $clientRegistry; |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @Route("/connect/oauth", name="connect_oauth_start") |
|
| 29 | - */ |
|
| 30 | - public function connectAction(Request $request): Response { |
|
| 27 | + /** |
|
| 28 | + * @Route("/connect/oauth", name="connect_oauth_start") |
|
| 29 | + */ |
|
| 30 | + public function connectAction(Request $request): Response { |
|
| 31 | 31 | $referer = $request->headers->get('referer'); |
| 32 | 32 | |
| 33 | 33 | return $this->clientRegistry |
@@ -35,20 +35,20 @@ discard block |
||
| 35 | 35 | ->redirect([ |
| 36 | 36 | 'openid', 'email', 'profile', |
| 37 | 37 | ], ['state' => $referer]); |
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * This is where the user is redirected after being succesfully authenticated by the OAuth server. |
|
| 42 | - * |
|
| 43 | - * @Route("/connect/oauth/check", name="connect_oauth_check") |
|
| 44 | - */ |
|
| 45 | - public function connectCheckAction(Request $request, JWTTokenManagerInterface $jwtTokenManager): Response { |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * This is where the user is redirected after being succesfully authenticated by the OAuth server. |
|
| 42 | + * |
|
| 43 | + * @Route("/connect/oauth/check", name="connect_oauth_check") |
|
| 44 | + */ |
|
| 45 | + public function connectCheckAction(Request $request, JWTTokenManagerInterface $jwtTokenManager): Response { |
|
| 46 | 46 | // If we didn't log in, something went wrong. Throw an exception! |
| 47 | 47 | if (!($user = $this->getUser())) { |
| 48 | - $response = $this->render('bundles/TwigBundle/Exception/error403.html.twig'); |
|
| 49 | - $response->setStatusCode(403); |
|
| 48 | + $response = $this->render('bundles/TwigBundle/Exception/error403.html.twig'); |
|
| 49 | + $response->setStatusCode(403); |
|
| 50 | 50 | |
| 51 | - return $response; |
|
| 51 | + return $response; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $state = $request->query->get('state'); |
@@ -57,5 +57,5 @@ discard block |
||
| 57 | 57 | $response->headers->setCookie(Cookie::create(self::PUBLISHER_JWT_COOKIE, $jwtTokenManager->create($user))); |
| 58 | 58 | |
| 59 | 59 | return $response; |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -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 | } |
@@ -37,98 +37,98 @@ discard block |
||
| 37 | 37 | use Symfony\Component\Security\Core\User\UserProviderInterface; |
| 38 | 38 | |
| 39 | 39 | class AuthController extends AbstractController { |
| 40 | - protected FormFactoryInterface $formFactory; |
|
| 41 | - protected ApiKeyRepositoryInterface $apiKeyRepository; |
|
| 42 | - protected ApiKeyFactory $apiKeyFactory; |
|
| 43 | - protected LockFactory $lockFactory; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @param FormFactoryInterface $formFactory |
|
| 47 | - * @param ApiKeyRepositoryInterface $apiKeyRepository |
|
| 48 | - * @param ApiKeyFactory $apiKeyFactory |
|
| 49 | - * @param LockFactory $lockFactory |
|
| 50 | - */ |
|
| 51 | - public function __construct(FormFactoryInterface $formFactory, ApiKeyRepositoryInterface $apiKeyRepository, |
|
| 52 | - ApiKeyFactory $apiKeyFactory, LockFactory $lockFactory) { |
|
| 40 | + protected FormFactoryInterface $formFactory; |
|
| 41 | + protected ApiKeyRepositoryInterface $apiKeyRepository; |
|
| 42 | + protected ApiKeyFactory $apiKeyFactory; |
|
| 43 | + protected LockFactory $lockFactory; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param FormFactoryInterface $formFactory |
|
| 47 | + * @param ApiKeyRepositoryInterface $apiKeyRepository |
|
| 48 | + * @param ApiKeyFactory $apiKeyFactory |
|
| 49 | + * @param LockFactory $lockFactory |
|
| 50 | + */ |
|
| 51 | + public function __construct(FormFactoryInterface $formFactory, ApiKeyRepositoryInterface $apiKeyRepository, |
|
| 52 | + ApiKeyFactory $apiKeyFactory, LockFactory $lockFactory) { |
|
| 53 | 53 | $this->formFactory = $formFactory; |
| 54 | 54 | $this->apiKeyRepository = $apiKeyRepository; |
| 55 | 55 | $this->apiKeyFactory = $apiKeyFactory; |
| 56 | 56 | $this->lockFactory = $lockFactory; |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @Route("/api/{version}/auth/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_auth") |
|
| 62 | - */ |
|
| 63 | - public function authenticateAction(Request $request, UserProviderInterface $userProvider, |
|
| 64 | - UserPasswordHasherInterface $userPasswordEncoder) { |
|
| 60 | + /** |
|
| 61 | + * @Route("/api/{version}/auth/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_auth") |
|
| 62 | + */ |
|
| 63 | + public function authenticateAction(Request $request, UserProviderInterface $userProvider, |
|
| 64 | + UserPasswordHasherInterface $userPasswordEncoder) { |
|
| 65 | 65 | $form = $this->formFactory->createNamed('', UserAuthenticationType::class, []); |
| 66 | 66 | $form->handleRequest($request); |
| 67 | 67 | if ($form->isSubmitted() && $form->isValid()) { |
| 68 | - $formData = $form->getData(); |
|
| 68 | + $formData = $form->getData(); |
|
| 69 | 69 | |
| 70 | - try { |
|
| 70 | + try { |
|
| 71 | 71 | $user = $userProvider->loadUserByUsername($formData['username']); |
| 72 | - } catch (AuthenticationException $e) { |
|
| 72 | + } catch (AuthenticationException $e) { |
|
| 73 | 73 | $user = null; |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - if ((null !== $user) && $userPasswordEncoder->isPasswordValid($user, $formData['password'])) { |
|
| 76 | + if ((null !== $user) && $userPasswordEncoder->isPasswordValid($user, $formData['password'])) { |
|
| 77 | 77 | return $this->returnApiTokenResponse($user); |
| 78 | - } |
|
| 78 | + } |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | return new SingleResourceResponse([ |
| 82 | 82 | 'status' => 401, |
| 83 | 83 | 'message' => 'Unauthorized', |
| 84 | 84 | ], new ResponseContext(401)); |
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @Route("/api/{version}/auth/superdesk/", options={"expose"=true}, methods={"POST"}, defaults={"version"="v2"}, name="swp_api_auth_superdesk") |
|
| 89 | - */ |
|
| 90 | - public function authenticateWithSuperdeskAction( |
|
| 91 | - Request $request, |
|
| 92 | - LoggerInterface $logger, |
|
| 93 | - array $superdeskServers, |
|
| 94 | - UserProviderInterface $userProvider, |
|
| 95 | - UserManagerInterface $userManager |
|
| 96 | - ) { |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @Route("/api/{version}/auth/superdesk/", options={"expose"=true}, methods={"POST"}, defaults={"version"="v2"}, name="swp_api_auth_superdesk") |
|
| 89 | + */ |
|
| 90 | + public function authenticateWithSuperdeskAction( |
|
| 91 | + Request $request, |
|
| 92 | + LoggerInterface $logger, |
|
| 93 | + array $superdeskServers, |
|
| 94 | + UserProviderInterface $userProvider, |
|
| 95 | + UserManagerInterface $userManager |
|
| 96 | + ) { |
|
| 97 | 97 | $form = $this->formFactory->createNamed('', SuperdeskCredentialAuthenticationType::class, []); |
| 98 | 98 | $form->handleRequest($request); |
| 99 | 99 | if ($form->isSubmitted() && $form->isValid()) { |
| 100 | - $formData = $form->getData(); |
|
| 101 | - $authorizedSuperdeskHosts = $superdeskServers; |
|
| 102 | - $superdeskUser = null; |
|
| 103 | - $client = new GuzzleHttp\Client(); |
|
| 100 | + $formData = $form->getData(); |
|
| 101 | + $authorizedSuperdeskHosts = $superdeskServers; |
|
| 102 | + $superdeskUser = null; |
|
| 103 | + $client = new GuzzleHttp\Client(); |
|
| 104 | 104 | |
| 105 | - foreach ($authorizedSuperdeskHosts as $baseUrl) { |
|
| 105 | + foreach ($authorizedSuperdeskHosts as $baseUrl) { |
|
| 106 | 106 | try { |
| 107 | - $apiRequest = new GuzzleHttp\Psr7\Request('GET', sprintf('%s/api/sessions/%s', $baseUrl, $formData['sessionId']), [ |
|
| 108 | - 'Authorization' => $formData['token'], |
|
| 109 | - ]); |
|
| 107 | + $apiRequest = new GuzzleHttp\Psr7\Request('GET', sprintf('%s/api/sessions/%s', $baseUrl, $formData['sessionId']), [ |
|
| 108 | + 'Authorization' => $formData['token'], |
|
| 109 | + ]); |
|
| 110 | 110 | |
| 111 | - $apiResponse = $client->send($apiRequest); |
|
| 112 | - if (200 !== $apiResponse->getStatusCode()) { |
|
| 111 | + $apiResponse = $client->send($apiRequest); |
|
| 112 | + if (200 !== $apiResponse->getStatusCode()) { |
|
| 113 | 113 | $logger->warning(sprintf('[%s] Unsuccessful response from Superdesk Server: %s', $apiResponse->getStatusCode(), $apiResponse->getBody()->getContents())); |
| 114 | 114 | |
| 115 | 115 | continue; |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - $content = json_decode($apiResponse->getBody()->getContents(), true); |
|
| 119 | - if (is_array($content) && array_key_exists('user', $content)) { |
|
| 118 | + $content = json_decode($apiResponse->getBody()->getContents(), true); |
|
| 119 | + if (is_array($content) && array_key_exists('user', $content)) { |
|
| 120 | 120 | $superdeskUser = $content['user']; |
| 121 | 121 | |
| 122 | 122 | break; |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | } catch (GuzzleHttp\Exception\ClientException $e) { |
| 125 | - $logger->warning(sprintf('Error when logging in Superdesk: %s', $e->getMessage())); |
|
| 125 | + $logger->warning(sprintf('Error when logging in Superdesk: %s', $e->getMessage())); |
|
| 126 | 126 | |
| 127 | - continue; |
|
| 127 | + continue; |
|
| 128 | + } |
|
| 128 | 129 | } |
| 129 | - } |
|
| 130 | 130 | |
| 131 | - if (null === $superdeskUser) { |
|
| 131 | + if (null === $superdeskUser) { |
|
| 132 | 132 | return new SingleResourceResponse([ |
| 133 | 133 | 'status' => 401, |
| 134 | 134 | 'message' => <<<'MESSAGE' |
@@ -136,18 +136,18 @@ discard block |
||
| 136 | 136 | Make sure that Publisher can talk to Superdesk instance. Set it's address in "SUPERDESK_SERVERS" environment variable. |
| 137 | 137 | MESSAGE, |
| 138 | 138 | ], new ResponseContext(401)); |
| 139 | - } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - $publisherUser = $userProvider->findOneByEmail($superdeskUser['email']); |
|
| 142 | - if (null === $publisherUser) { |
|
| 141 | + $publisherUser = $userProvider->findOneByEmail($superdeskUser['email']); |
|
| 142 | + if (null === $publisherUser) { |
|
| 143 | 143 | try { |
| 144 | - $publisherUser = $userProvider->loadUserByUsername($superdeskUser['username']); |
|
| 144 | + $publisherUser = $userProvider->loadUserByUsername($superdeskUser['username']); |
|
| 145 | 145 | } catch (AuthenticationException $e) { |
| 146 | - $publisherUser = null; |
|
| 146 | + $publisherUser = null; |
|
| 147 | + } |
|
| 147 | 148 | } |
| 148 | - } |
|
| 149 | 149 | |
| 150 | - if (null === $publisherUser) { |
|
| 150 | + if (null === $publisherUser) { |
|
| 151 | 151 | /** @var UserInterface $publisherUser */ |
| 152 | 152 | $publisherUser = $userManager->createUser(); |
| 153 | 153 | $publisherUser->setUsername($superdeskUser['username']); |
@@ -157,20 +157,20 @@ discard block |
||
| 157 | 157 | $publisherUser->setLastName(\array_key_exists('last_name', $superdeskUser) ? $superdeskUser['last_name'] : ''); |
| 158 | 158 | $publisherUser->setPassword(password_hash(random_bytes(36), PASSWORD_BCRYPT)); |
| 159 | 159 | $userManager->updateUser($publisherUser); |
| 160 | - } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - if (null !== $publisherUser) { |
|
| 162 | + if (null !== $publisherUser) { |
|
| 163 | 163 | return $this->returnApiTokenResponse($publisherUser, str_replace('Basic ', '', $formData['token'])); |
| 164 | - } |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return new SingleResourceResponse([ |
| 168 | 168 | 'status' => 401, |
| 169 | 169 | 'message' => 'Unauthorized', |
| 170 | 170 | ], new ResponseContext(401)); |
| 171 | - } |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - private function returnApiTokenResponse(UserInterface $user, string $token = null): SingleResourceResponseInterface { |
|
| 173 | + private function returnApiTokenResponse(UserInterface $user, string $token = null): SingleResourceResponseInterface { |
|
| 174 | 174 | /** @var ApiKeyInterface $apiKey */ |
| 175 | 175 | $apiKey = $this->generateOrGetApiKey($user, $token); |
| 176 | 176 | |
@@ -181,36 +181,36 @@ discard block |
||
| 181 | 181 | ], |
| 182 | 182 | 'user' => $user, |
| 183 | 183 | ]); |
| 184 | - } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - private function generateOrGetApiKey(UserInterface $user, $token): ?ApiKeyInterface { |
|
| 186 | + private function generateOrGetApiKey(UserInterface $user, $token): ?ApiKeyInterface { |
|
| 187 | 187 | $apiKey = null; |
| 188 | 188 | if (null !== $token) { |
| 189 | - $apiKey = $this->apiKeyRepository->getValidToken($token)->getQuery()->getOneOrNullResult(); |
|
| 189 | + $apiKey = $this->apiKeyRepository->getValidToken($token)->getQuery()->getOneOrNullResult(); |
|
| 190 | 190 | } else { |
| 191 | - $validKeys = $this->apiKeyRepository->getValidTokenForUser($user)->getQuery()->getResult(); |
|
| 192 | - if (count($validKeys) > 0) { |
|
| 191 | + $validKeys = $this->apiKeyRepository->getValidTokenForUser($user)->getQuery()->getResult(); |
|
| 192 | + if (count($validKeys) > 0) { |
|
| 193 | 193 | $apiKey = reset($validKeys); |
| 194 | - } |
|
| 194 | + } |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | if (null === $apiKey) { |
| 198 | - $apiKey = $this->apiKeyFactory->create($user, $token); |
|
| 198 | + $apiKey = $this->apiKeyFactory->create($user, $token); |
|
| 199 | 199 | |
| 200 | - try { |
|
| 200 | + try { |
|
| 201 | 201 | $lock = $this->lockFactory->createLock(md5(json_encode(['type' => 'user_api_key', 'user' => $user->getId()])), 2); |
| 202 | 202 | if (!$lock->acquire()) { |
| 203 | - throw new RuntimeException('Other api key is created right now for this user'); |
|
| 203 | + throw new RuntimeException('Other api key is created right now for this user'); |
|
| 204 | 204 | } |
| 205 | 205 | $this->apiKeyRepository->add($apiKey); |
| 206 | 206 | $lock->release(); |
| 207 | - } catch (RuntimeException $e) { |
|
| 207 | + } catch (RuntimeException $e) { |
|
| 208 | 208 | sleep(2); |
| 209 | 209 | |
| 210 | 210 | return $this->generateOrGetApiKey($user, $token); |
| 211 | - } |
|
| 211 | + } |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return $apiKey; |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | } |
@@ -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', Mime::getMimeFromExtension($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', Mime::getMimeFromExtension($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 | |
@@ -64,16 +64,16 @@ |
||
| 64 | 64 | ParameterBagInterface $parameterBag, |
| 65 | 65 | ThemeServiceInterface $themeService |
| 66 | 66 | ) { |
| 67 | - $this->tenantContext = $tenantContext; |
|
| 68 | - $this->tenantRepository = $tenantRepository; |
|
| 69 | - $this->eventDispatcher = $eventDispatcher; |
|
| 70 | - $this->parameterBag = $parameterBag; |
|
| 71 | - $this->themeService = $themeService; |
|
| 72 | - parent::__construct(); |
|
| 67 | + $this->tenantContext = $tenantContext; |
|
| 68 | + $this->tenantRepository = $tenantRepository; |
|
| 69 | + $this->eventDispatcher = $eventDispatcher; |
|
| 70 | + $this->parameterBag = $parameterBag; |
|
| 71 | + $this->themeService = $themeService; |
|
| 72 | + parent::__construct(); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | - /** |
|
| 76 | + /** |
|
| 77 | 77 | * {@inheritdoc} |
| 78 | 78 | */ |
| 79 | 79 | protected function configure() |