Skip to content

Commit ef6f4b3

Browse files
committed
CS Fixes
1 parent 1d43033 commit ef6f4b3

File tree

9 files changed

+79
-73
lines changed

9 files changed

+79
-73
lines changed

bundle/Controller/Admin/AdminController.php

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Netgen\Bundle\InformationCollectionBundle\Controller\Admin;
46

5-
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
6-
use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute;
77
use Ibexa\Bundle\Core\Controller;
88
use Ibexa\Contracts\Core\Repository\ContentService;
9+
use Ibexa\Contracts\Core\Repository\Values\Content\Content;
910
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
11+
use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute;
1012
use Netgen\Bundle\InformationCollectionBundle\Form\Builder\FormBuilder;
1113
use Netgen\InformationCollection\API\Persistence\Anonymizer\Anonymizer;
1214
use Netgen\InformationCollection\API\Service\InformationCollection;
1315
use Netgen\InformationCollection\API\Value\Collection;
1416
use Netgen\InformationCollection\API\Value\Filter\CollectionFields;
15-
use Netgen\InformationCollection\API\Value\Filter\Collections;
1617
use Netgen\InformationCollection\API\Value\Filter\CollectionId;
18+
use Netgen\InformationCollection\API\Value\Filter\Collections;
1719
use Netgen\InformationCollection\API\Value\Filter\ContentId;
1820
use Netgen\InformationCollection\API\Value\Filter\Contents;
1921
use Netgen\InformationCollection\API\Value\Filter\Query;
@@ -31,6 +33,10 @@
3133
use Symfony\Component\HttpFoundation\Response;
3234
use Symfony\Contracts\Translation\TranslatorInterface;
3335

36+
use function array_merge;
37+
use function count;
38+
use function time;
39+
3440
class AdminController extends Controller
3541
{
3642
protected InformationCollection $service;
@@ -60,8 +66,7 @@ public function __construct(
6066
EzInfoCollectionRepository $infoCollectionRepository,
6167
EzInfoCollectionAttributeRepository $infoCollectionAttributeRepository,
6268
FormBuilder $builder
63-
)
64-
{
69+
) {
6570
$this->service = $service;
6671
$this->contentService = $contentService;
6772
$this->configResolver = $configResolver;
@@ -74,7 +79,7 @@ public function __construct(
7479
}
7580

7681
/**
77-
* Displays overview page
82+
* Displays overview page.
7883
*/
7984
public function overviewAction(Request $request): Response
8085
{
@@ -83,27 +88,27 @@ public function overviewAction(Request $request): Response
8388
$adapter = new InformationCollectionContentsAdapter($this->service, Query::countQuery());
8489
$pager = $this->getPager($adapter, (int) $request->query->get('page'));
8590

86-
return $this->render("@NetgenInformationCollection/admin/overview.html.twig", ['objects' => $pager]);
91+
return $this->render('@NetgenInformationCollection/admin/overview.html.twig', ['objects' => $pager]);
8792
}
8893

8994
/**
90-
* Displays list of collection for selected Content
95+
* Displays list of collection for selected Content.
9196
*/
9297
public function collectionListAction(Request $request, Content $content): Response
9398
{
9499
$this->checkReadPermissions();
95100

96101
$adapter = new InformationCollectionCollectionListAdapter($this->service, ContentId::withContentId($content->id));
97-
$pager = $this->getPager($adapter, (int)$request->query->get('page'));
102+
$pager = $this->getPager($adapter, (int) $request->query->get('page'));
98103

99-
return $this->render("@NetgenInformationCollection/admin/collection_list.html.twig", [
104+
return $this->render('@NetgenInformationCollection/admin/collection_list.html.twig', [
100105
'objects' => $pager,
101106
'content' => $content,
102107
]);
103108
}
104109

105110
/**
106-
* Handles collection search
111+
* Handles collection search.
107112
*/
108113
public function searchAction(Request $request, Content $content): Response
109114
{
@@ -112,9 +117,10 @@ public function searchAction(Request $request, Content $content): Response
112117
$query = SearchQuery::withContentAndSearchText($content->id, $request->query->get('searchText'));
113118

114119
$adapter = new InformationCollectionCollectionListSearchAdapter($this->service, $query);
115-
$pager = $this->getPager($adapter, (int)$request->query->get('page'));
120+
$pager = $this->getPager($adapter, (int) $request->query->get('page'));
116121

117-
return $this->render("@NetgenInformationCollection/admin/collection_list.html.twig",
122+
return $this->render(
123+
'@NetgenInformationCollection/admin/collection_list.html.twig',
118124
[
119125
'objects' => $pager,
120126
'content' => $content,
@@ -123,20 +129,20 @@ public function searchAction(Request $request, Content $content): Response
123129
}
124130

125131
/**
126-
* Displays individual collection details
132+
* Displays individual collection details.
127133
*/
128134
public function viewAction(Collection $collection): Response
129135
{
130136
$this->checkReadPermissions();
131137

132-
return $this->render("@NetgenInformationCollection/admin/view.html.twig", [
138+
return $this->render('@NetgenInformationCollection/admin/view.html.twig', [
133139
'collection' => $collection,
134140
'content' => $collection->getContent(),
135141
]);
136142
}
137143

138144
/**
139-
* Handles actions performed on overview page
145+
* Handles actions performed on overview page.
140146
*/
141147
public function handleContentsAction(Request $request): RedirectResponse
142148
{
@@ -152,7 +158,6 @@ public function handleContentsAction(Request $request): RedirectResponse
152158
}
153159

154160
if ($request->request->has('DeleteCollectionByContentAction')) {
155-
156161
$this->checkDeletePermissions();
157162

158163
$query = new Contents($contents);
@@ -170,7 +175,7 @@ public function handleContentsAction(Request $request): RedirectResponse
170175
}
171176

172177
/**
173-
* Handles actions performed on collection list page
178+
* Handles actions performed on collection list page.
174179
*/
175180
public function handleCollectionListAction(Request $request): RedirectResponse
176181
{
@@ -187,7 +192,6 @@ public function handleCollectionListAction(Request $request): RedirectResponse
187192
}
188193

189194
if ($request->request->has('DeleteCollectionAction')) {
190-
191195
$this->checkDeletePermissions();
192196

193197
$query = new Collections($contentId, $collections);
@@ -200,7 +204,6 @@ public function handleCollectionListAction(Request $request): RedirectResponse
200204
}
201205

202206
if ($request->request->has('AnonymizeCollectionAction')) {
203-
204207
$this->checkAnonymizePermissions();
205208

206209
foreach ($collections as $collection) {
@@ -218,7 +221,7 @@ public function handleCollectionListAction(Request $request): RedirectResponse
218221
}
219222

220223
/**
221-
* Handles action on collection details page
224+
* Handles action on collection details page.
222225
*/
223226
public function handleCollectionAction(Request $request): RedirectResponse
224227
{
@@ -239,7 +242,6 @@ public function handleCollectionAction(Request $request): RedirectResponse
239242
}
240243

241244
if ($request->request->has('DeleteFieldAction')) {
242-
243245
$this->checkDeletePermissions();
244246

245247
$query = new CollectionFields($contentId, $collectionId, $fields);
@@ -252,7 +254,6 @@ public function handleCollectionAction(Request $request): RedirectResponse
252254
}
253255

254256
if ($request->request->has('AnonymizeFieldAction')) {
255-
256257
$this->checkAnonymizePermissions();
257258

258259
$this->anonymizer->anonymizeCollection($collectionId, $fields);
@@ -263,25 +264,22 @@ public function handleCollectionAction(Request $request): RedirectResponse
263264
}
264265

265266
if ($request->request->has('DeleteCollectionAction')) {
266-
267267
$this->checkDeletePermissions();
268268

269269
$query = new Collections($contentId, [$collectionId]);
270270
$this->service->deleteCollections($query);
271271

272-
$this->addFlashMessage("success", "collection_removed");
272+
$this->addFlashMessage('success', 'collection_removed');
273273

274274
return $this->redirectToRoute('netgen_information_collection.route.admin.collection_list', ['contentId' => $contentId]);
275-
276275
}
277276

278277
if ($request->request->has('AnonymizeCollectionAction')) {
279-
280278
$this->checkAnonymizePermissions();
281279

282280
$this->anonymizer->anonymizeCollection($collectionId);
283281

284-
$this->addFlashMessage("success", "collection_anonymized");
282+
$this->addFlashMessage('success', 'collection_anonymized');
285283

286284
return $this->redirectToRoute('netgen_information_collection.route.admin.view', ['collectionId' => $collectionId]);
287285
}
@@ -355,19 +353,17 @@ public function editAction(Request $request, int $collectionId)
355353
);
356354
}
357355

358-
return $this->render("@NetgenInformationCollection/admin/edit.html.twig", [
356+
return $this->render('@NetgenInformationCollection/admin/edit.html.twig', [
359357
'collection' => $collection,
360358
'content' => $location->getContent(),
361359
'form' => $form->createView(),
362360
]);
363361
}
364362

365-
366-
367363
/**
368364
* Adds a flash message with specified parameters.
369365
*/
370-
protected function addFlashMessage(string $messageType, string $message, int $count = 1, array $parameters = array()): void
366+
protected function addFlashMessage(string $messageType, string $message, int $count = 1, array $parameters = []): void
371367
{
372368
$parameters = array_merge($parameters, ['count' => $count]);
373369

@@ -382,7 +378,7 @@ protected function addFlashMessage(string $messageType, string $message, int $co
382378
}
383379

384380
/**
385-
* Returns configured instance of Pagerfanta
381+
* Returns configured instance of Pagerfanta.
386382
*/
387383
protected function getPager(AdapterInterface $adapter, int $currentPage): Pagerfanta
388384
{

bundle/Form/Builder/FormBuilder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Netgen\Bundle\InformationCollectionBundle\Form\Builder;
46

57
use Ibexa\Contracts\Core\Repository\Values\Content\Location;
@@ -21,12 +23,12 @@
2123
class FormBuilder
2224
{
2325
public function __construct(
24-
protected readonly FormFactoryInterface $formFactory,
25-
protected readonly ContentTypeService $contentTypeService,
26-
protected readonly RouterInterface $router,
26+
protected readonly FormFactoryInterface $formFactory,
27+
protected readonly ContentTypeService $contentTypeService,
28+
protected readonly RouterInterface $router,
2729
protected readonly ConfigResolverInterface $configResolver,
28-
protected readonly FieldDataFactory $legacyFactory,
29-
protected readonly FieldHandlerRegistry $registry
30+
protected readonly FieldDataFactory $legacyFactory,
31+
protected readonly FieldHandlerRegistry $registry
3032
) {
3133
}
3234

@@ -37,14 +39,12 @@ public function createUpdateFormForLocation(Location $location, Collection $coll
3739
$struct = new InformationCollectionStruct();
3840

3941
foreach ($collection->getAttributes() as $attribute) {
40-
4142
$fieldValue = $this->fromLegacyValue(
4243
new FieldValue(
4344
$attribute->getField()->id,
4445
$attribute->getValue()->getDataText(),
4546
$attribute->getValue()->getDataInt(),
4647
$attribute->getValue()->getDataFloat()
47-
4848
),
4949
$attribute->getFieldDefinition()
5050
);

bundle/Form/InformationCollectionUpdateType.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Netgen\Bundle\InformationCollectionBundle\Form;
46

57
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
@@ -14,6 +16,9 @@
1416
use Symfony\Component\Form\FormBuilderInterface;
1517
use Symfony\Component\OptionsResolver\OptionsResolver;
1618

19+
use function array_keys;
20+
use function in_array;
21+
1722
class InformationCollectionUpdateType extends AbstractContentType
1823
{
1924
protected FieldTypeHandlerRegistry $fieldTypeHandlerRegistry;
@@ -24,8 +29,8 @@ class InformationCollectionUpdateType extends AbstractContentType
2429

2530
public function __construct(
2631
FieldTypeHandlerRegistry $fieldTypeHandlerRegistry,
27-
DataMapperInterface $dataMapper,
28-
ConfigResolverInterface $configResolver
32+
DataMapperInterface $dataMapper,
33+
ConfigResolverInterface $configResolver
2934
) {
3035
parent::__construct($fieldTypeHandlerRegistry, $dataMapper);
3136
$this->configResolver = $configResolver;
@@ -38,7 +43,6 @@ public function getName(): string
3843

3944
/**
4045
* Returns the prefix of the template block name for this type.
41-
*
4246
*/
4347
public function getBlockPrefix(): string
4448
{
@@ -122,5 +126,3 @@ protected function getLanguageCode(ContentType $contentType): string
122126
return $contentType->mainLanguageCode;
123127
}
124128
}
125-
126-

lib/Core/Persistence/FieldHandler/Custom/BirthdayFieldHandler.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
46

5-
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
6-
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
7-
use Ibexa\Core\FieldType\Value;
87
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
8+
use Ibexa\Core\FieldType\Value;
99
use Netgen\Bundle\BirthdayBundle\Core\FieldType\Birthday\Value as BirthdayValue;
10+
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
11+
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
1012

1113
class BirthdayFieldHandler implements CustomLegacyFieldHandlerInterface
1214
{
1315
/**
14-
* @inheritDoc
16+
* {@inheritDoc}
1517
*/
1618
public function supports(Value $value): bool
1719
{
1820
return $value instanceof BirthdayValue;
1921
}
2022

2123
/**
22-
* @inheritDoc
24+
* {@inheritDoc}
2325
*/
2426
public function toString(Value $value, FieldDefinition $fieldDefinition): string
2527
{
2628
return (string) $value;
2729
}
2830

2931
/**
30-
* @inheritDoc
32+
* {@inheritDoc}
3133
*/
3234
public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
3335
{
3436
return new FieldValue($fieldDefinition->id, (string) $value, 0, 0);
3537
}
3638

3739
/**
38-
* @inheritDoc
40+
* {@inheritDoc}
3941
*/
4042
public function fromLegacyValue(FieldValue $legacyData)
4143
{

lib/Core/Persistence/FieldHandler/Custom/CountryFieldHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
66

77
use Ibexa\Contracts\Core\Repository\Values\ContentType\FieldDefinition;
8-
use Ibexa\Core\FieldType\Checkbox\Value as CheckboxValue;
98
use Ibexa\Core\FieldType\Country\Value as CountryValue;
109
use Ibexa\Core\FieldType\Value;
1110
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
1211
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
12+
1313
use function array_column;
1414
use function implode;
1515

0 commit comments

Comments
 (0)