Completed
Pull Request — master (#1218)
by
unknown
41s
created
src/SWP/Bundle/CoreBundle/Migrations/Version20180314091410.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     /**
40 40
      * @param Schema $schema
41 41
      */
42
-   public function postUp(Schema $schema) : void
42
+    public function postUp(Schema $schema) : void
43 43
     {
44 44
         $entityManager = $this->container->get('doctrine.orm.default_entity_manager');
45 45
         $query = $entityManager
Please login to merge, or discard this patch.
SWP/Component/ContentList/Repository/ContentListItemRepositoryInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
     public function getSortedItems(Criteria $criteria, array $sorting = [], array $groupValues = []): QueryBuilder;
32 32
 
33
-    public function getPaginatedByCriteria(EventDispatcherInterface $eventDispatcher,Criteria $criteria, array $sorting = [], PaginationData $paginationData = null);
33
+    public function getPaginatedByCriteria(EventDispatcherInterface $eventDispatcher, Criteria $criteria, array $sorting = [], PaginationData $paginationData = null);
34 34
 
35 35
     public function getCountByCriteria(Criteria $criteria): int;
36 36
 
Please login to merge, or discard this patch.
SWP/Bundle/ElasticSearchBundle/Controller/Api/ArticleSearchController.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -106,15 +106,15 @@
 block discarded – undo
106 106
 
107 107
   protected function createAdditionalCriteria(Request $request): array {
108 108
     return [
109
-        'routes' => array_filter((array)$request->query->get('route', [])),
110
-        'statuses' => array_filter((array)$request->query->get('status', [])),
111
-        'authors' => array_filter((array)$request->query->get('author', [])),
109
+        'routes' => array_filter((array) $request->query->get('route', [])),
110
+        'statuses' => array_filter((array) $request->query->get('status', [])),
111
+        'authors' => array_filter((array) $request->query->get('author', [])),
112 112
         'publishedBefore' => $request->query->has('published_before') ? new \DateTime($request->query->get('published_before')) : null,
113 113
         'publishedAfter' => $request->query->has('published_after') ? new \DateTime($request->query->get('published_after')) : null,
114 114
         'publishedAt' => $request->query->get('published_at'),
115
-        'sources' => array_filter((array)$request->query->get('source', [])),
116
-        'metadata' => array_filter((array)$request->query->get('metadata', [])),
117
-        'keywords' => array_filter((array)$request->query->get('keywords', [])),
115
+        'sources' => array_filter((array) $request->query->get('source', [])),
116
+        'metadata' => array_filter((array) $request->query->get('metadata', [])),
117
+        'keywords' => array_filter((array) $request->query->get('keywords', [])),
118 118
     ];
119 119
   }
120 120
 }
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -28,25 +28,25 @@  discard block
 block discarded – undo
28 28
 use FOS\RestBundle\Controller\Annotations\Route;
29 29
 
30 30
 class ArticleSearchController extends AbstractController {
31
-  private $extraFields; //
32
-  private CachedTenantContext $cachedTenantContext; // swp_multi_tenancy.tenant_context
33
-  private PaginatorInterface $paginator; // knp_paginator
34
-
35
-  /**
36
-   * @param $extraFields
37
-   * @param CachedTenantContext $cachedTenantContext
38
-   * @param PaginatorInterface $paginator
39
-   */
40
-  public function __construct($extraFields, CachedTenantContext $cachedTenantContext, PaginatorInterface $paginator) {
31
+    private $extraFields; //
32
+    private CachedTenantContext $cachedTenantContext; // swp_multi_tenancy.tenant_context
33
+    private PaginatorInterface $paginator; // knp_paginator
34
+
35
+    /**
36
+     * @param $extraFields
37
+     * @param CachedTenantContext $cachedTenantContext
38
+     * @param PaginatorInterface $paginator
39
+     */
40
+    public function __construct($extraFields, CachedTenantContext $cachedTenantContext, PaginatorInterface $paginator) {
41 41
     $this->extraFields = $extraFields;
42 42
     $this->cachedTenantContext = $cachedTenantContext;
43 43
     $this->paginator = $paginator;
44
-  }
44
+    }
45 45
 
46
-  /**
47
-   * @Route("/api/{version}/content/articles/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_list_articles")
48
-   */
49
-  public function searchAction(Request $request, RepositoryManagerInterface $repositoryManager) {
46
+    /**
47
+     * @Route("/api/{version}/content/articles/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_content_list_articles")
48
+     */
49
+    public function searchAction(Request $request, RepositoryManagerInterface $repositoryManager) {
50 50
     $criteria = $this->createCriteriaFrom($request);
51 51
     $extraFields = $this->extraFields;
52 52
 
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
     $responseContext->setSerializationGroups($this->getSerializationGroups());
70 70
 
71 71
     return new ResourcesListResponse($pagination, $responseContext);
72
-  }
72
+    }
73 73
 
74
-  private function createCriteriaFrom(Request $request): Criteria {
74
+    private function createCriteriaFrom(Request $request): Criteria {
75 75
     return Criteria::fromQueryParameters(
76 76
         $request->query->get('term', ''),
77 77
         array_merge($this->createDefaultCriteria($request), $this->createAdditionalCriteria($request)
78 78
         ));
79
-  }
79
+    }
80 80
 
81
-  private function createDefaultCriteria(Request $request): array {
81
+    private function createDefaultCriteria(Request $request): array {
82 82
     $currentTenant = $this->cachedTenantContext->getTenant();
83 83
 
84 84
     return [
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
         'limit' => $request->query->get('limit', 10),
88 88
         'tenantCode' => $currentTenant->getCode(),
89 89
     ];
90
-  }
90
+    }
91 91
 
92
-  protected function getSerializationGroups(): array {
92
+    protected function getSerializationGroups(): array {
93 93
     return [
94 94
         'Default',
95 95
         'api_articles_list',
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
         'api_tenant_list',
103 103
         'api_articles_statistics_list',
104 104
     ];
105
-  }
105
+    }
106 106
 
107
-  protected function createAdditionalCriteria(Request $request): array {
107
+    protected function createAdditionalCriteria(Request $request): array {
108 108
     return [
109 109
         'routes' => array_filter((array)$request->query->get('route', [])),
110 110
         'statuses' => array_filter((array)$request->query->get('status', [])),
@@ -116,5 +116,5 @@  discard block
 block discarded – undo
116 116
         'metadata' => array_filter((array)$request->query->get('metadata', [])),
117 117
         'keywords' => array_filter((array)$request->query->get('keywords', [])),
118 118
     ];
119
-  }
119
+    }
120 120
 }
Please login to merge, or discard this patch.
SWP/Bundle/ElasticSearchBundle/Controller/Api/PackageSearchController.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
 
33 33
 class PackageSearchController extends AbstractController {
34 34
 
35
-  private PaginatorInterface $paginator;
36
-  private EventDispatcherInterface $eventDispatcher;
37
-  private CachedTenantContext $cachedTenantContext;
35
+    private PaginatorInterface $paginator;
36
+    private EventDispatcherInterface $eventDispatcher;
37
+    private CachedTenantContext $cachedTenantContext;
38 38
 
39
-  /**
40
-   * @param PaginatorInterface $paginator
41
-   * @param EventDispatcherInterface $eventDispatcher
42
-   * @param CachedTenantContext $cachedTenantContext
43
-   */
44
-  public function __construct(PaginatorInterface  $paginator, EventDispatcherInterface $eventDispatcher,
45
-                              CachedTenantContext $cachedTenantContext) {
39
+    /**
40
+     * @param PaginatorInterface $paginator
41
+     * @param EventDispatcherInterface $eventDispatcher
42
+     * @param CachedTenantContext $cachedTenantContext
43
+     */
44
+    public function __construct(PaginatorInterface  $paginator, EventDispatcherInterface $eventDispatcher,
45
+                                CachedTenantContext $cachedTenantContext) {
46 46
     $this->paginator = $paginator;
47 47
     $this->eventDispatcher = $eventDispatcher;
48 48
     $this->cachedTenantContext = $cachedTenantContext;
49
-  }
49
+    }
50 50
 
51 51
 
52
-  /**
53
-   * @Route("/api/{version}/packages/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_packages")
54
-   */
55
-  public function searchAction(Request $request, RepositoryManagerInterface $repositoryManager) {
52
+    /**
53
+     * @Route("/api/{version}/packages/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_packages")
54
+     */
55
+    public function searchAction(Request $request, RepositoryManagerInterface $repositoryManager) {
56 56
     $this->eventDispatcher->dispatch( new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
57 57
     $currentTenant = $this->cachedTenantContext->getTenant();
58 58
 
@@ -106,5 +106,5 @@  discard block
 block discarded – undo
106 106
     );
107 107
 
108 108
     return new ResourcesListResponse($pagination, $responseContext);
109
-  }
109
+    }
110 110
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
    * @Route("/api/{version}/packages/", methods={"GET"}, options={"expose"=true}, defaults={"version"="v2"}, name="swp_api_core_list_packages")
54 54
    */
55 55
   public function searchAction(Request $request, RepositoryManagerInterface $repositoryManager) {
56
-    $this->eventDispatcher->dispatch( new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
56
+    $this->eventDispatcher->dispatch(new GenericEvent(), MultiTenancyEvents::TENANTABLE_DISABLE);
57 57
     $currentTenant = $this->cachedTenantContext->getTenant();
58 58
 
59 59
     $criteria = Criteria::fromQueryParameters(
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
             'page' => $request->query->get('page'),
63 63
             'sort' => $request->query->get('sorting'),
64 64
             'limit' => $request->query->get('limit', 10),
65
-            'authors' => array_filter((array)$request->query->get('author', [])),
65
+            'authors' => array_filter((array) $request->query->get('author', [])),
66 66
             'publishedBefore' => $request->query->get('published_before'),
67 67
             'publishedAfter' => $request->query->get('published_after'),
68 68
             'organization' => $currentTenant->getOrganization()->getId(),
69
-            'sources' => array_filter((array)$request->query->get('source', [])),
70
-            'tenants' => array_filter((array)$request->query->get('tenant', [])),
71
-            'routes' => array_filter((array)$request->query->get('route', [])),
72
-            'statuses' => array_filter((array)$request->query->get('status', [])),
69
+            'sources' => array_filter((array) $request->query->get('source', [])),
70
+            'tenants' => array_filter((array) $request->query->get('tenant', [])),
71
+            'routes' => array_filter((array) $request->query->get('route', [])),
72
+            'statuses' => array_filter((array) $request->query->get('status', [])),
73 73
             'language' => $request->query->get('language', ''),
74 74
         ]
75 75
     );
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/EventListener/BodyListener.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 
106 106
       $request->request = new ParameterBag($data);
107 107
 
108
-      if(!empty($request->files->all())) {
108
+      if (!empty($request->files->all())) {
109 109
         $data = $request->files->all();
110 110
 
111 111
         try {
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@  discard block
 block discarded – undo
28 28
 
29 29
 class BodyListener
30 30
 {
31
-  private $decoderProvider;
32
-  private $throwExceptionOnUnsupportedContentType;
33
-  private $defaultFormat;
34
-  private $arrayNormalizer;
35
-  private $normalizeForms;
36
-
37
-  public function __construct(
38
-      DecoderProviderInterface $decoderProvider,
39
-      bool $throwExceptionOnUnsupportedContentType = false,
40
-      ArrayNormalizerInterface $arrayNormalizer = null,
41
-      bool $normalizeForms = false
42
-  ) {
31
+    private $decoderProvider;
32
+    private $throwExceptionOnUnsupportedContentType;
33
+    private $defaultFormat;
34
+    private $arrayNormalizer;
35
+    private $normalizeForms;
36
+
37
+    public function __construct(
38
+        DecoderProviderInterface $decoderProvider,
39
+        bool $throwExceptionOnUnsupportedContentType = false,
40
+        ArrayNormalizerInterface $arrayNormalizer = null,
41
+        bool $normalizeForms = false
42
+    ) {
43 43
     $this->decoderProvider = $decoderProvider;
44 44
     $this->throwExceptionOnUnsupportedContentType = $throwExceptionOnUnsupportedContentType;
45 45
     $this->arrayNormalizer = $arrayNormalizer;
46 46
     $this->normalizeForms = true;
47
-  }
47
+    }
48 48
 
49
-  public function setDefaultFormat(?string $defaultFormat): void
50
-  {
49
+    public function setDefaultFormat(?string $defaultFormat): void
50
+    {
51 51
     $this->defaultFormat = $defaultFormat;
52
-  }
52
+    }
53 53
 
54
-  public function onKernelRequest(RequestEvent $event): void
55
-  {
54
+    public function onKernelRequest(RequestEvent $event): void
55
+    {
56 56
     $request = $event->getRequest();
57 57
 
58 58
     if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) {
59
-      return;
59
+        return;
60 60
     }
61 61
 
62 62
     $method = $request->getMethod();
@@ -64,83 +64,83 @@  discard block
 block discarded – undo
64 64
     $normalizeRequest = $this->normalizeForms && $this->isFormRequest($request);
65 65
 
66 66
     if ($this->isDecodeable($request)) {
67
-      $format = null === $contentType
67
+        $format = null === $contentType
68 68
           ? $request->getRequestFormat()
69 69
           : $request->getFormat($contentType);
70 70
 
71
-      $format = $format ?: $this->defaultFormat;
71
+        $format = $format ?: $this->defaultFormat;
72 72
 
73
-      $content = $request->getContent();
73
+        $content = $request->getContent();
74 74
 
75
-      if (null === $format || !$this->decoderProvider->supports($format)) {
75
+        if (null === $format || !$this->decoderProvider->supports($format)) {
76 76
         if ($this->throwExceptionOnUnsupportedContentType
77 77
             && $this->isNotAnEmptyDeleteRequestWithNoSetContentType($method, $content, $contentType)
78 78
         ) {
79
-          throw new UnsupportedMediaTypeHttpException("Request body format '$format' not supported");
79
+            throw new UnsupportedMediaTypeHttpException("Request body format '$format' not supported");
80 80
         }
81 81
 
82 82
         return;
83
-      }
83
+        }
84 84
 
85
-      if (!empty($content)) {
85
+        if (!empty($content)) {
86 86
         $decoder = $this->decoderProvider->getDecoder($format);
87 87
         $data = $decoder->decode($content);
88 88
         if (is_array($data)) {
89
-          $request->request = new ParameterBag($data);
90
-          $normalizeRequest = true;
89
+            $request->request = new ParameterBag($data);
90
+            $normalizeRequest = true;
91 91
         } else {
92
-          throw new BadRequestHttpException('Invalid '.$format.' message received');
92
+            throw new BadRequestHttpException('Invalid '.$format.' message received');
93
+        }
93 94
         }
94
-      }
95 95
     }
96 96
 
97 97
     if (null !== $this->arrayNormalizer && $normalizeRequest) {
98
-      $data = $request->request->all();
98
+        $data = $request->request->all();
99 99
 
100
-      try {
100
+        try {
101 101
         $data = $this->arrayNormalizer->normalize($data);
102
-      } catch (NormalizationException $e) {
102
+        } catch (NormalizationException $e) {
103 103
         throw new BadRequestHttpException($e->getMessage());
104
-      }
104
+        }
105 105
 
106
-      $request->request = new ParameterBag($data);
106
+        $request->request = new ParameterBag($data);
107 107
 
108
-      if(!empty($request->files->all())) {
108
+        if(!empty($request->files->all())) {
109 109
         $data = $request->files->all();
110 110
 
111 111
         try {
112
-          $data = $this->arrayNormalizer->normalize($data);
112
+            $data = $this->arrayNormalizer->normalize($data);
113 113
         } catch (NormalizationException $e) {
114
-          throw new BadRequestHttpException($e->getMessage());
114
+            throw new BadRequestHttpException($e->getMessage());
115 115
         }
116 116
 
117 117
         $request->files = new ParameterBag($data);
118
-      }
118
+        }
119
+    }
119 120
     }
120
-  }
121 121
 
122
-  private function isNotAnEmptyDeleteRequestWithNoSetContentType(string $method, $content, ?string $contentType): bool
123
-  {
122
+    private function isNotAnEmptyDeleteRequestWithNoSetContentType(string $method, $content, ?string $contentType): bool
123
+    {
124 124
     return false === ('DELETE' === $method && empty($content) && empty($contentType));
125
-  }
125
+    }
126 126
 
127
-  private function isDecodeable(Request $request): bool
128
-  {
127
+    private function isDecodeable(Request $request): bool
128
+    {
129 129
     if (!in_array($request->getMethod(), ['POST', 'PUT', 'PATCH', 'DELETE'])) {
130
-      return false;
130
+        return false;
131 131
     }
132 132
 
133 133
     return !$this->isFormRequest($request);
134
-  }
134
+    }
135 135
 
136
-  private function isFormRequest(Request $request): bool
137
-  {
136
+    private function isFormRequest(Request $request): bool
137
+    {
138 138
     $contentTypeParts = explode(';', $request->headers->get('Content-Type', ''));
139 139
 
140 140
     if (isset($contentTypeParts[0])) {
141
-      return in_array($contentTypeParts[0], ['multipart/form-data', 'application/x-www-form-urlencoded']);
141
+        return in_array($contentTypeParts[0], ['multipart/form-data', 'application/x-www-form-urlencoded']);
142 142
     }
143 143
 
144 144
     return false;
145
-  }
145
+    }
146 146
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/EventListener/SecuredContentPushListener.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 use SWP\Bundle\CoreBundle\Model\OrganizationInterface;
21 21
 use SWP\Component\MultiTenancy\Context\TenantContextInterface;
22 22
 use Symfony\Component\HttpFoundation\Response;
23
-use Symfony\Component\HttpKernel\Event\RequestEvent ;
23
+use Symfony\Component\HttpKernel\Event\RequestEvent;
24 24
 
25 25
 class SecuredContentPushListener
26 26
 {
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/EventListener/CurrentDeviceListener.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 namespace SWP\Bundle\CoreBundle\EventListener;
16 16
 
17 17
 use SWP\Bundle\CoreBundle\Detection\DeviceDetectionInterface;
18
-use Symfony\Component\HttpKernel\Event\RequestEvent ;
18
+use Symfony\Component\HttpKernel\Event\RequestEvent;
19 19
 use Symfony\Component\HttpKernel\HttpKernelInterface;
20 20
 
21 21
 class CurrentDeviceListener
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/SubscriptionController.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -28,24 +28,24 @@  discard block
 block discarded – undo
28 28
 
29 29
 class SubscriptionController extends Controller {
30 30
 
31
-  private SubscriptionsProviderInterface $subscriptionsProvider;
32
-  private RepositoryInterface $userRepository;
33
-
34
-  /**
35
-   * @param SubscriptionsProviderInterface $subscriptionsProvider
36
-   * @param RepositoryInterface $userRepository
37
-   */
38
-  public function __construct(SubscriptionsProviderInterface $subscriptionsProvider,
39
-                              RepositoryInterface            $userRepository) {
31
+    private SubscriptionsProviderInterface $subscriptionsProvider;
32
+    private RepositoryInterface $userRepository;
33
+
34
+    /**
35
+     * @param SubscriptionsProviderInterface $subscriptionsProvider
36
+     * @param RepositoryInterface $userRepository
37
+     */
38
+    public function __construct(SubscriptionsProviderInterface $subscriptionsProvider,
39
+                                RepositoryInterface            $userRepository) {
40 40
     $this->subscriptionsProvider = $subscriptionsProvider;
41 41
     $this->userRepository = $userRepository;
42
-  }
42
+    }
43 43
 
44 44
 
45
-  /**
46
-   * @Route("/api/{version}/subscriptions/{userId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_paywall_list_subscriptions", requirements={"id"="\d+"})
47
-   */
48
-  public function getAction(Request $request, int $userId) {
45
+    /**
46
+     * @Route("/api/{version}/subscriptions/{userId}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_paywall_list_subscriptions", requirements={"id"="\d+"})
47
+     */
48
+    public function getAction(Request $request, int $userId) {
49 49
     $subscriptionsProvider = $this->subscriptionsProvider;
50 50
 
51 51
     $filters = [
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
58 58
     $subscriptions = $subscriptionsProvider->getSubscriptions($user, $filters);
59 59
 
60 60
     return new SingleResourceResponse($subscriptions);
61
-  }
61
+    }
62 62
 
63
-  private function findOr404(int $id) {
63
+    private function findOr404(int $id) {
64 64
     $user = $this->userRepository->findOneById($id);
65 65
 
66 66
     if (!$user instanceof UserInterface) {
67
-      throw new NotFoundHttpException(sprintf('User with id "%s" was not found.', $id));
67
+        throw new NotFoundHttpException(sprintf('User with id "%s" was not found.', $id));
68 68
     }
69 69
 
70 70
     return $user;
71
-  }
71
+    }
72 72
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/CoreBundle/Controller/ExternalDataController.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -29,40 +29,40 @@  discard block
 block discarded – undo
29 29
 
30 30
 class ExternalDataController extends AbstractController {
31 31
 
32
-  private PackageRepositoryInterface $packageRepository;
33
-  private FactoryInterface $factory;
34
-
35
-  /**
36
-   * @param PackageRepositoryInterface $packageRepository
37
-   * @param FactoryInterface $factory
38
-   */
39
-  public function __construct(PackageRepositoryInterface $packageRepository, FactoryInterface $factory) {
32
+    private PackageRepositoryInterface $packageRepository;
33
+    private FactoryInterface $factory;
34
+
35
+    /**
36
+     * @param PackageRepositoryInterface $packageRepository
37
+     * @param FactoryInterface $factory
38
+     */
39
+    public function __construct(PackageRepositoryInterface $packageRepository, FactoryInterface $factory) {
40 40
     $this->packageRepository = $packageRepository;
41 41
     $this->factory = $factory;
42
-  }
42
+    }
43 43
 
44
-  /**
45
-   * @Route("/api/{version}/packages/extra/{slug}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PUT"}, name="swp_api_core_add_extra_data")
46
-   */
47
-  public function setAction(Request $request, string $slug): SingleResourceResponseInterface {
44
+    /**
45
+     * @Route("/api/{version}/packages/extra/{slug}", options={"expose"=true}, defaults={"version"="v2"}, methods={"PUT"}, name="swp_api_core_add_extra_data")
46
+     */
47
+    public function setAction(Request $request, string $slug): SingleResourceResponseInterface {
48 48
     $packageRepository = $this->packageRepository;
49 49
     $existingPackage = $packageRepository->findOneBy(['slugline' => $slug]);
50 50
     if (null === $existingPackage) {
51
-      throw new NotFoundHttpException(sprintf('Package with slug %s was not found', $slug));
51
+        throw new NotFoundHttpException(sprintf('Package with slug %s was not found', $slug));
52 52
     }
53 53
 
54 54
     $externalData = $existingPackage->getExternalData();
55 55
     if (null === $externalData) {
56
-      foreach ($externalData as $data) {
56
+        foreach ($externalData as $data) {
57 57
         $packageRepository->remove($data);
58
-      }
59
-      $packageRepository->flush();
58
+        }
59
+        $packageRepository->flush();
60 60
     }
61 61
 
62 62
     if (null !== $request->getContent()) {
63
-      $validJson = self::getArrayFromJson($request->getContent());
64
-      $responseData = [];
65
-      foreach ($validJson as $key => $value) {
63
+        $validJson = self::getArrayFromJson($request->getContent());
64
+        $responseData = [];
65
+        foreach ($validJson as $key => $value) {
66 66
         /** @var ExternalDataInterface $externalData */
67 67
         $externalData = $this->factory->create();
68 68
         $externalData->setKey($key);
@@ -70,45 +70,45 @@  discard block
 block discarded – undo
70 70
         $externalData->setPackage($existingPackage);
71 71
         $packageRepository->persist($externalData);
72 72
         $responseData[$externalData->getKey()] = $externalData->getValue();
73
-      }
74
-      $packageRepository->flush();
73
+        }
74
+        $packageRepository->flush();
75 75
 
76
-      return new SingleResourceResponse($responseData, new ResponseContext(200));
76
+        return new SingleResourceResponse($responseData, new ResponseContext(200));
77 77
     }
78 78
 
79 79
     return new SingleResourceResponse(['Provided request content is not valid JSON'], new ResponseContext(400));
80
-  }
80
+    }
81 81
 
82
-  /**
83
-   * @Route("/api/{version}/packages/extra/{slug}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_extra_data")
84
-   */
85
-  public function getAction(string $slug): SingleResourceResponseInterface {
82
+    /**
83
+     * @Route("/api/{version}/packages/extra/{slug}", options={"expose"=true}, defaults={"version"="v2"}, methods={"GET"}, name="swp_api_core_get_extra_data")
84
+     */
85
+    public function getAction(string $slug): SingleResourceResponseInterface {
86 86
     $packageRepository = $this->packageRepository;
87 87
     $existingPackage = $packageRepository->findOneBy(['slugline' => $slug]);
88 88
     if (null === $existingPackage) {
89
-      throw new NotFoundHttpException(sprintf('package with slug %s was not found', $slug));
89
+        throw new NotFoundHttpException(sprintf('package with slug %s was not found', $slug));
90 90
     }
91 91
 
92 92
     $externalData = $existingPackage->getExternalData();
93 93
     if (null === $externalData) {
94
-      return new SingleResourceResponse([], new ResponseContext(200));
94
+        return new SingleResourceResponse([], new ResponseContext(200));
95 95
     }
96 96
 
97 97
     $responseData = [];
98 98
     /** @var ExternalDataInterface $data */
99 99
     foreach ($externalData as $data) {
100
-      $responseData[$data->getKey()] = $data->getValue();
100
+        $responseData[$data->getKey()] = $data->getValue();
101 101
     }
102 102
 
103 103
     return new SingleResourceResponse($responseData, new ResponseContext(200));
104
-  }
104
+    }
105 105
 
106
-  private static function getArrayFromJson($jsonString) {
106
+    private static function getArrayFromJson($jsonString) {
107 107
     $jsonArray = json_decode($jsonString, true);
108 108
     if (null === $jsonArray || JSON_ERROR_NONE !== json_last_error()) {
109
-      throw new \UnexpectedValueException('Provided request content is not valid JSON');
109
+        throw new \UnexpectedValueException('Provided request content is not valid JSON');
110 110
     }
111 111
 
112 112
     return $jsonArray;
113
-  }
113
+    }
114 114
 }
Please login to merge, or discard this patch.