Completed
Push — 2.4.2-sftest ( 438545...626c30 )
by
unknown
01:12
created
src/SWP/Bundle/CoreBundle/Controller/TenantController.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -42,30 +42,30 @@  discard block
 block discarded – undo
42 42
 
43 43
 class TenantController extends FOSRestController {
44 44
 
45
-  private CachedTenantContextInterface $cachedTenantContext;
46
-  private EventDispatcherInterface $eventDispatcher;
47
-  private FormFactoryInterface $formFactory;
48
-  private TenantRepositoryInterface $tenantRepository;
49
-  private EntityManagerInterface $entityManager;
50
-  private SettingsManagerInterface $settingsManager;
51
-  private TenantFactoryInterface $tenantFactory;
52
-  private ArticleRepositoryInterface $articleRepository;
53
-
54
-  /**
55
-   * @param CachedTenantContextInterface $cachedTenantContext
56
-   * @param EventDispatcherInterface $eventDispatcher
57
-   * @param FormFactoryInterface $formFactory
58
-   * @param TenantRepositoryInterface $tenantRepository
59
-   * @param EntityManagerInterface $entityManager
60
-   * @param SettingsManagerInterface $settingsManager
61
-   * @param TenantFactoryInterface $tenantFactory
62
-   * @param ArticleRepositoryInterface $articleRepository
63
-   */
64
-  public function __construct(CachedTenantContextInterface $cachedTenantContext,
65
-                              EventDispatcherInterface     $eventDispatcher, FormFactoryInterface $formFactory,
66
-                              TenantRepositoryInterface    $tenantRepository, EntityManagerInterface $entityManager,
67
-                              SettingsManagerInterface     $settingsManager, TenantFactoryInterface $tenantFactory,
68
-                              ArticleRepositoryInterface   $articleRepository) {
45
+    private CachedTenantContextInterface $cachedTenantContext;
46
+    private EventDispatcherInterface $eventDispatcher;
47
+    private FormFactoryInterface $formFactory;
48
+    private TenantRepositoryInterface $tenantRepository;
49
+    private EntityManagerInterface $entityManager;
50
+    private SettingsManagerInterface $settingsManager;
51
+    private TenantFactoryInterface $tenantFactory;
52
+    private ArticleRepositoryInterface $articleRepository;
53
+
54
+    /**
55
+     * @param CachedTenantContextInterface $cachedTenantContext
56
+     * @param EventDispatcherInterface $eventDispatcher
57
+     * @param FormFactoryInterface $formFactory
58
+     * @param TenantRepositoryInterface $tenantRepository
59
+     * @param EntityManagerInterface $entityManager
60
+     * @param SettingsManagerInterface $settingsManager
61
+     * @param TenantFactoryInterface $tenantFactory
62
+     * @param ArticleRepositoryInterface $articleRepository
63
+     */
64
+    public function __construct(CachedTenantContextInterface $cachedTenantContext,
65
+                                EventDispatcherInterface     $eventDispatcher, FormFactoryInterface $formFactory,
66
+                                TenantRepositoryInterface    $tenantRepository, EntityManagerInterface $entityManager,
67
+                                SettingsManagerInterface     $settingsManager, TenantFactoryInterface $tenantFactory,
68
+                                ArticleRepositoryInterface   $articleRepository) {
69 69
     $this->cachedTenantContext = $cachedTenantContext;
70 70
     $this->eventDispatcher = $eventDispatcher;
71 71
     $this->formFactory = $formFactory;
@@ -74,32 +74,32 @@  discard block
 block discarded – undo
74 74
     $this->settingsManager = $settingsManager;
75 75
     $this->tenantFactory = $tenantFactory;
76 76
     $this->articleRepository = $articleRepository;
77
-  }
77
+    }
78 78
 
79 79
 
80
-  /**
81
-   * @Route("/api/{version}/tenants/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_tenants")
82
-   */
83
-  public function listAction(Request $request) {
80
+    /**
81
+     * @Route("/api/{version}/tenants/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_tenants")
82
+     */
83
+    public function listAction(Request $request) {
84 84
     $tenants = $this->getTenantRepository()
85 85
         ->getPaginatedByCriteria($this->eventDispatcher, new Criteria(), $request->query->all('sorting'), new PaginationData($request));
86 86
     $responseContext = new ResponseContext();
87 87
     $responseContext->setSerializationGroups(['Default', 'api', 'details_api']);
88 88
 
89 89
     return new ResourcesListResponse($tenants, $responseContext);
90
-  }
90
+    }
91 91
 
92
-  /**
93
-   * @Route("/api/{version}/tenants/{code}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_tenant", requirements={"code"="[a-z0-9]+"})
94
-   */
95
-  public function getAction($code) {
92
+    /**
93
+     * @Route("/api/{version}/tenants/{code}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_tenant", requirements={"code"="[a-z0-9]+"})
94
+     */
95
+    public function getAction($code) {
96 96
     return new SingleResourceResponse($this->findOr404($code));
97
-  }
97
+    }
98 98
 
99
-  /**
100
-   * @Route("/api/{version}/tenants/{code}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_tenant", requirements={"code"="[a-z0-9]+"})
101
-   */
102
-  public function deleteAction(Request $request, $code) {
99
+    /**
100
+     * @Route("/api/{version}/tenants/{code}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_tenant", requirements={"code"="[a-z0-9]+"})
101
+     */
102
+    public function deleteAction(Request $request, $code) {
103 103
     $tenantContext = $this->cachedTenantContext;
104 104
     $eventDispatcher = $this->eventDispatcher;
105 105
     $currentTenant = $tenantContext->getTenant();
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 
110 110
     $forceRemove = $request->query->has('force');
111 111
     if (!$forceRemove) {
112
-      $tenantContext->setTenant($tenant);
113
-      $eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_ENABLE);
114
-      $articlesRepository = $this->articleRepository;
115
-      $existingArticles = $articlesRepository->findAll();
116
-      if (0 !== \count($existingArticles)) {
112
+        $tenantContext->setTenant($tenant);
113
+        $eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_ENABLE);
114
+        $articlesRepository = $this->articleRepository;
115
+        $existingArticles = $articlesRepository->findAll();
116
+        if (0 !== \count($existingArticles)) {
117 117
         throw new ConflictHttpException('This tenant have articles attached to it.');
118
-      }
118
+        }
119 119
     }
120 120
 
121 121
     $repository->remove($tenant);
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
     $eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_ENABLE);
125 125
 
126 126
     return new SingleResourceResponse(null, new ResponseContext(204));
127
-  }
127
+    }
128 128
 
129
-  /**
130
-   * @Route("/api/{version}/tenants/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_tenant")
131
-   */
132
-  public function createAction(Request $request) {
129
+    /**
130
+     * @Route("/api/{version}/tenants/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_tenant")
131
+     */
132
+    public function createAction(Request $request) {
133 133
     $tenant = $this->tenantFactory->create();
134 134
     $tenantContext = $this->cachedTenantContext;
135 135
     $tenantObjectManager = $this->entityManager;
@@ -137,83 +137,83 @@  discard block
 block discarded – undo
137 137
     $form->handleRequest($request);
138 138
 
139 139
     if ($form->isSubmitted() && $form->isValid()) {
140
-      $this->ensureTenantDontExists($tenant->getDomainName(), $tenant->getSubdomain());
141
-      if (null === $tenant->getOrganization()) {
140
+        $this->ensureTenantDontExists($tenant->getDomainName(), $tenant->getSubdomain());
141
+        if (null === $tenant->getOrganization()) {
142 142
         $organization = $tenantObjectManager->merge($tenantContext->getTenant()->getOrganization());
143 143
         $tenant->setOrganization($organization);
144
-      }
145
-      $this->getTenantRepository()->add($tenant);
144
+        }
145
+        $this->getTenantRepository()->add($tenant);
146 146
 
147
-      return new SingleResourceResponse($tenant, new ResponseContext(201));
147
+        return new SingleResourceResponse($tenant, new ResponseContext(201));
148 148
     }
149 149
 
150 150
     return new SingleResourceResponse($form, new ResponseContext(400));
151
-  }
151
+    }
152 152
 
153
-  /**
154
-   * @Route("/api/{version}/tenants/{code}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_tenant", requirements={"code"="[a-z0-9]+"})
155
-   */
156
-  public function updateAction(Request $request, $code) {
153
+    /**
154
+     * @Route("/api/{version}/tenants/{code}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_tenant", requirements={"code"="[a-z0-9]+"})
155
+     */
156
+    public function updateAction(Request $request, $code) {
157 157
     $tenant = $this->findOr404($code);
158 158
     $form = $this->formFactory->createNamed('', TenantType::class, $tenant, ['method' => $request->getMethod()]);
159 159
     $form->handleRequest($request);
160 160
 
161 161
     if ($form->isSubmitted() && $form->isValid()) {
162
-      $formData = $request->request->all();
163
-      $tenant->setUpdatedAt(new DateTime('now'));
164
-      $this->entityManager->flush();
162
+        $formData = $request->request->all();
163
+        $tenant->setUpdatedAt(new DateTime('now'));
164
+        $this->entityManager->flush();
165 165
 
166
-      $tenantContext = $this->cachedTenantContext;
167
-      $tenantContext->setTenant($tenant);
166
+        $tenantContext = $this->cachedTenantContext;
167
+        $tenantContext->setTenant($tenant);
168 168
 
169
-      $settingsManager = $this->settingsManager;
169
+        $settingsManager = $this->settingsManager;
170 170
 
171
-      if (array_key_exists('fbiaEnabled', $formData)) {
171
+        if (array_key_exists('fbiaEnabled', $formData)) {
172 172
         $settingsManager->set('fbia_enabled', (bool)$formData['fbiaEnabled'], ScopeContextInterface::SCOPE_TENANT, $tenant);
173
-      }
174
-      if (array_key_exists('paywallEnabled', $formData)) {
173
+        }
174
+        if (array_key_exists('paywallEnabled', $formData)) {
175 175
         $settingsManager->set('paywall_enabled', (bool)$formData['paywallEnabled'], ScopeContextInterface::SCOPE_TENANT, $tenant);
176
-      }
177
-      if (array_key_exists('defaultLanguage', $formData)) {
176
+        }
177
+        if (array_key_exists('defaultLanguage', $formData)) {
178 178
         $settingsManager->set('default_language', $formData['defaultLanguage'], ScopeContextInterface::SCOPE_TENANT, $tenant);
179
-      }
179
+        }
180 180
 
181
-      return new SingleResourceResponse($tenant);
181
+        return new SingleResourceResponse($tenant);
182 182
     }
183 183
 
184 184
     return new SingleResourceResponse($form, new ResponseContext(400));
185
-  }
186
-
187
-  /**
188
-   * @param string $code
189
-   *
190
-   * @return mixed|TenantInterface|null
191
-   * @throws NotFoundHttpException
192
-   *
193
-   */
194
-  private function findOr404($code) {
185
+    }
186
+
187
+    /**
188
+     * @param string $code
189
+     *
190
+     * @return mixed|TenantInterface|null
191
+     * @throws NotFoundHttpException
192
+     *
193
+     */
194
+    private function findOr404($code) {
195 195
     if (null === $tenant = $this->getTenantRepository()->findOneByCode($code)) {
196
-      throw $this->createNotFoundException(sprintf('Tenant with code "%s" was not found.', $code));
196
+        throw $this->createNotFoundException(sprintf('Tenant with code "%s" was not found.', $code));
197 197
     }
198 198
 
199 199
     return $tenant;
200
-  }
200
+    }
201 201
 
202
-  /**
203
-   * @return mixed|TenantInterface|null
204
-   */
205
-  private function ensureTenantDontExists(string $domain, string $subdomain = null) {
202
+    /**
203
+     * @return mixed|TenantInterface|null
204
+     */
205
+    private function ensureTenantDontExists(string $domain, string $subdomain = null) {
206 206
     if (null !== $tenant = $this->getTenantRepository()->findOneBySubdomainAndDomain($subdomain, $domain)) {
207
-      throw new ConflictHttpException('Tenant for this host already exists.');
207
+        throw new ConflictHttpException('Tenant for this host already exists.');
208 208
     }
209 209
 
210 210
     return $tenant;
211
-  }
211
+    }
212 212
 
213
-  /**
214
-   * @return object|\SWP\Bundle\MultiTenancyBundle\Doctrine\ORM\TenantRepository
215
-   */
216
-  private function getTenantRepository() {
213
+    /**
214
+     * @return object|\SWP\Bundle\MultiTenancyBundle\Doctrine\ORM\TenantRepository
215
+     */
216
+    private function getTenantRepository() {
217 217
     return $this->tenantRepository;
218
-  }
218
+    }
219 219
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -169,10 +169,10 @@
 block discarded – undo
169 169
       $settingsManager = $this->settingsManager;
170 170
 
171 171
       if (array_key_exists('fbiaEnabled', $formData)) {
172
-        $settingsManager->set('fbia_enabled', (bool)$formData['fbiaEnabled'], ScopeContextInterface::SCOPE_TENANT, $tenant);
172
+        $settingsManager->set('fbia_enabled', (bool) $formData['fbiaEnabled'], ScopeContextInterface::SCOPE_TENANT, $tenant);
173 173
       }
174 174
       if (array_key_exists('paywallEnabled', $formData)) {
175
-        $settingsManager->set('paywall_enabled', (bool)$formData['paywallEnabled'], ScopeContextInterface::SCOPE_TENANT, $tenant);
175
+        $settingsManager->set('paywall_enabled', (bool) $formData['paywallEnabled'], ScopeContextInterface::SCOPE_TENANT, $tenant);
176 176
       }
177 177
       if (array_key_exists('defaultLanguage', $formData)) {
178 178
         $settingsManager->set('default_language', $formData['defaultLanguage'], ScopeContextInterface::SCOPE_TENANT, $tenant);
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/FbPageController.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
 
36 36
 class FbPageController extends AbstractController {
37 37
 
38
-  private FormFactoryInterface $formFactory;
39
-  private RepositoryInterface $facebookInstantArticlesFeedRepository;
40
-  private RepositoryInterface $facebookPageRepository;
41
-  private FactoryInterface $facebookPageFactory;
42
-  private EventDispatcherInterface $eventDispatcher;
43
-
44
-  /**
45
-   * @param FormFactoryInterface $formFactory
46
-   * @param RepositoryInterface $facebookInstantArticlesFeedRepository
47
-   * @param RepositoryInterface $facebookPageRepository
48
-   * @param FactoryInterface $facebookPageFactory
49
-   * @param EventDispatcherInterface $eventDispatcher
50
-   */
51
-  public function __construct(FormFactoryInterface $formFactory,
52
-                              RepositoryInterface  $facebookInstantArticlesFeedRepository,
53
-                              RepositoryInterface  $facebookPageRepository, FactoryInterface $facebookPageFactory,
54
-                              EventDispatcherInterface      $eventDispatcher) {
38
+    private FormFactoryInterface $formFactory;
39
+    private RepositoryInterface $facebookInstantArticlesFeedRepository;
40
+    private RepositoryInterface $facebookPageRepository;
41
+    private FactoryInterface $facebookPageFactory;
42
+    private EventDispatcherInterface $eventDispatcher;
43
+
44
+    /**
45
+     * @param FormFactoryInterface $formFactory
46
+     * @param RepositoryInterface $facebookInstantArticlesFeedRepository
47
+     * @param RepositoryInterface $facebookPageRepository
48
+     * @param FactoryInterface $facebookPageFactory
49
+     * @param EventDispatcherInterface $eventDispatcher
50
+     */
51
+    public function __construct(FormFactoryInterface $formFactory,
52
+                                RepositoryInterface  $facebookInstantArticlesFeedRepository,
53
+                                RepositoryInterface  $facebookPageRepository, FactoryInterface $facebookPageFactory,
54
+                                EventDispatcherInterface      $eventDispatcher) {
55 55
     $this->formFactory = $formFactory;
56 56
     $this->facebookInstantArticlesFeedRepository = $facebookInstantArticlesFeedRepository;
57 57
     $this->facebookPageRepository = $facebookPageRepository;
58 58
     $this->facebookPageFactory = $facebookPageFactory;
59 59
     $this->eventDispatcher = $eventDispatcher;
60
-  }
60
+    }
61 61
 
62 62
 
63
-  /**
64
-   * @Route("/api/{version}/facebook/pages/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_pages")
65
-   */
66
-  public function listAction(Request $request) {
63
+    /**
64
+     * @Route("/api/{version}/facebook/pages/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_pages")
65
+     */
66
+    public function listAction(Request $request) {
67 67
     $repository = $this->facebookPageRepository;
68 68
     $sort = $request->query->all('sorting');
69 69
     if (empty($sort)) {
70
-      $sort = ['id' => 'asc'];
70
+        $sort = ['id' => 'asc'];
71 71
     }
72 72
     $items = $repository->getPaginatedByCriteria(
73 73
         $this->eventDispatcher,
@@ -77,51 +77,51 @@  discard block
 block discarded – undo
77 77
     );
78 78
 
79 79
     return new ResourcesListResponse($items);
80
-  }
80
+    }
81 81
 
82
-  /**
83
-   * @Route("/api/{version}/facebook/pages/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_create_facebook_pages")
84
-   */
85
-  public function createAction(Request $request) {
82
+    /**
83
+     * @Route("/api/{version}/facebook/pages/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_create_facebook_pages")
84
+     */
85
+    public function createAction(Request $request) {
86 86
     /* @var FacebookPage $feed */
87 87
     $page = $this->facebookPageFactory->create();
88 88
     $form = $this->formFactory->createNamed('', FacebookPageType::class, $page, ['method' => $request->getMethod()]);
89 89
 
90 90
     $form->handleRequest($request);
91 91
     if ($form->isSubmitted() && $form->isValid()) {
92
-      $this->checkIfPageExists($page);
93
-      $this->facebookPageRepository->add($page);
92
+        $this->checkIfPageExists($page);
93
+        $this->facebookPageRepository->add($page);
94 94
 
95
-      return new SingleResourceResponse($page, new ResponseContext(201));
95
+        return new SingleResourceResponse($page, 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}/facebook/pages/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_delete_facebook_pages")
103
-   */
104
-  public function deleteAction(int $id): SingleResourceResponseInterface {
101
+    /**
102
+     * @Route("/api/{version}/facebook/pages/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_delete_facebook_pages")
103
+     */
104
+    public function deleteAction(int $id): SingleResourceResponseInterface {
105 105
     $repository = $this->facebookPageRepository;
106 106
     if (null === $page = $this->facebookPageRepository->findOneBy(['id' => $id])) {
107
-      throw new NotFoundHttpException('There is no Page with provided id!');
107
+        throw new NotFoundHttpException('There is no Page with provided id!');
108 108
     }
109 109
 
110 110
     if (null !== $feed = $this->facebookInstantArticlesFeedRepository->findOneBy(['facebookPage' => $id])) {
111
-      throw new ConflictHttpException(sprintf('This Page is used by Instant Articles Feed with id: %s!', $feed->getId()));
111
+        throw new ConflictHttpException(sprintf('This Page is used by Instant Articles Feed with id: %s!', $feed->getId()));
112 112
     }
113 113
 
114 114
     $repository->remove($page);
115 115
 
116 116
     return new SingleResourceResponse(null, new ResponseContext(204));
117
-  }
117
+    }
118 118
 
119
-  private function checkIfPageExists(PageInterface $page): void {
119
+    private function checkIfPageExists(PageInterface $page): void {
120 120
     if (null !== $this->facebookPageRepository->findOneBy([
121 121
             'pageId' => $page->getPageId(),
122 122
         ])
123 123
     ) {
124
-      throw new ConflictHttpException('This Page already exists!');
124
+        throw new ConflictHttpException('This Page already exists!');
125
+    }
125 126
     }
126
-  }
127 127
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ContentListController.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -43,32 +43,32 @@  discard block
 block discarded – undo
43 43
 
44 44
 class ContentListController extends AbstractController {
45 45
 
46
-  private ContentListRepositoryInterface $contentListRepository;
47
-  private ContentListItemRepositoryInterface $contentListItemRepository;
48
-  private ContentListServiceInterface $contentListService;
49
-  private FormFactoryInterface $formFactory;
50
-  private EntityManagerInterface $entityManager;
51
-  private EventDispatcherInterface $eventDispatcher;
52
-  private FactoryInterface $factory;
53
-
54
-  /**
55
-   * @param ContentListRepositoryInterface $contentListRepository
56
-   * @param ContentListItemRepositoryInterface $contentListItemRepository
57
-   * @param ContentListServiceInterface $contentListService
58
-   * @param FormFactoryInterface $formFactory
59
-   * @param EntityManagerInterface $entityManager
60
-   * @param EventDispatcherInterface $eventDispatcher
61
-   * @param FactoryInterface $factory
62
-   */
63
-  public function __construct(
64
-      ContentListRepositoryInterface     $contentListRepository,
65
-      ContentListItemRepositoryInterface $contentListItemRepository,
66
-      ContentListServiceInterface        $contentListService,
67
-      FormFactoryInterface               $formFactory,
68
-      EntityManagerInterface             $entityManager,
69
-      EventDispatcherInterface           $eventDispatcher,
70
-      FactoryInterface                   $factory
71
-  ) {
46
+    private ContentListRepositoryInterface $contentListRepository;
47
+    private ContentListItemRepositoryInterface $contentListItemRepository;
48
+    private ContentListServiceInterface $contentListService;
49
+    private FormFactoryInterface $formFactory;
50
+    private EntityManagerInterface $entityManager;
51
+    private EventDispatcherInterface $eventDispatcher;
52
+    private FactoryInterface $factory;
53
+
54
+    /**
55
+     * @param ContentListRepositoryInterface $contentListRepository
56
+     * @param ContentListItemRepositoryInterface $contentListItemRepository
57
+     * @param ContentListServiceInterface $contentListService
58
+     * @param FormFactoryInterface $formFactory
59
+     * @param EntityManagerInterface $entityManager
60
+     * @param EventDispatcherInterface $eventDispatcher
61
+     * @param FactoryInterface $factory
62
+     */
63
+    public function __construct(
64
+        ContentListRepositoryInterface     $contentListRepository,
65
+        ContentListItemRepositoryInterface $contentListItemRepository,
66
+        ContentListServiceInterface        $contentListService,
67
+        FormFactoryInterface               $formFactory,
68
+        EntityManagerInterface             $entityManager,
69
+        EventDispatcherInterface           $eventDispatcher,
70
+        FactoryInterface                   $factory
71
+    ) {
72 72
     $this->contentListRepository = $contentListRepository;
73 73
     $this->contentListItemRepository = $contentListItemRepository;
74 74
     $this->contentListService = $contentListService;
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
     $this->entityManager = $entityManager;
77 77
     $this->eventDispatcher = $eventDispatcher;
78 78
     $this->factory = $factory;
79
-  }
79
+    }
80 80
 
81
-  /**
82
-   * @Route("/api/{version}/content/lists/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_content_list_lists")
83
-   */
84
-  public function listAction(Request $request): ResourcesListResponseInterface {
81
+    /**
82
+     * @Route("/api/{version}/content/lists/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_content_list_lists")
83
+     */
84
+    public function listAction(Request $request): ResourcesListResponseInterface {
85 85
     $lists = $this->contentListRepository->getPaginatedByCriteria($this->eventDispatcher, new Criteria(), $request->query->all('sorting'), new PaginationData($request));
86 86
 
87 87
     return new ResourcesListResponse($lists);
88
-  }
88
+    }
89 89
 
90
-  /**
91
-   * @Route("/api/{version}/content/lists/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_content_show_lists", requirements={"id"="\d+"})
92
-   */
93
-  public function getAction($id): SingleResourceResponseInterface {
90
+    /**
91
+     * @Route("/api/{version}/content/lists/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_content_show_lists", requirements={"id"="\d+"})
92
+     */
93
+    public function getAction($id): SingleResourceResponseInterface {
94 94
     return new SingleResourceResponse($this->findOr404($id));
95
-  }
95
+    }
96 96
 
97
-  /**
98
-   * @Route("/api/{version}/content/lists/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_content_create_lists")
99
-   */
100
-  public function createAction(Request $request): SingleResourceResponseInterface {
97
+    /**
98
+     * @Route("/api/{version}/content/lists/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_content_create_lists")
99
+     */
100
+    public function createAction(Request $request): SingleResourceResponseInterface {
101 101
     /* @var ContentListInterface $contentList */
102 102
     $contentList = $this->factory->create();
103 103
     $form = $this->formFactory->createNamed('', ContentListType::class, $contentList, ['method' => $request->getMethod()]);
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
     $this->ensureContentListExists($contentList->getName());
107 107
 
108 108
     if ($form->isSubmitted() && $form->isValid()) {
109
-      $this->contentListRepository->add($contentList);
109
+        $this->contentListRepository->add($contentList);
110 110
 
111
-      return new SingleResourceResponse($contentList, new ResponseContext(201));
111
+        return new SingleResourceResponse($contentList, new ResponseContext(201));
112 112
     }
113 113
 
114 114
     return new SingleResourceResponse($form, new ResponseContext(400));
115
-  }
115
+    }
116 116
 
117
-  /**
118
-   * @Route("/api/{version}/content/lists/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_content_update_lists", requirements={"id"="\d+"})
119
-   */
120
-  public function updateAction(Request $request, int $id): SingleResourceResponseInterface {
117
+    /**
118
+     * @Route("/api/{version}/content/lists/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_content_update_lists", requirements={"id"="\d+"})
119
+     */
120
+    public function updateAction(Request $request, int $id): SingleResourceResponseInterface {
121 121
     $objectManager = $this->entityManager;
122 122
     /** @var ContentListInterface $contentList */
123 123
     $contentList = $this->findOr404($id);
@@ -128,51 +128,51 @@  discard block
 block discarded – undo
128 128
     $form->handleRequest($request);
129 129
 
130 130
     if ($form->isSubmitted() && $form->isValid()) {
131
-      $this->eventDispatcher->dispatch(
132
-          new GenericEvent($contentList, ['filters' => $filters, 'previousLimit' => $listLimit]),
133
-          ContentListEvents::LIST_CRITERIA_CHANGE
134
-      );
131
+        $this->eventDispatcher->dispatch(
132
+            new GenericEvent($contentList, ['filters' => $filters, 'previousLimit' => $listLimit]),
133
+            ContentListEvents::LIST_CRITERIA_CHANGE
134
+        );
135 135
 
136
-      $objectManager->flush();
136
+        $objectManager->flush();
137 137
 
138
-      return new SingleResourceResponse($contentList);
138
+        return new SingleResourceResponse($contentList);
139 139
     }
140 140
 
141 141
     return new SingleResourceResponse($form, new ResponseContext(400));
142
-  }
142
+    }
143 143
 
144
-  /**
145
-   * @Route("/api/{version}/content/lists/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_content_delete_lists", requirements={"id"="\d+"})
146
-   */
147
-  public function deleteAction($id): SingleResourceResponseInterface {
144
+    /**
145
+     * @Route("/api/{version}/content/lists/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_content_delete_lists", requirements={"id"="\d+"})
146
+     */
147
+    public function deleteAction($id): SingleResourceResponseInterface {
148 148
     $repository = $this->contentListRepository;
149 149
     $contentList = $this->findOr404($id);
150 150
 
151 151
     $repository->remove($contentList);
152 152
 
153 153
     return new SingleResourceResponse(null, new ResponseContext(204));
154
-  }
154
+    }
155 155
 
156
-  /**
157
-   * @Route("/api/{version}/content/lists/{id}", requirements={"id"="\w+"}, defaults={"version"="v2"}, methods={"LINK","UNLINK"}, name="swp_api_content_list_link_unlink")
158
-   */
159
-  public function linkUnlinkToContentListAction(Request $request, string $id): SingleResourceResponseInterface {
156
+    /**
157
+     * @Route("/api/{version}/content/lists/{id}", requirements={"id"="\w+"}, defaults={"version"="v2"}, methods={"LINK","UNLINK"}, name="swp_api_content_list_link_unlink")
158
+     */
159
+    public function linkUnlinkToContentListAction(Request $request, string $id): SingleResourceResponseInterface {
160 160
     $objectManager = $this->entityManager;
161 161
     /** @var ContentListInterface $contentList */
162 162
     $contentList = $this->findOr404($id);
163 163
 
164 164
     $matched = false;
165 165
     foreach ($request->attributes->get('links', []) as $key => $objectArray) {
166
-      if (!is_array($objectArray)) {
166
+        if (!is_array($objectArray)) {
167 167
         continue;
168
-      }
168
+        }
169 169
 
170
-      $object = $objectArray['object'];
171
-      if ($object instanceof Exception) {
170
+        $object = $objectArray['object'];
171
+        if ($object instanceof Exception) {
172 172
         throw $object;
173
-      }
173
+        }
174 174
 
175
-      if ($object instanceof ArticleInterface) {
175
+        if ($object instanceof ArticleInterface) {
176 176
         $contentListItem = $this->contentListItemRepository
177 177
             ->findOneBy([
178 178
                 'contentList' => $contentList,
@@ -180,59 +180,59 @@  discard block
 block discarded – undo
180 180
             ]);
181 181
 
182 182
         if ('LINK' === $request->getMethod()) {
183
-          $position = 0;
184
-          if (count($notConvertedLinks = RequestParser::getNotConvertedLinks($request->attributes->get('links'))) > 0) {
183
+            $position = 0;
184
+            if (count($notConvertedLinks = RequestParser::getNotConvertedLinks($request->attributes->get('links'))) > 0) {
185 185
             foreach ($notConvertedLinks as $link) {
186
-              if (isset($link['resourceType']) && 'position' === $link['resourceType']) {
186
+                if (isset($link['resourceType']) && 'position' === $link['resourceType']) {
187 187
                 $position = $link['resource'];
188
-              }
188
+                }
189
+            }
189 190
             }
190
-          }
191 191
 
192
-          if (false === $position && $contentListItem) {
192
+            if (false === $position && $contentListItem) {
193 193
             throw new ConflictHttpException('This content is already linked to Content List');
194
-          }
194
+            }
195 195
 
196
-          if (!$contentListItem) {
196
+            if (!$contentListItem) {
197 197
             $contentListItem = $this->contentListService->addArticleToContentList($contentList, $object, $position);
198 198
             $objectManager->persist($contentListItem);
199
-          } else {
199
+            } else {
200 200
             $contentListItem->setPosition($position);
201
-          }
201
+            }
202 202
 
203
-          $objectManager->flush();
203
+            $objectManager->flush();
204 204
         } elseif ('UNLINK' === $request->getMethod()) {
205
-          if ($contentListItem->getContentList() !== $contentList) {
205
+            if ($contentListItem->getContentList() !== $contentList) {
206 206
             throw new ConflictHttpException('Content is not linked to content list');
207
-          }
208
-          $objectManager->remove($contentListItem);
207
+            }
208
+            $objectManager->remove($contentListItem);
209 209
         }
210 210
 
211 211
         $matched = true;
212 212
 
213 213
         break;
214
-      }
214
+        }
215 215
     }
216 216
     if (false === $matched) {
217
-      throw new NotFoundHttpException('Any supported link object was not found');
217
+        throw new NotFoundHttpException('Any supported link object was not found');
218 218
     }
219 219
 
220 220
     $objectManager->flush();
221 221
 
222 222
     return new SingleResourceResponse($contentList, new ResponseContext(201));
223
-  }
223
+    }
224 224
 
225
-  private function findOr404($id) {
225
+    private function findOr404($id) {
226 226
     if (null === $list = $this->contentListRepository->find($id)) {
227
-      throw new NotFoundHttpException(sprintf('Content list with id "%s" was not found.', $id));
227
+        throw new NotFoundHttpException(sprintf('Content list with id "%s" was not found.', $id));
228 228
     }
229 229
 
230 230
     return $list;
231
-  }
231
+    }
232 232
 
233
-  private function ensureContentListExists($name) {
233
+    private function ensureContentListExists($name) {
234 234
     if (null !== $this->contentListRepository->findOneBy(['name' => $name])) {
235
-      throw new ConflictHttpException(sprintf('Content list named "%s" already exists!', $name));
235
+        throw new ConflictHttpException(sprintf('Content list named "%s" already exists!', $name));
236
+    }
236 237
     }
237
-  }
238 238
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/RedirectingController.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -27,51 +27,51 @@
 block discarded – undo
27 27
 
28 28
 class RedirectingController extends AbstractController {
29 29
 
30
-  private RouterInterface $router;
31
-  private ArticleRepositoryInterface $articleRepository;
30
+    private RouterInterface $router;
31
+    private ArticleRepositoryInterface $articleRepository;
32 32
 
33
-  /**
34
-   * @param RouterInterface $router
35
-   * @param ArticleRepositoryInterface $articleRepository
36
-   */
37
-  public function __construct(RouterInterface $router, ArticleRepositoryInterface $articleRepository) {
33
+    /**
34
+     * @param RouterInterface $router
35
+     * @param ArticleRepositoryInterface $articleRepository
36
+     */
37
+    public function __construct(RouterInterface $router, ArticleRepositoryInterface $articleRepository) {
38 38
     $this->router = $router;
39 39
     $this->articleRepository = $articleRepository;
40
-  }
40
+    }
41 41
 
42 42
 
43
-  public function redirectBasedOnExtraDataAction(Request $request, string $key, string $value): RedirectResponse {
43
+    public function redirectBasedOnExtraDataAction(Request $request, string $key, string $value): RedirectResponse {
44 44
     try {
45
-      $existingArticle = $this->articleRepository->getArticleByExtraData($key, $value)->getQuery()->getOneOrNullResult();
46
-      if (null === $existingArticle) {
45
+        $existingArticle = $this->articleRepository->getArticleByExtraData($key, $value)->getQuery()->getOneOrNullResult();
46
+        if (null === $existingArticle) {
47 47
         $existingArticle = $this->articleRepository->getArticleByPackageExtraData($key, $value)->getQuery()->getOneOrNullResult();
48
-      }
48
+        }
49 49
     } catch (NonUniqueResultException $e) {
50
-      $existingArticle = null;
50
+        $existingArticle = null;
51 51
     }
52 52
 
53 53
     if (null === $existingArticle || null === $existingArticle->getRoute()) {
54
-      throw $this->createNotFoundException('Article with provided data was not found.');
54
+        throw $this->createNotFoundException('Article with provided data was not found.');
55 55
     }
56 56
 
57 57
     return $this->redirect($this->generateArticleUrl($request, $existingArticle), 301);
58
-  }
58
+    }
59 59
 
60
-  public function redirectBasedOnSlugAction(Request $request, string $slug): RedirectResponse {
60
+    public function redirectBasedOnSlugAction(Request $request, string $slug): RedirectResponse {
61 61
     $existingArticle = $this->articleRepository->findOneBySlug($slug);
62 62
     if (null === $existingArticle || null === $existingArticle->getRoute()) {
63
-      throw $this->createNotFoundException('Article not found.');
63
+        throw $this->createNotFoundException('Article not found.');
64 64
     }
65 65
 
66 66
     return $this->redirect($this->generateArticleUrl($request, $existingArticle), 301);
67
-  }
67
+    }
68 68
 
69
-  private function generateArticleUrl(Request $request, ArticleInterface $article): string {
69
+    private function generateArticleUrl(Request $request, ArticleInterface $article): string {
70 70
     $parameters = ['slug' => $article->getSlug()];
71 71
     if ($request->query->has('amp')) {
72
-      $parameters['amp'] = 1;
72
+        $parameters['amp'] = 1;
73 73
     }
74 74
 
75 75
     return $this->router->generate($article->getRoute(), $parameters, UrlGeneratorInterface::ABSOLUTE_URL);
76
-  }
76
+    }
77 77
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/DefaultController.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,40 +28,40 @@  discard block
 block discarded – undo
28 28
 
29 29
 class DefaultController extends AbstractController {
30 30
 
31
-  private CachedTenantContextInterface $tenantContext;
32
-  private MetaFactoryInterface $metaFactory;
33
-  private Context $templateEngineContext;
34
-  private RouteFactoryInterface $routeFactory;
31
+    private CachedTenantContextInterface $tenantContext;
32
+    private MetaFactoryInterface $metaFactory;
33
+    private Context $templateEngineContext;
34
+    private RouteFactoryInterface $routeFactory;
35 35
 
36
-  public function __construct(
37
-      CachedTenantContextInterface $tenantContext,
38
-      MetaFactoryInterface         $metaFactory,
39
-      Context                      $templateEngineContext,
40
-      RouteFactoryInterface        $routeFactory
41
-  ) {
36
+    public function __construct(
37
+        CachedTenantContextInterface $tenantContext,
38
+        MetaFactoryInterface         $metaFactory,
39
+        Context                      $templateEngineContext,
40
+        RouteFactoryInterface        $routeFactory
41
+    ) {
42 42
     $this->tenantContext = $tenantContext;
43 43
     $this->metaFactory = $metaFactory;
44 44
     $this->templateEngineContext = $templateEngineContext;
45 45
     $this->routeFactory = $routeFactory;
46
-  }
46
+    }
47 47
 
48
-  /**
49
-   * @Route("/", methods={"GET","POST"}, name="homepage")
50
-   */
51
-  public function indexAction(Request $request): Response {
48
+    /**
49
+     * @Route("/", methods={"GET","POST"}, name="homepage")
50
+     */
51
+    public function indexAction(Request $request): Response {
52 52
     /** @var TenantInterface $currentTenant */
53 53
     $currentTenant = $this->tenantContext->getTenant();
54 54
     $route = $currentTenant->getHomepage();
55 55
 
56 56
     if (null === $route) {
57
-      /** @var RouteInterface $route */
58
-      $route = $this->routeFactory->create();
59
-      $route->setStaticPrefix('/');
60
-      $route->setName('Homepage');
61
-      $route->setType('content');
62
-      $route->setTemplateName('index.html.twig');
63
-      $route->setCacheTimeInSeconds(360);
64
-      $request->attributes->set(DynamicRouter::ROUTE_KEY, $route);
57
+        /** @var RouteInterface $route */
58
+        $route = $this->routeFactory->create();
59
+        $route->setStaticPrefix('/');
60
+        $route->setName('Homepage');
61
+        $route->setType('content');
62
+        $route->setTemplateName('index.html.twig');
63
+        $route->setCacheTimeInSeconds(360);
64
+        $request->attributes->set(DynamicRouter::ROUTE_KEY, $route);
65 65
     }
66 66
 
67 67
     $this->templateEngineContext->setCurrentPage($this->metaFactory->create($route));
@@ -70,5 +70,5 @@  discard block
 block discarded – undo
70 70
     $response->headers->set('Content-Type', 'text/html; charset=UTF-8');
71 71
 
72 72
     return $this->render('index.html.twig', [], $response);
73
-  }
73
+    }
74 74
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/PackageController.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -45,39 +45,39 @@  discard block
 block discarded – undo
45 45
 
46 46
 class PackageController extends Controller {
47 47
 
48
-  private FormFactoryInterface $formFactory;
49
-  private EventDispatcherInterface $eventDispatcher;
50
-  private CachedTenantContextInterface $cachedTenantContext;
51
-  private ArticlePublisherInterface $articlePublisher;
52
-  private PersisterRegistry $elasticaPersisterRegistry;
53
-  private PackageRepositoryInterface $packageRepository;
54
-
55
-  /**
56
-   * @param FormFactoryInterface $formFactory
57
-   * @param EventDispatcherInterface $eventDispatcher
58
-   * @param CachedTenantContextInterface $cachedTenantContext
59
-   * @param ArticlePublisherInterface $articlePublisher
60
-   * @param PersisterRegistry $elasticaPersisterRegistry
61
-   * @param PackageRepositoryInterface $packageRepository
62
-   */
63
-  public function __construct(FormFactoryInterface         $formFactory, EventDispatcherInterface $eventDispatcher,
64
-                              CachedTenantContextInterface $cachedTenantContext,
65
-                              ArticlePublisherInterface    $articlePublisher,
66
-                              PersisterRegistry            $elasticaPersisterRegistry,
67
-                              PackageRepositoryInterface   $packageRepository) {
48
+    private FormFactoryInterface $formFactory;
49
+    private EventDispatcherInterface $eventDispatcher;
50
+    private CachedTenantContextInterface $cachedTenantContext;
51
+    private ArticlePublisherInterface $articlePublisher;
52
+    private PersisterRegistry $elasticaPersisterRegistry;
53
+    private PackageRepositoryInterface $packageRepository;
54
+
55
+    /**
56
+     * @param FormFactoryInterface $formFactory
57
+     * @param EventDispatcherInterface $eventDispatcher
58
+     * @param CachedTenantContextInterface $cachedTenantContext
59
+     * @param ArticlePublisherInterface $articlePublisher
60
+     * @param PersisterRegistry $elasticaPersisterRegistry
61
+     * @param PackageRepositoryInterface $packageRepository
62
+     */
63
+    public function __construct(FormFactoryInterface         $formFactory, EventDispatcherInterface $eventDispatcher,
64
+                                CachedTenantContextInterface $cachedTenantContext,
65
+                                ArticlePublisherInterface    $articlePublisher,
66
+                                PersisterRegistry            $elasticaPersisterRegistry,
67
+                                PackageRepositoryInterface   $packageRepository) {
68 68
     $this->formFactory = $formFactory;
69 69
     $this->eventDispatcher = $eventDispatcher;
70 70
     $this->cachedTenantContext = $cachedTenantContext;
71 71
     $this->articlePublisher = $articlePublisher;
72 72
     $this->elasticaPersisterRegistry = $elasticaPersisterRegistry;
73 73
     $this->packageRepository = $packageRepository;
74
-  }
74
+    }
75 75
 
76 76
 
77
-  /**
78
-   * @Route("/api/{version}/packages/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_packages")
79
-   */
80
-  public function listAction(Request $request) {
77
+    /**
78
+     * @Route("/api/{version}/packages/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_packages")
79
+     */
80
+    public function listAction(Request $request) {
81 81
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
82 82
     $tenantContext = $this->cachedTenantContext;
83 83
 
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
         ]), $request->query->all('sorting'), new PaginationData($request));
89 89
 
90 90
     return new ResourcesListResponse($packages);
91
-  }
91
+    }
92 92
 
93
-  /**
94
-   * @Route("/api/{version}/packages/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_show_package", requirements={"id"="\d+"})
95
-   */
96
-  public function getAction(int $id): SingleResourceResponseInterface {
93
+    /**
94
+     * @Route("/api/{version}/packages/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_show_package", requirements={"id"="\d+"})
95
+     */
96
+    public function getAction(int $id): SingleResourceResponseInterface {
97 97
     return new SingleResourceResponse($this->findOr404($id));
98
-  }
98
+    }
99 99
 
100
-  /**
101
-   * @Route("/api/{version}/packages/{id}/publish/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_publish_package", requirements={"id"="\d+"})
102
-   */
103
-  public function publishAction(Request $request, int $id): SingleResourceResponseInterface {
100
+    /**
101
+     * @Route("/api/{version}/packages/{id}/publish/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_publish_package", requirements={"id"="\d+"})
102
+     */
103
+    public function publishAction(Request $request, int $id): SingleResourceResponseInterface {
104 104
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
105 105
     /** @var PackageInterface $package */
106 106
     $package = $this->findOr404($id);
@@ -109,74 +109,74 @@  discard block
 block discarded – undo
109 109
     $form->handleRequest($request);
110 110
 
111 111
     if ($form->isSubmitted() && $form->isValid()) {
112
-      $this->articlePublisher->publish($package, $form->getData());
113
-      $this->elasticaPersisterRegistry->getPersister('swp_package')->replaceOne($package);
112
+        $this->articlePublisher->publish($package, $form->getData());
113
+        $this->elasticaPersisterRegistry->getPersister('swp_package')->replaceOne($package);
114 114
 
115
-      return new SingleResourceResponse(null, new ResponseContext(201));
115
+        return new SingleResourceResponse(null, new ResponseContext(201));
116 116
     }
117 117
 
118 118
     return new SingleResourceResponse($form, new ResponseContext(400));
119
-  }
119
+    }
120 120
 
121
-  /**
122
-   * @Route("/api/{version}/packages/{id}/unpublish/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_unpublish_package", requirements={"id"="\d+"})
123
-   */
124
-  public function unpublishAction(Request $request, int $id): SingleResourceResponseInterface {
121
+    /**
122
+     * @Route("/api/{version}/packages/{id}/unpublish/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_unpublish_package", requirements={"id"="\d+"})
123
+     */
124
+    public function unpublishAction(Request $request, int $id): SingleResourceResponseInterface {
125 125
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
126 126
     $package = $this->findOr404($id);
127 127
     $form = $this->formFactory->createNamed('', UnpublishFromTenantsType::class, null, ['method' => $request->getMethod()]);
128 128
 
129 129
     $form->handleRequest($request);
130 130
     if ($form->isSubmitted() && $form->isValid()) {
131
-      $formData = $form->getData();
132
-      /** @var Collection $tenants */
133
-      $tenants = $formData['tenants'];
134
-      $this->articlePublisher->unpublish($package, $tenants->toArray());
131
+        $formData = $form->getData();
132
+        /** @var Collection $tenants */
133
+        $tenants = $formData['tenants'];
134
+        $this->articlePublisher->unpublish($package, $tenants->toArray());
135 135
 
136
-      return new SingleResourceResponse(null, new ResponseContext(200));
136
+        return new SingleResourceResponse(null, new ResponseContext(200));
137 137
     }
138 138
 
139 139
     return new SingleResourceResponse($form, new ResponseContext(400));
140
-  }
141
-
142
-  /**
143
-   * @Route("/api/{version}/packages/{id}/", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_package", requirements={"id"="\d+"})
144
-   *
145
-   * @return SingleResourceResponse
146
-   */
147
-  public function updateAction(Request $request, int $id) {
140
+    }
141
+
142
+    /**
143
+     * @Route("/api/{version}/packages/{id}/", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_package", requirements={"id"="\d+"})
144
+     *
145
+     * @return SingleResourceResponse
146
+     */
147
+    public function updateAction(Request $request, int $id) {
148 148
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
149 149
     $package = $this->findOr404($id);
150 150
     $form = $this->formFactory->createNamed('', PackageType::class, $package, ['method' => $request->getMethod()]);
151 151
 
152 152
     $form->handleRequest($request);
153 153
     if ($form->isSubmitted() && $form->isValid()) {
154
-      if (ContentInterface::STATUS_CANCELED === $package->getPubStatus()) {
154
+        if (ContentInterface::STATUS_CANCELED === $package->getPubStatus()) {
155 155
         $package->setStatus(ContentInterface::STATUS_CANCELED);
156
-      }
157
-      $this->getPackageRepository()->flush();
156
+        }
157
+        $this->getPackageRepository()->flush();
158 158
 
159
-      return new SingleResourceResponse($package, new ResponseContext(200));
159
+        return new SingleResourceResponse($package, new ResponseContext(200));
160 160
     }
161 161
 
162 162
     return new SingleResourceResponse($form, new ResponseContext(400));
163
-  }
163
+    }
164 164
 
165
-  /**
166
-   * @return object|null
167
-   */
168
-  private function findOr404(int $id) {
165
+    /**
166
+     * @return object|null
167
+     */
168
+    private function findOr404(int $id) {
169 169
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
170 170
     $tenantContext = $this->cachedTenantContext;
171 171
 
172 172
     if (null === $package = $this->getPackageRepository()->findOneBy(['id' => $id, 'organization' => $tenantContext->getTenant()->getOrganization()])) {
173
-      throw new NotFoundHttpException('Package was not found.');
173
+        throw new NotFoundHttpException('Package was not found.');
174 174
     }
175 175
 
176 176
     return $package;
177
-  }
177
+    }
178 178
 
179
-  protected function getPackageRepository() {
179
+    protected function getPackageRepository() {
180 180
     return $this->packageRepository;
181
-  }
181
+    }
182 182
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ArticleCommentsController.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -37,30 +37,30 @@  discard block
 block discarded – undo
37 37
 
38 38
 class ArticleCommentsController extends AbstractController {
39 39
 
40
-  private ArticleRepositoryInterface $articleRepository;
41
-  private ArticleResolverInterface $articleResolver;
42
-  private FormFactoryInterface $formFactory;
43
-  private EventDispatcherInterface $eventDispatcher;
44
-
45
-  /**
46
-   * @param ArticleRepositoryInterface $articleRepository
47
-   * @param ArticleResolverInterface $articleResolver
48
-   * @param FormFactoryInterface $formFactory
49
-   * @param EventDispatcherInterface $eventDispatcher
50
-   */
51
-  public function __construct(ArticleRepositoryInterface $articleRepository, ArticleResolverInterface $articleResolver,
52
-                              FormFactoryInterface       $formFactory, EventDispatcherInterface $eventDispatcher) {
40
+    private ArticleRepositoryInterface $articleRepository;
41
+    private ArticleResolverInterface $articleResolver;
42
+    private FormFactoryInterface $formFactory;
43
+    private EventDispatcherInterface $eventDispatcher;
44
+
45
+    /**
46
+     * @param ArticleRepositoryInterface $articleRepository
47
+     * @param ArticleResolverInterface $articleResolver
48
+     * @param FormFactoryInterface $formFactory
49
+     * @param EventDispatcherInterface $eventDispatcher
50
+     */
51
+    public function __construct(ArticleRepositoryInterface $articleRepository, ArticleResolverInterface $articleResolver,
52
+                                FormFactoryInterface       $formFactory, EventDispatcherInterface $eventDispatcher) {
53 53
     $this->articleRepository = $articleRepository;
54 54
     $this->articleResolver = $articleResolver;
55 55
     $this->formFactory = $formFactory;
56 56
     $this->eventDispatcher = $eventDispatcher;
57
-  }
57
+    }
58 58
 
59 59
 
60
-  /**
61
-   * @Route("/api/{version}/content/articles", methods={"PATCH"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_article_comments")
62
-   */
63
-  public function updateAction(Request $request): SingleResourceResponseInterface {
60
+    /**
61
+     * @Route("/api/{version}/content/articles", methods={"PATCH"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_article_comments")
62
+     */
63
+    public function updateAction(Request $request): SingleResourceResponseInterface {
64 64
     $repository = $this->articleRepository;
65 65
     $articleResolver = $this->articleResolver;
66 66
     $form = $this->formFactory->createNamed('', ArticleCommentsType::class, [], ['method' => $request->getMethod()]);
@@ -68,42 +68,42 @@  discard block
 block discarded – undo
68 68
     $form->handleRequest($request);
69 69
 
70 70
     if ($form->isSubmitted() && $form->isValid()) {
71
-      $data = $form->getData();
72
-      $article = null;
73
-      if (null !== $data['url']) {
71
+        $data = $form->getData();
72
+        $article = null;
73
+        if (null !== $data['url']) {
74 74
         $article = strpos($data['url'], '/r/') ? $repository->findOneBySlug(
75 75
             str_replace('/r/', '', $this->getFragmentFromUrl($data['url'], 'path'))
76 76
         ) : $articleResolver->resolve($data['url']);
77
-      } elseif (null !== $data['id']) {
77
+        } elseif (null !== $data['id']) {
78 78
         $article = $repository->findOneBy(['id' => $data['id']]);
79
-      }
79
+        }
80 80
 
81
-      if (null === $article) {
81
+        if (null === $article) {
82 82
         throw new NotFoundHttpException('Article was not found');
83
-      }
83
+        }
84 84
 
85
-      $article->setCommentsCount((int)$data['commentsCount']);
86
-      $article->cancelTimestampable();
87
-      $repository->flush();
85
+        $article->setCommentsCount((int)$data['commentsCount']);
86
+        $article->cancelTimestampable();
87
+        $repository->flush();
88 88
 
89
-      $this->eventDispatcher->dispatch(new ArticleEvent(
90
-          $article,
91
-          $article->getPackage(),
92
-          ArticleEvents::POST_UPDATE
93
-      ), ArticleEvents::POST_UPDATE);
89
+        $this->eventDispatcher->dispatch(new ArticleEvent(
90
+            $article,
91
+            $article->getPackage(),
92
+            ArticleEvents::POST_UPDATE
93
+        ), ArticleEvents::POST_UPDATE);
94 94
 
95
-      return new SingleResourceResponse($article);
95
+        return new SingleResourceResponse($article);
96 96
     }
97 97
 
98 98
     return new SingleResourceResponse($form, new ResponseContext(400));
99
-  }
99
+    }
100 100
 
101
-  private function getFragmentFromUrl(string $url, string $fragment): ?string {
101
+    private function getFragmentFromUrl(string $url, string $fragment): ?string {
102 102
     $fragments = parse_url($url);
103 103
     if (!array_key_exists($fragment, $fragments)) {
104
-      return null;
104
+        return null;
105 105
     }
106 106
 
107 107
     return $fragments[$fragment];
108
-  }
108
+    }
109 109
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@
 block discarded – undo
82 82
         throw new NotFoundHttpException('Article was not found');
83 83
       }
84 84
 
85
-      $article->setCommentsCount((int)$data['commentsCount']);
85
+      $article->setCommentsCount((int) $data['commentsCount']);
86 86
       $article->cancelTimestampable();
87 87
       $repository->flush();
88 88
 
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/FbiaFeedController.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -34,36 +34,36 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ExternalOauthController.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
57 57
     $response->headers->setCookie(Cookie::create(self::PUBLISHER_JWT_COOKIE, $jwtTokenManager->create($user)));
58 58
 
59 59
     return $response;
60
-  }
60
+    }
61 61
 }
Please login to merge, or discard this patch.