Completed
Pull Request — master (#1218)
by
unknown
38s
created
src/SWP/Bundle/UserBundle/Controller/ResetPasswordController.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -36,88 +36,88 @@  discard block
 block discarded – undo
36 36
  * @Route("/reset-password")
37 37
  */
38 38
 class ResetPasswordController extends AbstractController {
39
-  use ResetPasswordControllerTrait;
39
+    use ResetPasswordControllerTrait;
40 40
 
41
-  private ResetPasswordHelperInterface $resetPasswordHelper;
42
-  private EntityManagerInterface  $entityManager;
41
+    private ResetPasswordHelperInterface $resetPasswordHelper;
42
+    private EntityManagerInterface  $entityManager;
43 43
 
44
-  /**
45
-   * @param ResetPasswordHelperInterface $resetPasswordHelper
46
-   * @param EntityManagerInterface $entityManager
47
-   */
48
-  public function __construct(ResetPasswordHelperInterface $resetPasswordHelper,
49
-                              EntityManagerInterface       $entityManager) {
44
+    /**
45
+     * @param ResetPasswordHelperInterface $resetPasswordHelper
46
+     * @param EntityManagerInterface $entityManager
47
+     */
48
+    public function __construct(ResetPasswordHelperInterface $resetPasswordHelper,
49
+                                EntityManagerInterface       $entityManager) {
50 50
     $this->resetPasswordHelper = $resetPasswordHelper;
51 51
     $this->entityManager = $entityManager;
52
-  }
52
+    }
53 53
 
54 54
 
55
-  /**
56
-   * Display & process form to request a password reset.
57
-   *
58
-   * @Route("", name="swp_user_forgot_password_request")
59
-   */
60
-  public function request(Request $request, MailerInterface $mailer): Response {
55
+    /**
56
+     * Display & process form to request a password reset.
57
+     *
58
+     * @Route("", name="swp_user_forgot_password_request")
59
+     */
60
+    public function request(Request $request, MailerInterface $mailer): Response {
61 61
     $form = $this->createForm(ResetPasswordRequestFormType::class);
62 62
     $form->handleRequest($request);
63 63
 
64 64
     if ($form->isSubmitted() && $form->isValid()) {
65
-      return $this->processSendingPasswordResetEmail(
66
-          $form->get('email')->getData(),
67
-          $mailer
68
-      );
65
+        return $this->processSendingPasswordResetEmail(
66
+            $form->get('email')->getData(),
67
+            $mailer
68
+        );
69 69
     }
70 70
 
71 71
     return $this->render('@SWPUser/reset_password/request.html.twig', [
72 72
         'requestForm' => $form->createView(),
73 73
     ]);
74
-  }
75
-
76
-  /**
77
-   * Confirmation page after a user has requested a password reset.
78
-   *
79
-   * @Route("/check-email", name="swp_user_check_email")
80
-   */
81
-  public function checkEmail(): Response {
74
+    }
75
+
76
+    /**
77
+     * Confirmation page after a user has requested a password reset.
78
+     *
79
+     * @Route("/check-email", name="swp_user_check_email")
80
+     */
81
+    public function checkEmail(): Response {
82 82
     // We prevent users from directly accessing this page
83 83
     if (!$this->canCheckEmail()) {
84
-      return $this->redirectToRoute('swp_user_forgot_password_request');
84
+        return $this->redirectToRoute('swp_user_forgot_password_request');
85 85
     }
86 86
 
87 87
     return $this->render('@SWPUser/reset_password/check_email.html.twig', [
88 88
         'tokenLifetime' => $this->resetPasswordHelper->getTokenLifetime(),
89 89
     ]);
90
-  }
91
-
92
-  /**
93
-   * Validates and process the reset URL that the user clicked in their email.
94
-   *
95
-   * @Route("/reset/{token}", name="swp_user_reset_password")
96
-   */
97
-  public function reset(Request $request, UserPasswordHasherInterface $passwordEncoder,
90
+    }
91
+
92
+    /**
93
+     * Validates and process the reset URL that the user clicked in their email.
94
+     *
95
+     * @Route("/reset/{token}", name="swp_user_reset_password")
96
+     */
97
+    public function reset(Request $request, UserPasswordHasherInterface $passwordEncoder,
98 98
                         string  $token = null): Response {
99 99
     if ($token) {
100
-      // We store the token in session and remove it from the URL, to avoid the URL being
101
-      // loaded in a browser and potentially leaking the token to 3rd party JavaScript.
102
-      $this->storeTokenInSession($token);
100
+        // We store the token in session and remove it from the URL, to avoid the URL being
101
+        // loaded in a browser and potentially leaking the token to 3rd party JavaScript.
102
+        $this->storeTokenInSession($token);
103 103
 
104
-      return $this->redirectToRoute('swp_user_reset_password');
104
+        return $this->redirectToRoute('swp_user_reset_password');
105 105
     }
106 106
 
107 107
     $token = $this->getTokenFromSession();
108 108
     if (null === $token) {
109
-      throw $this->createNotFoundException('No reset password token found in the URL or in the session.');
109
+        throw $this->createNotFoundException('No reset password token found in the URL or in the session.');
110 110
     }
111 111
 
112 112
     try {
113
-      $user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
113
+        $user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
114 114
     } catch (ResetPasswordExceptionInterface $e) {
115
-      $this->addFlash('reset_password_error', sprintf(
116
-          'There was a problem validating your reset request - %s',
117
-          $e->getReason()
118
-      ));
115
+        $this->addFlash('reset_password_error', sprintf(
116
+            'There was a problem validating your reset request - %s',
117
+            $e->getReason()
118
+        ));
119 119
 
120
-      return $this->redirectToRoute('swp_user_forgot_password_request');
120
+        return $this->redirectToRoute('swp_user_forgot_password_request');
121 121
     }
122 122
 
123 123
     // The token is valid; allow the user to change their password.
@@ -125,30 +125,30 @@  discard block
 block discarded – undo
125 125
     $form->handleRequest($request);
126 126
 
127 127
     if ($form->isSubmitted() && $form->isValid()) {
128
-      // A password reset token should be used only once, remove it.
129
-      $this->resetPasswordHelper->removeResetRequest($token);
128
+        // A password reset token should be used only once, remove it.
129
+        $this->resetPasswordHelper->removeResetRequest($token);
130 130
 
131
-      // Encode the plain password, and set it.
132
-      $encodedPassword = $passwordEncoder->hashPassword(
133
-          $user,
134
-          $form->get('plainPassword')->getData()
135
-      );
131
+        // Encode the plain password, and set it.
132
+        $encodedPassword = $passwordEncoder->hashPassword(
133
+            $user,
134
+            $form->get('plainPassword')->getData()
135
+        );
136 136
 
137
-      $user->setPassword($encodedPassword);
138
-      $this->entityManager->flush();
137
+        $user->setPassword($encodedPassword);
138
+        $this->entityManager->flush();
139 139
 
140
-      // The session is cleaned up after the password has been changed.
141
-      $this->cleanSessionAfterReset();
140
+        // The session is cleaned up after the password has been changed.
141
+        $this->cleanSessionAfterReset();
142 142
 
143
-      return $this->redirectToRoute('homepage');
143
+        return $this->redirectToRoute('homepage');
144 144
     }
145 145
 
146 146
     return $this->render('@SWPUser/reset_password/reset.html.twig', [
147 147
         'resetForm' => $form->createView(),
148 148
     ]);
149
-  }
149
+    }
150 150
 
151
-  private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse {
151
+    private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse {
152 152
     $user = $this->entityManager->getRepository(User::class)->findOneBy([
153 153
         'email' => $emailFormData,
154 154
     ]);
@@ -158,22 +158,22 @@  discard block
 block discarded – undo
158 158
 
159 159
     // Do not reveal whether a user account was found or not.
160 160
     if (!$user) {
161
-      return $this->redirectToRoute('swp_user_check_email');
161
+        return $this->redirectToRoute('swp_user_check_email');
162 162
     }
163 163
 
164 164
     try {
165
-      $resetToken = $this->resetPasswordHelper->generateResetToken($user);
165
+        $resetToken = $this->resetPasswordHelper->generateResetToken($user);
166 166
     } catch (ResetPasswordExceptionInterface $e) {
167
-      $this->addFlash('reset_password_error', sprintf(
168
-          'There was a problem handling your password reset request - %s',
169
-          $e->getReason()
170
-      ));
167
+        $this->addFlash('reset_password_error', sprintf(
168
+            'There was a problem handling your password reset request - %s',
169
+            $e->getReason()
170
+        ));
171 171
 
172
-      return $this->redirectToRoute('swp_user_check_email');
172
+        return $this->redirectToRoute('swp_user_check_email');
173 173
     }
174 174
 
175 175
     $mailer->sendResetPasswordEmail($user, $resetToken);
176 176
 
177 177
     return $this->redirectToRoute('swp_user_check_email');
178
-  }
178
+    }
179 179
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Theme/Uploader/OrganizationAwareThemeUploader.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -24,33 +24,33 @@  discard block
 block discarded – undo
24 24
  * Class OrganizationAwareThemeUploader.
25 25
  */
26 26
 final class OrganizationAwareThemeUploader implements ThemeUploaderInterface {
27
-  /**
28
-   * @var TenantContextInterface
29
-   */
30
-  private $tenantContext;
31
-
32
-  /**
33
-   * @var string
34
-   */
35
-  private $baseDir;
36
-
37
-  /**
38
-   * OrganizationAwareThemeUploader constructor.
39
-   *
40
-   * @param TenantContextInterface $tenantContext
41
-   * @param string $baseDir
42
-   */
43
-  public function __construct(TenantContextInterface $tenantContext, string $baseDir) {
27
+    /**
28
+     * @var TenantContextInterface
29
+     */
30
+    private $tenantContext;
31
+
32
+    /**
33
+     * @var string
34
+     */
35
+    private $baseDir;
36
+
37
+    /**
38
+     * OrganizationAwareThemeUploader constructor.
39
+     *
40
+     * @param TenantContextInterface $tenantContext
41
+     * @param string $baseDir
42
+     */
43
+    public function __construct(TenantContextInterface $tenantContext, string $baseDir) {
44 44
     $this->tenantContext = $tenantContext;
45 45
     $this->baseDir = $baseDir;
46
-  }
46
+    }
47 47
 
48
-  /**
49
-   * {@inheritdoc}
50
-   */
51
-  public function upload(UploadedFile $file) {
48
+    /**
49
+     * {@inheritdoc}
50
+     */
51
+    public function upload(UploadedFile $file) {
52 52
     if (null === $this->tenantContext->getTenant()) {
53
-      throw new \Exception('Tenant was not found in context!');
53
+        throw new \Exception('Tenant was not found in context!');
54 54
     }
55 55
 
56 56
     $destinationFolder = $this->getAvailableThemesPath();
@@ -59,48 +59,48 @@  discard block
 block discarded – undo
59 59
 
60 60
     $zip = new \ZipArchive();
61 61
     if (true === $zip->open($filePath)) {
62
-      if (!$filesystem->exists($destinationFolder)) {
62
+        if (!$filesystem->exists($destinationFolder)) {
63 63
         $filesystem->mkdir($destinationFolder);
64
-      }
65
-      $pathInArray = explode('/', $zip->getNameIndex(0));
66
-      $themeDirInZip = array_shift($pathInArray);
64
+        }
65
+        $pathInArray = explode('/', $zip->getNameIndex(0));
66
+        $themeDirInZip = array_shift($pathInArray);
67 67
 
68
-      $themeConfiguration = $zip->getFromName($themeDirInZip . DIRECTORY_SEPARATOR . 'theme.json');
69
-      if (false === $themeConfiguration) {
68
+        $themeConfiguration = $zip->getFromName($themeDirInZip . DIRECTORY_SEPARATOR . 'theme.json');
69
+        if (false === $themeConfiguration) {
70 70
         throw new \Exception('In ZIP file we expect one directory and theme.json file inside');
71
-      }
71
+        }
72 72
 
73
-      $themeConfiguration = \json_decode($themeConfiguration, true);
74
-      if (\JSON_ERROR_NONE !== json_last_error()) {
73
+        $themeConfiguration = \json_decode($themeConfiguration, true);
74
+        if (\JSON_ERROR_NONE !== json_last_error()) {
75 75
         throw new \Exception('Theme configuration is not valid. Syntax error in theme.json');
76
-      }
76
+        }
77 77
 
78
-      $themeName = $themeConfiguration['name'];
79
-      $unpackedThemePath = $destinationFolder . DIRECTORY_SEPARATOR . $themeDirInZip;
78
+        $themeName = $themeConfiguration['name'];
79
+        $unpackedThemePath = $destinationFolder . DIRECTORY_SEPARATOR . $themeDirInZip;
80 80
 
81
-      if ($filesystem->exists($unpackedThemePath)) {
81
+        if ($filesystem->exists($unpackedThemePath)) {
82 82
         $filesystem->remove($unpackedThemePath);
83
-      }
83
+        }
84 84
 
85
-      $zip->extractTo($destinationFolder);
86
-      $zip->close();
85
+        $zip->extractTo($destinationFolder);
86
+        $zip->close();
87 87
 
88
-      $finalPath = $destinationFolder . DIRECTORY_SEPARATOR . str_replace('/', '__', $themeName);
89
-      $filesystem->rename($unpackedThemePath, $finalPath, true);
88
+        $finalPath = $destinationFolder . DIRECTORY_SEPARATOR . str_replace('/', '__', $themeName);
89
+        $filesystem->rename($unpackedThemePath, $finalPath, true);
90 90
 
91
-      return $finalPath;
91
+        return $finalPath;
92 92
     }
93 93
 
94 94
     return false;
95
-  }
95
+    }
96 96
 
97
-  /**
98
-   * @return string
99
-   */
100
-  public function getAvailableThemesPath() {
97
+    /**
98
+     * @return string
99
+     */
100
+    public function getAvailableThemesPath() {
101 101
     $tenant = $this->tenantContext->getTenant();
102 102
     $organization = $tenant->getOrganization();
103 103
     $organizationCode = $organization->getCode();
104 104
     return sprintf($this->baseDir . DIRECTORY_SEPARATOR . ThemeUploaderInterface::AVAILABLE_THEMES_PATH, $organizationCode);
105
-  }
105
+    }
106 106
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ContentController.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@
 block discarded – undo
22 22
 class ContentController extends AbstractController
23 23
 {
24 24
 
25
-  public function __construct() {
26
-  }
25
+    public function __construct() {
26
+    }
27 27
 
28
-  public function renderPageAction(string $contentTemplate): Response
28
+    public function renderPageAction(string $contentTemplate): Response
29 29
     {
30 30
         $response = new Response();
31 31
         $response->headers->set('Content-Type', 'text/html; charset=UTF-8');
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Context/CachedTenantContext.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,46 +24,46 @@
 block discarded – undo
24 24
 use SWP\Component\MultiTenancy\Model\TenantInterface;
25 25
 
26 26
 class CachedTenantContext extends TenantContext implements CachedTenantContextInterface {
27
-  private $resolvedTenants = [];
27
+    private $resolvedTenants = [];
28 28
 
29
-  public function getTenant(): ?TenantInterface {
29
+    public function getTenant(): ?TenantInterface {
30 30
     $currentRequest = $this->requestStack->getCurrentRequest();
31 31
     if ($currentRequest && $this->requestStack->getCurrentRequest()->attributes->get('exception') instanceof TenantNotFoundException) {
32
-      return null;
32
+        return null;
33 33
     }
34 34
     if (null === $this->tenant && null !== $currentRequest) {
35
-      $cacheKey = self::getCacheKey($currentRequest->getHost());
36
-      if (!array_key_exists($cacheKey, $this->resolvedTenants) || $this->resolvedTenants[$cacheKey] instanceof TenantInterface) {
35
+        $cacheKey = self::getCacheKey($currentRequest->getHost());
36
+        if (!array_key_exists($cacheKey, $this->resolvedTenants) || $this->resolvedTenants[$cacheKey] instanceof TenantInterface) {
37 37
         $this->resolvedTenants[$cacheKey] = parent::getTenant();
38
-      } else {
38
+        } else {
39 39
         $this->tenant = $this->resolvedTenants[$cacheKey];
40
-      }
40
+        }
41 41
     } else {
42
-      try {
42
+        try {
43 43
         return parent::getTenant();
44
-      } catch (\Throwable $e) {
44
+        } catch (\Throwable $e) {
45 45
         return null;
46
-      }
46
+        }
47 47
     }
48 48
 
49 49
     return $this->tenant;
50
-  }
50
+    }
51 51
 
52
-  public function setTenant(TenantInterface $tenant): void {
52
+    public function setTenant(TenantInterface $tenant): void {
53 53
     parent::setTenant($tenant);
54 54
     $this->dispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_ENABLE);
55 55
 
56 56
     $this->resolvedTenants[self::getCacheKey(
57 57
         $tenant->getSubdomain() ? $tenant->getSubdomain() . '.' . $tenant->getDomainName() : $tenant->getDomainName()
58 58
     )] = $tenant;
59
-  }
59
+    }
60 60
 
61
-  public function reset(): void {
61
+    public function reset(): void {
62 62
     $this->tenant = null;
63 63
     $this->resolvedTenants = [];
64
-  }
64
+    }
65 65
 
66
-  private static function getCacheKey(string $host): string {
66
+    private static function getCacheKey(string $host): string {
67 67
     return md5('tenant_cache__' . $host);
68
-  }
68
+    }
69 69
 }
Please login to merge, or discard this patch.
SWP/Bundle/ElasticSearchBundle/Controller/Api/ArticleSearchController.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,25 +28,25 @@  discard block
 block discarded – undo
28 28
 use FOS\RestBundle\Controller\Annotations\Route;
29 29
 
30 30
 class ArticleSearchController extends AbstractController {
31
-  private $extraFields; //
32
-  private CachedTenantContext $cachedTenantContext; // swp_multi_tenancy.tenant_context
33
-  private PaginatorInterface $paginator; // knp_paginator
34
-
35
-  /**
36
-   * @param $extraFields
37
-   * @param CachedTenantContext $cachedTenantContext
38
-   * @param PaginatorInterface $paginator
39
-   */
40
-  public function __construct($extraFields, CachedTenantContext $cachedTenantContext, PaginatorInterface $paginator) {
31
+    private $extraFields; //
32
+    private CachedTenantContext $cachedTenantContext; // swp_multi_tenancy.tenant_context
33
+    private PaginatorInterface $paginator; // knp_paginator
34
+
35
+    /**
36
+     * @param $extraFields
37
+     * @param CachedTenantContext $cachedTenantContext
38
+     * @param PaginatorInterface $paginator
39
+     */
40
+    public function __construct($extraFields, CachedTenantContext $cachedTenantContext, PaginatorInterface $paginator) {
41 41
     $this->extraFields = $extraFields;
42 42
     $this->cachedTenantContext = $cachedTenantContext;
43 43
     $this->paginator = $paginator;
44
-  }
44
+    }
45 45
 
46
-  /**
47
-   * @Route("/api/{version}/content/articles/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_list_articles")
48
-   */
49
-  public function searchAction(Request $request, RepositoryManagerInterface $repositoryManager) {
46
+    /**
47
+     * @Route("/api/{version}/content/articles/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_list_articles")
48
+     */
49
+    public function searchAction(Request $request, RepositoryManagerInterface $repositoryManager) {
50 50
     $criteria = $this->createCriteriaFrom($request);
51 51
     $extraFields = $this->extraFields;
52 52
 
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
     $responseContext->setSerializationGroups($this->getSerializationGroups());
70 70
 
71 71
     return new ResourcesListResponse($pagination, $responseContext);
72
-  }
72
+    }
73 73
 
74
-  private function createCriteriaFrom(Request $request): Criteria {
74
+    private function createCriteriaFrom(Request $request): Criteria {
75 75
     return Criteria::fromQueryParameters(
76 76
         $request->query->get('term', ''),
77 77
         array_merge($this->createDefaultCriteria($request), $this->createAdditionalCriteria($request)
78 78
         ));
79
-  }
79
+    }
80 80
 
81
-  private function createDefaultCriteria(Request $request): array {
81
+    private function createDefaultCriteria(Request $request): array {
82 82
     $currentTenant = $this->cachedTenantContext->getTenant();
83 83
 
84 84
     return [
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
         'limit' => $request->query->get('limit', 10),
88 88
         'tenantCode' => $currentTenant->getCode(),
89 89
     ];
90
-  }
90
+    }
91 91
 
92
-  protected function getSerializationGroups(): array {
92
+    protected function getSerializationGroups(): array {
93 93
     return [
94 94
         'Default',
95 95
         'api_articles_list',
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
         'api_tenant_list',
103 103
         'api_articles_statistics_list',
104 104
     ];
105
-  }
105
+    }
106 106
 
107
-  protected function createAdditionalCriteria(Request $request): array {
107
+    protected function createAdditionalCriteria(Request $request): array {
108 108
     return [
109 109
         'routes' => array_filter((array)$request->query->get('route', [])),
110 110
         'statuses' => array_filter((array)$request->query->get('status', [])),
@@ -116,5 +116,5 @@  discard block
 block discarded – undo
116 116
         'metadata' => array_filter((array)$request->query->get('metadata', [])),
117 117
         'keywords' => array_filter((array)$request->query->get('keywords', [])),
118 118
     ];
119
-  }
119
+    }
120 120
 }
Please login to merge, or discard this patch.
SWP/Bundle/ElasticSearchBundle/Controller/Api/AuthorSearchController.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 use FOS\RestBundle\Controller\Annotations\Route;
27 27
 
28 28
 class AuthorSearchController extends AbstractController {
29
-  private RepositoryManagerInterface $repositoryManager;
30
-  private PaginatorInterface $paginator;
31
-  private string $authorClassName;
29
+    private RepositoryManagerInterface $repositoryManager;
30
+    private PaginatorInterface $paginator;
31
+    private string $authorClassName;
32 32
 
33
-  /**
34
-   * @param RepositoryManagerInterface $repositoryManager
35
-   * @param PaginatorInterface $paginator
36
-   * @param string $authorClassName
37
-   */
38
-  public function __construct(RepositoryManagerInterface $repositoryManager, PaginatorInterface $paginator,
39
-                              string                     $authorClassName) {
33
+    /**
34
+     * @param RepositoryManagerInterface $repositoryManager
35
+     * @param PaginatorInterface $paginator
36
+     * @param string $authorClassName
37
+     */
38
+    public function __construct(RepositoryManagerInterface $repositoryManager, PaginatorInterface $paginator,
39
+                                string                     $authorClassName) {
40 40
     $this->repositoryManager = $repositoryManager;
41 41
     $this->paginator = $paginator;
42 42
     $this->authorClassName = $authorClassName;
43
-  }
43
+    }
44 44
 
45 45
 
46
-  /**
47
-   * @Route("/api/{version}/authors/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_authors")
48
-   */
49
-  public function searchAction(Request $request): ResourcesListResponse {
46
+    /**
47
+     * @Route("/api/{version}/authors/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_authors")
48
+     */
49
+    public function searchAction(Request $request): ResourcesListResponse {
50 50
     $criteria = Criteria::fromQueryParameters(
51 51
         $request->query->get('term', ''),
52 52
         [
@@ -87,5 +87,5 @@  discard block
 block discarded – undo
87 87
     );
88 88
 
89 89
     return new ResourcesListResponse($pagination, $responseContext);
90
-  }
90
+    }
91 91
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/AnalyticsExportController.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -51,33 +51,33 @@  discard block
 block discarded – undo
51 51
 
52 52
 class AnalyticsExportController extends AbstractController {
53 53
 
54
-  protected CacheInterface $cacheProvider;
55
-  protected RepositoryInterface $analyticsReportRepository;
56
-  protected Filesystem $filesystem;
57
-  protected CsvReportFileLocationResolver $csvReportFileLocationResolver;
58
-  protected CachedTenantContextInterface $cachedTenantContext;
59
-  protected RouteRepositoryInterface $routeRepository;
60
-  private MessageBusInterface $messageBus;
61
-  private FormFactoryInterface $formFactory;
62
-  private EventDispatcherInterface $eventDispatcher;
63
-
64
-  /**
65
-   * @param CacheInterface $cacheProvider
66
-   * @param RepositoryInterface $analyticsReportRepository
67
-   * @param Filesystem $filesystem
68
-   * @param CsvReportFileLocationResolver $csvReportFileLocationResolver
69
-   * @param CachedTenantContextInterface $cachedTenantContext
70
-   * @param RouteRepositoryInterface $routeRepository
71
-   * @param MessageBusInterface $messageBus
72
-   * @param FormFactoryInterface $formFactory
73
-   * @param EventDispatcherInterface $eventDispatcher
74
-   */
75
-  public function __construct(CacheInterface                $cacheProvider,
76
-                              RepositoryInterface           $analyticsReportRepository, Filesystem $filesystem,
77
-                              CsvReportFileLocationResolver $csvReportFileLocationResolver,
78
-                              CachedTenantContextInterface  $cachedTenantContext,
79
-                              RouteRepositoryInterface      $routeRepository, MessageBusInterface $messageBus,
80
-                              FormFactoryInterface          $formFactory, EventDispatcherInterface $eventDispatcher) {
54
+    protected CacheInterface $cacheProvider;
55
+    protected RepositoryInterface $analyticsReportRepository;
56
+    protected Filesystem $filesystem;
57
+    protected CsvReportFileLocationResolver $csvReportFileLocationResolver;
58
+    protected CachedTenantContextInterface $cachedTenantContext;
59
+    protected RouteRepositoryInterface $routeRepository;
60
+    private MessageBusInterface $messageBus;
61
+    private FormFactoryInterface $formFactory;
62
+    private EventDispatcherInterface $eventDispatcher;
63
+
64
+    /**
65
+     * @param CacheInterface $cacheProvider
66
+     * @param RepositoryInterface $analyticsReportRepository
67
+     * @param Filesystem $filesystem
68
+     * @param CsvReportFileLocationResolver $csvReportFileLocationResolver
69
+     * @param CachedTenantContextInterface $cachedTenantContext
70
+     * @param RouteRepositoryInterface $routeRepository
71
+     * @param MessageBusInterface $messageBus
72
+     * @param FormFactoryInterface $formFactory
73
+     * @param EventDispatcherInterface $eventDispatcher
74
+     */
75
+    public function __construct(CacheInterface                $cacheProvider,
76
+                                RepositoryInterface           $analyticsReportRepository, Filesystem $filesystem,
77
+                                CsvReportFileLocationResolver $csvReportFileLocationResolver,
78
+                                CachedTenantContextInterface  $cachedTenantContext,
79
+                                RouteRepositoryInterface      $routeRepository, MessageBusInterface $messageBus,
80
+                                FormFactoryInterface          $formFactory, EventDispatcherInterface $eventDispatcher) {
81 81
     $this->cacheProvider = $cacheProvider;
82 82
     $this->analyticsReportRepository = $analyticsReportRepository;
83 83
     $this->filesystem = $filesystem;
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
     $this->messageBus = $messageBus;
88 88
     $this->formFactory = $formFactory;
89 89
     $this->eventDispatcher = $eventDispatcher;
90
-  }
90
+    }
91 91
 
92 92
 
93
-  /**
94
-   * @FosRoute("/api/{version}/export/analytics/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_analytics_export_post")
95
-   *
96
-   * @throws \Exception
97
-   */
98
-  public function post(Request $request): SingleResourceResponseInterface {
93
+    /**
94
+     * @FosRoute("/api/{version}/export/analytics/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_analytics_export_post")
95
+     *
96
+     * @throws \Exception
97
+     */
98
+    public function post(Request $request): SingleResourceResponseInterface {
99 99
     /** @var UserInterface $currentlyLoggedInUser */
100 100
     $currentlyLoggedInUser = $this->getUser();
101 101
 
@@ -106,46 +106,46 @@  discard block
 block discarded – undo
106 106
     $form->handleRequest($request);
107 107
 
108 108
     if ($form->isSubmitted() && $form->isValid()) {
109
-      $data = $form->getData();
109
+        $data = $form->getData();
110 110
 
111
-      $analyticsReport = new AnalyticsReport();
112
-      $analyticsReport->setAssetId($fileName);
113
-      $analyticsReport->setFileExtension('csv');
114
-      $analyticsReport->setUser($currentlyLoggedInUser);
111
+        $analyticsReport = new AnalyticsReport();
112
+        $analyticsReport->setAssetId($fileName);
113
+        $analyticsReport->setFileExtension('csv');
114
+        $analyticsReport->setUser($currentlyLoggedInUser);
115 115
 
116
-      $exportAnalytics = new ExportAnalytics(
117
-          $data['start'],
118
-          $data['end'],
119
-          $this->cachedTenantContext->getTenant()->getCode(),
120
-          $fileName,
121
-          $currentlyLoggedInUser->getEmail(),
122
-          !empty($data['routes']) ? $this->toIds($data['routes']) : [],
123
-          !empty($data['authors']) ? $this->toIds($data['authors']) : [],
124
-          $data['term'] ?? ''
125
-      );
116
+        $exportAnalytics = new ExportAnalytics(
117
+            $data['start'],
118
+            $data['end'],
119
+            $this->cachedTenantContext->getTenant()->getCode(),
120
+            $fileName,
121
+            $currentlyLoggedInUser->getEmail(),
122
+            !empty($data['routes']) ? $this->toIds($data['routes']) : [],
123
+            !empty($data['authors']) ? $this->toIds($data['authors']) : [],
124
+            $data['term'] ?? ''
125
+        );
126 126
 
127
-      $filters = $this->processFilters(
128
-          $exportAnalytics->getFilters(),
129
-          !empty($data['routes']) ? $data['routes'] : [],
130
-          !empty($data['authors']) ? $data['authors'] : []
131
-      );
127
+        $filters = $this->processFilters(
128
+            $exportAnalytics->getFilters(),
129
+            !empty($data['routes']) ? $data['routes'] : [],
130
+            !empty($data['authors']) ? $data['authors'] : []
131
+        );
132 132
 
133
-      $analyticsReport->setFilters($filters);
133
+        $analyticsReport->setFilters($filters);
134 134
 
135
-      $this->analyticsReportRepository->add($analyticsReport);
135
+        $this->analyticsReportRepository->add($analyticsReport);
136 136
 
137
-      $this->messageBus->dispatch($exportAnalytics);
137
+        $this->messageBus->dispatch($exportAnalytics);
138 138
 
139
-      return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201));
139
+        return new SingleResourceResponse(['status' => 'OK'], new ResponseContext(201));
140 140
     }
141 141
 
142 142
     return new SingleResourceResponse($form, new ResponseContext(400));
143
-  }
143
+    }
144 144
 
145
-  /**
146
-   * @FosRoute("/api/{version}/export/analytics/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_analytics_reports")
147
-   */
148
-  public function listAction(Request $request): ResourcesListResponseInterface {
145
+    /**
146
+     * @FosRoute("/api/{version}/export/analytics/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_analytics_reports")
147
+     */
148
+    public function listAction(Request $request): ResourcesListResponseInterface {
149 149
     $sorting = $request->query->all('sorting');
150 150
     $reports = $this->analyticsReportRepository->getPaginatedByCriteria(
151 151
         $this->eventDispatcher,
@@ -155,21 +155,21 @@  discard block
 block discarded – undo
155 155
     );
156 156
 
157 157
     return new ResourcesListResponse($reports);
158
-  }
158
+    }
159 159
 
160
-  /**
161
-   * @Route("/analytics/export/{fileName}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_export_analytics_download")
162
-   */
163
-  public function downloadFile(string $fileName): Response {
160
+    /**
161
+     * @Route("/analytics/export/{fileName}", methods={"GET"}, options={"expose"=true}, requirements={"mediaId"=".+"}, name="swp_export_analytics_download")
162
+     */
163
+    public function downloadFile(string $fileName): Response {
164 164
     $cacheKey = md5(serialize(['analytics_report', $fileName]));
165 165
 
166 166
     $analyticsReport = $this->cacheProvider->get($cacheKey, function () use ($fileName) {
167
-      /* @var AnalyticsReportInterface|null $analyticsReport */
168
-      return $this->analyticsReportRepository->findOneBy(['assetId' => $fileName]);
167
+        /* @var AnalyticsReportInterface|null $analyticsReport */
168
+        return $this->analyticsReportRepository->findOneBy(['assetId' => $fileName]);
169 169
     });
170 170
 
171 171
     if (null === $analyticsReport) {
172
-      throw new NotFoundHttpException('Report file was not found.');
172
+        throw new NotFoundHttpException('Report file was not found.');
173 173
     }
174 174
 
175 175
     $response = new Response();
@@ -188,30 +188,30 @@  discard block
 block discarded – undo
188 188
     $response->setContent($this->filesystem->read($this->csvReportFileLocationResolver->getMediaBasePath() . '/' . $analyticsReport->getAssetId()));
189 189
 
190 190
     return $response;
191
-  }
191
+    }
192 192
 
193
-  private function toIds(array $items): array {
193
+    private function toIds(array $items): array {
194 194
     $ids = [];
195 195
     foreach ($items as $item) {
196
-      foreach ($item as $entity) {
196
+        foreach ($item as $entity) {
197 197
         if (!$entity instanceof PersistableInterface) {
198
-          continue;
198
+            continue;
199 199
         }
200 200
 
201 201
         $ids[] = $entity->getId();
202
-      }
202
+        }
203 203
     }
204 204
 
205 205
     return $ids;
206
-  }
206
+    }
207 207
 
208
-  private function processFilters(array $filters, array $routes, array $authors): array {
208
+    private function processFilters(array $filters, array $routes, array $authors): array {
209 209
     $routeNames = [];
210 210
 
211 211
     foreach ($routes as $route) {
212
-      foreach ($route as $entity) {
212
+        foreach ($route as $entity) {
213 213
         $routeNames[] = $entity->getName();
214
-      }
214
+        }
215 215
     }
216 216
 
217 217
     $filters['routes'] = $routeNames;
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
     $authorNames = [];
220 220
     /** @var ArticleAuthorInterface $author */
221 221
     foreach ($authors as $author) {
222
-      foreach ($author as $entity) {
222
+        foreach ($author as $entity) {
223 223
         $authorNames[] = $entity->getName();
224
-      }
224
+        }
225 225
     }
226 226
 
227 227
     $filters['authors'] = $authorNames;
228 228
 
229 229
     return $filters;
230
-  }
230
+    }
231 231
 }
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 FOS\RestBundle\Controller\Annotations\Route;
30 30
 
31 31
 class SlideshowController extends Controller {
32
-  private ArticleRepositoryInterface $articleRepository;
33
-  private SlideshowRepositoryInterface $slideshowRepository;
34
-  private EventDispatcherInterface $eventDispatcher;
32
+    private ArticleRepositoryInterface $articleRepository;
33
+    private SlideshowRepositoryInterface $slideshowRepository;
34
+    private EventDispatcherInterface $eventDispatcher;
35 35
 
36
-  /**
37
-   * @param ArticleRepositoryInterface $articleRepository
38
-   * @param SlideshowRepositoryInterface $slideshowRepository
39
-   * @param EventDispatcherInterface $eventDispatcher
40
-   */
41
-  public function __construct(ArticleRepositoryInterface   $articleRepository,
42
-                              SlideshowRepositoryInterface $slideshowRepository,
43
-                              EventDispatcherInterface     $eventDispatcher) {
36
+    /**
37
+     * @param ArticleRepositoryInterface $articleRepository
38
+     * @param SlideshowRepositoryInterface $slideshowRepository
39
+     * @param EventDispatcherInterface $eventDispatcher
40
+     */
41
+    public function __construct(ArticleRepositoryInterface   $articleRepository,
42
+                                SlideshowRepositoryInterface $slideshowRepository,
43
+                                EventDispatcherInterface     $eventDispatcher) {
44 44
     $this->articleRepository = $articleRepository;
45 45
     $this->slideshowRepository = $slideshowRepository;
46 46
     $this->eventDispatcher = $eventDispatcher;
47
-  }
47
+    }
48 48
 
49 49
 
50
-  /**
51
-   * @Route("/api/{version}/content/slideshows/{articleId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_slideshows_list")
52
-   */
53
-  public function listAction(Request $request, string $articleId): ResourcesListResponseInterface {
50
+    /**
51
+     * @Route("/api/{version}/content/slideshows/{articleId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_slideshows_list")
52
+     */
53
+    public function listAction(Request $request, string $articleId): ResourcesListResponseInterface {
54 54
     $repository = $this->slideshowRepository;
55 55
 
56 56
     $article = $this->findArticleOr404($articleId);
@@ -60,29 +60,29 @@  discard block
 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/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 FOS\RestBundle\Controller\Annotations\Route;
29 29
 
30 30
 class PackageSeoMediaUploadController extends AbstractController {
31
-  private FactoryInterface $seoMetadataFactory;
32
-  private RepositoryInterface $seoMetadataRepository;
33
-  private FormFactoryInterface $formFactory;
31
+    private FactoryInterface $seoMetadataFactory;
32
+    private RepositoryInterface $seoMetadataRepository;
33
+    private FormFactoryInterface $formFactory;
34 34
 
35
-  /**
36
-   * @param FactoryInterface $seoMetadataFactory
37
-   * @param RepositoryInterface $seoMetadataRepository
38
-   * @param FormFactoryInterface $formFactory
39
-   */
40
-  public function __construct(FactoryInterface     $seoMetadataFactory, RepositoryInterface $seoMetadataRepository,
41
-                              FormFactoryInterface $formFactory) {
35
+    /**
36
+     * @param FactoryInterface $seoMetadataFactory
37
+     * @param RepositoryInterface $seoMetadataRepository
38
+     * @param FormFactoryInterface $formFactory
39
+     */
40
+    public function __construct(FactoryInterface     $seoMetadataFactory, RepositoryInterface $seoMetadataRepository,
41
+                                FormFactoryInterface $formFactory) {
42 42
     $this->seoMetadataFactory = $seoMetadataFactory;
43 43
     $this->seoMetadataRepository = $seoMetadataRepository;
44 44
     $this->formFactory = $formFactory;
45
-  }
45
+    }
46 46
 
47 47
 
48
-  /**
49
-   * @Route("/api/{version}/packages/seo/upload/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_package_seo_image")
50
-   */
51
-  public function uploadAction(Request                   $request, string $packageGuid,
52
-                               SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse {
48
+    /**
49
+     * @Route("/api/{version}/packages/seo/upload/{packageGuid}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_package_seo_image")
50
+     */
51
+    public function uploadAction(Request                   $request, string $packageGuid,
52
+                                SeoImageUploaderInterface $seoImageUploader): SingleResourceResponse {
53 53
     $seoMetadata = $this->seoMetadataRepository->findOneByPackageGuid($packageGuid);
54 54
 
55 55
     if (null === $seoMetadata) {
56
-      $seoMetadata = $this->seoMetadataFactory->create();
56
+        $seoMetadata = $this->seoMetadataFactory->create();
57 57
     }
58 58
 
59 59
     $form = $this->formFactory->createNamed('', SeoImageType::class, $seoMetadata);
60 60
     $form->handleRequest($request);
61 61
 
62 62
     if ($form->isSubmitted() && $form->isValid()) {
63
-      try {
63
+        try {
64 64
         $seoMetadata->setPackageGuid($packageGuid);
65 65
         $seoImageUploader->handleUpload($seoMetadata);
66 66
 
67 67
         $this->seoMetadataRepository->add($seoMetadata);
68
-      } catch (\Exception $e) {
68
+        } catch (\Exception $e) {
69 69
         return new SingleResourceResponse(['message' => 'Could not upload an image.'], new ResponseContext(400));
70
-      }
70
+        }
71 71
 
72
-      return new SingleResourceResponse($seoMetadata, new ResponseContext(201));
72
+        return new SingleResourceResponse($seoMetadata, new ResponseContext(201));
73 73
     }
74 74
 
75 75
     return new SingleResourceResponse($form, new ResponseContext(400));
76
-  }
76
+    }
77 77
 }
Please login to merge, or discard this patch.