Completed
Pull Request — master (#1218)
by
unknown
40s
created
src/SWP/Bundle/CoreBundle/Controller/AnalyticsExportController.php 2 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -50,33 +50,33 @@  discard block
 block discarded – undo
50 50
 
51 51
 class AnalyticsExportController extends AbstractController {
52 52
 
53
-  protected CacheInterface $cacheProvider;
54
-  protected RepositoryInterface $analyticsReportRepository;
55
-  protected Filesystem $filesystem;
56
-  protected CsvReportFileLocationResolver $csvReportFileLocationResolver;
57
-  protected CachedTenantContextInterface $cachedTenantContext;
58
-  protected RouteRepositoryInterface $routeRepository;
59
-  private MessageBusInterface $messageBus;
60
-  private FormFactoryInterface $formFactory;
61
-  private EventDispatcherInterface $eventDispatcher;
62
-
63
-  /**
64
-   * @param CacheInterface $cacheProvider
65
-   * @param RepositoryInterface $analyticsReportRepository
66
-   * @param Filesystem $filesystem
67
-   * @param CsvReportFileLocationResolver $csvReportFileLocationResolver
68
-   * @param CachedTenantContextInterface $cachedTenantContext
69
-   * @param RouteRepositoryInterface $routeRepository
70
-   * @param MessageBusInterface $messageBus
71
-   * @param FormFactoryInterface $formFactory
72
-   * @param EventDispatcherInterface $eventDispatcher
73
-   */
74
-  public function __construct(CacheInterface                $cacheProvider,
75
-                              RepositoryInterface           $analyticsReportRepository, Filesystem $filesystem,
76
-                              CsvReportFileLocationResolver $csvReportFileLocationResolver,
77
-                              CachedTenantContextInterface  $cachedTenantContext,
78
-                              RouteRepositoryInterface      $routeRepository, MessageBusInterface $messageBus,
79
-                              FormFactoryInterface          $formFactory, EventDispatcherInterface $eventDispatcher) {
53
+    protected CacheInterface $cacheProvider;
54
+    protected RepositoryInterface $analyticsReportRepository;
55
+    protected Filesystem $filesystem;
56
+    protected CsvReportFileLocationResolver $csvReportFileLocationResolver;
57
+    protected CachedTenantContextInterface $cachedTenantContext;
58
+    protected RouteRepositoryInterface $routeRepository;
59
+    private MessageBusInterface $messageBus;
60
+    private FormFactoryInterface $formFactory;
61
+    private EventDispatcherInterface $eventDispatcher;
62
+
63
+    /**
64
+     * @param CacheInterface $cacheProvider
65
+     * @param RepositoryInterface $analyticsReportRepository
66
+     * @param Filesystem $filesystem
67
+     * @param CsvReportFileLocationResolver $csvReportFileLocationResolver
68
+     * @param CachedTenantContextInterface $cachedTenantContext
69
+     * @param RouteRepositoryInterface $routeRepository
70
+     * @param MessageBusInterface $messageBus
71
+     * @param FormFactoryInterface $formFactory
72
+     * @param EventDispatcherInterface $eventDispatcher
73
+     */
74
+    public function __construct(CacheInterface                $cacheProvider,
75
+                                RepositoryInterface           $analyticsReportRepository, Filesystem $filesystem,
76
+                                CsvReportFileLocationResolver $csvReportFileLocationResolver,
77
+                                CachedTenantContextInterface  $cachedTenantContext,
78
+                                RouteRepositoryInterface      $routeRepository, MessageBusInterface $messageBus,
79
+                                FormFactoryInterface          $formFactory, EventDispatcherInterface $eventDispatcher) {
80 80
     $this->cacheProvider = $cacheProvider;
81 81
     $this->analyticsReportRepository = $analyticsReportRepository;
82 82
     $this->filesystem = $filesystem;
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
     $this->messageBus = $messageBus;
87 87
     $this->formFactory = $formFactory;
88 88
     $this->eventDispatcher = $eventDispatcher;
89
-  }
89
+    }
90 90
 
91 91
 
92
-  /**
93
-   * @Route("/api/{version}/export/analytics/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_analytics_export_post")
94
-   *
95
-   * @throws \Exception
96
-   */
97
-  public function post(Request $request): SingleResourceResponseInterface {
92
+    /**
93
+     * @Route("/api/{version}/export/analytics/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_analytics_export_post")
94
+     *
95
+     * @throws \Exception
96
+     */
97
+    public function post(Request $request): SingleResourceResponseInterface {
98 98
     /** @var UserInterface $currentlyLoggedInUser */
99 99
     $currentlyLoggedInUser = $this->getUser();
100 100
 
@@ -105,46 +105,46 @@  discard block
 block discarded – undo
105 105
     $form->handleRequest($request);
106 106
 
107 107
     if ($form->isSubmitted() && $form->isValid()) {
108
-      $data = $form->getData();
108
+        $data = $form->getData();
109 109
 
110
-      $analyticsReport = new AnalyticsReport();
111
-      $analyticsReport->setAssetId($fileName);
112
-      $analyticsReport->setFileExtension('csv');
113
-      $analyticsReport->setUser($currentlyLoggedInUser);
110
+        $analyticsReport = new AnalyticsReport();
111
+        $analyticsReport->setAssetId($fileName);
112
+        $analyticsReport->setFileExtension('csv');
113
+        $analyticsReport->setUser($currentlyLoggedInUser);
114 114
 
115
-      $exportAnalytics = new ExportAnalytics(
116
-          $data['start'],
117
-          $data['end'],
118
-          $this->cachedTenantContext->getTenant()->getCode(),
119
-          $fileName,
120
-          $currentlyLoggedInUser->getEmail(),
121
-          !empty($data['routes']) ? $this->toIds($data['routes']) : [],
122
-          !empty($data['authors']) ? $this->toIds($data['authors']) : [],
123
-          $data['term'] ?? ''
124
-      );
115
+        $exportAnalytics = new ExportAnalytics(
116
+            $data['start'],
117
+            $data['end'],
118
+            $this->cachedTenantContext->getTenant()->getCode(),
119
+            $fileName,
120
+            $currentlyLoggedInUser->getEmail(),
121
+            !empty($data['routes']) ? $this->toIds($data['routes']) : [],
122
+            !empty($data['authors']) ? $this->toIds($data['authors']) : [],
123
+            $data['term'] ?? ''
124
+        );
125 125
 
126
-      $filters = $this->processFilters(
127
-          $exportAnalytics->getFilters(),
128
-          !empty($data['routes']) ? $data['routes'] : [],
129
-          !empty($data['authors']) ? $data['authors'] : []
130
-      );
126
+        $filters = $this->processFilters(
127
+            $exportAnalytics->getFilters(),
128
+            !empty($data['routes']) ? $data['routes'] : [],
129
+            !empty($data['authors']) ? $data['authors'] : []
130
+        );
131 131
 
132
-      $analyticsReport->setFilters($filters);
132
+        $analyticsReport->setFilters($filters);
133 133
 
134
-      $this->analyticsReportRepository->add($analyticsReport);
134
+        $this->analyticsReportRepository->add($analyticsReport);
135 135
 
136
-      $this->messageBus->dispatch($exportAnalytics);
136
+        $this->messageBus->dispatch($exportAnalytics);
137 137
 
138
-      return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201));
138
+        return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201));
139 139
     }
140 140
 
141 141
     return new SingleResourceResponse($form, new ResponseContext(400));
142
-  }
142
+    }
143 143
 
144
-  /**
145
-   * @Route("/api/{version}/export/analytics/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_analytics_reports")
146
-   */
147
-  public function listAction(Request $request): ResourcesListResponseInterface {
144
+    /**
145
+     * @Route("/api/{version}/export/analytics/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_analytics_reports")
146
+     */
147
+    public function listAction(Request $request): ResourcesListResponseInterface {
148 148
     $sorting = $request->query->all('sorting');
149 149
     $reports = $this->analyticsReportRepository->getPaginatedByCriteria(
150 150
         $this->eventDispatcher,
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
     );
155 155
 
156 156
     return new ResourcesListResponse($reports);
157
-  }
157
+    }
158 158
 
159
-  /**
160
-   * @Route("/analytics/export/{fileName}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_export_analytics_download")
161
-   */
162
-  public function downloadFile(string $fileName): Response {
159
+    /**
160
+     * @Route("/analytics/export/{fileName}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_export_analytics_download")
161
+     */
162
+    public function downloadFile(string $fileName): Response {
163 163
     $cacheKey = md5(serialize(['analytics_report', $fileName]));
164 164
 
165 165
     $analyticsReport = $this->cacheProvider->get($cacheKey, function () use ($fileName) {
166
-      /* @var AnalyticsReportInterface|null $analyticsReport */
167
-      return $this->analyticsReportRepository->findOneBy(['assetId' => $fileName]);
166
+        /* @var AnalyticsReportInterface|null $analyticsReport */
167
+        return $this->analyticsReportRepository->findOneBy(['assetId' => $fileName]);
168 168
     });
169 169
 
170 170
     if (null === $analyticsReport) {
171
-      throw new NotFoundHttpException('Report file was not found.');
171
+        throw new NotFoundHttpException('Report file was not found.');
172 172
     }
173 173
 
174 174
     $response = new Response();
@@ -187,30 +187,30 @@  discard block
 block discarded – undo
187 187
     $response->setContent($this->filesystem->read($this->csvReportFileLocationResolver->getMediaBasePath() . '/' . $analyticsReport->getAssetId()));
188 188
 
189 189
     return $response;
190
-  }
190
+    }
191 191
 
192
-  private function toIds(array $items): array {
192
+    private function toIds(array $items): array {
193 193
     $ids = [];
194 194
     foreach ($items as $item) {
195
-      foreach ($item as $entity) {
195
+        foreach ($item as $entity) {
196 196
         if (!$entity instanceof PersistableInterface) {
197
-          continue;
197
+            continue;
198 198
         }
199 199
 
200 200
         $ids[] = $entity->getId();
201
-      }
201
+        }
202 202
     }
203 203
 
204 204
     return $ids;
205
-  }
205
+    }
206 206
 
207
-  private function processFilters(array $filters, array $routes, array $authors): array {
207
+    private function processFilters(array $filters, array $routes, array $authors): array {
208 208
     $routeNames = [];
209 209
 
210 210
     foreach ($routes as $route) {
211
-      foreach ($route as $entity) {
211
+        foreach ($route as $entity) {
212 212
         $routeNames[] = $entity->getName();
213
-      }
213
+        }
214 214
     }
215 215
 
216 216
     $filters['routes'] = $routeNames;
@@ -218,13 +218,13 @@  discard block
 block discarded – undo
218 218
     $authorNames = [];
219 219
     /** @var ArticleAuthorInterface $author */
220 220
     foreach ($authors as $author) {
221
-      foreach ($author as $entity) {
221
+        foreach ($author as $entity) {
222 222
         $authorNames[] = $entity->getName();
223
-      }
223
+        }
224 224
     }
225 225
 
226 226
     $filters['authors'] = $authorNames;
227 227
 
228 228
     return $filters;
229
-  }
229
+    }
230 230
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     $currentlyLoggedInUser = $this->getUser();
100 100
 
101 101
     $now = PublisherDateTime::getCurrentDateTime();
102
-    $fileName = 'analytics-' . $now->format('Y-m-d-H:i:s') . '.csv';
102
+    $fileName = 'analytics-'.$now->format('Y-m-d-H:i:s').'.csv';
103 103
 
104 104
     $form = $this->formFactory->createNamed('', ExportAnalyticsType::class, null, ['method' => $request->getMethod()]);
105 105
     $form->handleRequest($request);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
   public function downloadFile(string $fileName): Response {
163 163
     $cacheKey = md5(serialize(['analytics_report', $fileName]));
164 164
 
165
-    $analyticsReport = $this->cacheProvider->get($cacheKey, function () use ($fileName) {
165
+    $analyticsReport = $this->cacheProvider->get($cacheKey, function() use ($fileName) {
166 166
       /* @var AnalyticsReportInterface|null $analyticsReport */
167 167
       return $this->analyticsReportRepository->findOneBy(['assetId' => $fileName]);
168 168
     });
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
     $response->setMaxAge(63072000);
185 185
     $response->setSharedMaxAge(63072000);
186 186
     $response->setLastModified($analyticsReport->getUpdatedAt() ?: $analyticsReport->getCreatedAt());
187
-    $response->setContent($this->filesystem->read($this->csvReportFileLocationResolver->getMediaBasePath() . '/' . $analyticsReport->getAssetId()));
187
+    $response->setContent($this->filesystem->read($this->csvReportFileLocationResolver->getMediaBasePath().'/'.$analyticsReport->getAssetId()));
188 188
 
189 189
     return $response;
190 190
   }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/SlideshowController.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,28 +29,28 @@  discard block
 block discarded – undo
29 29
 use Symfony\Component\Routing\Annotation\Route;
30 30
 
31 31
 class SlideshowController extends Controller {
32
-  private ArticleRepositoryInterface $articleRepository;
33
-  private SlideshowRepositoryInterface $slideshowRepository;
34
-  private EventDispatcherInterface $eventDispatcher;
32
+    private ArticleRepositoryInterface $articleRepository;
33
+    private SlideshowRepositoryInterface $slideshowRepository;
34
+    private EventDispatcherInterface $eventDispatcher;
35 35
 
36
-  /**
37
-   * @param ArticleRepositoryInterface $articleRepository
38
-   * @param SlideshowRepositoryInterface $slideshowRepository
39
-   * @param EventDispatcherInterface $eventDispatcher
40
-   */
41
-  public function __construct(ArticleRepositoryInterface   $articleRepository,
42
-                              SlideshowRepositoryInterface $slideshowRepository,
43
-                              EventDispatcherInterface     $eventDispatcher) {
36
+    /**
37
+     * @param ArticleRepositoryInterface $articleRepository
38
+     * @param SlideshowRepositoryInterface $slideshowRepository
39
+     * @param EventDispatcherInterface $eventDispatcher
40
+     */
41
+    public function __construct(ArticleRepositoryInterface   $articleRepository,
42
+                                SlideshowRepositoryInterface $slideshowRepository,
43
+                                EventDispatcherInterface     $eventDispatcher) {
44 44
     $this->articleRepository = $articleRepository;
45 45
     $this->slideshowRepository = $slideshowRepository;
46 46
     $this->eventDispatcher = $eventDispatcher;
47
-  }
47
+    }
48 48
 
49 49
 
50
-  /**
51
-   * @Route("/api/{version}/content/slideshows/{articleId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_slideshows_list")
52
-   */
53
-  public function listAction(Request $request, string $articleId): ResourcesListResponseInterface {
50
+    /**
51
+     * @Route("/api/{version}/content/slideshows/{articleId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_slideshows_list")
52
+     */
53
+    public function listAction(Request $request, string $articleId): ResourcesListResponseInterface {
54 54
     $repository = $this->slideshowRepository;
55 55
 
56 56
     $article = $this->findArticleOr404($articleId);
@@ -60,29 +60,29 @@  discard block
 block discarded – undo
60 60
     ]), $request->query->all('sorting'), new PaginationData($request));
61 61
 
62 62
     return new ResourcesListResponse($slideshows);
63
-  }
63
+    }
64 64
 
65
-  /**
66
-   * @Route("/api/{version}/content/slideshows/{articleId}/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_get_slideshow", requirements={"id"="\d+"})
67
-   */
68
-  public function getAction($id, string $articleId): SingleResourceResponseInterface {
65
+    /**
66
+     * @Route("/api/{version}/content/slideshows/{articleId}/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_get_slideshow", requirements={"id"="\d+"})
67
+     */
68
+    public function getAction($id, string $articleId): SingleResourceResponseInterface {
69 69
     $article = $this->findArticleOr404($articleId);
70 70
 
71 71
     if (null === $list = $this->slideshowRepository->findOneBy([
72 72
             'id' => $id,
73 73
             'article' => $article,
74 74
         ])) {
75
-      throw new NotFoundHttpException(sprintf('Slideshow with id "%s" was not found.', $id));
75
+        throw new NotFoundHttpException(sprintf('Slideshow with id "%s" was not found.', $id));
76 76
     }
77 77
 
78 78
     return new SingleResourceResponse($list);
79
-  }
79
+    }
80 80
 
81
-  private function findArticleOr404($id) {
81
+    private function findArticleOr404($id) {
82 82
     if (null === $article = $this->articleRepository->findOneById($id)) {
83
-      throw new NotFoundHttpException(sprintf('Article with id "%s" was not found.', $id));
83
+        throw new NotFoundHttpException(sprintf('Article with id "%s" was not found.', $id));
84 84
     }
85 85
 
86 86
     return $article;
87
-  }
87
+    }
88 88
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/RedirectRouteController.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -37,45 +37,45 @@  discard block
 block discarded – undo
37 37
 
38 38
 class RedirectRouteController extends AbstractController {
39 39
 
40
-  private FormFactoryInterface $formFactory;
41
-  private RepositoryInterface $redirectRouteRepository;
42
-  private EntityManagerInterface $entityManager;
43
-  private FactoryInterface $redirectRouteFactory;
44
-  private EventDispatcherInterface $eventDispatcher;
45
-
46
-  /**
47
-   * @param FormFactoryInterface $formFactory
48
-   * @param RepositoryInterface $redirectRouteRepository
49
-   * @param EntityManagerInterface $entityManager
50
-   * @param FactoryInterface $redirectRouteFactory
51
-   * @param EventDispatcherInterface $eventDispatcher
52
-   */
53
-  public function __construct(FormFactoryInterface   $formFactory, RepositoryInterface $redirectRouteRepository,
54
-                              EntityManagerInterface $entityManager, FactoryInterface $redirectRouteFactory,
55
-                              EventDispatcherInterface        $eventDispatcher) {
40
+    private FormFactoryInterface $formFactory;
41
+    private RepositoryInterface $redirectRouteRepository;
42
+    private EntityManagerInterface $entityManager;
43
+    private FactoryInterface $redirectRouteFactory;
44
+    private EventDispatcherInterface $eventDispatcher;
45
+
46
+    /**
47
+     * @param FormFactoryInterface $formFactory
48
+     * @param RepositoryInterface $redirectRouteRepository
49
+     * @param EntityManagerInterface $entityManager
50
+     * @param FactoryInterface $redirectRouteFactory
51
+     * @param EventDispatcherInterface $eventDispatcher
52
+     */
53
+    public function __construct(FormFactoryInterface   $formFactory, RepositoryInterface $redirectRouteRepository,
54
+                                EntityManagerInterface $entityManager, FactoryInterface $redirectRouteFactory,
55
+                                EventDispatcherInterface        $eventDispatcher) {
56 56
     $this->formFactory = $formFactory;
57 57
     $this->redirectRouteRepository = $redirectRouteRepository;
58 58
     $this->entityManager = $entityManager;
59 59
     $this->redirectRouteFactory = $redirectRouteFactory;
60 60
     $this->eventDispatcher = $eventDispatcher;
61
-  }
61
+    }
62 62
 
63 63
 
64
-  /**
65
-   * @Route("/api/{version}/redirects/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_redirect_routes")
66
-   */
67
-  public function listAction(Request $request) {
64
+    /**
65
+     * @Route("/api/{version}/redirects/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_redirect_routes")
66
+     */
67
+    public function listAction(Request $request) {
68 68
     $redirectRouteRepository = $this->redirectRouteRepository;
69 69
 
70 70
     $redirectRoutes = $redirectRouteRepository->getPaginatedByCriteria($this->eventDispatcher, new Criteria(), $request->query->all('sorting'), new PaginationData($request));
71 71
 
72 72
     return new ResourcesListResponse($redirectRoutes);
73
-  }
73
+    }
74 74
 
75
-  /**
76
-   * @Route("/api/{version}/redirects/{id}", methods={"DELETE"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_redirect_route", requirements={"id"="\d+"})
77
-   */
78
-  public function deleteAction(int $id): SingleResourceResponseInterface {
75
+    /**
76
+     * @Route("/api/{version}/redirects/{id}", methods={"DELETE"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_redirect_route", requirements={"id"="\d+"})
77
+     */
78
+    public function deleteAction(int $id): SingleResourceResponseInterface {
79 79
     $objectManager = $this->entityManager;
80 80
     $redirectRoute = $this->findOr404($id);
81 81
 
@@ -83,69 +83,69 @@  discard block
 block discarded – undo
83 83
     $objectManager->flush();
84 84
 
85 85
     return new SingleResourceResponse(null, new ResponseContext(204));
86
-  }
86
+    }
87 87
 
88
-  /**
89
-   * @Route("/api/{version}/redirects/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_create_redirect_route")
90
-   */
91
-  public function createAction(Request $request): SingleResourceResponseInterface {
88
+    /**
89
+     * @Route("/api/{version}/redirects/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_create_redirect_route")
90
+     */
91
+    public function createAction(Request $request): SingleResourceResponseInterface {
92 92
     $redirectRoute = $this->redirectRouteFactory->create();
93 93
     $form = $this->formFactory->createNamed('', RedirectRouteType::class, $redirectRoute, ['method' => $request->getMethod()]);
94 94
 
95 95
     $form->handleRequest($request);
96 96
 
97 97
     if ($this->checkIfSourceRouteExists($redirectRoute)) {
98
-      $this->ensureRedirectRouteExists($redirectRoute->getRouteName());
98
+        $this->ensureRedirectRouteExists($redirectRoute->getRouteName());
99 99
     }
100 100
 
101 101
     if ($form->isSubmitted() && $form->isValid()) {
102
-      if ($this->checkIfSourceRouteExists($redirectRoute)) {
102
+        if ($this->checkIfSourceRouteExists($redirectRoute)) {
103 103
         $redirectRoute->setStaticPrefix($redirectRoute->getRouteName());
104
-      } else {
104
+        } else {
105 105
         $redirectRoute->setStaticPrefix($redirectRoute->getRouteSource()->getStaticPrefix());
106
-      }
106
+        }
107 107
 
108
-      $this->redirectRouteRepository->add($redirectRoute);
108
+        $this->redirectRouteRepository->add($redirectRoute);
109 109
 
110
-      return new SingleResourceResponse($redirectRoute, new ResponseContext(201));
110
+        return new SingleResourceResponse($redirectRoute, new ResponseContext(201));
111 111
     }
112 112
 
113 113
     return new SingleResourceResponse($form, new ResponseContext(400));
114
-  }
114
+    }
115 115
 
116
-  /**
117
-   * @Route("/api/{version}/redirects/{id}", methods={"PATCH"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_update_redirect_route", requirements={"id"="\d+"})
118
-   */
119
-  public function updateAction(Request $request, int $id): SingleResourceResponseInterface {
116
+    /**
117
+     * @Route("/api/{version}/redirects/{id}", methods={"PATCH"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_update_redirect_route", requirements={"id"="\d+"})
118
+     */
119
+    public function updateAction(Request $request, int $id): SingleResourceResponseInterface {
120 120
     $objectManager = $this->entityManager;
121 121
     $redirectRoute = $this->findOr404($id);
122 122
     $form = $this->formFactory->createNamed('', RedirectRouteType::class, $redirectRoute, ['method' => $request->getMethod()]);
123 123
     $form->handleRequest($request);
124 124
 
125 125
     if ($form->isSubmitted() && $form->isValid()) {
126
-      $objectManager->flush();
126
+        $objectManager->flush();
127 127
 
128
-      return new SingleResourceResponse($redirectRoute, new ResponseContext(200));
128
+        return new SingleResourceResponse($redirectRoute, new ResponseContext(200));
129 129
     }
130 130
 
131 131
     return new SingleResourceResponse($form, new ResponseContext(400));
132
-  }
132
+    }
133 133
 
134
-  private function findOr404(int $id): RedirectRouteInterface {
134
+    private function findOr404(int $id): RedirectRouteInterface {
135 135
     if (null === $redirectRoute = $this->redirectRouteRepository->findOneById($id)) {
136
-      throw new NotFoundHttpException('Redirect route was not found.');
136
+        throw new NotFoundHttpException('Redirect route was not found.');
137 137
     }
138 138
 
139 139
     return $redirectRoute;
140
-  }
140
+    }
141 141
 
142
-  private function ensureRedirectRouteExists(?string $name): void {
142
+    private function ensureRedirectRouteExists(?string $name): void {
143 143
     if (null !== $this->redirectRouteRepository->findOneBy(['routeName' => $name])) {
144
-      throw new ConflictHttpException(sprintf('Redirect route "%s" already exists!', $name));
144
+        throw new ConflictHttpException(sprintf('Redirect route "%s" already exists!', $name));
145
+    }
145 146
     }
146
-  }
147 147
 
148
-  private function checkIfSourceRouteExists(RedirectRouteInterface $redirectRoute): bool {
148
+    private function checkIfSourceRouteExists(RedirectRouteInterface $redirectRoute): bool {
149 149
     return null === $redirectRoute->getRouteSource();
150
-  }
150
+    }
151 151
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/PackageSeoMediaUploadController.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,50 +28,50 @@
 block discarded – undo
28 28
 use Symfony\Component\Routing\Annotation\Route;
29 29
 
30 30
 class PackageSeoMediaUploadController extends AbstractController {
31
-  private FactoryInterface $seoMetadataFactory;
32
-  private RepositoryInterface $seoMetadataRepository;
33
-  private FormFactoryInterface $formFactory;
31
+    private FactoryInterface $seoMetadataFactory;
32
+    private RepositoryInterface $seoMetadataRepository;
33
+    private FormFactoryInterface $formFactory;
34 34
 
35
-  /**
36
-   * @param FactoryInterface $seoMetadataFactory
37
-   * @param RepositoryInterface $seoMetadataRepository
38
-   * @param FormFactoryInterface $formFactory
39
-   */
40
-  public function __construct(FactoryInterface     $seoMetadataFactory, RepositoryInterface $seoMetadataRepository,
41
-                              FormFactoryInterface $formFactory) {
35
+    /**
36
+     * @param FactoryInterface $seoMetadataFactory
37
+     * @param RepositoryInterface $seoMetadataRepository
38
+     * @param FormFactoryInterface $formFactory
39
+     */
40
+    public function __construct(FactoryInterface     $seoMetadataFactory, RepositoryInterface $seoMetadataRepository,
41
+                                FormFactoryInterface $formFactory) {
42 42
     $this->seoMetadataFactory = $seoMetadataFactory;
43 43
     $this->seoMetadataRepository = $seoMetadataRepository;
44 44
     $this->formFactory = $formFactory;
45
-  }
45
+    }
46 46
 
47 47
 
48
-  /**
49
-   * @Route("/api/{version}/packages/seo/upload/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_package_seo_image")
50
-   */
51
-  public function uploadAction(Request                   $request, string $packageGuid,
52
-                               SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse {
48
+    /**
49
+     * @Route("/api/{version}/packages/seo/upload/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_package_seo_image")
50
+     */
51
+    public function uploadAction(Request                   $request, string $packageGuid,
52
+                                SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse {
53 53
     $seoMetadata = $this->seoMetadataRepository->findOneByPackageGuid($packageGuid);
54 54
 
55 55
     if (null === $seoMetadata) {
56
-      $seoMetadata = $this->seoMetadataFactory->create();
56
+        $seoMetadata = $this->seoMetadataFactory->create();
57 57
     }
58 58
 
59 59
     $form = $this->formFactory->createNamed('', SeoImageType::class, $seoMetadata);
60 60
     $form->handleRequest($request);
61 61
 
62 62
     if ($form->isSubmitted() && $form->isValid()) {
63
-      try {
63
+        try {
64 64
         $seoMetadata->setPackageGuid($packageGuid);
65 65
         $seoImageUploader->handleUpload($seoMetadata);
66 66
 
67 67
         $this->seoMetadataRepository->add($seoMetadata);
68
-      } catch (\Exception $e) {
68
+        } catch (\Exception $e) {
69 69
         return new SingleResourceResponse(['message' => 'Could not upload an image.'], new ResponseContext(400));
70
-      }
70
+        }
71 71
 
72
-      return new SingleResourceResponse($seoMetadata, new ResponseContext(201));
72
+        return new SingleResourceResponse($seoMetadata, new ResponseContext(201));
73 73
     }
74 74
 
75 75
     return new SingleResourceResponse($form, new ResponseContext(400));
76
-  }
76
+    }
77 77
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/SlideshowItemController.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -28,32 +28,32 @@  discard block
 block discarded – undo
28 28
 use Symfony\Component\Routing\Annotation\Route;
29 29
 
30 30
 class SlideshowItemController extends Controller {
31
-  private ArticleRepositoryInterface $articleRepository;
32
-  private SlideshowRepositoryInterface $slideshowRepository;
33
-  private SlideshowItemRepositoryInterface $slideshowItemRepository;
34
-  private EventDispatcherInterface $eventDispatcher;
31
+    private ArticleRepositoryInterface $articleRepository;
32
+    private SlideshowRepositoryInterface $slideshowRepository;
33
+    private SlideshowItemRepositoryInterface $slideshowItemRepository;
34
+    private EventDispatcherInterface $eventDispatcher;
35 35
 
36
-  /**
37
-   * @param ArticleRepositoryInterface $articleRepository
38
-   * @param SlideshowRepositoryInterface $slideshowRepository
39
-   * @param SlideshowItemRepositoryInterface $slideshowItemRepository
40
-   * @param EventDispatcherInterface $eventDispatcher
41
-   */
42
-  public function __construct(ArticleRepositoryInterface       $articleRepository,
43
-                              SlideshowRepositoryInterface     $slideshowRepository,
44
-                              SlideshowItemRepositoryInterface $slideshowItemRepository,
45
-                              EventDispatcherInterface         $eventDispatcher) {
36
+    /**
37
+     * @param ArticleRepositoryInterface $articleRepository
38
+     * @param SlideshowRepositoryInterface $slideshowRepository
39
+     * @param SlideshowItemRepositoryInterface $slideshowItemRepository
40
+     * @param EventDispatcherInterface $eventDispatcher
41
+     */
42
+    public function __construct(ArticleRepositoryInterface       $articleRepository,
43
+                                SlideshowRepositoryInterface     $slideshowRepository,
44
+                                SlideshowItemRepositoryInterface $slideshowItemRepository,
45
+                                EventDispatcherInterface         $eventDispatcher) {
46 46
     $this->articleRepository = $articleRepository;
47 47
     $this->slideshowRepository = $slideshowRepository;
48 48
     $this->slideshowItemRepository = $slideshowItemRepository;
49 49
     $this->eventDispatcher = $eventDispatcher;
50
-  }
50
+    }
51 51
 
52 52
 
53
-  /**
54
-   * @Route("/api/{version}/content/slideshows/{articleId}/{id}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_slideshow_items", requirements={"id"="\d+"})
55
-   */
56
-  public function listAction(Request $request, string $articleId, string $id) {
53
+    /**
54
+     * @Route("/api/{version}/content/slideshows/{articleId}/{id}/items/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_slideshow_items", requirements={"id"="\d+"})
55
+     */
56
+    public function listAction(Request $request, string $articleId, string $id) {
57 57
     $article = $this->findArticleOr404($articleId);
58 58
     $repository = $this->slideshowItemRepository;
59 59
 
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
     );
69 69
 
70 70
     return new ResourcesListResponse($items);
71
-  }
71
+    }
72 72
 
73
-  private function findOr404($id): ?SlideshowInterface {
73
+    private function findOr404($id): ?SlideshowInterface {
74 74
     if (null === $slideshow = $this->slideshowRepository->findOneById($id)) {
75
-      throw new NotFoundHttpException(sprintf('Slideshow with id "%s" was not found.', $id));
75
+        throw new NotFoundHttpException(sprintf('Slideshow with id "%s" was not found.', $id));
76 76
     }
77 77
 
78 78
     return $slideshow;
79
-  }
79
+    }
80 80
 
81
-  private function findArticleOr404($id) {
81
+    private function findArticleOr404($id) {
82 82
     if (null === $article = $this->articleRepository->findOneById($id)) {
83
-      throw new NotFoundHttpException(sprintf('Article with id "%s" was not found.', $id));
83
+        throw new NotFoundHttpException(sprintf('Article with id "%s" was not found.', $id));
84 84
     }
85 85
 
86 86
     return $article;
87
-  }
87
+    }
88 88
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ArticleSourceController.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
 
29 29
 class ArticleSourceController extends AbstractController {
30 30
 
31
-  private EntityRepository $entityRepository;
32
-  private EventDispatcherInterface $eventDispatcher;
33
-
34
-  /**
35
-   * @param EntityRepository $entityRepository
36
-   * @param EventDispatcherInterface $eventDispatcher
37
-   */
38
-  public function __construct(EntityRepository $entityRepository, EventDispatcherInterface $eventDispatcher) {
31
+    private EntityRepository $entityRepository;
32
+    private EventDispatcherInterface $eventDispatcher;
33
+
34
+    /**
35
+     * @param EntityRepository $entityRepository
36
+     * @param EventDispatcherInterface $eventDispatcher
37
+     */
38
+    public function __construct(EntityRepository $entityRepository, EventDispatcherInterface $eventDispatcher) {
39 39
     $this->entityRepository = $entityRepository;
40 40
     $this->eventDispatcher = $eventDispatcher;
41
-  }
41
+    }
42 42
 
43
-  /**
44
-   * @Route("/api/{version}/content/sources/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_article_sources")
45
-   */
46
-  public function listAction(Request $request): ResourcesListResponseInterface {
43
+    /**
44
+     * @Route("/api/{version}/content/sources/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_article_sources")
45
+     */
46
+    public function listAction(Request $request): ResourcesListResponseInterface {
47 47
     $sorting = $request->query->all('sorting');
48 48
     $lists = $this->entityRepository->getPaginatedByCriteria(
49 49
         $this->eventDispatcher,
@@ -52,5 +52,5 @@  discard block
 block discarded – undo
52 52
         new PaginationData($request));
53 53
 
54 54
     return new ResourcesListResponse($lists);
55
-  }
55
+    }
56 56
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/CurrentThemeController.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,78 +33,78 @@  discard block
 block discarded – undo
33 33
 
34 34
 class CurrentThemeController extends AbstractController {
35 35
 
36
-  private TenantAwareThemeContextInterface $tenantAwareThemeContext;
37
-  private FormFactoryInterface $formFactory;
38
-  private CachedTenantContextInterface $tenantContext;
39
-  private SettingsManagerInterface $settingsManager;
40
-  private ThemeLogoUploaderInterface $themeLogoUploader;
41
-
42
-  /**
43
-   * @param TenantAwareThemeContextInterface $tenantAwareThemeContext
44
-   * @param FormFactoryInterface $formFactory
45
-   * @param CachedTenantContextInterface $tenantContext
46
-   * @param SettingsManagerInterface $settingsManager
47
-   * @param ThemeLogoUploaderInterface $themeLogoUploader
48
-   */
49
-  public function __construct(TenantAwareThemeContextInterface $tenantAwareThemeContext,
50
-                              FormFactoryInterface             $formFactory,
51
-                              CachedTenantContextInterface     $tenantContext,
52
-                              SettingsManagerInterface         $settingsManager,
53
-                              ThemeLogoUploaderInterface       $themeLogoUploader) {
36
+    private TenantAwareThemeContextInterface $tenantAwareThemeContext;
37
+    private FormFactoryInterface $formFactory;
38
+    private CachedTenantContextInterface $tenantContext;
39
+    private SettingsManagerInterface $settingsManager;
40
+    private ThemeLogoUploaderInterface $themeLogoUploader;
41
+
42
+    /**
43
+     * @param TenantAwareThemeContextInterface $tenantAwareThemeContext
44
+     * @param FormFactoryInterface $formFactory
45
+     * @param CachedTenantContextInterface $tenantContext
46
+     * @param SettingsManagerInterface $settingsManager
47
+     * @param ThemeLogoUploaderInterface $themeLogoUploader
48
+     */
49
+    public function __construct(TenantAwareThemeContextInterface $tenantAwareThemeContext,
50
+                                FormFactoryInterface             $formFactory,
51
+                                CachedTenantContextInterface     $tenantContext,
52
+                                SettingsManagerInterface         $settingsManager,
53
+                                ThemeLogoUploaderInterface       $themeLogoUploader) {
54 54
     $this->tenantAwareThemeContext = $tenantAwareThemeContext;
55 55
     $this->formFactory = $formFactory;
56 56
     $this->tenantContext = $tenantContext;
57 57
     $this->settingsManager = $settingsManager;
58 58
     $this->themeLogoUploader = $themeLogoUploader;
59
-  }
59
+    }
60 60
 
61 61
 
62
-  /**
63
-   * @Route("/api/{version}/theme/logo_upload/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme_logo_2")
64
-   * @Route("/api/{version}/theme/logo_upload/{type}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme_logo")
65
-   */
66
-  public function uploadThemeLogoAction(Request $request,
62
+    /**
63
+     * @Route("/api/{version}/theme/logo_upload/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme_logo_2")
64
+     * @Route("/api/{version}/theme/logo_upload/{type}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme_logo")
65
+     */
66
+    public function uploadThemeLogoAction(Request $request,
67 67
                                         string  $type = ThemeLogoProviderInterface::SETTING_NAME_DEFAULT): SingleResourceResponseInterface {
68 68
     $themeContext = $this->tenantAwareThemeContext;
69 69
 
70 70
     if (null === ($theme = $themeContext->getTheme())) {
71
-      throw new \LogicException('Theme is not set!');
71
+        throw new \LogicException('Theme is not set!');
72 72
     }
73 73
 
74 74
     $form = $this->formFactory->createNamed('', ThemeLogoUploadType::class, $theme);
75 75
     $form->handleRequest($request);
76 76
 
77 77
     if ($form->isSubmitted() && $form->isValid()) {
78
-      $tenantContext = $this->tenantContext;
79
-      $currentTenant = $tenantContext->getTenant();
78
+        $tenantContext = $this->tenantContext;
79
+        $currentTenant = $tenantContext->getTenant();
80 80
 
81
-      try {
81
+        try {
82 82
         $settingsManager = $this->settingsManager;
83 83
         $setting = $settingsManager->get($type, ScopeContextInterface::SCOPE_THEME, $currentTenant);
84 84
         $theme->setLogoPath($setting);
85 85
         $themeLogoUploader = $this->themeLogoUploader;
86 86
         $themeLogoUploader->upload($theme);
87
-      } catch (\Exception $e) {
87
+        } catch (\Exception $e) {
88 88
         return new SingleResourceResponse(['message' => 'Could not upload logo.'], new ResponseContext(400));
89
-      }
89
+        }
90 90
 
91
-      $settingsManager = $this->settingsManager;
92
-      $setting = $settingsManager->set($type, $theme->getLogoPath(), ScopeContextInterface::SCOPE_THEME, $currentTenant);
91
+        $settingsManager = $this->settingsManager;
92
+        $setting = $settingsManager->set($type, $theme->getLogoPath(), ScopeContextInterface::SCOPE_THEME, $currentTenant);
93 93
 
94
-      return new SingleResourceResponse($setting, new ResponseContext(201));
94
+        return new SingleResourceResponse($setting, 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}/theme/settings/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_theme_settings_list")
102
-   */
103
-  public function listSettingsAction(): SingleResourceResponseInterface {
100
+    /**
101
+     * @Route("/api/{version}/theme/settings/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_theme_settings_list")
102
+     */
103
+    public function listSettingsAction(): SingleResourceResponseInterface {
104 104
     $themeContext = $this->tenantAwareThemeContext;
105 105
 
106 106
     if (null === $themeContext->getTheme()) {
107
-      throw new \LogicException('Theme is not set!');
107
+        throw new \LogicException('Theme is not set!');
108 108
     }
109 109
 
110 110
     $tenantContext = $this->tenantContext;
@@ -112,5 +112,5 @@  discard block
 block discarded – undo
112 112
     $settings = $settingsManager->getByScopeAndOwner(ScopeContextInterface::SCOPE_THEME, $tenantContext->getTenant());
113 113
 
114 114
     return new SingleResourceResponse($settings);
115
-  }
115
+    }
116 116
 }
Please login to merge, or discard this patch.
SWP/Bundle/CoreBundle/Controller/RelatedArticleOrganizationController.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -35,102 +35,102 @@
 block discarded – undo
35 35
 use Symfony\Component\Routing\Annotation\Route;
36 36
 
37 37
 class RelatedArticleOrganizationController extends Controller {
38
-  private EventDispatcherInterface $eventDispatcher;
39
-  private DataTransformerInterface $dataTransformer;
40
-  private CachedTenantContextInterface $cachedTenantContext;
41
-  private PackageRepositoryInterface $packageRepository;
42
-  private ArticleRepositoryInterface $articleRepository;
43
-  private TenantRepositoryInterface $tenantRepository;
44
-
45
-  /**
46
-   * @param EventDispatcherInterface $eventDispatcher
47
-   * @param DataTransformerInterface $dataTransformer
48
-   * @param CachedTenantContextInterface $cachedTenantContext
49
-   * @param PackageRepositoryInterface $packageRepository
50
-   * @param ArticleRepositoryInterface $articleRepository
51
-   * @param TenantRepositoryInterface $tenantRepository
52
-   */
53
-  public function __construct(EventDispatcherInterface     $eventDispatcher,
54
-                              DataTransformerInterface     $dataTransformer,
55
-                              CachedTenantContextInterface $cachedTenantContext,
56
-                              PackageRepositoryInterface   $packageRepository,
57
-                              ArticleRepositoryInterface   $articleRepository,
58
-                              TenantRepositoryInterface    $tenantRepository) {
38
+    private EventDispatcherInterface $eventDispatcher;
39
+    private DataTransformerInterface $dataTransformer;
40
+    private CachedTenantContextInterface $cachedTenantContext;
41
+    private PackageRepositoryInterface $packageRepository;
42
+    private ArticleRepositoryInterface $articleRepository;
43
+    private TenantRepositoryInterface $tenantRepository;
44
+
45
+    /**
46
+     * @param EventDispatcherInterface $eventDispatcher
47
+     * @param DataTransformerInterface $dataTransformer
48
+     * @param CachedTenantContextInterface $cachedTenantContext
49
+     * @param PackageRepositoryInterface $packageRepository
50
+     * @param ArticleRepositoryInterface $articleRepository
51
+     * @param TenantRepositoryInterface $tenantRepository
52
+     */
53
+    public function __construct(EventDispatcherInterface     $eventDispatcher,
54
+                                DataTransformerInterface     $dataTransformer,
55
+                                CachedTenantContextInterface $cachedTenantContext,
56
+                                PackageRepositoryInterface   $packageRepository,
57
+                                ArticleRepositoryInterface   $articleRepository,
58
+                                TenantRepositoryInterface    $tenantRepository) {
59 59
     $this->eventDispatcher = $eventDispatcher;
60 60
     $this->dataTransformer = $dataTransformer;
61 61
     $this->cachedTenantContext = $cachedTenantContext;
62 62
     $this->packageRepository = $packageRepository;
63 63
     $this->articleRepository = $articleRepository;
64 64
     $this->tenantRepository = $tenantRepository;
65
-  }
65
+    }
66 66
 
67 67
 
68
-  /**
69
-   * @Route("/api/{version}/organization/articles/related/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_organization_related_articles")
70
-   */
71
-  public function postAction(Request $request) {
68
+    /**
69
+     * @Route("/api/{version}/organization/articles/related/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_organization_related_articles")
70
+     */
71
+    public function postAction(Request $request) {
72 72
     $content = $request->getContent();
73 73
     $package = $this->dataTransformer->transform($content);
74 74
     $relatedArticlesList = $this->getRelated($package);
75 75
 
76 76
     return new SingleResourceResponse($relatedArticlesList);
77
-  }
77
+    }
78 78
 
79
-  /**
80
-   * @Route("/api/{version}/packages/{id}/related/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_packages_related_articles", requirements={"id"="\d+"})
81
-   */
82
-  public function getRelatedAction(string $id) {
79
+    /**
80
+     * @Route("/api/{version}/packages/{id}/related/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_packages_related_articles", requirements={"id"="\d+"})
81
+     */
82
+    public function getRelatedAction(string $id) {
83 83
     $package = $this->findOr404((int)$id);
84 84
 
85 85
     $relatedArticlesList = $this->getRelated($package);
86 86
 
87 87
     return new SingleResourceResponse($relatedArticlesList);
88
-  }
88
+    }
89 89
 
90
-  private function getRelated(PackageInterface $package): RelatedArticleList {
90
+    private function getRelated(PackageInterface $package): RelatedArticleList {
91 91
     $relatedItemsGroups = $package->getItems()->filter(static function ($group) {
92
-      return ItemInterface::TYPE_TEXT === $group->getType();
92
+        return ItemInterface::TYPE_TEXT === $group->getType();
93 93
     });
94 94
 
95 95
     $relatedArticlesList = new RelatedArticleList();
96 96
 
97 97
     if (null === $package || (null !== $package && 0 === \count($relatedItemsGroups))) {
98
-      return $relatedArticlesList;
98
+        return $relatedArticlesList;
99 99
     }
100 100
 
101 101
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
102 102
     $articleRepository = $this->articleRepository;
103 103
 
104 104
     foreach ($relatedItemsGroups as $item) {
105
-      if (null === ($existingArticles = $articleRepository->findBy(['code' => $item->getGuid()]))) {
105
+        if (null === ($existingArticles = $articleRepository->findBy(['code' => $item->getGuid()]))) {
106 106
         continue;
107
-      }
107
+        }
108 108
 
109
-      $tenants = [];
110
-      foreach ($existingArticles as $existingArticle) {
109
+        $tenants = [];
110
+        foreach ($existingArticles as $existingArticle) {
111 111
         $tenantCode = $existingArticle->getTenantCode();
112 112
         $tenant = $this->tenantRepository->findOneByCode($tenantCode);
113 113
 
114 114
         $tenants[] = $tenant;
115
-      }
115
+        }
116 116
 
117
-      $relatedArticleListItem = new RelatedArticleListItem();
118
-      $relatedArticleListItem->setTenants($tenants);
119
-      $relatedArticleListItem->setTitle($item->getHeadline());
117
+        $relatedArticleListItem = new RelatedArticleListItem();
118
+        $relatedArticleListItem->setTenants($tenants);
119
+        $relatedArticleListItem->setTitle($item->getHeadline());
120 120
 
121
-      $relatedArticlesList->addRelatedArticleItem($relatedArticleListItem);
121
+        $relatedArticlesList->addRelatedArticleItem($relatedArticleListItem);
122 122
     }
123 123
 
124 124
     return $relatedArticlesList;
125
-  }
125
+    }
126 126
 
127
-  private function findOr404(int $id): PackageInterface {
127
+    private function findOr404(int $id): PackageInterface {
128 128
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
129 129
     $tenantContext = $this->cachedTenantContext;
130 130
     if (null === $package = $this->packageRepository->findOneBy(['id' => $id, 'organization' => $tenantContext->getTenant()->getOrganization()])) {
131
-      throw new NotFoundHttpException('Package was not found.');
131
+        throw new NotFoundHttpException('Package was not found.');
132 132
     }
133 133
 
134 134
     return $package;
135
-  }
135
+    }
136 136
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
    * @Route("/api/{version}/packages/{id}/related/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_packages_related_articles", requirements={"id"="\d+"})
81 81
    */
82 82
   public function getRelatedAction(string $id) {
83
-    $package = $this->findOr404((int)$id);
83
+    $package = $this->findOr404((int) $id);
84 84
 
85 85
     $relatedArticlesList = $this->getRelated($package);
86 86
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
   }
89 89
 
90 90
   private function getRelated(PackageInterface $package): RelatedArticleList {
91
-    $relatedItemsGroups = $package->getItems()->filter(static function ($group) {
91
+    $relatedItemsGroups = $package->getItems()->filter(static function($group) {
92 92
       return ItemInterface::TYPE_TEXT === $group->getType();
93 93
     });
94 94
 
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/SeoMediaController.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -36,75 +36,75 @@
 block discarded – undo
36 36
 use Symfony\Contracts\Cache\CacheInterface;
37 37
 
38 38
 class SeoMediaController extends AbstractMediaController {
39
-  private FactoryInterface $seoMetadataFactory;
40
-  private ArticleProviderInterface $articleProvider;
41
-  private EntityManagerInterface $seoObjectManager;
42
-  private FormFactoryInterface $formFactory;
43
-
44
-  public function __construct(
45
-      FactoryInterface              $seoMetadataFactory,
46
-      ArticleProviderInterface      $articleProvider,
47
-      FormFactoryInterface          $formFactory,
48
-      EntityManagerInterface        $seoObjectManager,
49
-      MediaManagerInterface         $seoMediaManager,
50
-      CacheInterface                $cacheProvider,
51
-      FileProviderInterface         $fileProvider,
52
-      FileExtensionCheckerInterface $fileExtensionChecker
53
-  ) {
39
+    private FactoryInterface $seoMetadataFactory;
40
+    private ArticleProviderInterface $articleProvider;
41
+    private EntityManagerInterface $seoObjectManager;
42
+    private FormFactoryInterface $formFactory;
43
+
44
+    public function __construct(
45
+        FactoryInterface              $seoMetadataFactory,
46
+        ArticleProviderInterface      $articleProvider,
47
+        FormFactoryInterface          $formFactory,
48
+        EntityManagerInterface        $seoObjectManager,
49
+        MediaManagerInterface         $seoMediaManager,
50
+        CacheInterface                $cacheProvider,
51
+        FileProviderInterface         $fileProvider,
52
+        FileExtensionCheckerInterface $fileExtensionChecker
53
+    ) {
54 54
     $this->seoMetadataFactory = $seoMetadataFactory;
55 55
     $this->formFactory = $formFactory;
56 56
     $this->articleProvider = $articleProvider;
57 57
     $this->seoObjectManager = $seoObjectManager;
58 58
 
59 59
     parent::__construct($seoMediaManager, $cacheProvider, $fileProvider, $fileExtensionChecker);
60
-  }
60
+    }
61 61
 
62
-  /**
63
-   * @Route("/seo/media/{mediaId}.{extension}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_seo_media_get")
64
-   */
65
-  public function getAction(string $mediaId, string $extension): Response {
62
+    /**
63
+     * @Route("/seo/media/{mediaId}.{extension}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_seo_media_get")
64
+     */
65
+    public function getAction(string $mediaId, string $extension): Response {
66 66
     return $this->getMedia($mediaId, $extension);
67
-  }
67
+    }
68 68
 
69
-  /**
70
-   * @Route("/api/{version}/upload/seo_image/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_seo_image")
71
-   */
72
-  public function uploadSeoImageAction(Request                   $request, string $id,
73
-                                       SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse {
69
+    /**
70
+     * @Route("/api/{version}/upload/seo_image/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_seo_image")
71
+     */
72
+    public function uploadSeoImageAction(Request                   $request, string $id,
73
+                                        SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse {
74 74
     $article = $this->findOr404($id);
75 75
     $seoMetadata = $article->getSeoMetadata();
76 76
 
77 77
     if (null === $seoMetadata) {
78
-      $seoMetadata = $this->seoMetadataFactory->create();
78
+        $seoMetadata = $this->seoMetadataFactory->create();
79 79
     }
80 80
 
81 81
     $form = $this->formFactory->createNamed('', SeoImageType::class, $seoMetadata);
82 82
     $form->handleRequest($request);
83 83
 
84 84
     if ($form->isSubmitted() && $form->isValid()) {
85
-      try {
85
+        try {
86 86
         $seoImageUploader->handleUpload($seoMetadata);
87 87
 
88 88
         if (null === $article->getSeoMetadata()) {
89
-          $article->setSeoMetadata($seoMetadata);
89
+            $article->setSeoMetadata($seoMetadata);
90 90
         }
91 91
 
92 92
         $this->seoObjectManager->flush();
93
-      } catch (\Exception $e) {
93
+        } catch (\Exception $e) {
94 94
         return new SingleResourceResponse(['message' => 'Could not upload an image.'], new ResponseContext(400));
95
-      }
95
+        }
96 96
 
97
-      return new SingleResourceResponse($seoMetadata, new ResponseContext(201));
97
+        return new SingleResourceResponse($seoMetadata, new ResponseContext(201));
98 98
     }
99 99
 
100 100
     return new SingleResourceResponse($form, new ResponseContext(400));
101
-  }
101
+    }
102 102
 
103
-  private function findOr404(string $id): ArticleInterface {
103
+    private function findOr404(string $id): ArticleInterface {
104 104
     if (null === $article = $this->articleProvider->getOneById($id)) {
105
-      throw new NotFoundHttpException('Article was not found.');
105
+        throw new NotFoundHttpException('Article was not found.');
106 106
     }
107 107
 
108 108
     return $article;
109
-  }
109
+    }
110 110
 }
Please login to merge, or discard this patch.