@@ -65,7 +65,7 @@ |
||
65 | 65 | public function registerPeriodicTimer(Topic $topic): void |
66 | 66 | { |
67 | 67 | $n = 1; |
68 | - $this->periodicTimer->addPeriodicTimer($this, 'ping', 5, function () use ($topic, &$n) { |
|
68 | + $this->periodicTimer->addPeriodicTimer($this, 'ping', 5, function() use ($topic, &$n) { |
|
69 | 69 | $topic->broadcast(['ping' => $n]); |
70 | 70 | |
71 | 71 | ++$n; |
@@ -162,6 +162,6 @@ |
||
162 | 162 | */ |
163 | 163 | private function dispatchRouteEvent($eventName, RouteInterface $route) |
164 | 164 | { |
165 | - $this->eventDispatcher->dispatch(new RouteEvent($route, $eventName), $eventName); |
|
165 | + $this->eventDispatcher->dispatch(new RouteEvent($route, $eventName), $eventName); |
|
166 | 166 | } |
167 | 167 | } |
@@ -25,166 +25,166 @@ |
||
25 | 25 | use SWP\Component\Storage\Model\PersistableInterface; |
26 | 26 | |
27 | 27 | interface ArticleInterface extends TimestampableInterface, TimestampableCancelInterface, RuleSubjectInterface, TranslatableInterface, PersistableInterface, SoftDeletableInterface, MetadataAwareInterface, MediaAwareInterface, AuthorsAwareInterface, KeywordAwareInterface, RelatedArticlesAwareInterface, SeoMetadataAwareInterface { |
28 | - const STATUS_NEW = 'new'; |
|
29 | - |
|
30 | - const STATUS_PUBLISHED = 'published'; |
|
31 | - |
|
32 | - const STATUS_UNPUBLISHED = 'unpublished'; |
|
33 | - |
|
34 | - const STATUS_CANCELED = 'canceled'; |
|
35 | - |
|
36 | - /** |
|
37 | - * @return mixed |
|
38 | - */ |
|
39 | - public function getId(); |
|
40 | - |
|
41 | - /** |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function getBody(); |
|
45 | - |
|
46 | - /** |
|
47 | - * @param string $body |
|
48 | - */ |
|
49 | - public function setBody($body); |
|
28 | + const STATUS_NEW = 'new'; |
|
29 | + |
|
30 | + const STATUS_PUBLISHED = 'published'; |
|
31 | + |
|
32 | + const STATUS_UNPUBLISHED = 'unpublished'; |
|
33 | + |
|
34 | + const STATUS_CANCELED = 'canceled'; |
|
35 | + |
|
36 | + /** |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | + public function getId(); |
|
40 | + |
|
41 | + /** |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function getBody(); |
|
45 | + |
|
46 | + /** |
|
47 | + * @param string $body |
|
48 | + */ |
|
49 | + public function setBody($body); |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - public function getTitle(); |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + public function getTitle(); |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $title |
|
58 | - */ |
|
59 | - public function setTitle($title); |
|
56 | + /** |
|
57 | + * @param string $title |
|
58 | + */ |
|
59 | + public function setTitle($title); |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function getSlug(); |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function getSlug(); |
|
65 | 65 | |
66 | - /** |
|
67 | - * @param string $slug |
|
68 | - */ |
|
69 | - public function setSlug($slug); |
|
66 | + /** |
|
67 | + * @param string $slug |
|
68 | + */ |
|
69 | + public function setSlug($slug); |
|
70 | 70 | |
71 | - /** |
|
72 | - * @return \DateTime |
|
73 | - */ |
|
74 | - public function getPublishedAt(); |
|
71 | + /** |
|
72 | + * @return \DateTime |
|
73 | + */ |
|
74 | + public function getPublishedAt(); |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $publishedAt |
|
78 | - * |
|
79 | - * @return \DateTime |
|
80 | - */ |
|
81 | - public function setPublishedAt(\DateTime $publishedAt); |
|
76 | + /** |
|
77 | + * @param string $publishedAt |
|
78 | + * |
|
79 | + * @return \DateTime |
|
80 | + */ |
|
81 | + public function setPublishedAt(\DateTime $publishedAt); |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return bool |
|
85 | - */ |
|
86 | - public function isPublished(); |
|
83 | + /** |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | + public function isPublished(); |
|
87 | 87 | |
88 | - /** |
|
89 | - * @param string $status |
|
90 | - * |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public function setStatus($status); |
|
88 | + /** |
|
89 | + * @param string $status |
|
90 | + * |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public function setStatus($status); |
|
94 | 94 | |
95 | - /** |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function getStatus(); |
|
95 | + /** |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function getStatus(); |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function getTemplateName(); |
|
100 | + /** |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function getTemplateName(); |
|
104 | 104 | |
105 | - /** |
|
106 | - * @param string $templateName |
|
107 | - */ |
|
108 | - public function setTemplateName($templateName); |
|
105 | + /** |
|
106 | + * @param string $templateName |
|
107 | + */ |
|
108 | + public function setTemplateName($templateName); |
|
109 | 109 | |
110 | - /** |
|
111 | - * @param RouteInterface|void $route |
|
112 | - */ |
|
113 | - public function setRoute(RouteInterface $route = null); |
|
110 | + /** |
|
111 | + * @param RouteInterface|void $route |
|
112 | + */ |
|
113 | + public function setRoute(RouteInterface $route = null); |
|
114 | 114 | |
115 | - /** |
|
116 | - * @return RouteInterface |
|
117 | - */ |
|
118 | - public function getRoute(); |
|
115 | + /** |
|
116 | + * @return RouteInterface |
|
117 | + */ |
|
118 | + public function getRoute(); |
|
119 | 119 | |
120 | - /** |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function getLead(); |
|
120 | + /** |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function getLead(); |
|
124 | 124 | |
125 | - /** |
|
126 | - * @param string $lead |
|
127 | - */ |
|
128 | - public function setLead($lead); |
|
125 | + /** |
|
126 | + * @param string $lead |
|
127 | + */ |
|
128 | + public function setLead($lead); |
|
129 | 129 | |
130 | - public function getCode(): string; |
|
130 | + public function getCode(): string; |
|
131 | 131 | |
132 | - public function setCode(string $code); |
|
132 | + public function setCode(string $code); |
|
133 | 133 | |
134 | - public function addSourceReference(ArticleSourceReferenceInterface $source); |
|
134 | + public function addSourceReference(ArticleSourceReferenceInterface $source); |
|
135 | 135 | |
136 | - public function removeSourceReference(ArticleSourceReferenceInterface $source); |
|
136 | + public function removeSourceReference(ArticleSourceReferenceInterface $source); |
|
137 | 137 | |
138 | - public function hasSourceReference(ArticleSourceReferenceInterface $source): bool; |
|
138 | + public function hasSourceReference(ArticleSourceReferenceInterface $source): bool; |
|
139 | 139 | |
140 | - /** |
|
141 | - * @return Collection|ArticleSourceReferenceInterface[] |
|
142 | - */ |
|
143 | - public function getSources(): Collection; |
|
140 | + /** |
|
141 | + * @return Collection|ArticleSourceReferenceInterface[] |
|
142 | + */ |
|
143 | + public function getSources(): Collection; |
|
144 | 144 | |
145 | - public function getExtra(): array; |
|
145 | + public function getExtra(): array; |
|
146 | 146 | |
147 | - public function setExtra(?array $extra): void; |
|
147 | + public function setExtra(?array $extra): void; |
|
148 | 148 | |
149 | - public function getSlideshows(): Collection; |
|
149 | + public function getSlideshows(): Collection; |
|
150 | 150 | |
151 | - public function hasSlideshow(SlideshowInterface $slideshow): bool; |
|
151 | + public function hasSlideshow(SlideshowInterface $slideshow): bool; |
|
152 | 152 | |
153 | - public function addSlideshow(SlideshowInterface $slideshow): void; |
|
153 | + public function addSlideshow(SlideshowInterface $slideshow): void; |
|
154 | 154 | |
155 | - public function removeSlideshow(SlideshowInterface $slideshow): void; |
|
155 | + public function removeSlideshow(SlideshowInterface $slideshow): void; |
|
156 | 156 | |
157 | - public function getPreviousRelativeUrl(): Collection; |
|
157 | + public function getPreviousRelativeUrl(): Collection; |
|
158 | 158 | |
159 | - public function hasPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): bool; |
|
159 | + public function hasPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): bool; |
|
160 | 160 | |
161 | - public function addPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void; |
|
161 | + public function addPreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void; |
|
162 | 162 | |
163 | - public function removePreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void; |
|
163 | + public function removePreviousRelativeUrl(ArticlePreviousRelativeUrlInterface $previousRelativeUrl): void; |
|
164 | 164 | |
165 | - public function getData(): ?MetadataInterface; |
|
165 | + public function getData(): ?MetadataInterface; |
|
166 | 166 | |
167 | - public function setData(?MetadataInterface $metadata): void; |
|
167 | + public function setData(?MetadataInterface $metadata): void; |
|
168 | 168 | |
169 | - public function getExtraTextFields(): Collection; |
|
169 | + public function getExtraTextFields(): Collection; |
|
170 | 170 | |
171 | - public function getExtraEmbedFields(): Collection; |
|
171 | + public function getExtraEmbedFields(): Collection; |
|
172 | 172 | |
173 | - public function setExtraFields(array $extra): void; |
|
173 | + public function setExtraFields(array $extra): void; |
|
174 | 174 | |
175 | - public function getExtraByKey(string $key): ?ArticleExtraFieldInterface; |
|
175 | + public function getExtraByKey(string $key): ?ArticleExtraFieldInterface; |
|
176 | 176 | |
177 | - public function getExtraArray(): array; |
|
177 | + public function getExtraArray(): array; |
|
178 | 178 | |
179 | - public function isPublishable(): bool; |
|
179 | + public function isPublishable(): bool; |
|
180 | 180 | |
181 | - public function setPublishable(bool $boolean): void; |
|
181 | + public function setPublishable(bool $boolean): void; |
|
182 | 182 | |
183 | - public function setPublishStartDate(\DateTime $startDate = null); |
|
183 | + public function setPublishStartDate(\DateTime $startDate = null); |
|
184 | 184 | |
185 | - public function getPublishStartDate(); |
|
185 | + public function getPublishStartDate(); |
|
186 | 186 | |
187 | - public function setPublishEndDate(\DateTime $endDate = null); |
|
187 | + public function setPublishEndDate(\DateTime $endDate = null); |
|
188 | 188 | |
189 | - public function getPublishEndDate(); |
|
189 | + public function getPublishEndDate(); |
|
190 | 190 | } |
@@ -39,7 +39,7 @@ |
||
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 |
@@ -39,7 +39,7 @@ |
||
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 |
@@ -30,7 +30,7 @@ |
||
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 |
@@ -106,15 +106,15 @@ |
||
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 | } |
@@ -28,25 +28,25 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -32,27 +32,27 @@ discard block |
||
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 |
||
106 | 106 | ); |
107 | 107 | |
108 | 108 | return new ResourcesListResponse($pagination, $responseContext); |
109 | - } |
|
109 | + } |
|
110 | 110 | } |
@@ -53,7 +53,7 @@ discard block |
||
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 |
||
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 | ); |
@@ -105,7 +105,7 @@ |
||
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 { |
@@ -28,35 +28,35 @@ discard block |
||
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 |
||
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 | } |