Completed
Push — revert-1243-SWP-2230 ( 4e935b )
by
unknown
50s
created
src/SWP/Bundle/CoreBundle/Controller/StaticThemeAssetsController.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -27,138 +27,138 @@
 block discarded – undo
27 27
 use Symfony\Component\Routing\Annotation\Route;
28 28
 
29 29
 class StaticThemeAssetsController extends Controller {
30
-  /**
31
-   * Directory with assets inside theme.
32
-   */
33
-  const ASSETS_DIRECTORY = 'public';
34
-
35
-  private TenantAwareThemeContextInterface $tenantAwareThemeContext;
36
-  private ThemeLoaderInterface $themeLoader;
37
-  private ThemeRepositoryInterface $themeRepository;
38
-
39
-  /**
40
-   * @param TenantAwareThemeContextInterface $tenantAwareThemeContext
41
-   * @param ThemeLoaderInterface $themeLoader
42
-   * @param ThemeRepositoryInterface $themeRepository
43
-   */
44
-  public function __construct(TenantAwareThemeContextInterface $tenantAwareThemeContext,
45
-                              ThemeLoaderInterface             $themeLoader,
46
-                              ThemeRepositoryInterface         $themeRepository) {
30
+    /**
31
+     * Directory with assets inside theme.
32
+     */
33
+    const ASSETS_DIRECTORY = 'public';
34
+
35
+    private TenantAwareThemeContextInterface $tenantAwareThemeContext;
36
+    private ThemeLoaderInterface $themeLoader;
37
+    private ThemeRepositoryInterface $themeRepository;
38
+
39
+    /**
40
+     * @param TenantAwareThemeContextInterface $tenantAwareThemeContext
41
+     * @param ThemeLoaderInterface $themeLoader
42
+     * @param ThemeRepositoryInterface $themeRepository
43
+     */
44
+    public function __construct(TenantAwareThemeContextInterface $tenantAwareThemeContext,
45
+                                ThemeLoaderInterface             $themeLoader,
46
+                                ThemeRepositoryInterface         $themeRepository) {
47 47
     $this->tenantAwareThemeContext = $tenantAwareThemeContext;
48 48
     $this->themeLoader = $themeLoader;
49 49
     $this->themeRepository = $themeRepository;
50
-  }
50
+    }
51 51
 
52 52
 
53
-  /**
54
-   * @Route("/{fileName}.{fileExtension}", methods={"GET"}, name="static_theme_assets_root", requirements={"fileName": "sw|manifest|favicon|ads|OneSignalSDKWorker|OneSignalSDKUpdaterWorker|amp-web-push-helper-frame|amp-web-push-permission-dialog"})
55
-   * @Route("/public-{fileName}.{fileExtension}", methods={"GET"}, name="static_theme_assets_root_public", requirements={"fileName"=".+"})
56
-   * @Route("/public/{fileName}.{fileExtension}", methods={"GET"}, name="static_theme_assets_public", requirements={"fileName"=".+"})
57
-   */
58
-  public function rootAction($fileName, $fileExtension, ThemeHierarchyProviderInterface $themeHierarchyProvider) {
53
+    /**
54
+     * @Route("/{fileName}.{fileExtension}", methods={"GET"}, name="static_theme_assets_root", requirements={"fileName": "sw|manifest|favicon|ads|OneSignalSDKWorker|OneSignalSDKUpdaterWorker|amp-web-push-helper-frame|amp-web-push-permission-dialog"})
55
+     * @Route("/public-{fileName}.{fileExtension}", methods={"GET"}, name="static_theme_assets_root_public", requirements={"fileName"=".+"})
56
+     * @Route("/public/{fileName}.{fileExtension}", methods={"GET"}, name="static_theme_assets_public", requirements={"fileName"=".+"})
57
+     */
58
+    public function rootAction($fileName, $fileExtension, ThemeHierarchyProviderInterface $themeHierarchyProvider) {
59 59
     $themes = $themeHierarchyProvider->getThemeHierarchy(
60 60
         $this->tenantAwareThemeContext->getTheme()
61 61
     );
62 62
 
63 63
     $fileName = (null === $fileExtension) ? basename($fileName) : $fileName . '.' . $fileExtension;
64 64
     foreach ($themes as $theme) {
65
-      $filePath = $theme->getPath() . '/' . self::ASSETS_DIRECTORY . '/' . $fileName;
66
-      if (null !== $response = $this->handleFileLoading($filePath)) {
65
+        $filePath = $theme->getPath() . '/' . self::ASSETS_DIRECTORY . '/' . $fileName;
66
+        if (null !== $response = $this->handleFileLoading($filePath)) {
67 67
         return $response;
68
-      }
68
+        }
69 69
     }
70 70
 
71 71
     throw new NotFoundHttpException('File was not found.');
72
-  }
73
-
74
-  /**
75
-   * @Route("/themes/{type}/{themeName}/screenshots/{fileName}", methods={"GET"}, name="static_theme_screenshots", requirements={
76
-   *     "type": "organization|tenant"
77
-   * })
78
-   */
79
-  public function screenshotsAction(string $type, string $themeName, $fileName) {
72
+    }
73
+
74
+    /**
75
+     * @Route("/themes/{type}/{themeName}/screenshots/{fileName}", methods={"GET"}, name="static_theme_screenshots", requirements={
76
+     *     "type": "organization|tenant"
77
+     * })
78
+     */
79
+    public function screenshotsAction(string $type, string $themeName, $fileName) {
80 80
     if ('organization' === $type) {
81
-      $theme = $this->loadOrganizationTheme(str_replace('__', '/', $themeName));
81
+        $theme = $this->loadOrganizationTheme(str_replace('__', '/', $themeName));
82 82
     } elseif ('tenant' === $type) {
83
-      $theme = $this->loadTenantTheme(str_replace('__', '/', $themeName));
83
+        $theme = $this->loadTenantTheme(str_replace('__', '/', $themeName));
84 84
     } else {
85
-      throw new NotFoundHttpException('File was not found.');
85
+        throw new NotFoundHttpException('File was not found.');
86 86
     }
87 87
 
88 88
     $filePath = $theme->getPath() . '/screenshots/' . $fileName;
89 89
     if (null !== $response = $this->handleFileLoading($filePath)) {
90
-      return $response;
90
+        return $response;
91 91
     }
92 92
 
93 93
     throw new NotFoundHttpException('File was not found.');
94
-  }
95
-
96
-  /**
97
-   * @param $filePath
98
-   *
99
-   * @return Response
100
-   */
101
-  private function handleFileLoading($filePath) {
94
+    }
95
+
96
+    /**
97
+     * @param $filePath
98
+     *
99
+     * @return Response
100
+     */
101
+    private function handleFileLoading($filePath) {
102 102
     if (file_exists($filePath)) {
103
-      $response = new Response(file_get_contents($filePath));
104
-      $disposition = $response->headers->makeDisposition(
105
-          ResponseHeaderBag::DISPOSITION_INLINE,
106
-          basename($filePath)
107
-      );
108
-      $response->headers->set('Content-Disposition', $disposition);
109
-
110
-      try {
103
+        $response = new Response(file_get_contents($filePath));
104
+        $disposition = $response->headers->makeDisposition(
105
+            ResponseHeaderBag::DISPOSITION_INLINE,
106
+            basename($filePath)
107
+        );
108
+        $response->headers->set('Content-Disposition', $disposition);
109
+
110
+        try {
111 111
         $type = new Mime(new Read($filePath));
112 112
         $mime = str_replace('/x-', '/', Mime::getMimeFromExtension($type->getExtension()));
113
-      } catch (\Exception $e) {
113
+        } catch (\Exception $e) {
114 114
         $mime = 'text/plain';
115
-      }
115
+        }
116 116
 
117
-      $response->headers->set('Content-Type', $mime);
118
-      $response->setStatusCode(Response::HTTP_OK);
119
-      $response->setPublic();
120
-      $response->setMaxAge(3600);
121
-      $response->setSharedMaxAge(7200);
117
+        $response->headers->set('Content-Type', $mime);
118
+        $response->setStatusCode(Response::HTTP_OK);
119
+        $response->setPublic();
120
+        $response->setMaxAge(3600);
121
+        $response->setSharedMaxAge(7200);
122 122
 
123
-      return $response;
123
+        return $response;
124
+    }
124 125
     }
125
-  }
126 126
 
127
-  /**
128
-   * @return mixed
129
-   */
130
-  private function loadOrganizationTheme(string $themeName) {
127
+    /**
128
+     * @return mixed
129
+     */
130
+    private function loadOrganizationTheme(string $themeName) {
131 131
     $loadedThemes = $this->themeLoader->load();
132 132
 
133 133
     return $this->filterThemes($loadedThemes, $themeName);
134
-  }
134
+    }
135 135
 
136
-  /**
137
-   * @return mixed
138
-   */
139
-  private function loadTenantTheme(string $themeName) {
136
+    /**
137
+     * @return mixed
138
+     */
139
+    private function loadTenantTheme(string $themeName) {
140 140
     $loadedThemes = $this->themeRepository->findAll();
141 141
 
142 142
     return $this->filterThemes($loadedThemes, $themeName);
143
-  }
144
-
145
-  /**
146
-   * @param array $loadedThemes
147
-   *
148
-   * @return mixed
149
-   */
150
-  private function filterThemes($loadedThemes, string $themeName) {
143
+    }
144
+
145
+    /**
146
+     * @param array $loadedThemes
147
+     *
148
+     * @return mixed
149
+     */
150
+    private function filterThemes($loadedThemes, string $themeName) {
151 151
     $themes = array_filter(
152 152
         $loadedThemes,
153 153
         function ($element) use (&$themeName) {
154
-          return $element->getName() === $themeName;
154
+            return $element->getName() === $themeName;
155 155
         }
156 156
     );
157 157
 
158 158
     if (0 === count($themes)) {
159
-      throw new NotFoundHttpException(sprintf('Theme with name "%s" was not found in organization themes.', $themeName));
159
+        throw new NotFoundHttpException(sprintf('Theme with name "%s" was not found in organization themes.', $themeName));
160 160
     }
161 161
 
162 162
     return reset($themes);
163
-  }
163
+    }
164 164
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/PublishDestinationController.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
 
36 36
 class PublishDestinationController extends Controller {
37 37
 
38
-  private FormFactoryInterface $formFactory;
39
-  private EventDispatcherInterface $eventDispatcher;
40
-  private CachedTenantContextInterface $cachedTenantContext;
41
-  private RepositoryInterface $publishDestinationRepository;
42
-  private EntityManagerInterface $entityManager;
43
-  private FactoryInterface $publishDestinationFactory;
44
-
45
-  /**
46
-   * @param FormFactoryInterface $formFactory
47
-   * @param EventDispatcherInterface $eventDispatcher
48
-   * @param CachedTenantContextInterface $cachedTenantContext
49
-   * @param RepositoryInterface $publishDestinationRepository
50
-   * @param EntityManagerInterface $entityManager
51
-   * @param FactoryInterface $publishDestinationFactory
52
-   */
53
-  public function __construct(FormFactoryInterface         $formFactory,
54
-                              EventDispatcherInterface     $eventDispatcher,
55
-                              CachedTenantContextInterface $cachedTenantContext,
56
-                              RepositoryInterface          $publishDestinationRepository,
57
-                              EntityManagerInterface       $entityManager,
58
-                              FactoryInterface             $publishDestinationFactory) {
38
+    private FormFactoryInterface $formFactory;
39
+    private EventDispatcherInterface $eventDispatcher;
40
+    private CachedTenantContextInterface $cachedTenantContext;
41
+    private RepositoryInterface $publishDestinationRepository;
42
+    private EntityManagerInterface $entityManager;
43
+    private FactoryInterface $publishDestinationFactory;
44
+
45
+    /**
46
+     * @param FormFactoryInterface $formFactory
47
+     * @param EventDispatcherInterface $eventDispatcher
48
+     * @param CachedTenantContextInterface $cachedTenantContext
49
+     * @param RepositoryInterface $publishDestinationRepository
50
+     * @param EntityManagerInterface $entityManager
51
+     * @param FactoryInterface $publishDestinationFactory
52
+     */
53
+    public function __construct(FormFactoryInterface         $formFactory,
54
+                                EventDispatcherInterface     $eventDispatcher,
55
+                                CachedTenantContextInterface $cachedTenantContext,
56
+                                RepositoryInterface          $publishDestinationRepository,
57
+                                EntityManagerInterface       $entityManager,
58
+                                FactoryInterface             $publishDestinationFactory) {
59 59
     $this->formFactory = $formFactory;
60 60
     $this->eventDispatcher = $eventDispatcher;
61 61
     $this->cachedTenantContext = $cachedTenantContext;
62 62
     $this->publishDestinationRepository = $publishDestinationRepository;
63 63
     $this->entityManager = $entityManager;
64 64
     $this->publishDestinationFactory = $publishDestinationFactory;
65
-  }
65
+    }
66 66
 
67
-  /**
68
-   * @Route("/api/{version}/organization/destinations/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_publishing_destination_create")
69
-   */
70
-  public function createAction(Request $request): SingleResourceResponse {
67
+    /**
68
+     * @Route("/api/{version}/organization/destinations/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_publishing_destination_create")
69
+     */
70
+    public function createAction(Request $request): SingleResourceResponse {
71 71
     $tenantContext = $this->cachedTenantContext;
72 72
 
73 73
     $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
@@ -78,28 +78,28 @@  discard block
 block discarded – undo
78 78
     $form->handleRequest($request);
79 79
 
80 80
     if ($form->isSubmitted() && $form->isValid()) {
81
-      $repository = $this->publishDestinationRepository;
82
-      /** @var PublishDestinationInterface $publishDestination */
83
-      $publishDestination = $repository->findOneByTenant($destination->getTenant());
84
-      if (null !== $publishDestination) {
81
+        $repository = $this->publishDestinationRepository;
82
+        /** @var PublishDestinationInterface $publishDestination */
83
+        $publishDestination = $repository->findOneByTenant($destination->getTenant());
84
+        if (null !== $publishDestination) {
85 85
         $repository->remove($publishDestination);
86
-      }
86
+        }
87 87
 
88
-      $currentOrganization->addPublishDestination($destination);
89
-      $this->entityManager->flush();
88
+        $currentOrganization->addPublishDestination($destination);
89
+        $this->entityManager->flush();
90 90
 
91
-      return new SingleResourceResponse($destination, new ResponseContext(200));
91
+        return new SingleResourceResponse($destination, new ResponseContext(200));
92 92
     }
93 93
 
94 94
     return new SingleResourceResponse($form, new ResponseContext(400));
95
-  }
96
-
97
-  /**
98
-   * @Route("/api/{version}/organization/destinations/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_publishing_destination_update", requirements={"id"="\d+"})
99
-   * @ParamConverter("publishDestination", class="SWP\Bundle\CoreBundle\Model\PublishDestination")
100
-   */
101
-  public function updateAction(Request                     $request,
102
-                               PublishDestinationInterface $publishDestination): SingleResourceResponse {
95
+    }
96
+
97
+    /**
98
+     * @Route("/api/{version}/organization/destinations/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_publishing_destination_update", requirements={"id"="\d+"})
99
+     * @ParamConverter("publishDestination", class="SWP\Bundle\CoreBundle\Model\PublishDestination")
100
+     */
101
+    public function updateAction(Request                     $request,
102
+                                PublishDestinationInterface $publishDestination): SingleResourceResponse {
103 103
     $objectManager = $this->entityManager;
104 104
 
105 105
     $form = $this->formFactory->createNamed('', PublishDestinationType::class, $publishDestination, [
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
     $form->handleRequest($request);
110 110
     if ($form->isSubmitted() && $form->isValid()) {
111
-      $objectManager->flush();
112
-      $objectManager->refresh($publishDestination);
111
+        $objectManager->flush();
112
+        $objectManager->refresh($publishDestination);
113 113
 
114
-      return new SingleResourceResponse($publishDestination);
114
+        return new SingleResourceResponse($publishDestination);
115 115
     }
116 116
 
117 117
     return new SingleResourceResponse($form, new ResponseContext(400));
118
-  }
118
+    }
119 119
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/RuleController.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -34,86 +34,86 @@  discard block
 block discarded – undo
34 34
 
35 35
 class RuleController extends FOSRestController {
36 36
 
37
-  private FormFactoryInterface $formFactory;
38
-  private EntityManagerInterface $entityManager;
39
-  private RuleRepositoryInterface $ruleRepository;
40
-  private FactoryInterface $ruleFactory;
41
-  private EventDispatcherInterface $eventDispatcher;
42
-
43
-  /**
44
-   * @param FormFactoryInterface $formFactory
45
-   * @param EntityManagerInterface $entityManager
46
-   * @param RuleRepositoryInterface $ruleRepository
47
-   * @param FactoryInterface $ruleFactory
48
-   * @param EventDispatcherInterface $eventDispatcher
49
-   */
50
-  public function __construct(FormFactoryInterface    $formFactory, EntityManagerInterface $entityManager,
51
-                              RuleRepositoryInterface $ruleRepository, FactoryInterface $ruleFactory,
52
-                              EventDispatcherInterface         $eventDispatcher) {
37
+    private FormFactoryInterface $formFactory;
38
+    private EntityManagerInterface $entityManager;
39
+    private RuleRepositoryInterface $ruleRepository;
40
+    private FactoryInterface $ruleFactory;
41
+    private EventDispatcherInterface $eventDispatcher;
42
+
43
+    /**
44
+     * @param FormFactoryInterface $formFactory
45
+     * @param EntityManagerInterface $entityManager
46
+     * @param RuleRepositoryInterface $ruleRepository
47
+     * @param FactoryInterface $ruleFactory
48
+     * @param EventDispatcherInterface $eventDispatcher
49
+     */
50
+    public function __construct(FormFactoryInterface    $formFactory, EntityManagerInterface $entityManager,
51
+                                RuleRepositoryInterface $ruleRepository, FactoryInterface $ruleFactory,
52
+                                EventDispatcherInterface         $eventDispatcher) {
53 53
     $this->formFactory = $formFactory;
54 54
     $this->entityManager = $entityManager;
55 55
     $this->ruleRepository = $ruleRepository;
56 56
     $this->ruleFactory = $ruleFactory;
57 57
     $this->eventDispatcher = $eventDispatcher;
58
-  }
58
+    }
59 59
 
60 60
 
61
-  /**
62
-   * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_rule")
63
-   */
64
-  public function listAction(Request $request) {
61
+    /**
62
+     * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_rule")
63
+     */
64
+    public function listAction(Request $request) {
65 65
     $rules = $this->ruleRepository
66 66
         ->getPaginatedByCriteria($this->eventDispatcher, new Criteria(), $request->query->all('sorting'), new PaginationData($request));
67 67
 
68 68
     if (0 === $rules->count()) {
69
-      throw new NotFoundHttpException('No rules were found.');
69
+        throw new NotFoundHttpException('No rules were found.');
70 70
     }
71 71
 
72 72
     return new ResourcesListResponse($rules);
73
-  }
73
+    }
74 74
 
75
-  /**
76
-   * @Route("/api/{version}/rules/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_rule")
77
-   * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule")
78
-   */
79
-  public function getAction(RuleInterface $rule) {
75
+    /**
76
+     * @Route("/api/{version}/rules/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_rule")
77
+     * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule")
78
+     */
79
+    public function getAction(RuleInterface $rule) {
80 80
     return new SingleResourceResponse($rule);
81
-  }
81
+    }
82 82
 
83
-  /**
84
-   * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_rule")
85
-   */
86
-  public function createAction(Request $request) {
83
+    /**
84
+     * @Route("/api/{version}/rules/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_rule")
85
+     */
86
+    public function createAction(Request $request) {
87 87
     $ruleRepository = $this->ruleRepository;
88 88
     $rule = $this->ruleFactory->create();
89 89
     $form = $this->formFactory->createNamed('', RuleType::class, $rule);
90 90
     $form->handleRequest($request);
91 91
 
92 92
     if ($form->isSubmitted() && $form->isValid()) {
93
-      $ruleRepository->add($rule);
93
+        $ruleRepository->add($rule);
94 94
 
95
-      return new SingleResourceResponse($rule, new ResponseContext(201));
95
+        return new SingleResourceResponse($rule, new ResponseContext(201));
96 96
     }
97 97
 
98 98
     return new SingleResourceResponse($form, new ResponseContext(400));
99
-  }
99
+    }
100 100
 
101
-  /**
102
-   * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_rule", methods={"DELETE"}, requirements={"id"="\d+"})
103
-   * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule")
104
-   */
105
-  public function deleteAction(RuleInterface $rule) {
101
+    /**
102
+     * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_delete_rule", methods={"DELETE"}, requirements={"id"="\d+"})
103
+     * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule")
104
+     */
105
+    public function deleteAction(RuleInterface $rule) {
106 106
     $ruleRepository = $this->ruleRepository;
107 107
     $ruleRepository->remove($rule);
108 108
 
109 109
     return new SingleResourceResponse(null, new ResponseContext(204));
110
-  }
110
+    }
111 111
 
112
-  /**
113
-   * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_rule", requirements={"id"="\d+"})
114
-   * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule")
115
-   */
116
-  public function updateAction(Request $request, RuleInterface $rule) {
112
+    /**
113
+     * @Route("/api/{version}/rules/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_rule", requirements={"id"="\d+"})
114
+     * @ParamConverter("rule", class="SWP\Bundle\CoreBundle\Model\Rule")
115
+     */
116
+    public function updateAction(Request $request, RuleInterface $rule) {
117 117
     $objectManager = $this->entityManager;
118 118
 
119 119
     $form = $this->formFactory->createNamed('', RuleType::class, $rule, [
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 
123 123
     $form->handleRequest($request);
124 124
     if ($form->isSubmitted() && $form->isValid()) {
125
-      $objectManager->flush();
126
-      $objectManager->refresh($rule);
125
+        $objectManager->flush();
126
+        $objectManager->refresh($rule);
127 127
 
128
-      return new SingleResourceResponse($rule);
128
+        return new SingleResourceResponse($rule);
129 129
     }
130 130
 
131 131
     return new SingleResourceResponse($form, new ResponseContext(400));
132
-  }
132
+    }
133 133
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/AuthController.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -37,98 +37,98 @@  discard block
 block discarded – undo
37 37
 use Symfony\Component\Security\Core\User\UserProviderInterface;
38 38
 
39 39
 class AuthController extends AbstractController {
40
-  protected FormFactoryInterface $formFactory;
41
-  protected ApiKeyRepositoryInterface $apiKeyRepository;
42
-  protected ApiKeyFactory $apiKeyFactory;
43
-  protected LockFactory $lockFactory;
44
-
45
-  /**
46
-   * @param FormFactoryInterface $formFactory
47
-   * @param ApiKeyRepositoryInterface $apiKeyRepository
48
-   * @param ApiKeyFactory $apiKeyFactory
49
-   * @param LockFactory $lockFactory
50
-   */
51
-  public function __construct(FormFactoryInterface $formFactory, ApiKeyRepositoryInterface $apiKeyRepository,
52
-                              ApiKeyFactory        $apiKeyFactory, LockFactory $lockFactory) {
40
+    protected FormFactoryInterface $formFactory;
41
+    protected ApiKeyRepositoryInterface $apiKeyRepository;
42
+    protected ApiKeyFactory $apiKeyFactory;
43
+    protected LockFactory $lockFactory;
44
+
45
+    /**
46
+     * @param FormFactoryInterface $formFactory
47
+     * @param ApiKeyRepositoryInterface $apiKeyRepository
48
+     * @param ApiKeyFactory $apiKeyFactory
49
+     * @param LockFactory $lockFactory
50
+     */
51
+    public function __construct(FormFactoryInterface $formFactory, ApiKeyRepositoryInterface $apiKeyRepository,
52
+                                ApiKeyFactory        $apiKeyFactory, LockFactory $lockFactory) {
53 53
     $this->formFactory = $formFactory;
54 54
     $this->apiKeyRepository = $apiKeyRepository;
55 55
     $this->apiKeyFactory = $apiKeyFactory;
56 56
     $this->lockFactory = $lockFactory;
57
-  }
57
+    }
58 58
 
59 59
 
60
-  /**
61
-   * @Route("/api/{version}/auth/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_auth")
62
-   */
63
-  public function authenticateAction(Request                     $request, UserProviderInterface $userProvider,
64
-                                     UserPasswordHasherInterface $userPasswordEncoder) {
60
+    /**
61
+     * @Route("/api/{version}/auth/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_auth")
62
+     */
63
+    public function authenticateAction(Request                     $request, UserProviderInterface $userProvider,
64
+                                        UserPasswordHasherInterface $userPasswordEncoder) {
65 65
     $form = $this->formFactory->createNamed('', UserAuthenticationType::class, []);
66 66
     $form->handleRequest($request);
67 67
     if ($form->isSubmitted() && $form->isValid()) {
68
-      $formData = $form->getData();
68
+        $formData = $form->getData();
69 69
 
70
-      try {
70
+        try {
71 71
         $user = $userProvider->loadUserByUsername($formData['username']);
72
-      } catch (AuthenticationException $e) {
72
+        } catch (AuthenticationException $e) {
73 73
         $user = null;
74
-      }
74
+        }
75 75
 
76
-      if ((null !== $user) && $userPasswordEncoder->isPasswordValid($user, $formData['password'])) {
76
+        if ((null !== $user) && $userPasswordEncoder->isPasswordValid($user, $formData['password'])) {
77 77
         return $this->returnApiTokenResponse($user);
78
-      }
78
+        }
79 79
     }
80 80
 
81 81
     return new SingleResourceResponse([
82 82
         'status' => 401,
83 83
         'message' => 'Unauthorized',
84 84
     ], new ResponseContext(401));
85
-  }
86
-
87
-  /**
88
-   * @Route("/api/{version}/auth/superdesk/", options={"expose"=true}, methods={"POST"}, defaults={"version"="v2"}, name="swp_api_auth_superdesk")
89
-   */
90
-  public function authenticateWithSuperdeskAction(
91
-      Request               $request,
92
-      LoggerInterface       $logger,
93
-      array                 $superdeskServers,
94
-      UserProviderInterface $userProvider,
95
-      UserManagerInterface  $userManager
96
-  ) {
85
+    }
86
+
87
+    /**
88
+     * @Route("/api/{version}/auth/superdesk/", options={"expose"=true}, methods={"POST"}, defaults={"version"="v2"}, name="swp_api_auth_superdesk")
89
+     */
90
+    public function authenticateWithSuperdeskAction(
91
+        Request               $request,
92
+        LoggerInterface       $logger,
93
+        array                 $superdeskServers,
94
+        UserProviderInterface $userProvider,
95
+        UserManagerInterface  $userManager
96
+    ) {
97 97
     $form = $this->formFactory->createNamed('', SuperdeskCredentialAuthenticationType::class, []);
98 98
     $form->handleRequest($request);
99 99
     if ($form->isSubmitted() && $form->isValid()) {
100
-      $formData = $form->getData();
101
-      $authorizedSuperdeskHosts = $superdeskServers;
102
-      $superdeskUser = null;
103
-      $client = new GuzzleHttp\Client();
100
+        $formData = $form->getData();
101
+        $authorizedSuperdeskHosts = $superdeskServers;
102
+        $superdeskUser = null;
103
+        $client = new GuzzleHttp\Client();
104 104
 
105
-      foreach ($authorizedSuperdeskHosts as $baseUrl) {
105
+        foreach ($authorizedSuperdeskHosts as $baseUrl) {
106 106
         try {
107
-          $apiRequest = new GuzzleHttp\Psr7\Request('GET', sprintf('%s/api/sessions/%s', $baseUrl, $formData['sessionId']), [
108
-              'Authorization' => $formData['token'],
109
-          ]);
107
+            $apiRequest = new GuzzleHttp\Psr7\Request('GET', sprintf('%s/api/sessions/%s', $baseUrl, $formData['sessionId']), [
108
+                'Authorization' => $formData['token'],
109
+            ]);
110 110
 
111
-          $apiResponse = $client->send($apiRequest);
112
-          if (200 !== $apiResponse->getStatusCode()) {
111
+            $apiResponse = $client->send($apiRequest);
112
+            if (200 !== $apiResponse->getStatusCode()) {
113 113
             $logger->warning(sprintf('[%s] Unsuccessful response from Superdesk Server: %s', $apiResponse->getStatusCode(), $apiResponse->getBody()->getContents()));
114 114
 
115 115
             continue;
116
-          }
116
+            }
117 117
 
118
-          $content = json_decode($apiResponse->getBody()->getContents(), true);
119
-          if (is_array($content) && array_key_exists('user', $content)) {
118
+            $content = json_decode($apiResponse->getBody()->getContents(), true);
119
+            if (is_array($content) && array_key_exists('user', $content)) {
120 120
             $superdeskUser = $content['user'];
121 121
 
122 122
             break;
123
-          }
123
+            }
124 124
         } catch (GuzzleHttp\Exception\ClientException $e) {
125
-          $logger->warning(sprintf('Error when logging in Superdesk: %s', $e->getMessage()));
125
+            $logger->warning(sprintf('Error when logging in Superdesk: %s', $e->getMessage()));
126 126
 
127
-          continue;
127
+            continue;
128
+        }
128 129
         }
129
-      }
130 130
 
131
-      if (null === $superdeskUser) {
131
+        if (null === $superdeskUser) {
132 132
         return new SingleResourceResponse([
133 133
             'status' => 401,
134 134
             'message' => <<<'MESSAGE'
@@ -136,18 +136,18 @@  discard block
 block discarded – undo
136 136
 Make sure that Publisher can talk to Superdesk instance. Set it's address in "SUPERDESK_SERVERS" environment variable.
137 137
 MESSAGE,
138 138
         ], new ResponseContext(401));
139
-      }
139
+        }
140 140
 
141
-      $publisherUser = $userProvider->findOneByEmail($superdeskUser['email']);
142
-      if (null === $publisherUser) {
141
+        $publisherUser = $userProvider->findOneByEmail($superdeskUser['email']);
142
+        if (null === $publisherUser) {
143 143
         try {
144
-          $publisherUser = $userProvider->loadUserByUsername($superdeskUser['username']);
144
+            $publisherUser = $userProvider->loadUserByUsername($superdeskUser['username']);
145 145
         } catch (AuthenticationException $e) {
146
-          $publisherUser = null;
146
+            $publisherUser = null;
147
+        }
147 148
         }
148
-      }
149 149
 
150
-      if (null === $publisherUser) {
150
+        if (null === $publisherUser) {
151 151
         /** @var UserInterface $publisherUser */
152 152
         $publisherUser = $userManager->createUser();
153 153
         $publisherUser->setUsername($superdeskUser['username']);
@@ -157,20 +157,20 @@  discard block
 block discarded – undo
157 157
         $publisherUser->setLastName(\array_key_exists('last_name', $superdeskUser) ? $superdeskUser['last_name'] : '');
158 158
         $publisherUser->setPassword(password_hash(random_bytes(36), PASSWORD_BCRYPT));
159 159
         $userManager->updateUser($publisherUser);
160
-      }
160
+        }
161 161
 
162
-      if (null !== $publisherUser) {
162
+        if (null !== $publisherUser) {
163 163
         return $this->returnApiTokenResponse($publisherUser, str_replace('Basic ', '', $formData['token']));
164
-      }
164
+        }
165 165
     }
166 166
 
167 167
     return new SingleResourceResponse([
168 168
         'status' => 401,
169 169
         'message' => 'Unauthorized',
170 170
     ], new ResponseContext(401));
171
-  }
171
+    }
172 172
 
173
-  private function returnApiTokenResponse(UserInterface $user, string $token = null): SingleResourceResponseInterface {
173
+    private function returnApiTokenResponse(UserInterface $user, string $token = null): SingleResourceResponseInterface {
174 174
     /** @var ApiKeyInterface $apiKey */
175 175
     $apiKey = $this->generateOrGetApiKey($user, $token);
176 176
 
@@ -181,36 +181,36 @@  discard block
 block discarded – undo
181 181
         ],
182 182
         'user' => $user,
183 183
     ]);
184
-  }
184
+    }
185 185
 
186
-  private function generateOrGetApiKey(UserInterface $user, $token): ?ApiKeyInterface {
186
+    private function generateOrGetApiKey(UserInterface $user, $token): ?ApiKeyInterface {
187 187
     $apiKey = null;
188 188
     if (null !== $token) {
189
-      $apiKey = $this->apiKeyRepository->getValidToken($token)->getQuery()->getOneOrNullResult();
189
+        $apiKey = $this->apiKeyRepository->getValidToken($token)->getQuery()->getOneOrNullResult();
190 190
     } else {
191
-      $validKeys = $this->apiKeyRepository->getValidTokenForUser($user)->getQuery()->getResult();
192
-      if (count($validKeys) > 0) {
191
+        $validKeys = $this->apiKeyRepository->getValidTokenForUser($user)->getQuery()->getResult();
192
+        if (count($validKeys) > 0) {
193 193
         $apiKey = reset($validKeys);
194
-      }
194
+        }
195 195
     }
196 196
 
197 197
     if (null === $apiKey) {
198
-      $apiKey = $this->apiKeyFactory->create($user, $token);
198
+        $apiKey = $this->apiKeyFactory->create($user, $token);
199 199
 
200
-      try {
200
+        try {
201 201
         $lock = $this->lockFactory->createLock(md5(json_encode(['type' => 'user_api_key', 'user' => $user->getId()])), 2);
202 202
         if (!$lock->acquire()) {
203
-          throw new RuntimeException('Other api key is created right now for this user');
203
+            throw new RuntimeException('Other api key is created right now for this user');
204 204
         }
205 205
         $this->apiKeyRepository->add($apiKey);
206 206
         $lock->release();
207
-      } catch (RuntimeException $e) {
207
+        } catch (RuntimeException $e) {
208 208
         sleep(2);
209 209
 
210 210
         return $this->generateOrGetApiKey($user, $token);
211
-      }
211
+        }
212 212
     }
213 213
 
214 214
     return $apiKey;
215
-  }
215
+    }
216 216
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ThemeLogoController.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -29,50 +29,50 @@
 block discarded – undo
29 29
 
30 30
 class ThemeLogoController extends Controller {
31 31
 
32
-  private Filesystem $filesystem;
33
-  private ThemeLogoUploaderInterface $themeLogoUploader;
34
-  private CacheInterface $cacheInterface;
32
+    private Filesystem $filesystem;
33
+    private ThemeLogoUploaderInterface $themeLogoUploader;
34
+    private CacheInterface $cacheInterface;
35 35
 
36
-  /**
37
-   * @param Filesystem $filesystem
38
-   * @param ThemeLogoUploaderInterface $themeLogoUploader
39
-   * @param CacheInterface $cacheInterface
40
-   */
41
-  public function __construct(Filesystem     $filesystem, ThemeLogoUploaderInterface $themeLogoUploader,
42
-                              CacheInterface $cacheInterface) {
36
+    /**
37
+     * @param Filesystem $filesystem
38
+     * @param ThemeLogoUploaderInterface $themeLogoUploader
39
+     * @param CacheInterface $cacheInterface
40
+     */
41
+    public function __construct(Filesystem     $filesystem, ThemeLogoUploaderInterface $themeLogoUploader,
42
+                                CacheInterface $cacheInterface) {
43 43
     $this->filesystem = $filesystem;
44 44
     $this->themeLogoUploader = $themeLogoUploader;
45 45
     $this->cacheInterface = $cacheInterface;
46
-  }
46
+    }
47 47
 
48
-  /**
49
-   * @Route("/theme_logo/{id}", options={"expose"=true}, requirements={"id"=".+"}, methods={"GET"}, name="swp_theme_logo_get")
50
-   */
51
-  public function getLogoAction(string $id) {
48
+    /**
49
+     * @Route("/theme_logo/{id}", options={"expose"=true}, requirements={"id"=".+"}, methods={"GET"}, name="swp_theme_logo_get")
50
+     */
51
+    public function getLogoAction(string $id) {
52 52
     $cacheKey = md5(serialize(['upload', $id]));
53 53
     return $this->cacheInterface->get($cacheKey, function (CacheItemInterface $item, &$save) use ($id) {
54
-      $item->expiresAfter(63072000);
54
+        $item->expiresAfter(63072000);
55 55
 
56
-      $fileSystem = $this->filesystem;
57
-      $themeLogoUploader = $this->themeLogoUploader;
58
-      $id = $themeLogoUploader->getThemeLogoUploadPath($id);
59
-      $file = $fileSystem->has($id);
60
-      if (!$file) {
56
+        $fileSystem = $this->filesystem;
57
+        $themeLogoUploader = $this->themeLogoUploader;
58
+        $id = $themeLogoUploader->getThemeLogoUploadPath($id);
59
+        $file = $fileSystem->has($id);
60
+        if (!$file) {
61 61
         $save = false;
62 62
         throw new NotFoundHttpException('File was not found.');
63
-      }
63
+        }
64 64
 
65
-      $path = $fileSystem->get($id)->getPath();
66
-      $response = new Response();
67
-      $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE, pathinfo($path, PATHINFO_BASENAME));
68
-      $response->headers->set('Content-Disposition', $disposition);
69
-      $response->headers->set('Content-Type', Mime::getMimeFromExtension($path));
70
-      $response->setPublic();
71
-      $response->setMaxAge(63072000);
72
-      $response->setSharedMaxAge(63072000);
73
-      $response->setContent($fileSystem->read($path));
65
+        $path = $fileSystem->get($id)->getPath();
66
+        $response = new Response();
67
+        $disposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE, pathinfo($path, PATHINFO_BASENAME));
68
+        $response->headers->set('Content-Disposition', $disposition);
69
+        $response->headers->set('Content-Type', Mime::getMimeFromExtension($path));
70
+        $response->setPublic();
71
+        $response->setMaxAge(63072000);
72
+        $response->setSharedMaxAge(63072000);
73
+        $response->setContent($fileSystem->read($path));
74 74
 
75
-      return $response;
75
+        return $response;
76 76
     });
77
-  }
77
+    }
78 78
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/UserBundle/Controller/RegistrationController.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
    */
122 122
   public function verifyUserEmail(Request            $request, GuardAuthenticatorHandler $guardHandler,
123 123
                                   LoginAuthenticator $authenticator): Response {
124
-    $id = (int)$request->get('id'); // retrieve the user id from the url
124
+    $id = (int) $request->get('id'); // retrieve the user id from the url
125 125
 
126 126
     if ($request->isXmlHttpRequest()) {
127 127
       return $this->verifyUserEmailFromPWA($id, $request);
Please login to merge, or discard this patch.
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -40,43 +40,43 @@  discard block
 block discarded – undo
40 40
 
41 41
 class RegistrationController extends AbstractController {
42 42
 
43
-  private SettingsManagerInterface $settingsManager;
44
-  private ScopeContextInterface $scopeContext;
45
-  private EmailVerifier $emailVerifier;
46
-  private UserManagerInterface $userManager;
47
-  private EntityManagerInterface $entityManager;
48
-
49
-  /**
50
-   * @param SettingsManagerInterface $settingsManager
51
-   * @param ScopeContextInterface $scopeContext
52
-   * @param EmailVerifier $emailVerifier
53
-   * @param UserManagerInterface $userManager
54
-   * @param EntityManagerInterface $entityManager
55
-   */
56
-  public function __construct(SettingsManagerInterface $settingsManager, ScopeContextInterface $scopeContext,
57
-                              EmailVerifier            $emailVerifier, UserManagerInterface $userManager,
58
-                              EntityManagerInterface   $entityManager) {
43
+    private SettingsManagerInterface $settingsManager;
44
+    private ScopeContextInterface $scopeContext;
45
+    private EmailVerifier $emailVerifier;
46
+    private UserManagerInterface $userManager;
47
+    private EntityManagerInterface $entityManager;
48
+
49
+    /**
50
+     * @param SettingsManagerInterface $settingsManager
51
+     * @param ScopeContextInterface $scopeContext
52
+     * @param EmailVerifier $emailVerifier
53
+     * @param UserManagerInterface $userManager
54
+     * @param EntityManagerInterface $entityManager
55
+     */
56
+    public function __construct(SettingsManagerInterface $settingsManager, ScopeContextInterface $scopeContext,
57
+                                EmailVerifier            $emailVerifier, UserManagerInterface $userManager,
58
+                                EntityManagerInterface   $entityManager) {
59 59
     $this->settingsManager = $settingsManager;
60 60
     $this->scopeContext = $scopeContext;
61 61
     $this->emailVerifier = $emailVerifier;
62 62
     $this->userManager = $userManager;
63 63
     $this->entityManager = $entityManager;
64
-  }
65
-
66
-
67
-  /**
68
-   * @FOSRoute("/api/{version}/users/register/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_register_user")
69
-   */
70
-  public function registerAction(
71
-      Request                     $request,
72
-      UserPasswordEncoderInterface $passwordEncoder,
73
-      UserManagerInterface        $userManager,
74
-      MailerInterface             $mailer
75
-  ) {
64
+    }
65
+
66
+
67
+    /**
68
+     * @FOSRoute("/api/{version}/users/register/", methods={"POST"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_register_user")
69
+     */
70
+    public function registerAction(
71
+        Request                     $request,
72
+        UserPasswordEncoderInterface $passwordEncoder,
73
+        UserManagerInterface        $userManager,
74
+        MailerInterface             $mailer
75
+    ) {
76 76
     try {
77
-      $this->ensureThatRegistrationIsEnabled();
77
+        $this->ensureThatRegistrationIsEnabled();
78 78
     } catch (NotFoundHttpException $e) {
79
-      return new SingleResourceResponse(null, new ResponseContext(404));
79
+        return new SingleResourceResponse(null, new ResponseContext(404));
80 80
     }
81 81
 
82 82
     $user = $userManager->createUser();
@@ -85,66 +85,66 @@  discard block
 block discarded – undo
85 85
     $form->handleRequest($request);
86 86
 
87 87
     if ($form->isSubmitted() && $form->isValid()) {
88
-      $user->addRole('ROLE_USER');
89
-      // encode the plain password
90
-      $user->setPassword(
91
-          $passwordEncoder->encodePassword(
92
-              $user,
93
-              $form->get('plainPassword')->getData()
94
-          )
95
-      );
96
-
97
-      $entityManager = $this->entityManager;
98
-      $entityManager->persist($user);
99
-      $entityManager->flush();
100
-
101
-      $signatureComponents = $this->emailVerifier->getSignatureComponents('swp_user_verify_email', $user);
102
-      $url = $signatureComponents->getSignedUrl();
103
-
104
-      $mailer->sendConfirmationEmail($user, $url);
105
-
106
-      return new JsonResponse([
107
-          'message' => sprintf(
108
-              'The user has been created successfully.
88
+        $user->addRole('ROLE_USER');
89
+        // encode the plain password
90
+        $user->setPassword(
91
+            $passwordEncoder->encodePassword(
92
+                $user,
93
+                $form->get('plainPassword')->getData()
94
+            )
95
+        );
96
+
97
+        $entityManager = $this->entityManager;
98
+        $entityManager->persist($user);
99
+        $entityManager->flush();
100
+
101
+        $signatureComponents = $this->emailVerifier->getSignatureComponents('swp_user_verify_email', $user);
102
+        $url = $signatureComponents->getSignedUrl();
103
+
104
+        $mailer->sendConfirmationEmail($user, $url);
105
+
106
+        return new JsonResponse([
107
+            'message' => sprintf(
108
+                'The user has been created successfully.
109 109
                  An email has been sent to %s. It contains an activation link you must click to activate your account.',
110
-              $user->getEmail()
111
-          ),
112
-          'url' => $url,
113
-      ]);
110
+                $user->getEmail()
111
+            ),
112
+            'url' => $url,
113
+        ]);
114 114
     }
115 115
 
116 116
     return new SingleResourceResponse($form, new ResponseContext(400));
117
-  }
117
+    }
118 118
 
119
-  /**
120
-   * @Route("/verify/email", name="swp_user_verify_email")
121
-   */
122
-  public function verifyUserEmail(Request            $request, GuardAuthenticatorHandler $guardHandler,
123
-                                  LoginAuthenticator $authenticator): Response {
119
+    /**
120
+     * @Route("/verify/email", name="swp_user_verify_email")
121
+     */
122
+    public function verifyUserEmail(Request            $request, GuardAuthenticatorHandler $guardHandler,
123
+                                    LoginAuthenticator $authenticator): Response {
124 124
     $id = (int)$request->get('id'); // retrieve the user id from the url
125 125
 
126 126
     if ($request->isXmlHttpRequest()) {
127
-      return $this->verifyUserEmailFromPWA($id, $request);
127
+        return $this->verifyUserEmailFromPWA($id, $request);
128 128
     }
129 129
 
130 130
     // Verify the user id exists and is not null
131 131
     if (null === $id) {
132
-      return $this->redirectToRoute('homepage');
132
+        return $this->redirectToRoute('homepage');
133 133
     }
134 134
 
135 135
     $user = $this->userManager->find($id);
136 136
 
137 137
     // Ensure the user exists in persistence
138 138
     if (null === $user) {
139
-      return $this->redirectToRoute('homepage');
139
+        return $this->redirectToRoute('homepage');
140 140
     }
141 141
     // validate email confirmation link, sets User::isVerified=true and persists
142 142
     try {
143
-      $this->emailVerifier->handleEmailConfirmation($request, $user);
143
+        $this->emailVerifier->handleEmailConfirmation($request, $user);
144 144
     } catch (VerifyEmailExceptionInterface $exception) {
145
-      $this->addFlash('verify_email_error', $exception->getReason());
145
+        $this->addFlash('verify_email_error', $exception->getReason());
146 146
 
147
-      return $this->redirectToRoute('homepage');
147
+        return $this->redirectToRoute('homepage');
148 148
     }
149 149
 
150 150
     $guardHandler->authenticateUserAndHandleSuccess(
@@ -157,63 +157,63 @@  discard block
 block discarded – undo
157 157
     $this->addFlash('success', 'The user has been created successfully.');
158 158
 
159 159
     return $this->redirectToRoute('swp_user_registration_confirmed');
160
-  }
160
+    }
161 161
 
162
-  /**
163
-   * Tell the user his account is now confirmed.
164
-   */
165
-  public function confirmedAction(Request $request) {
162
+    /**
163
+     * Tell the user his account is now confirmed.
164
+     */
165
+    public function confirmedAction(Request $request) {
166 166
     $user = $this->getUser();
167 167
     if (!is_object($user) || !$user instanceof UserInterface) {
168
-      $this->createAccessDeniedException('This user does not have access to this section.');
168
+        $this->createAccessDeniedException('This user does not have access to this section.');
169 169
     }
170 170
 
171 171
     return $this->render('@SWPUser/Registration/confirmed.html.twig', [
172 172
         'user' => $user,
173 173
     ]);
174
-  }
174
+    }
175 175
 
176
-  /**
177
-   * @throws NotFoundHttpException
178
-   */
179
-  private function ensureThatRegistrationIsEnabled() {
176
+    /**
177
+     * @throws NotFoundHttpException
178
+     */
179
+    private function ensureThatRegistrationIsEnabled() {
180 180
     $settingName = 'registration_enabled';
181 181
     $setting = $this->settingsManager->getOneSettingByName($settingName);
182 182
     $registrationEnabled = $this->settingsManager
183 183
         ->get($settingName, $setting['scope'], $this->scopeContext->getScopeOwner($setting['scope']));
184 184
     if (!$registrationEnabled) {
185
-      throw new NotFoundHttpException('Registration is disabled.');
185
+        throw new NotFoundHttpException('Registration is disabled.');
186
+    }
186 187
     }
187
-  }
188 188
 
189
-  private function verifyUserEmailFromPWA(int $id, Request $request): JsonResponse {
189
+    private function verifyUserEmailFromPWA(int $id, Request $request): JsonResponse {
190 190
     // Verify the user id exists and is not null
191 191
     if (null === $id) {
192
-      return new JsonResponse(
193
-          ['error' => 'User does not exist']
194
-      );
192
+        return new JsonResponse(
193
+            ['error' => 'User does not exist']
194
+        );
195 195
     }
196 196
 
197 197
     $user = $this->userManager->find($id);
198 198
 
199 199
     // Ensure the user exists in persistence
200 200
     if (null === $user) {
201
-      return new JsonResponse(
202
-          ['error' => 'User does not exist']
203
-      );
201
+        return new JsonResponse(
202
+            ['error' => 'User does not exist']
203
+        );
204 204
     }
205 205
 
206 206
     // validate email confirmation link, sets User::isVerified=true and persists
207 207
     try {
208
-      $this->emailVerifier->handleEmailConfirmation($request, $user);
208
+        $this->emailVerifier->handleEmailConfirmation($request, $user);
209 209
     } catch (VerifyEmailExceptionInterface $exception) {
210
-      return new JsonResponse(
211
-          ['error' => 'Registration confirmation invalid']
212
-      );
210
+        return new JsonResponse(
211
+            ['error' => 'Registration confirmation invalid']
212
+        );
213 213
     }
214 214
 
215 215
     return new JsonResponse(
216 216
         ['message' => 'The user has been created successfully.']
217 217
     );
218
-  }
218
+    }
219 219
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/WebhookController.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -28,77 +28,77 @@
 block discarded – undo
28 28
 use FOS\RestBundle\Controller\Annotations\Route;
29 29
 
30 30
 class WebhookController extends AbstractAPIController {
31
-  private WebhookRepositoryInterface $webhookRepository;
32
-  private FormFactoryInterface $formFactory;
33
-  private FactoryInterface $webhookFactory;
34
-  private EntityManagerInterface $entityManager;
35
-  private EventDispatcherInterface $eventDispatcher;
31
+    private WebhookRepositoryInterface $webhookRepository;
32
+    private FormFactoryInterface $formFactory;
33
+    private FactoryInterface $webhookFactory;
34
+    private EntityManagerInterface $entityManager;
35
+    private EventDispatcherInterface $eventDispatcher;
36 36
 
37
-  /**
38
-   * @param WebhookRepositoryInterface $webhookRepository
39
-   * @param FormFactoryInterface $formFactory
40
-   * @param FactoryInterface $webhookFactory
41
-   * @param EntityManagerInterface $entityManager
42
-   * @param EventDispatcherInterface $eventDispatcher
43
-   */
44
-  public function __construct(WebhookRepositoryInterface $webhookRepository, FormFactoryInterface $formFactory,
45
-                              FactoryInterface           $webhookFactory, EntityManagerInterface $entityManager,
46
-                              EventDispatcherInterface            $eventDispatcher) {
37
+    /**
38
+     * @param WebhookRepositoryInterface $webhookRepository
39
+     * @param FormFactoryInterface $formFactory
40
+     * @param FactoryInterface $webhookFactory
41
+     * @param EntityManagerInterface $entityManager
42
+     * @param EventDispatcherInterface $eventDispatcher
43
+     */
44
+    public function __construct(WebhookRepositoryInterface $webhookRepository, FormFactoryInterface $formFactory,
45
+                                FactoryInterface           $webhookFactory, EntityManagerInterface $entityManager,
46
+                                EventDispatcherInterface            $eventDispatcher) {
47 47
     $this->webhookRepository = $webhookRepository;
48 48
     $this->formFactory = $formFactory;
49 49
     $this->webhookFactory = $webhookFactory;
50 50
     $this->entityManager = $entityManager;
51 51
     $this->eventDispatcher = $eventDispatcher;
52
-  }
52
+    }
53 53
 
54 54
 
55
-  /**
56
-   * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_webhook")
57
-   */
58
-  public function listAction(Request $request): ResourcesListResponseInterface {
55
+    /**
56
+     * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_list_webhook")
57
+     */
58
+    public function listAction(Request $request): ResourcesListResponseInterface {
59 59
     return $this->listWebhooks($this->eventDispatcher,$this->webhookRepository, $request);
60
-  }
60
+    }
61 61
 
62
-  /**
63
-   * @Route("/api/{version}/webhooks/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_webhook")
64
-   *
65
-   * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook")
66
-   */
67
-  public function getAction(WebhookInterface $webhook): SingleResourceResponseInterface {
62
+    /**
63
+     * @Route("/api/{version}/webhooks/{id}", requirements={"id"="\d+"}, options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_webhook")
64
+     *
65
+     * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook")
66
+     */
67
+    public function getAction(WebhookInterface $webhook): SingleResourceResponseInterface {
68 68
     return $this->getSingleWebhook($webhook);
69
-  }
69
+    }
70 70
 
71
-  /**
72
-   * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_webhook")
73
-   */
74
-  public function createAction(Request $request): SingleResourceResponseInterface {
71
+    /**
72
+     * @Route("/api/{version}/webhooks/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_core_create_webhook")
73
+     */
74
+    public function createAction(Request $request): SingleResourceResponseInterface {
75 75
     $ruleRepository = $this->webhookRepository;
76 76
     $ruleFactory = $this->webhookFactory;
77 77
     $formFactory = $this->formFactory;
78 78
 
79 79
     return $this->createWebhook($ruleRepository, $ruleFactory, $request, $formFactory);
80
-  }
80
+    }
81 81
 
82
-  /**
83
-   * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_webhook", requirements={"id"="\d+"})
84
-   *
85
-   * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook")
86
-   */
87
-  public function deleteAction(WebhookInterface $webhook): SingleResourceResponseInterface {
82
+    /**
83
+     * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"DELETE"}, name="swp_api_core_delete_webhook", requirements={"id"="\d+"})
84
+     *
85
+     * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook")
86
+     */
87
+    public function deleteAction(WebhookInterface $webhook): SingleResourceResponseInterface {
88 88
     $webhookRepository = $this->webhookRepository;
89 89
 
90 90
     return $this->deleteWebhook($webhookRepository, $webhook);
91
-  }
91
+    }
92 92
 
93
-  /**
94
-   * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_webhook", requirements={"id"="\d+"})
95
-   *
96
-   * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook")
97
-   */
98
-  public function updateAction(Request $request, WebhookInterface $webhook): SingleResourceResponseInterface {
93
+    /**
94
+     * @Route("/api/{version}/webhooks/{id}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PATCH"}, name="swp_api_core_update_webhook", requirements={"id"="\d+"})
95
+     *
96
+     * @ParamConverter("webhook", class="SWP\Bundle\WebhookBundle\Model\Webhook")
97
+     */
98
+    public function updateAction(Request $request, WebhookInterface $webhook): SingleResourceResponseInterface {
99 99
     $objectManager = $this->entityManager;
100 100
     $formFactory = $this->formFactory;
101 101
 
102 102
     return $this->updateWebhook($objectManager, $request, $webhook, $formFactory);
103
-  }
103
+    }
104 104
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Migrations/2021/01/Version20210112135542.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
                     if (is_array($extraItem)) {
101 101
                         $extra = ArticleExtraEmbedField::newFromValue($key, $extraItem);
102 102
                     } else {
103
-                        $extra = ArticleExtraTextField::newFromValue($key, (string)$extraItem);
103
+                        $extra = ArticleExtraTextField::newFromValue($key, (string) $extraItem);
104 104
                     }
105 105
                     $extra->setArticle($article);
106 106
                 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Command/FillArticleExtraTableCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
                     if (is_array($extraItem)) {
101 101
                         $extra = ArticleExtraEmbedField::newFromValue($key, $extraItem);
102 102
                     } else {
103
-                        $extra = ArticleExtraTextField::newFromValue($key, (string)$extraItem);
103
+                        $extra = ArticleExtraTextField::newFromValue($key, (string) $extraItem);
104 104
                     }
105 105
                     $extra->setArticle($article);
106 106
                 }
Please login to merge, or discard this patch.