Completed
Pull Request — master (#1218)
by
unknown
58s
created
src/SWP/Bundle/UserBundle/Controller/RegistrationController.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -41,43 +41,43 @@  discard block
 block discarded – undo
41 41
 
42 42
 class RegistrationController extends AbstractController {
43 43
 
44
-  private SettingsManagerInterface $settingsManager;
45
-  private ScopeContextInterface $scopeContext;
46
-  private EmailVerifier $emailVerifier;
47
-  private UserManagerInterface $userManager;
48
-  private EntityManagerInterface $entityManager;
49
-
50
-  /**
51
-   * @param SettingsManagerInterface $settingsManager
52
-   * @param ScopeContextInterface $scopeContext
53
-   * @param EmailVerifier $emailVerifier
54
-   * @param UserManagerInterface $userManager
55
-   * @param EntityManagerInterface $entityManager
56
-   */
57
-  public function __construct(SettingsManagerInterface $settingsManager, ScopeContextInterface $scopeContext,
58
-                              EmailVerifier            $emailVerifier, UserManagerInterface $userManager,
59
-                              EntityManagerInterface   $entityManager) {
44
+    private SettingsManagerInterface $settingsManager;
45
+    private ScopeContextInterface $scopeContext;
46
+    private EmailVerifier $emailVerifier;
47
+    private UserManagerInterface $userManager;
48
+    private EntityManagerInterface $entityManager;
49
+
50
+    /**
51
+     * @param SettingsManagerInterface $settingsManager
52
+     * @param ScopeContextInterface $scopeContext
53
+     * @param EmailVerifier $emailVerifier
54
+     * @param UserManagerInterface $userManager
55
+     * @param EntityManagerInterface $entityManager
56
+     */
57
+    public function __construct(SettingsManagerInterface $settingsManager, ScopeContextInterface $scopeContext,
58
+                                EmailVerifier            $emailVerifier, UserManagerInterface $userManager,
59
+                                EntityManagerInterface   $entityManager) {
60 60
     $this->settingsManager = $settingsManager;
61 61
     $this->scopeContext = $scopeContext;
62 62
     $this->emailVerifier = $emailVerifier;
63 63
     $this->userManager = $userManager;
64 64
     $this->entityManager = $entityManager;
65
-  }
66
-
67
-
68
-  /**
69
-   * @FOSRoute("/api/{version}/users/register/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_register_user")
70
-   */
71
-  public function registerAction(
72
-      Request                     $request,
73
-      UserPasswordHasherInterface $passwordEncoder,
74
-      UserManagerInterface        $userManager,
75
-      MailerInterface             $mailer
76
-  ) {
65
+    }
66
+
67
+
68
+    /**
69
+     * @FOSRoute("/api/{version}/users/register/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_register_user")
70
+     */
71
+    public function registerAction(
72
+        Request                     $request,
73
+        UserPasswordHasherInterface $passwordEncoder,
74
+        UserManagerInterface        $userManager,
75
+        MailerInterface             $mailer
76
+    ) {
77 77
     try {
78
-      $this->ensureThatRegistrationIsEnabled();
78
+        $this->ensureThatRegistrationIsEnabled();
79 79
     } catch (NotFoundHttpException $e) {
80
-      return new SingleResourceResponse(null, new ResponseContext(404));
80
+        return new SingleResourceResponse(null, new ResponseContext(404));
81 81
     }
82 82
 
83 83
     $user = $userManager->createUser();
@@ -86,66 +86,66 @@  discard block
 block discarded – undo
86 86
     $form->handleRequest($request);
87 87
 
88 88
     if ($form->isSubmitted() && $form->isValid()) {
89
-      $user->addRole('ROLE_USER');
90
-      // encode the plain password
91
-      $user->setPassword(
92
-          $passwordEncoder->hashPassword(
93
-              $user,
94
-              $form->get('plainPassword')->getData()
95
-          )
96
-      );
97
-
98
-      $entityManager = $this->entityManager;
99
-      $entityManager->persist($user);
100
-      $entityManager->flush();
101
-
102
-      $signatureComponents = $this->emailVerifier->getSignatureComponents('swp_user_verify_email', $user);
103
-      $url = $signatureComponents->getSignedUrl();
104
-
105
-      $mailer->sendConfirmationEmail($user, $url);
106
-
107
-      return new JsonResponse([
108
-          'message' => sprintf(
109
-              'The user has been created successfully.
89
+        $user->addRole('ROLE_USER');
90
+        // encode the plain password
91
+        $user->setPassword(
92
+            $passwordEncoder->hashPassword(
93
+                $user,
94
+                $form->get('plainPassword')->getData()
95
+            )
96
+        );
97
+
98
+        $entityManager = $this->entityManager;
99
+        $entityManager->persist($user);
100
+        $entityManager->flush();
101
+
102
+        $signatureComponents = $this->emailVerifier->getSignatureComponents('swp_user_verify_email', $user);
103
+        $url = $signatureComponents->getSignedUrl();
104
+
105
+        $mailer->sendConfirmationEmail($user, $url);
106
+
107
+        return new JsonResponse([
108
+            'message' => sprintf(
109
+                'The user has been created successfully.
110 110
                  An email has been sent to %s. It contains an activation link you must click to activate your account.',
111
-              $user->getEmail()
112
-          ),
113
-          'url' => $url,
114
-      ]);
111
+                $user->getEmail()
112
+            ),
113
+            'url' => $url,
114
+        ]);
115 115
     }
116 116
 
117 117
     return new SingleResourceResponse($form, new ResponseContext(400));
118
-  }
118
+    }
119 119
 
120
-  /**
121
-   * @Route("/verify/email", name="swp_user_verify_email")
122
-   */
123
-  public function verifyUserEmail(Request            $request, GuardAuthenticatorHandler $guardHandler,
124
-                                  LoginAuthenticator $authenticator): Response {
120
+    /**
121
+     * @Route("/verify/email", name="swp_user_verify_email")
122
+     */
123
+    public function verifyUserEmail(Request            $request, GuardAuthenticatorHandler $guardHandler,
124
+                                    LoginAuthenticator $authenticator): Response {
125 125
     $id = (int)$request->get('id'); // retrieve the user id from the url
126 126
 
127 127
     if ($request->isXmlHttpRequest()) {
128
-      return $this->verifyUserEmailFromPWA($id, $request);
128
+        return $this->verifyUserEmailFromPWA($id, $request);
129 129
     }
130 130
 
131 131
     // Verify the user id exists and is not null
132 132
     if (null === $id) {
133
-      return $this->redirectToRoute('homepage');
133
+        return $this->redirectToRoute('homepage');
134 134
     }
135 135
 
136 136
     $user = $this->userManager->find($id);
137 137
 
138 138
     // Ensure the user exists in persistence
139 139
     if (null === $user) {
140
-      return $this->redirectToRoute('homepage');
140
+        return $this->redirectToRoute('homepage');
141 141
     }
142 142
     // validate email confirmation link, sets User::isVerified=true and persists
143 143
     try {
144
-      $this->emailVerifier->handleEmailConfirmation($request, $user);
144
+        $this->emailVerifier->handleEmailConfirmation($request, $user);
145 145
     } catch (VerifyEmailExceptionInterface $exception) {
146
-      $this->addFlash('verify_email_error', $exception->getReason());
146
+        $this->addFlash('verify_email_error', $exception->getReason());
147 147
 
148
-      return $this->redirectToRoute('homepage');
148
+        return $this->redirectToRoute('homepage');
149 149
     }
150 150
 
151 151
     $guardHandler->authenticateUserAndHandleSuccess(
@@ -158,63 +158,63 @@  discard block
 block discarded – undo
158 158
     $this->addFlash('success', 'The user has been created successfully.');
159 159
 
160 160
     return $this->redirectToRoute('swp_user_registration_confirmed');
161
-  }
161
+    }
162 162
 
163
-  /**
164
-   * Tell the user his account is now confirmed.
165
-   */
166
-  public function confirmedAction(Request $request) {
163
+    /**
164
+     * Tell the user his account is now confirmed.
165
+     */
166
+    public function confirmedAction(Request $request) {
167 167
     $user = $this->getUser();
168 168
     if (!is_object($user) || !$user instanceof UserInterface) {
169
-      $this->createAccessDeniedException('This user does not have access to this section.');
169
+        $this->createAccessDeniedException('This user does not have access to this section.');
170 170
     }
171 171
 
172 172
     return $this->render('@SWPUser/Registration/confirmed.html.twig', [
173 173
         'user' => $user,
174 174
     ]);
175
-  }
175
+    }
176 176
 
177
-  /**
178
-   * @throws NotFoundHttpException
179
-   */
180
-  private function ensureThatRegistrationIsEnabled() {
177
+    /**
178
+     * @throws NotFoundHttpException
179
+     */
180
+    private function ensureThatRegistrationIsEnabled() {
181 181
     $settingName = 'registration_enabled';
182 182
     $setting = $this->settingsManager->getOneSettingByName($settingName);
183 183
     $registrationEnabled = $this->settingsManager
184 184
         ->get($settingName, $setting['scope'], $this->scopeContext->getScopeOwner($setting['scope']));
185 185
     if (!$registrationEnabled) {
186
-      throw new NotFoundHttpException('Registration is disabled.');
186
+        throw new NotFoundHttpException('Registration is disabled.');
187
+    }
187 188
     }
188
-  }
189 189
 
190
-  private function verifyUserEmailFromPWA(int $id, Request $request): JsonResponse {
190
+    private function verifyUserEmailFromPWA(int $id, Request $request): JsonResponse {
191 191
     // Verify the user id exists and is not null
192 192
     if (null === $id) {
193
-      return new JsonResponse(
194
-          ['error' => 'User does not exist']
195
-      );
193
+        return new JsonResponse(
194
+            ['error' => 'User does not exist']
195
+        );
196 196
     }
197 197
 
198 198
     $user = $this->userManager->find($id);
199 199
 
200 200
     // Ensure the user exists in persistence
201 201
     if (null === $user) {
202
-      return new JsonResponse(
203
-          ['error' => 'User does not exist']
204
-      );
202
+        return new JsonResponse(
203
+            ['error' => 'User does not exist']
204
+        );
205 205
     }
206 206
 
207 207
     // validate email confirmation link, sets User::isVerified=true and persists
208 208
     try {
209
-      $this->emailVerifier->handleEmailConfirmation($request, $user);
209
+        $this->emailVerifier->handleEmailConfirmation($request, $user);
210 210
     } catch (VerifyEmailExceptionInterface $exception) {
211
-      return new JsonResponse(
212
-          ['error' => 'Registration confirmation invalid']
213
-      );
211
+        return new JsonResponse(
212
+            ['error' => 'Registration confirmation invalid']
213
+        );
214 214
     }
215 215
 
216 216
     return new JsonResponse(
217 217
         ['message' => 'The user has been created successfully.']
218 218
     );
219
-  }
219
+    }
220 220
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/EventListener/BodyListener.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@  discard block
 block discarded – undo
28 28
 
29 29
 class BodyListener
30 30
 {
31
-  private $decoderProvider;
32
-  private $throwExceptionOnUnsupportedContentType;
33
-  private $defaultFormat;
34
-  private $arrayNormalizer;
35
-  private $normalizeForms;
36
-
37
-  public function __construct(
38
-      DecoderProviderInterface $decoderProvider,
39
-      bool $throwExceptionOnUnsupportedContentType = false,
40
-      ArrayNormalizerInterface $arrayNormalizer = null,
41
-      bool $normalizeForms = false
42
-  ) {
31
+    private $decoderProvider;
32
+    private $throwExceptionOnUnsupportedContentType;
33
+    private $defaultFormat;
34
+    private $arrayNormalizer;
35
+    private $normalizeForms;
36
+
37
+    public function __construct(
38
+        DecoderProviderInterface $decoderProvider,
39
+        bool $throwExceptionOnUnsupportedContentType = false,
40
+        ArrayNormalizerInterface $arrayNormalizer = null,
41
+        bool $normalizeForms = false
42
+    ) {
43 43
     $this->decoderProvider = $decoderProvider;
44 44
     $this->throwExceptionOnUnsupportedContentType = $throwExceptionOnUnsupportedContentType;
45 45
     $this->arrayNormalizer = $arrayNormalizer;
46 46
     $this->normalizeForms = true;
47
-  }
47
+    }
48 48
 
49
-  public function setDefaultFormat(?string $defaultFormat): void
50
-  {
49
+    public function setDefaultFormat(?string $defaultFormat): void
50
+    {
51 51
     $this->defaultFormat = $defaultFormat;
52
-  }
52
+    }
53 53
 
54
-  public function onKernelRequest(RequestEvent $event): void
55
-  {
54
+    public function onKernelRequest(RequestEvent $event): void
55
+    {
56 56
     $request = $event->getRequest();
57 57
 
58 58
     if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) {
59
-      return;
59
+        return;
60 60
     }
61 61
 
62 62
     $method = $request->getMethod();
@@ -64,83 +64,83 @@  discard block
 block discarded – undo
64 64
     $normalizeRequest = $this->normalizeForms && $this->isFormRequest($request);
65 65
 
66 66
     if ($this->isDecodeable($request)) {
67
-      $format = null === $contentType
67
+        $format = null === $contentType
68 68
           ? $request->getRequestFormat()
69 69
           : $request->getFormat($contentType);
70 70
 
71
-      $format = $format ?: $this->defaultFormat;
71
+        $format = $format ?: $this->defaultFormat;
72 72
 
73
-      $content = $request->getContent();
73
+        $content = $request->getContent();
74 74
 
75
-      if (null === $format || !$this->decoderProvider->supports($format)) {
75
+        if (null === $format || !$this->decoderProvider->supports($format)) {
76 76
         if ($this->throwExceptionOnUnsupportedContentType
77 77
             && $this->isNotAnEmptyDeleteRequestWithNoSetContentType($method, $content, $contentType)
78 78
         ) {
79
-          throw new UnsupportedMediaTypeHttpException("Request body format '$format' not supported");
79
+            throw new UnsupportedMediaTypeHttpException("Request body format '$format' not supported");
80 80
         }
81 81
 
82 82
         return;
83
-      }
83
+        }
84 84
 
85
-      if (!empty($content)) {
85
+        if (!empty($content)) {
86 86
         $decoder = $this->decoderProvider->getDecoder($format);
87 87
         $data = $decoder->decode($content);
88 88
         if (is_array($data)) {
89
-          $request->request = new ParameterBag($data);
90
-          $normalizeRequest = true;
89
+            $request->request = new ParameterBag($data);
90
+            $normalizeRequest = true;
91 91
         } else {
92
-          throw new BadRequestHttpException('Invalid '.$format.' message received');
92
+            throw new BadRequestHttpException('Invalid '.$format.' message received');
93
+        }
93 94
         }
94
-      }
95 95
     }
96 96
 
97 97
     if (null !== $this->arrayNormalizer && $normalizeRequest) {
98
-      $data = $request->request->all();
98
+        $data = $request->request->all();
99 99
 
100
-      try {
100
+        try {
101 101
         $data = $this->arrayNormalizer->normalize($data);
102
-      } catch (NormalizationException $e) {
102
+        } catch (NormalizationException $e) {
103 103
         throw new BadRequestHttpException($e->getMessage());
104
-      }
104
+        }
105 105
 
106
-      $request->request = new ParameterBag($data);
106
+        $request->request = new ParameterBag($data);
107 107
 
108
-      if(!empty($request->files->all())) {
108
+        if(!empty($request->files->all())) {
109 109
         $data = $request->files->all();
110 110
 
111 111
         try {
112
-          $data = $this->arrayNormalizer->normalize($data);
112
+            $data = $this->arrayNormalizer->normalize($data);
113 113
         } catch (NormalizationException $e) {
114
-          throw new BadRequestHttpException($e->getMessage());
114
+            throw new BadRequestHttpException($e->getMessage());
115 115
         }
116 116
 
117 117
         $request->files = new ParameterBag($data);
118
-      }
118
+        }
119
+    }
119 120
     }
120
-  }
121 121
 
122
-  private function isNotAnEmptyDeleteRequestWithNoSetContentType(string $method, $content, ?string $contentType): bool
123
-  {
122
+    private function isNotAnEmptyDeleteRequestWithNoSetContentType(string $method, $content, ?string $contentType): bool
123
+    {
124 124
     return false === ('DELETE' === $method && empty($content) && empty($contentType));
125
-  }
125
+    }
126 126
 
127
-  private function isDecodeable(Request $request): bool
128
-  {
127
+    private function isDecodeable(Request $request): bool
128
+    {
129 129
     if (!in_array($request->getMethod(), ['POST', 'PUT', 'PATCH', 'DELETE'])) {
130
-      return false;
130
+        return false;
131 131
     }
132 132
 
133 133
     return !$this->isFormRequest($request);
134
-  }
134
+    }
135 135
 
136
-  private function isFormRequest(Request $request): bool
137
-  {
136
+    private function isFormRequest(Request $request): bool
137
+    {
138 138
     $contentTypeParts = explode(';', $request->headers->get('Content-Type', ''));
139 139
 
140 140
     if (isset($contentTypeParts[0])) {
141
-      return in_array($contentTypeParts[0], ['multipart/form-data', 'application/x-www-form-urlencoded']);
141
+        return in_array($contentTypeParts[0], ['multipart/form-data', 'application/x-www-form-urlencoded']);
142 142
     }
143 143
 
144 144
     return false;
145
-  }
145
+    }
146 146
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/AmpController.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -26,46 +26,46 @@
 block discarded – undo
26 26
 
27 27
 final class AmpController extends AbstractController {
28 28
 
29
-  private Environment $twig;
30
-  private AmpConverterInterface $converter;
31
-  private ThemeLoaderInterface $themeLoader;
32
-  private CacheInterface $cacheService;
29
+    private Environment $twig;
30
+    private AmpConverterInterface $converter;
31
+    private ThemeLoaderInterface $themeLoader;
32
+    private CacheInterface $cacheService;
33 33
 
34
-  public function __construct(
35
-      Environment           $twig,
36
-      AmpConverterInterface $ampConverter,
37
-      ThemeLoaderInterface  $ampThemeLoader,
38
-      CacheInterface        $cacheService
39
-  ) {
34
+    public function __construct(
35
+        Environment           $twig,
36
+        AmpConverterInterface $ampConverter,
37
+        ThemeLoaderInterface  $ampThemeLoader,
38
+        CacheInterface        $cacheService
39
+    ) {
40 40
     $this->twig = $twig;
41 41
     $this->converter = $ampConverter;
42 42
     $this->themeLoader = $ampThemeLoader;
43 43
     $this->cacheService = $cacheService;
44
-  }
44
+    }
45 45
 
46
-  public function viewAction(AmpInterface $object): Response {
46
+    public function viewAction(AmpInterface $object): Response {
47 47
     return $this->cacheService->get($this->getCacheKey($object), function () use ($object) {
48
-      $this->themeLoader->load();
49
-      $content = $this->twig->render(sprintf('@%s/index.html.twig', ThemeLoaderInterface::THEME_NAMESPACE), [
50
-          'object' => $object,
51
-      ]);
48
+        $this->themeLoader->load();
49
+        $content = $this->twig->render(sprintf('@%s/index.html.twig', ThemeLoaderInterface::THEME_NAMESPACE), [
50
+            'object' => $object,
51
+        ]);
52 52
 
53
-      $response = new Response();
54
-      $response->setContent($this->converter->convertToAmp($content));
55
-      return $response;
53
+        $response = new Response();
54
+        $response->setContent($this->converter->convertToAmp($content));
55
+        return $response;
56 56
     });
57
-  }
57
+    }
58 58
 
59
-  private function getCacheKey(AmpInterface $object): string {
59
+    private function getCacheKey(AmpInterface $object): string {
60 60
     $elements = ['amp_article'];
61 61
     if ($object instanceof PersistableInterface) {
62
-      $elements[] = $object->getId();
62
+        $elements[] = $object->getId();
63 63
     }
64 64
 
65 65
     if ($object instanceof TimestampableInterface && null !== $object->getUpdatedAt()) {
66
-      $elements[] = $object->getUpdatedAt()->getTimestamp();
66
+        $elements[] = $object->getUpdatedAt()->getTimestamp();
67 67
     }
68 68
 
69 69
     return md5(implode('__', $elements));
70
-  }
70
+    }
71 71
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/MultiTenancyBundle/Routing/TenantAwareRouter.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@
 block discarded – undo
31 31
      */
32 32
     public function generate($name, $parameters = [], $referenceType = false)
33 33
     {
34
-      if (RouteObjectInterface::OBJECT_BASED_ROUTE_NAME === $name
34
+        if (RouteObjectInterface::OBJECT_BASED_ROUTE_NAME === $name
35 35
           && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)
36
-      ) {
36
+        ) {
37 37
         $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
38 38
         unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
39
-      }
39
+        }
40 40
 
41 41
         if (null === $name && isset($parameters['content_id'])) {
42 42
             $contentId = $this->checkAndRemoveFirstSlash($parameters['content_id']);
Please login to merge, or discard this patch.
src/SWP/Component/MultiTenancy/Exception/TenantNotFoundException.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
18 18
 
19 19
 class TenantNotFoundException extends NotFoundHttpException {
20
-  public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) {
20
+    public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) {
21 21
     parent::__construct(sprintf('Tenant for host "%s" could not be found! Please check tenants configuration.', $message), $previous, $code, $headers);
22
-  }
22
+    }
23 23
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Routing/MetaRouter.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,43 +24,43 @@  discard block
 block discarded – undo
24 24
 use Symfony\Component\Routing\Route as SymfonyRoute;
25 25
 
26 26
 class MetaRouter extends DynamicRouter {
27
-  const OBJECT_BASED_ROUTE_NAME = "__meta_router_route_name__";
27
+    const OBJECT_BASED_ROUTE_NAME = "__meta_router_route_name__";
28 28
 
29
-  protected $internalRoutesCache = [];
29
+    protected $internalRoutesCache = [];
30 30
 
31
-  public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) {
31
+    public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) {
32 32
     if (self::OBJECT_BASED_ROUTE_NAME === $name
33 33
         && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)
34 34
     ) {
35
-      $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
36
-      unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
35
+        $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
36
+        unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
37 37
     }
38 38
 
39 39
     $cacheKey = $this->getCacheKey($name, $parameters, $referenceType);
40 40
     if (array_key_exists($cacheKey, $this->internalRoutesCache)) {
41
-      return $this->internalRoutesCache[$cacheKey];
41
+        return $this->internalRoutesCache[$cacheKey];
42 42
     }
43 43
 
44 44
     $route = $name;
45 45
     if ($name instanceof Meta) {
46
-      $object = $name->getValues();
47
-      if ($object instanceof ArticleInterface) {
46
+        $object = $name->getValues();
47
+        if ($object instanceof ArticleInterface) {
48 48
         $parameters['slug'] = $object->getSlug();
49 49
         $route = $object->getRoute();
50 50
         if (null === $route && $name->getContext()->getCurrentPage()) {
51
-          $parameters['slug'] = null;
52
-          $route = $name->getContext()->getCurrentPage()->getValues();
51
+            $parameters['slug'] = null;
52
+            $route = $name->getContext()->getCurrentPage()->getValues();
53 53
         }
54
-      } elseif ($name->getValues() instanceof RouteInterface) {
54
+        } elseif ($name->getValues() instanceof RouteInterface) {
55 55
         $route = $name->getValues();
56
-      }
56
+        }
57 57
     } elseif ($name instanceof ArticleInterface) {
58
-      $route = $name->getRoute();
59
-      $parameters['slug'] = $name->getSlug();
58
+        $route = $name->getRoute();
59
+        $parameters['slug'] = $name->getSlug();
60 60
     }
61 61
 
62 62
     if (null === $route || is_array($route)) {
63
-      throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
63
+        throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
64 64
     }
65 65
 
66 66
     $result = parent::generate($route, $parameters, $referenceType);
@@ -68,29 +68,29 @@  discard block
 block discarded – undo
68 68
     unset($route);
69 69
 
70 70
     return $result;
71
-  }
71
+    }
72 72
 
73
-  private function getCacheKey($route, $parameters, $type) {
73
+    private function getCacheKey($route, $parameters, $type) {
74 74
     $name = $route;
75 75
     if ($route instanceof Meta) {
76
-      if ($route->getValues() instanceof ArticleInterface) {
76
+        if ($route->getValues() instanceof ArticleInterface) {
77 77
         $name = $route->getValues()->getId();
78
-      } elseif ($route->getValues() instanceof RouteInterface) {
78
+        } elseif ($route->getValues() instanceof RouteInterface) {
79 79
         $name = $route->getValues()->getName();
80
-      }
80
+        }
81 81
     } elseif ($route instanceof RouteInterface) {
82
-      $name = $route->getName();
82
+        $name = $route->getName();
83 83
     } elseif ($route instanceof ArticleInterface) {
84
-      $name = $route->getId();
84
+        $name = $route->getId();
85 85
     }
86 86
 
87 87
     return md5($name . serialize($parameters) . $type);
88
-  }
88
+    }
89 89
 
90
-  /**
91
-   * {@inheritdoc}
92
-   */
93
-  public function supports($name) {
90
+    /**
91
+     * {@inheritdoc}
92
+     */
93
+    public function supports($name) {
94 94
     return
95 95
         ($name instanceof Meta && (
96 96
                 $name->getValues() instanceof ArticleInterface ||
@@ -106,5 +106,5 @@  discard block
 block discarded – undo
106 106
             'swp_media_get' !== $name &&
107 107
             false === strpos($name, 'swp_api_')
108 108
         );
109
-  }
109
+    }
110 110
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Routing/ArticleAuthorMediaRouter.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,53 +27,53 @@
 block discarded – undo
27 27
 
28 28
 class ArticleAuthorMediaRouter extends Router implements VersatileGeneratorInterface {
29 29
 
30
-  const OBJECT_BASED_ROUTE_NAME = "__article_author_media_router_route_name__";
30
+    const OBJECT_BASED_ROUTE_NAME = "__article_author_media_router_route_name__";
31 31
 
32
-  protected $authorMediaManager;
32
+    protected $authorMediaManager;
33 33
 
34
-  public function __construct(
35
-      ContainerInterface $container,
36
-                         $resource,
37
-      array              $options = [],
38
-      RequestContext     $context = null,
39
-      ContainerInterface $parameters = null,
40
-      LoggerInterface    $logger = null,
41
-      string             $defaultLocale = null
42
-  ) {
34
+    public function __construct(
35
+        ContainerInterface $container,
36
+                            $resource,
37
+        array              $options = [],
38
+        RequestContext     $context = null,
39
+        ContainerInterface $parameters = null,
40
+        LoggerInterface    $logger = null,
41
+        string             $defaultLocale = null
42
+    ) {
43 43
     $this->authorMediaManager = $container->get('swp_core_bundle.manager.author_media');
44 44
 
45 45
     parent::__construct($container, $resource, $options, $context, $parameters, $logger, $defaultLocale);
46
-  }
46
+    }
47 47
 
48
-  public function generate($meta, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) {
48
+    public function generate($meta, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) {
49 49
     if (self::OBJECT_BASED_ROUTE_NAME === $meta
50 50
         && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)
51 51
     ) {
52
-      $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT];
53
-      unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
52
+        $meta = $parameters[RouteObjectInterface::ROUTE_OBJECT];
53
+        unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
54 54
     }
55 55
 
56 56
     if ($meta instanceof Meta && ($meta->getValues() instanceof AuthorMediaInterface)) {
57
-      return $this->authorMediaManager->getMediaPublicUrl($meta->getValues()->getImage());
57
+        return $this->authorMediaManager->getMediaPublicUrl($meta->getValues()->getImage());
58 58
     }
59 59
 
60 60
     return '';
61
-  }
61
+    }
62 62
 
63
-  /**
64
-   * {@inheritdoc}
65
-   */
66
-  public function supports($name) {
63
+    /**
64
+     * {@inheritdoc}
65
+     */
66
+    public function supports($name) {
67 67
     return (is_string($name) && $name == self::OBJECT_BASED_ROUTE_NAME) || ($name instanceof Meta && ($name->getValues() instanceof AuthorMediaInterface));
68
-  }
68
+    }
69 69
 
70
-  public function getRouteDebugMessage($name, array $parameters = []) {
70
+    public function getRouteDebugMessage($name, array $parameters = []) {
71 71
     if (self::OBJECT_BASED_ROUTE_NAME === $name
72 72
         && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)
73 73
     ) {
74
-      $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
75
-      unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
74
+        $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
75
+        unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
76 76
     }
77 77
     return 'Route for article author media ' . $name->getValues()->getId() . ' not found';
78
-  }
78
+    }
79 79
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Twig/DecoratingRoutingExtension.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -36,88 +36,88 @@
 block discarded – undo
36 36
 use Twig\TwigFunction;
37 37
 
38 38
 final class DecoratingRoutingExtension extends AbstractExtension {
39
-  private RoutingExtension $routingExtension;
39
+    private RoutingExtension $routingExtension;
40 40
 
41
-  public function __construct(RoutingExtension $routingExtension) {
41
+    public function __construct(RoutingExtension $routingExtension) {
42 42
     $this->routingExtension = $routingExtension;
43
-  }
43
+    }
44 44
 
45
-  public function getPath($name, $parameters = [], $relative = false): ?string {
45
+    public function getPath($name, $parameters = [], $relative = false): ?string {
46 46
     if ($name == null) {
47
-      return null;
47
+        return null;
48 48
     }
49 49
 
50 50
     if (is_object($name)) {
51
-      $object = $name;
52
-      $name = null;
53
-      self::setupParams($object, $name, $parameters);
51
+        $object = $name;
52
+        $name = null;
53
+        self::setupParams($object, $name, $parameters);
54 54
     }
55 55
 
56 56
     try {
57
-      return $this->routingExtension->getPath($name, $parameters, $relative);
57
+        return $this->routingExtension->getPath($name, $parameters, $relative);
58 58
     } catch (RouteNotFoundException|MissingMandatoryParametersException|InvalidParameterException $e) {
59
-      // allow empty path
59
+        // allow empty path
60 60
     }
61 61
 
62 62
     return null;
63
-  }
63
+    }
64 64
 
65
-  public function getUrl($name, $parameters = [], $schemeRelative = false): ?string {
65
+    public function getUrl($name, $parameters = [], $schemeRelative = false): ?string {
66 66
     if ($name == null) {
67
-      return null;
67
+        return null;
68 68
     }
69 69
 
70 70
     if (is_object($name)) {
71
-      $object = $name;
72
-      $name = null;
73
-      self::setupParams($object, $name, $parameters);
71
+        $object = $name;
72
+        $name = null;
73
+        self::setupParams($object, $name, $parameters);
74 74
     }
75 75
 
76 76
     try {
77
-      return $this->routingExtension->getUrl($name, $parameters, $schemeRelative);
77
+        return $this->routingExtension->getUrl($name, $parameters, $schemeRelative);
78 78
     } catch (RouteNotFoundException|MissingMandatoryParametersException|InvalidParameterException $e) {
79
-      // allow empty url
79
+        // allow empty url
80 80
     }
81 81
 
82 82
     return null;
83
-  }
83
+    }
84 84
 
85
-  private static function setupParams(object $object, &$name, &$parameters) {
85
+    private static function setupParams(object $object, &$name, &$parameters) {
86 86
     $name = RouteObjectInterface::OBJECT_BASED_ROUTE_NAME;
87 87
     $parameters[RouteObjectInterface::ROUTE_OBJECT] = $object;
88 88
 
89 89
     if ($object instanceof Meta) {
90
-      $values = $object->getValues();
91
-      if (($values instanceof ArticleMediaInterface || $values instanceof ImageRenditionInterface)) {
90
+        $values = $object->getValues();
91
+        if (($values instanceof ArticleMediaInterface || $values instanceof ImageRenditionInterface)) {
92 92
         $name = MediaRouter::OBJECT_BASED_ROUTE_NAME;
93 93
         return;
94
-      }
94
+        }
95 95
 
96
-      if ($values instanceof ArticleSeoMediaInterface) {
96
+        if ($values instanceof ArticleSeoMediaInterface) {
97 97
         $name = SeoMediaRouter::OBJECT_BASED_ROUTE_NAME;
98 98
         return;
99
-      }
99
+        }
100 100
 
101
-      if ($values instanceof AuthorMediaInterface) {
101
+        if ($values instanceof AuthorMediaInterface) {
102 102
         $name = ArticleAuthorMediaRouter::OBJECT_BASED_ROUTE_NAME;
103 103
         return;
104
-      }
104
+        }
105 105
 
106
-      if ($values instanceof ArticleInterface || $values instanceof RouteInterface) {
106
+        if ($values instanceof ArticleInterface || $values instanceof RouteInterface) {
107 107
         $name = MetaRouter::OBJECT_BASED_ROUTE_NAME;
108 108
         return;
109
-      }
109
+        }
110 110
     }
111 111
 
112 112
     if ($object instanceof RouteInterface || $object instanceof ArticleInterface) {
113
-      $name = MetaRouter::OBJECT_BASED_ROUTE_NAME;
113
+        $name = MetaRouter::OBJECT_BASED_ROUTE_NAME;
114
+    }
114 115
     }
115
-  }
116 116
 
117
-  public function getFunctions(): array {
117
+    public function getFunctions(): array {
118 118
     return [
119 119
         new TwigFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this->routingExtension, 'isUrlGenerationSafe']]),
120 120
         new TwigFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this->routingExtension, 'isUrlGenerationSafe']]),
121 121
     ];
122
-  }
122
+    }
123 123
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/ContentBundle/Routing/SeoMediaRouter.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 
27 27
 class SeoMediaRouter extends Router implements VersatileGeneratorInterface {
28 28
 
29
-  const OBJECT_BASED_ROUTE_NAME = "__seo_media_router_route_name__";
29
+    const OBJECT_BASED_ROUTE_NAME = "__seo_media_router_route_name__";
30 30
 
31
-  /**
32
-   * {@inheritdoc}
33
-   */
34
-  public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) {
31
+    /**
32
+     * {@inheritdoc}
33
+     */
34
+    public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) {
35 35
     if (self::OBJECT_BASED_ROUTE_NAME === $name && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)) {
36
-      $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
37
-      unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
36
+        $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
37
+        unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
38 38
     }
39 39
 
40 40
     $item = $name->getValues()->getImage();
@@ -43,18 +43,18 @@  discard block
 block discarded – undo
43 43
     $parameters['extension'] = $item->getFileExtension();
44 44
 
45 45
     return parent::generate('swp_seo_media_get', $parameters, $referenceType);
46
-  }
46
+    }
47 47
 
48
-  public function supports($name): bool {
48
+    public function supports($name): bool {
49 49
     return (is_string($name) && $name == self::OBJECT_BASED_ROUTE_NAME) || ($name instanceof Meta && $name->getValues() instanceof ArticleSeoMediaInterface);
50
-  }
50
+    }
51 51
 
52
-  public function getRouteDebugMessage($name, array $parameters = array()): string {
52
+    public function getRouteDebugMessage($name, array $parameters = array()): string {
53 53
     if (self::OBJECT_BASED_ROUTE_NAME === $name && array_key_exists(RouteObjectInterface::ROUTE_OBJECT, $parameters)) {
54
-      $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
55
-      unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
54
+        $name = $parameters[RouteObjectInterface::ROUTE_OBJECT];
55
+        unset($parameters[RouteObjectInterface::ROUTE_OBJECT]);
56 56
     }
57 57
 
58 58
     return 'Route for media ' . $name->getValues()->getId() . ' not found';
59
-  }
59
+    }
60 60
 }
Please login to merge, or discard this patch.