Completed
Pull Request — master (#1218)
by
unknown
29s
created
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/ThemesController.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -37,34 +37,34 @@  discard block
 block discarded – undo
37 37
 
38 38
 class ThemesController extends Controller {
39 39
 
40
-  private CachedTenantContextInterface $cachedTenantContext;
41
-  private FormFactoryInterface $formFactory;
42
-  private ThemeLoaderInterface $themeLoader;
43
-  private ThemeServiceInterface $themeService;
44
-  private ThemeUploaderInterface $themeUploader;
45
-
46
-  /**
47
-   * @param CachedTenantContextInterface $cachedTenantContext
48
-   * @param FormFactoryInterface $formFactory
49
-   * @param ThemeLoaderInterface $themeLoader
50
-   * @param ThemeServiceInterface $themeService
51
-   * @param ThemeUploaderInterface $themeUploader
52
-   */
53
-  public function __construct(CachedTenantContextInterface $cachedTenantContext, FormFactoryInterface $formFactory,
54
-                              ThemeLoaderInterface         $themeLoader, ThemeServiceInterface $themeService,
55
-                              ThemeUploaderInterface       $themeUploader) {
40
+    private CachedTenantContextInterface $cachedTenantContext;
41
+    private FormFactoryInterface $formFactory;
42
+    private ThemeLoaderInterface $themeLoader;
43
+    private ThemeServiceInterface $themeService;
44
+    private ThemeUploaderInterface $themeUploader;
45
+
46
+    /**
47
+     * @param CachedTenantContextInterface $cachedTenantContext
48
+     * @param FormFactoryInterface $formFactory
49
+     * @param ThemeLoaderInterface $themeLoader
50
+     * @param ThemeServiceInterface $themeService
51
+     * @param ThemeUploaderInterface $themeUploader
52
+     */
53
+    public function __construct(CachedTenantContextInterface $cachedTenantContext, FormFactoryInterface $formFactory,
54
+                                ThemeLoaderInterface         $themeLoader, ThemeServiceInterface $themeService,
55
+                                ThemeUploaderInterface       $themeUploader) {
56 56
     $this->cachedTenantContext = $cachedTenantContext;
57 57
     $this->formFactory = $formFactory;
58 58
     $this->themeLoader = $themeLoader;
59 59
     $this->themeService = $themeService;
60 60
     $this->themeUploader = $themeUploader;
61
-  }
61
+    }
62 62
 
63 63
 
64
-  /**
65
-   * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_available_themes")
66
-   */
67
-  public function listAvailableAction(): ResourcesListResponseInterface {
64
+    /**
65
+     * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_available_themes")
66
+     */
67
+    public function listAvailableAction(): ResourcesListResponseInterface {
68 68
     $themeLoader = $this->themeLoader;
69 69
     $themes = $themeLoader->load();
70 70
     $pagination = new SlidingPagination();
@@ -72,21 +72,21 @@  discard block
 block discarded – undo
72 72
     $pagination->setTotalItemCount(count($themes));
73 73
 
74 74
     return new ResourcesListResponse($pagination);
75
-  }
75
+    }
76 76
 
77
-  /**
78
-   * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_tenant_themes")
79
-   */
80
-  public function listInstalledAction(ThemeRepositoryInterface $themeRepository): ResourcesListResponseInterface {
77
+    /**
78
+     * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_tenant_themes")
79
+     */
80
+    public function listInstalledAction(ThemeRepositoryInterface $themeRepository): ResourcesListResponseInterface {
81 81
     /** @var TenantInterface $tenant */
82 82
     $tenant = $this->cachedTenantContext->getTenant();
83 83
     $tenantCode = $tenant->getCode();
84 84
     $themes = array_filter(
85 85
         $themeRepository->findAll(),
86 86
         static function ($element) use (&$tenantCode) {
87
-          if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR . $tenantCode)) {
87
+            if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR . $tenantCode)) {
88 88
             return true;
89
-          }
89
+            }
90 90
         }
91 91
     );
92 92
 
@@ -95,46 +95,46 @@  discard block
 block discarded – undo
95 95
     $pagination->setTotalItemCount(count($themes));
96 96
 
97 97
     return new ResourcesListResponse($pagination);
98
-  }
98
+    }
99 99
 
100
-  /**
101
-   * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme")
102
-   */
103
-  public function uploadThemeAction(Request $request): SingleResourceResponseInterface {
100
+    /**
101
+     * @Route("/api/{version}/organization/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_upload_theme")
102
+     */
103
+    public function uploadThemeAction(Request $request): SingleResourceResponseInterface {
104 104
     $form = $this->formFactory->createNamed('', ThemeUploadType::class, []);
105 105
     $form->handleRequest($request);
106 106
     if ($form->isSubmitted() && $form->isValid()) {
107
-      $formData = $form->getData();
108
-      $themeUploader = $this->themeUploader;
107
+        $formData = $form->getData();
108
+        $themeUploader = $this->themeUploader;
109 109
 
110
-      try {
110
+        try {
111 111
         $themePath = $themeUploader->upload($formData['file']);
112
-      } catch (\Exception $e) {
112
+        } catch (\Exception $e) {
113 113
         return new SingleResourceResponse(['message' => $e->getMessage()], new ResponseContext(400));
114
-      }
115
-      $themeConfig = json_decode(file_get_contents($themePath . DIRECTORY_SEPARATOR . 'theme.json'), true);
114
+        }
115
+        $themeConfig = json_decode(file_get_contents($themePath . DIRECTORY_SEPARATOR . 'theme.json'), true);
116 116
 
117
-      return new SingleResourceResponse($themeConfig, new ResponseContext(201));
117
+        return new SingleResourceResponse($themeConfig, new ResponseContext(201));
118 118
     }
119 119
 
120 120
     return new SingleResourceResponse($form, new ResponseContext(400));
121
-  }
121
+    }
122 122
 
123
-  /**
124
-   * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_install_theme")
125
-   */
126
-  public function installThemeAction(Request $request): SingleResourceResponseInterface {
123
+    /**
124
+     * @Route("/api/{version}/themes/", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_install_theme")
125
+     */
126
+    public function installThemeAction(Request $request): SingleResourceResponseInterface {
127 127
     $form = $this->formFactory->createNamed('', ThemeInstallType::class, []);
128 128
     $form->handleRequest($request);
129 129
     if ($form->isSubmitted() && $form->isValid()) {
130
-      $formData = $form->getData();
131
-      $themeService = $this->themeService;
132
-      [$sourceDir, $themeDir] = $themeService->getDirectoriesForTheme($formData['name']);
133
-      $themeService->installAndProcessGeneratedData($sourceDir, $themeDir, $formData['processGeneratedData']);
130
+        $formData = $form->getData();
131
+        $themeService = $this->themeService;
132
+        [$sourceDir, $themeDir] = $themeService->getDirectoriesForTheme($formData['name']);
133
+        $themeService->installAndProcessGeneratedData($sourceDir, $themeDir, $formData['processGeneratedData']);
134 134
 
135
-      return new SingleResourceResponse(['status' => 'installed'], new ResponseContext(201));
135
+        return new SingleResourceResponse(['status' => 'installed'], new ResponseContext(201));
136 136
     }
137 137
 
138 138
     return new SingleResourceResponse($form, new ResponseContext(400));
139
-  }
139
+    }
140 140
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
     $tenantCode = $tenant->getCode();
84 84
     $themes = array_filter(
85 85
         $themeRepository->findAll(),
86
-        static function ($element) use (&$tenantCode) {
87
-          if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR . $tenantCode)) {
86
+        static function($element) use (&$tenantCode) {
87
+          if (strpos($element->getName(), ThemeHelper::SUFFIX_SEPARATOR.$tenantCode)) {
88 88
             return true;
89 89
           }
90 90
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
       } catch (\Exception $e) {
113 113
         return new SingleResourceResponse(['message' => $e->getMessage()], new ResponseContext(400));
114 114
       }
115
-      $themeConfig = json_decode(file_get_contents($themePath . DIRECTORY_SEPARATOR . 'theme.json'), true);
115
+      $themeConfig = json_decode(file_get_contents($themePath.DIRECTORY_SEPARATOR.'theme.json'), true);
116 116
 
117 117
       return new SingleResourceResponse($themeConfig, new ResponseContext(201));
118 118
     }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ThemeLogoController.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
    */
51 51
   public function getLogoAction(string $id) {
52 52
     $cacheKey = md5(serialize(['upload', $id]));
53
-    return $this->cacheInterface->get($cacheKey, function (CacheItemInterface $item, &$save) use ($id) {
53
+    return $this->cacheInterface->get($cacheKey, function(CacheItemInterface $item, &$save) use ($id) {
54 54
       $item->expiresAfter(63072000);
55 55
 
56 56
       $fileSystem = $this->filesystem;
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/FbiaArticleController.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -29,32 +29,32 @@  discard block
 block discarded – undo
29 29
 
30 30
 class FbiaArticleController extends Controller {
31 31
 
32
-  private FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository;
33
-  private FacebookInstantArticlesService $facebookInstantArticlesService;
34
-  private EventDispatcherInterface $eventDispatcher;
32
+    private FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository;
33
+    private FacebookInstantArticlesService $facebookInstantArticlesService;
34
+    private EventDispatcherInterface $eventDispatcher;
35 35
 
36
-  /**
37
-   * @param FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository
38
-   * @param FacebookInstantArticlesService $facebookInstantArticlesService
39
-   * @param EventDispatcherInterface $eventDispatcher
40
-   */
41
-  public function __construct(FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository,
42
-                              FacebookInstantArticlesService           $facebookInstantArticlesService,
43
-                              EventDispatcherInterface                 $eventDispatcher) {
36
+    /**
37
+     * @param FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository
38
+     * @param FacebookInstantArticlesService $facebookInstantArticlesService
39
+     * @param EventDispatcherInterface $eventDispatcher
40
+     */
41
+    public function __construct(FacebookInstantArticlesArticleRepository $facebookInstantArticlesArticleRepository,
42
+                                FacebookInstantArticlesService           $facebookInstantArticlesService,
43
+                                EventDispatcherInterface                 $eventDispatcher) {
44 44
     $this->facebookInstantArticlesArticleRepository = $facebookInstantArticlesArticleRepository;
45 45
     $this->facebookInstantArticlesService = $facebookInstantArticlesService;
46 46
     $this->eventDispatcher = $eventDispatcher;
47
-  }
47
+    }
48 48
 
49 49
 
50
-  /**
51
-   * @Route("/api/{version}/facebook/instantarticles/articles/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_instant_articles_articles")
52
-   */
53
-  public function listAction(Request $request): ResourcesListResponseInterface {
50
+    /**
51
+     * @Route("/api/{version}/facebook/instantarticles/articles/", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_list_facebook_instant_articles_articles")
52
+     */
53
+    public function listAction(Request $request): ResourcesListResponseInterface {
54 54
     $repository = $this->facebookInstantArticlesArticleRepository;
55 55
     $sort = $request->query->all('sorting');
56 56
     if (empty($sort)) {
57
-      $sort = ['createdAt' => 'desc'];
57
+        $sort = ['createdAt' => 'desc'];
58 58
     }
59 59
     $items = $repository->getPaginatedByCriteria(
60 60
         $this->eventDispatcher,
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
     );
65 65
 
66 66
     return new ResourcesListResponse($items);
67
-  }
67
+    }
68 68
 
69
-  /**
70
-   * @Route("/api/{version}/facebook/instantarticles/articles/{submissionId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_facebook_instant_articles_articles_update")
71
-   */
72
-  public function updateSubmissionAction(string $submissionId): SingleResourceResponseInterface {
69
+    /**
70
+     * @Route("/api/{version}/facebook/instantarticles/articles/{submissionId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"POST"}, name="swp_api_facebook_instant_articles_articles_update")
71
+     */
72
+    public function updateSubmissionAction(string $submissionId): SingleResourceResponseInterface {
73 73
     $instantArticlesService = $this->facebookInstantArticlesService;
74 74
     $instantArticle = $instantArticlesService->updateSubmissionStatus($submissionId);
75 75
 
76 76
     return new SingleResourceResponse($instantArticle);
77
-  }
77
+    }
78 78
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Resolver/ArticleResolver.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -43,29 +43,29 @@
 block discarded – undo
43 43
     {
44 44
         $collectionRouteCacheKey = md5('route_'.$url);
45 45
         return $this->cacheProvider->get($collectionRouteCacheKey, function (ItemInterface $item, &$save) use ($url) {
46
-          try {
46
+            try {
47 47
             $route = $this->matcher->match($this->getFragmentFromUrl($url, 'path'));
48
-          } catch(ResourceNotFoundException $e) {
48
+            } catch(ResourceNotFoundException $e) {
49 49
             $save = false;
50 50
             return null;
51
-          }
52
-          if(!isset($route['_article_meta'])) {
51
+            }
52
+            if(!isset($route['_article_meta'])) {
53 53
             $save = false;
54 54
             return null;
55
-          }
55
+            }
56 56
 
57
-          if(!($route['_article_meta'] instanceof Meta)) {
57
+            if(!($route['_article_meta'] instanceof Meta)) {
58 58
             $save = false;
59 59
             return null;
60
-          }
60
+            }
61 61
 
62
-          $values = $route['_article_meta']->getValues();
63
-          if(!($values instanceof ArticleInterface)) {
62
+            $values = $route['_article_meta']->getValues();
63
+            if(!($values instanceof ArticleInterface)) {
64 64
             $save = false;
65 65
             return null;
66
-          }
66
+            }
67 67
 
68
-          return $values;
68
+            return $values;
69 69
         });
70 70
     }
71 71
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,25 +42,25 @@
 block discarded – undo
42 42
     public function resolve(string $url): ?ArticleInterface
43 43
     {
44 44
         $collectionRouteCacheKey = md5('route_'.$url);
45
-        return $this->cacheProvider->get($collectionRouteCacheKey, function (ItemInterface $item, &$save) use ($url) {
45
+        return $this->cacheProvider->get($collectionRouteCacheKey, function(ItemInterface $item, &$save) use ($url) {
46 46
           try {
47 47
             $route = $this->matcher->match($this->getFragmentFromUrl($url, 'path'));
48
-          } catch(ResourceNotFoundException $e) {
48
+          } catch (ResourceNotFoundException $e) {
49 49
             $save = false;
50 50
             return null;
51 51
           }
52
-          if(!isset($route['_article_meta'])) {
52
+          if (!isset($route['_article_meta'])) {
53 53
             $save = false;
54 54
             return null;
55 55
           }
56 56
 
57
-          if(!($route['_article_meta'] instanceof Meta)) {
57
+          if (!($route['_article_meta'] instanceof Meta)) {
58 58
             $save = false;
59 59
             return null;
60 60
           }
61 61
 
62 62
           $values = $route['_article_meta']->getValues();
63
-          if(!($values instanceof ArticleInterface)) {
63
+          if (!($values instanceof ArticleInterface)) {
64 64
             $save = false;
65 65
             return null;
66 66
           }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/MessageHandler/AbstractContentPushHandler.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
         if (null !== $existingPackage) {
126 126
             $existingPackage = $this->packageHydrator->hydrate($package, $existingPackage);
127 127
 
128
-            $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PRE_UPDATE]), Events::PACKAGE_PRE_UPDATE);
128
+            $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PRE_UPDATE]), Events::PACKAGE_PRE_UPDATE);
129 129
             $this->packageObjectManager->flush();
130
-            $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_POST_UPDATE]), Events::PACKAGE_POST_UPDATE);
131
-            $this->eventDispatcher->dispatch( new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED);
130
+            $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_POST_UPDATE]), Events::PACKAGE_POST_UPDATE);
131
+            $this->eventDispatcher->dispatch(new GenericEvent($existingPackage, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED);
132 132
             $this->packageObjectManager->flush();
133 133
 
134 134
             $this->reset();
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
             return;
138 138
         }
139 139
 
140
-        $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_PRE_CREATE]), Events::PACKAGE_PRE_CREATE);
140
+        $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_PRE_CREATE]), Events::PACKAGE_PRE_CREATE);
141 141
         $this->packageRepository->add($package);
142
-        $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_POST_CREATE]), Events::PACKAGE_POST_CREATE);
143
-        $this->eventDispatcher->dispatch( new GenericEvent($package, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED);
142
+        $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_POST_CREATE]), Events::PACKAGE_POST_CREATE);
143
+        $this->eventDispatcher->dispatch(new GenericEvent($package, ['eventName' => Events::PACKAGE_PROCESSED]), Events::PACKAGE_PROCESSED);
144 144
         $this->packageObjectManager->flush();
145 145
 
146 146
         $this->logger->info(sprintf('Package %s was created', $package->getGuid()));
Please login to merge, or discard this patch.
CoreBundle/Rule/Applicator/PublishArticleToAppleNewsRuleApplicator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 
53 53
         if ($isPublishedToAppleNews = (bool) $configuration[$this->supportedKeys[0]]) {
54 54
             $subject->setPublishedToAppleNews($isPublishedToAppleNews);
55
-            $this->eventDispatcher->dispatch( new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH);
55
+            $this->eventDispatcher->dispatch(new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH);
56 56
 
57 57
             $this->logger->info(sprintf(
58 58
                 'Configuration: "%s" for "%s" rule has been applied!',
Please login to merge, or discard this patch.
Bundle/CoreBundle/Rule/Applicator/PublishArticleToFBIARuleApplicator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 
61 61
         if ($isPublishedFBIA = (bool) $configuration['isPublishedFbia']) {
62 62
             $subject->setPublishedFBIA($isPublishedFBIA);
63
-            $this->eventDispatcher->dispatch( new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH);
63
+            $this->eventDispatcher->dispatch(new ArticleEvent($subject, null, ArticleEvents::PUBLISH), ArticleEvents::PUBLISH);
64 64
 
65 65
             $this->logger->info(sprintf(
66 66
                 'Configuration: "%s" for "%s" rule has been applied!',
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Rule/Populator/ArticlePopulator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -101,14 +101,14 @@
 block discarded – undo
101 101
 
102 102
             $this->articleRepository->persist($articleStatistics);
103 103
 
104
-            $this->eventDispatcher->dispatch( new GenericEvent($article), Events::SWP_VALIDATION);
104
+            $this->eventDispatcher->dispatch(new GenericEvent($article), Events::SWP_VALIDATION);
105 105
 
106 106
             $article->setPackage($package);
107 107
             $article->setArticleStatistics($articleStatistics);
108 108
             $this->articleRepository->persist($article);
109
-            $this->eventDispatcher->dispatch( new ArticleEvent($article, $package, ArticleEvents::PRE_CREATE), ArticleEvents::PRE_CREATE);
109
+            $this->eventDispatcher->dispatch(new ArticleEvent($article, $package, ArticleEvents::PRE_CREATE), ArticleEvents::PRE_CREATE);
110 110
             $this->articleRepository->flush();
111
-            $this->eventDispatcher->dispatch( new ArticleEvent($article, $package, ArticleEvents::POST_CREATE),ArticleEvents::POST_CREATE);
111
+            $this->eventDispatcher->dispatch(new ArticleEvent($article, $package, ArticleEvents::POST_CREATE), ArticleEvents::POST_CREATE);
112 112
             $this->entityManager->flush($article);
113 113
         }
114 114
         $this->tenantContext->setTenant($originalTenant);
Please login to merge, or discard this patch.