diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml
index 5b0323a5..3b9abf45 100644
--- a/.github/workflows/run-test.yml
+++ b/.github/workflows/run-test.yml
@@ -35,7 +35,5 @@ jobs:
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install Dependencies
run: composer install --no-scripts --no-ansi --no-interaction --no-progress
- - name: Run PHP Code Sniffer
- run: vendor/bin/phpcs -p ./src
- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress -c phpstan.neon
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 865ab9a1..00000000
--- a/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-
-test:
- php -d "memory_limit=-1" vendor/bin/phpcs --report=full --report-file=./report.txt -p ./
- php -d "memory_limit=-1" vendor/bin/phpstan analyse -c phpstan.neon
-
diff --git a/composer.json b/composer.json
index 84e8b005..cc99b80b 100644
--- a/composer.json
+++ b/composer.json
@@ -69,8 +69,7 @@
"phpstan/phpstan-doctrine": "^1.3",
"roadiz/entity-generator": "2.4.x-dev",
"roadiz/jwt": "2.4.x-dev",
- "roadiz/random": "2.4.x-dev",
- "squizlabs/php_codesniffer": "^3.5"
+ "roadiz/random": "2.4.x-dev"
},
"autoload": {
"psr-4": {
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
deleted file mode 100644
index 8e43eb01..00000000
--- a/phpcs.xml.dist
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- ./
- *.js
- *.vue
- */Resources/app
- */node_modules
- */.AppleDouble
- */vendor
- */cache
- */gen-src
- */tests
- */bin
- */themes
- .data/*
-
diff --git a/src/AjaxControllers/AbstractAjaxController.php b/src/AjaxControllers/AbstractAjaxController.php
index 54027996..a56cc6a1 100644
--- a/src/AjaxControllers/AbstractAjaxController.php
+++ b/src/AjaxControllers/AbstractAjaxController.php
@@ -20,7 +20,7 @@
abstract class AbstractAjaxController extends RozierApp
{
public function __construct(
- protected readonly SerializerInterface $serializer
+ protected readonly SerializerInterface $serializer,
) {
}
@@ -46,11 +46,7 @@ protected function getTranslation(Request $request): ?TranslationInterface
}
/**
- * @param Request $request
- * @param string $method
- * @param bool $requestCsrfToken
- *
- * @return bool Return true if request is valid, else throw exception
+ * @return bool Return true if request is valid, else throw exception
*/
protected function validateRequest(Request $request, string $method = 'POST', bool $requestCsrfToken = true): bool
{
@@ -59,15 +55,15 @@ protected function validateRequest(Request $request, string $method = 'POST', bo
}
if (
- $requestCsrfToken === true &&
- !$this->isCsrfTokenValid(static::AJAX_TOKEN_INTENTION, $request->get('_token'))
+ true === $requestCsrfToken
+ && !$this->isCsrfTokenValid(static::AJAX_TOKEN_INTENTION, $request->get('_token'))
) {
throw new BadRequestHttpException('Bad CSRF token');
}
if (
- in_array(\mb_strtolower($method), static::$validMethods) &&
- \mb_strtolower($request->getMethod()) != \mb_strtolower($method)
+ in_array(\mb_strtolower($method), static::$validMethods)
+ && \mb_strtolower($request->getMethod()) != \mb_strtolower($method)
) {
throw new BadRequestHttpException('Bad method');
}
@@ -84,7 +80,7 @@ protected function sortIsh(array &$arr, array $map): array
if ($element == $value->getId()) {
$return[] = $value;
unset($arr[$key]);
- break 1;
+ break;
}
}
}
@@ -92,10 +88,6 @@ protected function sortIsh(array &$arr, array $map): array
return $return;
}
- /**
- * @param array $data
- * @return JsonResponse
- */
protected function createSerializedResponse(array $data): JsonResponse
{
return new JsonResponse(
@@ -105,7 +97,7 @@ protected function createSerializedResponse(array $data): JsonResponse
SerializationContext::create()->setGroups([
'document_display',
'explorer_thumbnail',
- 'model'
+ 'model',
])
),
200,
diff --git a/src/AjaxControllers/AjaxAbstractFieldsController.php b/src/AjaxControllers/AjaxAbstractFieldsController.php
index 3fc4ab69..1ba0980c 100644
--- a/src/AjaxControllers/AjaxAbstractFieldsController.php
+++ b/src/AjaxControllers/AjaxAbstractFieldsController.php
@@ -16,7 +16,7 @@ abstract class AjaxAbstractFieldsController extends AbstractAjaxController
{
public function __construct(
protected readonly HandlerFactoryInterface $handlerFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -28,21 +28,16 @@ protected function findEntity(int|string $entityId): ?AbstractField
/**
* Handle actions for any abstract fields.
- *
- * @param Request $request
- * @param AbstractField|null $field
- *
- * @return null|Response
*/
- protected function handleFieldActions(Request $request, AbstractField $field = null): ?Response
+ protected function handleFieldActions(Request $request, ?AbstractField $field = null): ?Response
{
$this->validateRequest($request);
- if ($field !== null) {
+ if (null !== $field) {
/*
* Get the right update method against "_action" parameter
*/
- if ($request->get('_action') !== 'updatePosition') {
+ if ('updatePosition' !== $request->get('_action')) {
throw new BadRequestHttpException('Action does not exist');
}
@@ -57,13 +52,7 @@ protected function handleFieldActions(Request $request, AbstractField $field = n
return null;
}
- /**
- * @param array $parameters
- * @param AbstractField|null $field
- *
- * @return array
- */
- protected function updatePosition(array $parameters, AbstractField $field = null): array
+ protected function updatePosition(array $parameters, ?AbstractField $field = null): array
{
if (!empty($parameters['afterFieldId']) && is_numeric($parameters['afterFieldId'])) {
$afterField = $this->findEntity((int) $parameters['afterFieldId']);
@@ -76,6 +65,7 @@ protected function updatePosition(array $parameters, AbstractField $field = null
$handler = $this->handlerFactory->getHandler($field);
$handler->cleanPositions();
$this->em()->flush();
+
return [
'statusCode' => '200',
'status' => 'success',
@@ -95,6 +85,7 @@ protected function updatePosition(array $parameters, AbstractField $field = null
$handler = $this->handlerFactory->getHandler($field);
$handler->cleanPositions();
$this->em()->flush();
+
return [
'statusCode' => '200',
'status' => 'success',
diff --git a/src/AjaxControllers/AjaxAttributeValuesController.php b/src/AjaxControllers/AjaxAttributeValuesController.php
index a4bc2108..c728aa33 100644
--- a/src/AjaxControllers/AjaxAttributeValuesController.php
+++ b/src/AjaxControllers/AjaxAttributeValuesController.php
@@ -21,9 +21,6 @@ final class AjaxAttributeValuesController extends AbstractAjaxController
* Handle AJAX edition requests for NodeTypeFields
* such as coming from widgets.
*
- * @param Request $request
- * @param int $attributeValueId
- *
* @return Response JSON response
*/
public function editAction(Request $request, int $attributeValueId): Response
@@ -36,13 +33,8 @@ public function editAction(Request $request, int $attributeValueId): Response
/** @var AttributeValue|null $attributeValue */
$attributeValue = $this->em()->find(AttributeValue::class, (int) $attributeValueId);
- if ($attributeValue === null) {
- throw $this->createNotFoundException($this->getTranslator()->trans(
- 'attribute_value.%attributeValueId%.not_exists',
- [
- '%attributeValueId%' => $attributeValueId
- ]
- ));
+ if (null === $attributeValue) {
+ throw $this->createNotFoundException($this->getTranslator()->trans('attribute_value.%attributeValueId%.not_exists', ['%attributeValueId%' => $attributeValueId]));
}
$this->denyAccessUnlessGranted(NodeVoter::EDIT_ATTRIBUTE, $attributeValue->getAttributable());
@@ -79,6 +71,7 @@ protected function updatePosition(array $parameters, AttributeValue $attributeVa
}
$attributeValue->setPosition($afterAttributeValue->getPosition() + 0.5);
$this->em()->flush();
+
return [
'statusCode' => '200',
'status' => 'success',
@@ -96,6 +89,7 @@ protected function updatePosition(array $parameters, AttributeValue $attributeVa
}
$attributeValue->setPosition($beforeAttributeValue->getPosition() - 0.5);
$this->em()->flush();
+
return [
'statusCode' => '200',
'status' => 'success',
diff --git a/src/AjaxControllers/AjaxCustomFormFieldsController.php b/src/AjaxControllers/AjaxCustomFormFieldsController.php
index 4f475a08..7a014d5a 100644
--- a/src/AjaxControllers/AjaxCustomFormFieldsController.php
+++ b/src/AjaxControllers/AjaxCustomFormFieldsController.php
@@ -14,9 +14,6 @@ final class AjaxCustomFormFieldsController extends AjaxAbstractFieldsController
* Handle AJAX edition requests for CustomFormFields
* such as coming from widgets.
*
- * @param Request $request
- * @param int $customFormFieldId
- *
* @return Response JSON response
*/
public function editAction(Request $request, int $customFormFieldId): Response
@@ -30,12 +27,7 @@ public function editAction(Request $request, int $customFormFieldId): Response
return $response;
}
- throw $this->createNotFoundException($this->getTranslator()->trans(
- 'field.%customFormFieldId%.not_exists',
- [
- '%customFormFieldId%' => $customFormFieldId
- ]
- ));
+ throw $this->createNotFoundException($this->getTranslator()->trans('field.%customFormFieldId%.not_exists', ['%customFormFieldId%' => $customFormFieldId]));
}
protected function getEntityClass(): string
diff --git a/src/AjaxControllers/AjaxCustomFormsExplorerController.php b/src/AjaxControllers/AjaxCustomFormsExplorerController.php
index 8450efa2..39834df3 100644
--- a/src/AjaxControllers/AjaxCustomFormsExplorerController.php
+++ b/src/AjaxControllers/AjaxCustomFormsExplorerController.php
@@ -17,14 +17,12 @@ final class AjaxCustomFormsExplorerController extends AbstractAjaxController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
/**
- * @param Request $request
- *
* @return Response JSON response
*/
public function indexAction(Request $request): Response
@@ -60,8 +58,6 @@ public function indexAction(Request $request): Response
/**
* Get a CustomForm list from an array of id.
*
- * @param Request $request
- * @return Response
* @throws NotSupported
*/
public function listAction(Request $request): Response
@@ -73,7 +69,7 @@ public function listAction(Request $request): Response
$this->denyAccessUnlessGranted('ROLE_ACCESS_CUSTOMFORMS');
$cleanCustomFormsIds = array_filter($request->query->filter('ids', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
]));
$customFormsArray = [];
@@ -91,7 +87,7 @@ public function listAction(Request $request): Response
return $this->createSerializedResponse([
'status' => 'confirm',
'statusCode' => 200,
- 'forms' => $customFormsArray
+ 'forms' => $customFormsArray,
]);
}
@@ -99,7 +95,6 @@ public function listAction(Request $request): Response
* Normalize response CustomForm list result.
*
* @param iterable $customForms
- * @return array
*/
private function normalizeCustomForms(iterable $customForms): array
{
diff --git a/src/AjaxControllers/AjaxDocumentsExplorerController.php b/src/AjaxControllers/AjaxDocumentsExplorerController.php
index 17300f07..c2c06817 100644
--- a/src/AjaxControllers/AjaxDocumentsExplorerController.php
+++ b/src/AjaxControllers/AjaxDocumentsExplorerController.php
@@ -16,7 +16,7 @@ final class AjaxDocumentsExplorerController extends AbstractAjaxController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -47,7 +47,7 @@ public function indexAction(Request $request): JsonResponse
Document::class,
$arrayFilter,
[
- 'createdAt' => 'DESC'
+ 'createdAt' => 'DESC',
]
);
$listManager->setDisplayingNotPublishedNodes(true);
@@ -69,7 +69,7 @@ public function indexAction(Request $request): JsonResponse
if ($request->query->has('folderId') && $request->get('folderId') > 0) {
$responseArray['filters'] = array_merge($responseArray['filters'], [
- 'folderId' => $request->get('folderId')
+ 'folderId' => $request->get('folderId'),
]);
}
@@ -80,9 +80,6 @@ public function indexAction(Request $request): JsonResponse
/**
* Get a Document list from an array of id.
- *
- * @param Request $request
- * @return JsonResponse
*/
public function listAction(Request $request): JsonResponse
{
@@ -92,7 +89,7 @@ public function listAction(Request $request): JsonResponse
throw new InvalidParameterException('Ids should be provided within an array');
}
$cleanDocumentIds = array_filter($request->query->filter('ids', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
]));
$documentsArray = [];
@@ -111,7 +108,7 @@ public function listAction(Request $request): JsonResponse
'status' => 'confirm',
'statusCode' => 200,
'documents' => $documentsArray,
- 'trans' => $this->getTrans()
+ 'trans' => $this->getTrans(),
]);
}
@@ -119,7 +116,6 @@ public function listAction(Request $request): JsonResponse
* Normalize response Document list result.
*
* @param iterable $documents
- * @return array
*/
private function normalizeDocuments(iterable $documents): array
{
@@ -135,8 +131,6 @@ private function normalizeDocuments(iterable $documents): array
/**
* Get an array of translations.
- *
- * @return array
*/
private function getTrans(): array
{
@@ -144,7 +138,7 @@ private function getTrans(): array
'editDocument' => $this->getTranslator()->trans('edit.document'),
'unlinkDocument' => $this->getTranslator()->trans('unlink.document'),
'linkDocument' => $this->getTranslator()->trans('link.document'),
- 'moreItems' => $this->getTranslator()->trans('more.documents')
+ 'moreItems' => $this->getTranslator()->trans('more.documents'),
];
}
}
diff --git a/src/AjaxControllers/AjaxEntitiesExplorerController.php b/src/AjaxControllers/AjaxEntitiesExplorerController.php
index dcab945e..6f46ac3e 100644
--- a/src/AjaxControllers/AjaxEntitiesExplorerController.php
+++ b/src/AjaxControllers/AjaxEntitiesExplorerController.php
@@ -21,20 +21,16 @@ final class AjaxEntitiesExplorerController extends AbstractAjaxController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
- /**
- * @param NodeTypeField $nodeTypeField
- * @return array
- */
protected function getFieldConfiguration(NodeTypeField $nodeTypeField): array
{
if (
- $nodeTypeField->getType() !== AbstractField::MANY_TO_MANY_T &&
- $nodeTypeField->getType() !== AbstractField::MANY_TO_ONE_T
+ AbstractField::MANY_TO_MANY_T !== $nodeTypeField->getType()
+ && AbstractField::MANY_TO_ONE_T !== $nodeTypeField->getType()
) {
throw new BadRequestHttpException('nodeTypeField is not a valid entity join.');
}
@@ -127,7 +123,7 @@ public function listAction(Request $request): JsonResponse
$className = $configuration['classname'];
$cleanNodeIds = array_filter($request->query->filter('ids', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
]));
$entitiesArray = [];
@@ -144,7 +140,7 @@ public function listAction(Request $request): JsonResponse
return $this->createSerializedResponse([
'status' => 'confirm',
'statusCode' => 200,
- 'items' => $entitiesArray
+ 'items' => $entitiesArray,
]);
}
@@ -152,7 +148,7 @@ public function listAction(Request $request): JsonResponse
* Normalize response Node list result.
*
* @param iterable $entities
- * @param array $configuration
+ *
* @return array
*/
private function normalizeEntities(iterable $entities, array $configuration): array
diff --git a/src/AjaxControllers/AjaxExplorerProviderController.php b/src/AjaxControllers/AjaxExplorerProviderController.php
index 32e8092b..06bb1bfc 100644
--- a/src/AjaxControllers/AjaxExplorerProviderController.php
+++ b/src/AjaxControllers/AjaxExplorerProviderController.php
@@ -18,14 +18,14 @@ class AjaxExplorerProviderController extends AbstractAjaxController
{
public function __construct(
private readonly ContainerInterface $psrContainer,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
/**
* @param class-string $providerClass
- * @return ExplorerProviderInterface
+ *
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@@ -34,6 +34,7 @@ protected function getProvider(string $providerClass): ExplorerProviderInterface
if ($this->psrContainer->has($providerClass)) {
return $this->psrContainer->get($providerClass);
}
+
return new $providerClass();
}
@@ -62,8 +63,6 @@ protected function getProviderFromRequest(Request $request): ExplorerProviderInt
}
/**
- * @param Request $request
- * @return JsonResponse
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@@ -80,7 +79,7 @@ public function indexAction(Request $request): JsonResponse
if ($request->query->has('options')) {
$options = array_merge(
array_filter($request->query->filter('options', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
])),
$options
);
@@ -105,8 +104,6 @@ public function indexAction(Request $request): JsonResponse
/**
* Get a Node list from an array of id.
*
- * @param Request $request
- * @return JsonResponse
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@@ -117,10 +114,11 @@ public function listAction(Request $request): JsonResponse
$provider = $this->getProviderFromRequest($request);
$entitiesArray = [];
$cleanNodeIds = array_filter($request->query->filter('ids', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
]));
$cleanNodeIds = array_filter($cleanNodeIds, function ($value) {
$nullValues = ['null', null, 0, '0', false, 'false'];
+
return !in_array($value, $nullValues, true);
});
@@ -137,7 +135,7 @@ public function listAction(Request $request): JsonResponse
return $this->createSerializedResponse([
'status' => 'confirm',
'statusCode' => 200,
- 'items' => $entitiesArray
+ 'items' => $entitiesArray,
]);
}
}
diff --git a/src/AjaxControllers/AjaxFolderTreeController.php b/src/AjaxControllers/AjaxFolderTreeController.php
index f9339b22..6f013398 100644
--- a/src/AjaxControllers/AjaxFolderTreeController.php
+++ b/src/AjaxControllers/AjaxFolderTreeController.php
@@ -15,7 +15,7 @@ final class AjaxFolderTreeController extends AbstractAjaxController
{
public function __construct(
private readonly TreeWidgetFactory $treeWidgetFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -28,7 +28,7 @@ public function getTreeAction(Request $request): JsonResponse
/** @var FolderTreeWidget|null $folderTree */
$folderTree = null;
- switch ($request->get("_action")) {
+ switch ($request->get('_action')) {
/*
* Inner folder edit for folderTree
*/
@@ -48,9 +48,9 @@ public function getTreeAction(Request $request): JsonResponse
$this->assignation['mainFolderTree'] = false;
break;
- /*
- * Main panel tree folderTree
- */
+ /*
+ * Main panel tree folderTree
+ */
case 'requestMainFolderTree':
$parent = null;
$folderTree = $this->treeWidgetFactory->createFolderTree($parent, $translation);
diff --git a/src/AjaxControllers/AjaxFoldersController.php b/src/AjaxControllers/AjaxFoldersController.php
index 3e2c68f3..788600d1 100644
--- a/src/AjaxControllers/AjaxFoldersController.php
+++ b/src/AjaxControllers/AjaxFoldersController.php
@@ -5,9 +5,9 @@
namespace Themes\Rozier\AjaxControllers;
use JMS\Serializer\SerializerInterface;
+use RZ\Roadiz\Core\Handlers\HandlerFactoryInterface;
use RZ\Roadiz\CoreBundle\Entity\Folder;
use RZ\Roadiz\CoreBundle\EntityHandler\FolderHandler;
-use RZ\Roadiz\Core\Handlers\HandlerFactoryInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -17,7 +17,7 @@ final class AjaxFoldersController extends AbstractAjaxController
{
public function __construct(
private readonly HandlerFactoryInterface $handlerFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -33,11 +33,11 @@ public function editAction(Request $request, int $folderId): JsonResponse
$folder = $this->em()->find(Folder::class, (int) $folderId);
- if ($folder === null) {
+ if (null === $folder) {
throw $this->createNotFoundException($this->getTranslator()->trans('folder.does_not_exist'));
}
- if ($request->get('_action') !== 'updatePosition') {
+ if ('updatePosition' !== $request->get('_action')) {
throw new BadRequestHttpException('Action does not exist');
}
@@ -49,21 +49,17 @@ public function editAction(Request $request, int $folderId): JsonResponse
'status' => 'success',
'responseText' => $this->getTranslator()->trans('folder.%name%.updated', [
'%name%' => $folder->getName(),
- ])
+ ]),
],
Response::HTTP_PARTIAL_CONTENT
);
}
- /**
- * @param Request $request
- * @return JsonResponse
- */
public function searchAction(Request $request): JsonResponse
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_DOCUMENTS');
- if ($request->query->has('search') && $request->get('search') != "") {
+ if ($request->query->has('search') && '' != $request->get('search')) {
$responseArray = [];
$pattern = strip_tags($request->get('search'));
@@ -95,14 +91,14 @@ protected function updatePosition(array $parameters, Folder $folder): void
* First, we set the new parent
*/
if (
- !empty($parameters['newParent']) &&
- is_numeric($parameters['newParent']) &&
- $parameters['newParent'] > 0
+ !empty($parameters['newParent'])
+ && is_numeric($parameters['newParent'])
+ && $parameters['newParent'] > 0
) {
/** @var Folder $parent */
$parent = $this->em()->find(Folder::class, (int) $parameters['newParent']);
- if ($parent !== null) {
+ if (null !== $parent) {
$folder->setParent($parent);
}
} else {
@@ -113,22 +109,22 @@ protected function updatePosition(array $parameters, Folder $folder): void
* Then compute new position
*/
if (
- !empty($parameters['nextFolderId']) &&
- $parameters['nextFolderId'] > 0
+ !empty($parameters['nextFolderId'])
+ && $parameters['nextFolderId'] > 0
) {
/** @var Folder $nextFolder */
$nextFolder = $this->em()->find(Folder::class, (int) $parameters['nextFolderId']);
- if ($nextFolder !== null) {
+ if (null !== $nextFolder) {
$folder->setPosition($nextFolder->getPosition() - 0.5);
}
} elseif (
- !empty($parameters['prevFolderId']) &&
- $parameters['prevFolderId'] > 0
+ !empty($parameters['prevFolderId'])
+ && $parameters['prevFolderId'] > 0
) {
/** @var Folder $prevFolder */
$prevFolder = $this->em()
->find(Folder::class, (int) $parameters['prevFolderId']);
- if ($prevFolder !== null) {
+ if (null !== $prevFolder) {
$folder->setPosition($prevFolder->getPosition() + 0.5);
}
}
diff --git a/src/AjaxControllers/AjaxFoldersExplorerController.php b/src/AjaxControllers/AjaxFoldersExplorerController.php
index e41aeb20..12cbfcc5 100644
--- a/src/AjaxControllers/AjaxFoldersExplorerController.php
+++ b/src/AjaxControllers/AjaxFoldersExplorerController.php
@@ -35,7 +35,7 @@ public function indexAction(Request $request): JsonResponse
protected function recurseFolders(?iterable $folders = null): array
{
$foldersArray = [];
- if ($folders !== null) {
+ if (null !== $folders) {
/** @var Folder $folder */
foreach ($folders as $folder) {
$children = $this->recurseFolders($folder->getChildren());
diff --git a/src/AjaxControllers/AjaxNodeTreeController.php b/src/AjaxControllers/AjaxNodeTreeController.php
index 88f4db18..1dc5bd73 100644
--- a/src/AjaxControllers/AjaxNodeTreeController.php
+++ b/src/AjaxControllers/AjaxNodeTreeController.php
@@ -21,7 +21,7 @@ public function __construct(
private readonly NodeChrootResolver $nodeChrootResolver,
private readonly TreeWidgetFactory $treeWidgetFactory,
private readonly NodeTypes $nodeTypesBag,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -35,7 +35,7 @@ public function getTreeAction(Request $request): JsonResponse
$nodeTree = null;
$linkedTypes = [];
- switch ($request->get("_action")) {
+ switch ($request->get('_action')) {
/*
* Inner node edit for nodeTree
*/
@@ -55,8 +55,8 @@ public function getTreeAction(Request $request): JsonResponse
$nodeTree = $this->treeWidgetFactory->createNodeTree($node, $translation);
if (
- $request->get('tagId') &&
- $request->get('tagId') > 0
+ $request->get('tagId')
+ && $request->get('tagId') > 0
) {
$filterTag = $this->em()
->find(
@@ -77,7 +77,7 @@ public function getTreeAction(Request $request): JsonResponse
}, $linkedTypes));
$nodeTree->setAdditionalCriteria([
- 'nodeType' => $linkedTypes
+ 'nodeType' => $linkedTypes,
]);
}
@@ -87,9 +87,9 @@ public function getTreeAction(Request $request): JsonResponse
$nodeTree->setStackTree(true);
}
break;
- /*
- * Main panel tree nodeTree
- */
+ /*
+ * Main panel tree nodeTree
+ */
case 'requestMainNodeTree':
$parent = null;
if (null !== $this->getUser()) {
diff --git a/src/AjaxControllers/AjaxNodeTypeFieldsController.php b/src/AjaxControllers/AjaxNodeTypeFieldsController.php
index ce6ce419..7ee8f75c 100644
--- a/src/AjaxControllers/AjaxNodeTypeFieldsController.php
+++ b/src/AjaxControllers/AjaxNodeTypeFieldsController.php
@@ -14,9 +14,6 @@ final class AjaxNodeTypeFieldsController extends AjaxAbstractFieldsController
* Handle AJAX edition requests for NodeTypeFields
* such as coming from widgets.
*
- * @param Request $request
- * @param int $nodeTypeFieldId
- *
* @return Response JSON response
*/
public function editAction(Request $request, int $nodeTypeFieldId): Response
@@ -30,12 +27,7 @@ public function editAction(Request $request, int $nodeTypeFieldId): Response
return $response;
}
- throw $this->createNotFoundException($this->getTranslator()->trans(
- 'field.%nodeTypeFieldId%.not_exists',
- [
- '%nodeTypeFieldId%' => $nodeTypeFieldId
- ]
- ));
+ throw $this->createNotFoundException($this->getTranslator()->trans('field.%nodeTypeFieldId%.not_exists', ['%nodeTypeFieldId%' => $nodeTypeFieldId]));
}
protected function getEntityClass(): string
diff --git a/src/AjaxControllers/AjaxNodeTypesController.php b/src/AjaxControllers/AjaxNodeTypesController.php
index 3419c2a0..fab7e3f4 100644
--- a/src/AjaxControllers/AjaxNodeTypesController.php
+++ b/src/AjaxControllers/AjaxNodeTypesController.php
@@ -18,14 +18,12 @@ final class AjaxNodeTypesController extends AbstractAjaxController
{
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
/**
- * @param Request $request
- *
* @return Response JSON response
*/
public function indexAction(Request $request): Response
@@ -52,15 +50,15 @@ public function indexAction(Request $request): Response
'statusCode' => 200,
'nodeTypes' => $documentsArray,
'nodeTypesCount' => count($nodeTypes),
- 'filters' => $listManager->getAssignation()
+ 'filters' => $listManager->getAssignation(),
]);
}
/**
* Get a NodeType list from an array of id.
*
- * @param Request $request
* @return JsonResponse
+ *
* @throws NotSupported
*/
public function listAction(Request $request): Response
@@ -72,7 +70,7 @@ public function listAction(Request $request): Response
}
$cleanNodeTypesName = array_filter($request->query->filter('names', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
]));
$nodesArray = [];
@@ -80,7 +78,7 @@ public function listAction(Request $request): Response
/** @var EntityManager $em */
$em = $this->em();
$nodeTypes = $em->getRepository(NodeType::class)->findBy([
- 'name' => $cleanNodeTypesName
+ 'name' => $cleanNodeTypesName,
]);
// Sort array by ids given in request
@@ -90,7 +88,7 @@ public function listAction(Request $request): Response
return $this->createSerializedResponse([
'status' => 'confirm',
'statusCode' => 200,
- 'items' => $nodesArray
+ 'items' => $nodesArray,
]);
}
@@ -98,7 +96,6 @@ public function listAction(Request $request): Response
* Normalize response NodeType list result.
*
* @param iterable $nodeTypes
- * @return array
*/
private function normalizeNodeType(iterable $nodeTypes): array
{
diff --git a/src/AjaxControllers/AjaxNodesController.php b/src/AjaxControllers/AjaxNodesController.php
index cbc5c64a..354818f1 100644
--- a/src/AjaxControllers/AjaxNodesController.php
+++ b/src/AjaxControllers/AjaxNodesController.php
@@ -36,16 +36,11 @@ public function __construct(
private readonly NodeChrootResolver $nodeChrootResolver,
private readonly Registry $workflowRegistry,
private readonly UniqueNodeGenerator $uniqueNodeGenerator,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
- /**
- * @param Request $request
- * @param int $nodeId
- * @return JsonResponse
- */
public function getTagsAction(Request $request, int $nodeId): JsonResponse
{
$tags = [];
@@ -71,9 +66,6 @@ public function getTagsAction(Request $request, int $nodeId): JsonResponse
* Handle AJAX edition requests for Node
* such as coming from node-tree widgets.
*
- * @param Request $request
- * @param int|string $nodeId
- *
* @return Response JSON response
*/
public function editAction(Request $request, int|string $nodeId): Response
@@ -84,9 +76,7 @@ public function editAction(Request $request, int|string $nodeId): Response
$node = $this->em()->find(Node::class, (int) $nodeId);
if (null === $node) {
- throw $this->createNotFoundException($this->getTranslator()->trans('node.%nodeId%.not_exists', [
- '%nodeId%' => $nodeId,
- ]));
+ throw $this->createNotFoundException($this->getTranslator()->trans('node.%nodeId%.not_exists', ['%nodeId%' => $nodeId]));
}
/*
* Get the right update method against "_action" parameter
@@ -138,10 +128,6 @@ public function editAction(Request $request, int|string $nodeId): Response
);
}
- /**
- * @param array $parameters
- * @param Node $node
- */
protected function updatePosition(array $parameters, Node $node): void
{
if ($node->isLocked()) {
@@ -189,59 +175,47 @@ protected function updatePosition(array $parameters, Node $node): void
$this->em()->flush();
}
- /**
- * @param array $parameters
- *
- * @return Node|null
- */
protected function parseParentNode(array $parameters): ?Node
{
if (
- !empty($parameters['newParent']) &&
- is_numeric($parameters['newParent']) &&
- $parameters['newParent'] > 0
+ !empty($parameters['newParent'])
+ && is_numeric($parameters['newParent'])
+ && $parameters['newParent'] > 0
) {
return $this->em()->find(Node::class, (int) $parameters['newParent']);
} elseif (null !== $this->getUser()) {
// If user is jailed in a node, prevent moving nodes out.
return $this->nodeChrootResolver->getChroot($this->getUser());
}
+
return null;
}
- /**
- * @param array $parameters
- * @param float $default
- *
- * @return float
- */
protected function parsePosition(array $parameters, float $default = 0.0): float
{
if (key_exists('nextNodeId', $parameters) && (int) $parameters['nextNodeId'] > 0) {
/** @var Node $nextNode */
$nextNode = $this->em()->find(Node::class, (int) $parameters['nextNodeId']);
- if ($nextNode !== null) {
+ if (null !== $nextNode) {
return $nextNode->getPosition() - 0.5;
}
} elseif (key_exists('prevNodeId', $parameters) && $parameters['prevNodeId'] > 0) {
/** @var Node $prevNode */
$prevNode = $this->em()->find(Node::class, (int) $parameters['prevNodeId']);
- if ($prevNode !== null) {
+ if (null !== $prevNode) {
return $prevNode->getPosition() + 0.5;
}
- } elseif (key_exists('firstPosition', $parameters) && (bool) $parameters['firstPosition'] === true) {
+ } elseif (key_exists('firstPosition', $parameters) && true === (bool) $parameters['firstPosition']) {
return -0.5;
- } elseif (key_exists('lastPosition', $parameters) && (bool) $parameters['lastPosition'] === true) {
+ } elseif (key_exists('lastPosition', $parameters) && true === (bool) $parameters['lastPosition']) {
return 99999999;
}
+
return $default;
}
/**
* Update node's status.
- *
- * @param Request $request
- * @return JsonResponse
*/
public function statusesAction(Request $request): JsonResponse
{
@@ -254,9 +228,7 @@ public function statusesAction(Request $request): JsonResponse
/** @var Node|null $node */
$node = $this->em()->find(Node::class, (int) $request->get('nodeId'));
if (null === $node) {
- throw $this->createNotFoundException($this->getTranslator()->trans('node.%nodeId%.not_exists', [
- '%nodeId%' => $request->get('nodeId'),
- ]));
+ throw $this->createNotFoundException($this->getTranslator()->trans('node.%nodeId%.not_exists', ['%nodeId%' => $request->get('nodeId')]));
}
$this->denyAccessUnlessGranted(NodeVoter::EDIT_STATUS, $node);
@@ -268,8 +240,8 @@ public function statusesAction(Request $request): JsonResponse
'sterile' => 'setSterile',
];
- if ("nodeChangeStatus" == $request->get('_action') && "" != $request->get('statusName')) {
- if ($request->get('statusName') === 'status') {
+ if ('nodeChangeStatus' == $request->get('_action') && '' != $request->get('statusName')) {
+ if ('status' === $request->get('statusName')) {
return $this->changeNodeStatus($node, $request->get('statusValue'));
}
@@ -285,7 +257,7 @@ public function statusesAction(Request $request): JsonResponse
* If set locked to true,
* need to disable dynamic nodeName
*/
- if ($request->get('statusName') == 'locked' && $value === true) {
+ if ('locked' == $request->get('statusName') && true === $value) {
$node->setDynamicNodeName(false);
}
@@ -294,7 +266,7 @@ public function statusesAction(Request $request): JsonResponse
/*
* Dispatch event
*/
- if ($request->get('statusName') === 'visible') {
+ if ('visible' === $request->get('statusName')) {
$msg = $this->getTranslator()->trans('node.%name%.visibility_changed_to.%visible%', [
'%name%' => $node->getNodeName(),
'%visible%' => $node->isVisible() ? $this->getTranslator()->trans('visible') : $this->getTranslator()->trans('invisible'),
@@ -319,9 +291,7 @@ public function statusesAction(Request $request): JsonResponse
'value' => $value,
];
} else {
- throw new BadRequestHttpException($this->getTranslator()->trans('node.has_no.field.%field%', [
- '%field%' => $request->get('statusName'),
- ]));
+ throw new BadRequestHttpException($this->getTranslator()->trans('node.has_no.field.%field%', ['%field%' => $request->get('statusName')]));
}
} else {
throw new BadRequestHttpException('Status field name is invalid.');
@@ -333,12 +303,6 @@ public function statusesAction(Request $request): JsonResponse
);
}
- /**
- * @param Node $node
- * @param string $transition
- *
- * @return JsonResponse
- */
protected function changeNodeStatus(Node $node, string $transition): JsonResponse
{
$request = $this->getRequest();
@@ -364,10 +328,6 @@ protected function changeNodeStatus(Node $node, string $transition): JsonRespons
);
}
- /**
- * @param Request $request
- * @return JsonResponse
- */
public function quickAddAction(Request $request): JsonResponse
{
/*
diff --git a/src/AjaxControllers/AjaxNodesExplorerController.php b/src/AjaxControllers/AjaxNodesExplorerController.php
index b2c924dc..a4c85360 100644
--- a/src/AjaxControllers/AjaxNodesExplorerController.php
+++ b/src/AjaxControllers/AjaxNodesExplorerController.php
@@ -29,7 +29,7 @@ public function __construct(
private readonly ClientRegistry $clientRegistry,
private readonly NodeSourceSearchHandlerInterface $nodeSourceSearchHandler,
private readonly NodeTypeApi $nodeTypeApi,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -41,12 +41,10 @@ protected function getItemPerPage(): int
protected function isSearchEngineAvailable(Request $request): bool
{
- return $request->get('search') !== '' && null !== $this->clientRegistry->getClient();
+ return '' !== $request->get('search') && null !== $this->clientRegistry->getClient();
}
/**
- * @param Request $request
- *
* @return Response JSON response
*/
public function indexAction(Request $request): Response
@@ -64,17 +62,13 @@ public function indexAction(Request $request): Response
if ($request->query->has('tagId') && $request->get('tagId') > 0) {
$responseArray['filters'] = array_merge($responseArray['filters'], [
- 'tagId' => $request->get('tagId')
+ 'tagId' => $request->get('tagId'),
]);
}
return $this->createSerializedResponse($responseArray);
}
- /**
- * @param Request $request
- * @return array
- */
protected function parseFilterFromRequest(Request $request): array
{
$arrayFilter = [
@@ -102,13 +96,10 @@ protected function parseFilterFromRequest(Request $request): array
$arrayFilter['nodeType'] = $nodeTypes;
}
}
+
return $arrayFilter;
}
- /**
- * @param Request $request
- * @return array
- */
protected function parseSortingFromRequest(Request $request): array
{
if ($request->query->has('sort-alpha')) {
@@ -122,12 +113,6 @@ protected function parseSortingFromRequest(Request $request): array
];
}
- /**
- * @param Request $request
- * @param array $criteria
- * @param array $sorting
- * @return array
- */
protected function getNodeSearchResults(Request $request, array $criteria, array $sorting = []): array
{
/*
@@ -144,6 +129,7 @@ protected function getNodeSearchResults(Request $request, array $criteria, array
$nodes = $listManager->getEntities();
$nodesArray = $this->normalizeNodes($nodes);
+
return [
'status' => 'confirm',
'statusCode' => 200,
@@ -153,15 +139,9 @@ protected function getNodeSearchResults(Request $request, array $criteria, array
];
}
- /**
- * @param Request $request
- * @param array $arrayFilter
- *
- * @return array
- */
protected function getSolrSearchResults(
Request $request,
- array $arrayFilter
+ array $arrayFilter,
): array {
$this->nodeSourceSearchHandler->boostByUpdateDate();
$currentPage = $request->get('page', 1);
@@ -205,8 +185,6 @@ protected function getSolrSearchResults(
/**
* Get a Node list from an array of id.
*
- * @param Request $request
- * @return JsonResponse
* @throws NotSupported
*/
public function listAction(Request $request): JsonResponse
@@ -219,7 +197,7 @@ public function listAction(Request $request): JsonResponse
}
$cleanNodeIds = array_filter($request->query->filter('ids', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
]));
$nodesArray = [];
@@ -240,7 +218,7 @@ public function listAction(Request $request): JsonResponse
return $this->createSerializedResponse([
'status' => 'confirm',
'statusCode' => 200,
- 'items' => $nodesArray
+ 'items' => $nodesArray,
]);
}
@@ -248,6 +226,7 @@ public function listAction(Request $request): JsonResponse
* Normalize response Node list result.
*
* @param iterable $nodes
+ *
* @return array
*/
private function normalizeNodes(iterable $nodes): array
diff --git a/src/AjaxControllers/AjaxSearchNodesSourcesController.php b/src/AjaxControllers/AjaxSearchNodesSourcesController.php
index 55ec1ec6..9ff6f537 100644
--- a/src/AjaxControllers/AjaxSearchNodesSourcesController.php
+++ b/src/AjaxControllers/AjaxSearchNodesSourcesController.php
@@ -11,11 +11,11 @@
use RZ\Roadiz\CoreBundle\SearchEngine\GlobalNodeSourceSearchHandler;
use RZ\Roadiz\CoreBundle\Security\Authorization\Voter\NodeVoter;
use RZ\Roadiz\Documents\UrlGenerators\DocumentUrlGeneratorInterface;
+use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
-use Symfony\Bundle\SecurityBundle\Security;
final class AjaxSearchNodesSourcesController extends AbstractAjaxController
{
@@ -24,7 +24,7 @@ final class AjaxSearchNodesSourcesController extends AbstractAjaxController
public function __construct(
private readonly DocumentUrlGeneratorInterface $documentUrlGenerator,
private readonly Security $security,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -33,15 +33,13 @@ public function __construct(
* Handle AJAX edition requests for Node
* such as coming from node-tree widgets.
*
- * @param Request $request
- *
* @return Response JSON response
*/
public function searchAction(Request $request): Response
{
$this->denyAccessUnlessGranted(NodeVoter::SEARCH);
- if (!$request->query->has('searchTerms') || $request->query->get('searchTerms') == '') {
+ if (!$request->query->has('searchTerms') || '' == $request->query->get('searchTerms')) {
throw new BadRequestHttpException('searchTerms parameter is missing.');
}
@@ -54,7 +52,7 @@ public function searchAction(Request $request): Response
self::RESULT_COUNT
);
- if (count($nodesSources) === 0) {
+ if (0 === count($nodesSources)) {
return new JsonResponse([
'statusCode' => Response::HTTP_OK,
'status' => 'success',
@@ -67,14 +65,14 @@ public function searchAction(Request $request): Response
'statusCode' => Response::HTTP_OK,
'status' => 'success',
'data' => [],
- 'responseText' => count($nodesSources) . ' results found.',
+ 'responseText' => count($nodesSources).' results found.',
];
foreach ($nodesSources as $source) {
if (
- $source instanceof NodesSources &&
- $this->security->isGranted(NodeVoter::READ, $source) &&
- !key_exists($source->getNode()->getId(), $responseArray['data'])
+ $source instanceof NodesSources
+ && $this->security->isGranted(NodeVoter::READ, $source)
+ && !key_exists($source->getNode()->getId(), $responseArray['data'])
) {
$responseArray['data'][$source->getNode()->getId()] = $this->getNodeSourceData($source);
}
@@ -96,16 +94,18 @@ protected function getNodeSourceData(NodesSources $source): array
$translation = $source->getTranslation();
$displayableNSDoc = $source->getDocumentsByFields()->filter(function (NodesSourcesDocuments $nsDoc) {
$doc = $nsDoc->getDocument();
+
return !$doc->isPrivate() && ($doc->isImage() || $doc->isSvg());
})->first();
if (false !== $displayableNSDoc) {
$thumbnail = $displayableNSDoc->getDocument();
$this->documentUrlGenerator->setDocument($thumbnail);
$this->documentUrlGenerator->setOptions([
- "fit" => "60x60",
- "quality" => 80
+ 'fit' => '60x60',
+ 'quality' => 80,
]);
}
+
return [
'title' => $source->getTitle() ?? $source->getNode()->getNodeName(),
'parent' => $source->getParent() ?
diff --git a/src/AjaxControllers/AjaxSessionMessages.php b/src/AjaxControllers/AjaxSessionMessages.php
index 99d0bcaf..b56a6442 100644
--- a/src/AjaxControllers/AjaxSessionMessages.php
+++ b/src/AjaxControllers/AjaxSessionMessages.php
@@ -17,7 +17,7 @@ public function getMessagesAction(Request $request): JsonResponse
$responseArray = [
'statusCode' => Response::HTTP_OK,
- 'status' => 'success'
+ 'status' => 'success',
];
if ($request->hasPreviousSession()) {
@@ -26,6 +26,7 @@ public function getMessagesAction(Request $request): JsonResponse
$responseArray['messages'] = $session->getFlashBag()->all();
}
}
+
return new JsonResponse(
$responseArray
);
diff --git a/src/AjaxControllers/AjaxTagTreeController.php b/src/AjaxControllers/AjaxTagTreeController.php
index 67544e62..a1219982 100644
--- a/src/AjaxControllers/AjaxTagTreeController.php
+++ b/src/AjaxControllers/AjaxTagTreeController.php
@@ -15,7 +15,7 @@ final class AjaxTagTreeController extends AbstractAjaxController
{
public function __construct(
private readonly TreeWidgetFactory $treeWidgetFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
@@ -28,7 +28,7 @@ public function getTreeAction(Request $request): JsonResponse
/** @var TagTreeWidget|null $tagTree */
$tagTree = null;
- switch ($request->get("_action")) {
+ switch ($request->get('_action')) {
/*
* Inner tag edit for tagTree
*/
@@ -48,9 +48,9 @@ public function getTreeAction(Request $request): JsonResponse
$this->assignation['mainTagTree'] = false;
break;
- /*
- * Main panel tree tagTree
- */
+ /*
+ * Main panel tree tagTree
+ */
case 'requestMainTagTree':
$parent = null;
$tagTree = $this->treeWidgetFactory->createTagTree($parent, $translation);
diff --git a/src/AjaxControllers/AjaxTagsController.php b/src/AjaxControllers/AjaxTagsController.php
index 995ae34c..29620ead 100644
--- a/src/AjaxControllers/AjaxTagsController.php
+++ b/src/AjaxControllers/AjaxTagsController.php
@@ -26,22 +26,17 @@ final class AjaxTagsController extends AbstractAjaxController
public function __construct(
private readonly ExplorerItemFactoryInterface $explorerItemFactory,
private readonly HandlerFactoryInterface $handlerFactory,
- SerializerInterface $serializer
+ SerializerInterface $serializer,
) {
parent::__construct($serializer);
}
- /**
- * @return TagRepository
- */
protected function getRepository(): TagRepository
{
return $this->em()->getRepository(Tag::class);
}
/**
- * @param Request $request
- *
* @return Response JSON response
*/
public function indexAction(Request $request): Response
@@ -50,8 +45,8 @@ public function indexAction(Request $request): Response
$onlyParents = false;
if (
- $request->query->has('onlyParents') &&
- $request->query->get('onlyParents')
+ $request->query->has('onlyParents')
+ && $request->query->get('onlyParents')
) {
$onlyParents = true;
}
@@ -71,9 +66,6 @@ public function indexAction(Request $request): Response
/**
* Get a Tag list from an array of node id.
- *
- * @param Request $request
- * @return JsonResponse
*/
public function listArrayAction(Request $request): JsonResponse
{
@@ -84,7 +76,7 @@ public function listArrayAction(Request $request): JsonResponse
}
$cleanTagIds = array_filter($request->query->filter('ids', [], \FILTER_DEFAULT, [
- 'flags' => \FILTER_FORCE_ARRAY
+ 'flags' => \FILTER_FORCE_ARRAY,
]));
$normalizedTags = [];
@@ -101,13 +93,11 @@ public function listArrayAction(Request $request): JsonResponse
return $this->createSerializedResponse([
'status' => 'confirm',
'statusCode' => 200,
- 'tags' => $normalizedTags
+ 'tags' => $normalizedTags,
]);
}
/**
- * @param Request $request
- *
* @return Response JSON response
*/
public function explorerListAction(Request $request): Response
@@ -115,10 +105,10 @@ public function explorerListAction(Request $request): Response
$this->denyAccessUnlessGranted('ROLE_ACCESS_TAGS');
$arrayFilter = [
- 'translation' => $this->em()->getRepository(Translation::class)->findDefault()
+ 'translation' => $this->em()->getRepository(Translation::class)->findDefault(),
];
$defaultOrder = [
- 'createdAt' => 'DESC'
+ 'createdAt' => 'DESC',
];
if ($request->get('tagId') > 0) {
@@ -159,12 +149,13 @@ public function explorerListAction(Request $request): Response
/**
* @param array|\Traversable|null $tags
+ *
* @return array
*/
protected function normalizeTags($tags): array
{
$tagsArray = [];
- if ($tags !== null) {
+ if (null !== $tags) {
foreach ($tags as $tag) {
$tagModel = $this->explorerItemFactory->createForEntity($tag);
$tagsArray[] = $tagModel->toArray();
@@ -176,14 +167,11 @@ protected function normalizeTags($tags): array
/**
* @param Tag[]|null $tags
- * @param bool $onlyParents
- *
- * @return array
*/
- protected function recurseTags(array $tags = null, bool $onlyParents = false): array
+ protected function recurseTags(?array $tags = null, bool $onlyParents = false): array
{
$tagsArray = [];
- if ($tags !== null) {
+ if (null !== $tags) {
foreach ($tags as $tag) {
if ($onlyParents) {
$children = $this->getRepository()->findByParentWithChildrenAndDefaultTranslation($tag);
@@ -205,11 +193,6 @@ protected function recurseTags(array $tags = null, bool $onlyParents = false): a
/**
* Handle AJAX edition requests for Tag
* such as coming from tag-tree widgets.
- *
- * @param Request $request
- * @param int $tagId
- *
- * @return JsonResponse
*/
public function editAction(Request $request, int $tagId): JsonResponse
{
@@ -217,13 +200,13 @@ public function editAction(Request $request, int $tagId): JsonResponse
$tag = $this->em()->find(Tag::class, (int) $tagId);
- if ($tag === null) {
- throw $this->createNotFoundException('Tag ' . $tagId . ' does not exists');
+ if (null === $tag) {
+ throw $this->createNotFoundException('Tag '.$tagId.' does not exists');
}
/*
* Get the right update method against "_action" parameter
*/
- if ($request->get('_action') !== 'updatePosition') {
+ if ('updatePosition' !== $request->get('_action')) {
throw new BadRequestHttpException('Action does not exist');
}
@@ -233,16 +216,13 @@ public function editAction(Request $request, int $tagId): JsonResponse
[
'statusCode' => '200',
'status' => 'success',
- 'responseText' => ('Tag ' . $tagId . ' edited '),
+ 'responseText' => ('Tag '.$tagId.' edited '),
],
Response::HTTP_PARTIAL_CONTENT
);
}
/**
- * @param Request $request
- *
- * @return JsonResponse
* @throws \Exception
*/
public function searchAction(Request $request): JsonResponse
@@ -257,7 +237,7 @@ public function searchAction(Request $request): JsonResponse
$pattern = strip_tags($request->get('search'));
$tags = $this->getRepository()->searchBy($pattern, [], [], 10);
- if (count($tags) === 0) {
+ if (0 === count($tags)) {
/*
* Try again using tag slug
*/
@@ -265,7 +245,7 @@ public function searchAction(Request $request): JsonResponse
$tags = $this->getRepository()->searchBy($pattern, [], [], 10);
}
- if (count($tags) === 0) {
+ if (0 === count($tags)) {
throw $this->createNotFoundException('No tags found.');
}
@@ -279,22 +259,18 @@ public function searchAction(Request $request): JsonResponse
);
}
- /**
- * @param array $parameters
- * @param Tag $tag
- */
protected function updatePosition(array $parameters, Tag $tag): void
{
/*
* First, we set the new parent
*/
if (
- !empty($parameters['newParent']) &&
- is_numeric($parameters['newParent']) &&
- $parameters['newParent'] > 0
+ !empty($parameters['newParent'])
+ && is_numeric($parameters['newParent'])
+ && $parameters['newParent'] > 0
) {
$parent = $this->em()->find(Tag::class, (int) $parameters['newParent']);
- if ($parent !== null) {
+ if (null !== $parent) {
$tag->setParent($parent);
}
} else {
@@ -305,19 +281,19 @@ protected function updatePosition(array $parameters, Tag $tag): void
* Then compute new position
*/
if (
- !empty($parameters['nextTagId']) &&
- $parameters['nextTagId'] > 0
+ !empty($parameters['nextTagId'])
+ && $parameters['nextTagId'] > 0
) {
$nextTag = $this->em()->find(Tag::class, (int) $parameters['nextTagId']);
- if ($nextTag !== null) {
+ if (null !== $nextTag) {
$tag->setPosition($nextTag->getPosition() - 0.5);
}
} elseif (
- !empty($parameters['prevTagId']) &&
- $parameters['prevTagId'] > 0
+ !empty($parameters['prevTagId'])
+ && $parameters['prevTagId'] > 0
) {
$prevTag = $this->em()->find(Tag::class, (int) $parameters['prevTagId']);
- if ($prevTag !== null) {
+ if (null !== $prevTag) {
$tag->setPosition($prevTag->getPosition() + 0.5);
}
}
@@ -339,8 +315,6 @@ protected function updatePosition(array $parameters, Tag $tag): void
/**
* Create a new Tag.
*
- * @param Request $request
- * @return JsonResponse
* @throws ORMException
* @throws OptimisticLockException
*/
@@ -352,7 +326,7 @@ public function createAction(Request $request): JsonResponse
throw new InvalidParameterException('tagName should be provided to create a new Tag');
}
- if ($request->getMethod() != Request::METHOD_POST) {
+ if (Request::METHOD_POST != $request->getMethod()) {
throw new BadRequestHttpException();
}
@@ -362,7 +336,7 @@ public function createAction(Request $request): JsonResponse
return new JsonResponse(
[
- 'tag' => $tagModel->toArray()
+ 'tag' => $tagModel->toArray(),
],
Response::HTTP_CREATED
);
diff --git a/src/Controllers/AbstractAdminController.php b/src/Controllers/AbstractAdminController.php
index 2d73a9ba..50aa51bf 100644
--- a/src/Controllers/AbstractAdminController.php
+++ b/src/Controllers/AbstractAdminController.php
@@ -25,21 +25,15 @@ abstract class AbstractAdminController extends RozierApp
public function __construct(
protected readonly SerializerInterface $serializer,
- protected readonly UrlGeneratorInterface $urlGenerator
+ protected readonly UrlGeneratorInterface $urlGenerator,
) {
}
- /**
- * @return string
- */
protected function getThemeDirectory(): string
{
return RozierApp::getThemeDir();
}
- /**
- * @return string
- */
protected function getTemplateNamespace(): string
{
return '@RoadizRozier';
@@ -60,9 +54,6 @@ protected function getRepository(): ObjectRepository
return $this->em()->getRepository($this->getEntityClass());
}
- /**
- * @return string
- */
protected function getRequiredDeletionRole(): string
{
return $this->getRequiredRole();
@@ -89,8 +80,6 @@ protected function getRequiredExportRole(): string
}
/**
- * @param Request $request
- * @return Response|null
* @throws \Twig\Error\RuntimeError
*/
public function defaultAction(Request $request): ?Response
@@ -107,7 +96,7 @@ public function defaultAction(Request $request): ?Response
/*
* Stored item per pages in session
*/
- $sessionListFilter = new SessionListFilters($this->getNamespace() . '_item_per_page');
+ $sessionListFilter = new SessionListFilters($this->getNamespace().'_item_per_page');
$sessionListFilter->handleItemPerPage($request, $elm);
$elm->handle();
@@ -115,7 +104,7 @@ public function defaultAction(Request $request): ?Response
$this->assignation['filters'] = $elm->getAssignation();
return $this->render(
- $this->getTemplateFolder() . '/list.html.twig',
+ $this->getTemplateFolder().'/list.html.twig',
$this->assignation,
null,
$this->getTemplateNamespace()
@@ -123,8 +112,6 @@ public function defaultAction(Request $request): ?Response
}
/**
- * @param Request $request
- * @return Response|null
* @throws \Twig\Error\RuntimeError
*/
public function addAction(Request $request): ?Response
@@ -155,7 +142,7 @@ public function addAction(Request $request): ?Response
'%namespace%.%item%.was_created',
[
'%item%' => $this->getEntityName($item),
- '%namespace%' => $this->getTranslator()->trans($this->getNamespace())
+ '%namespace%' => $this->getTranslator()->trans($this->getNamespace()),
]
);
$this->publishConfirmMessage($request, $msg, $item);
@@ -167,7 +154,7 @@ public function addAction(Request $request): ?Response
$this->assignation['item'] = $item;
return $this->render(
- $this->getTemplateFolder() . '/add.html.twig',
+ $this->getTemplateFolder().'/add.html.twig',
$this->assignation,
null,
$this->getTemplateNamespace()
@@ -175,9 +162,8 @@ public function addAction(Request $request): ?Response
}
/**
- * @param Request $request
* @param int|string $id Numeric ID or UUID
- * @return Response|null
+ *
* @throws \Twig\Error\RuntimeError
*/
public function editAction(Request $request, $id): ?Response
@@ -216,7 +202,7 @@ public function editAction(Request $request, $id): ?Response
'%namespace%.%item%.was_updated',
[
'%item%' => $this->getEntityName($item),
- '%namespace%' => $this->getTranslator()->trans($this->getNamespace())
+ '%namespace%' => $this->getTranslator()->trans($this->getNamespace()),
]
);
$this->publishConfirmMessage($request, $msg, $item);
@@ -228,7 +214,7 @@ public function editAction(Request $request, $id): ?Response
$this->assignation['item'] = $item;
return $this->render(
- $this->getTemplateFolder() . '/edit.html.twig',
+ $this->getTemplateFolder().'/edit.html.twig',
$this->assignation,
null,
$this->getTemplateNamespace()
@@ -261,9 +247,8 @@ public function exportAction(Request $request): JsonResponse
}
/**
- * @param Request $request
* @param int|string $id Numeric ID or UUID
- * @return Response|null
+ *
* @throws \Twig\Error\RuntimeError
*/
public function deleteAction(Request $request, $id): ?Response
@@ -301,7 +286,7 @@ public function deleteAction(Request $request, $id): ?Response
'%namespace%.%item%.was_deleted',
[
'%item%' => $this->getEntityName($item),
- '%namespace%' => $this->getTranslator()->trans($this->getNamespace())
+ '%namespace%' => $this->getTranslator()->trans($this->getNamespace()),
]
);
$this->publishConfirmMessage($request, $msg, $item);
@@ -313,38 +298,24 @@ public function deleteAction(Request $request, $id): ?Response
$this->assignation['item'] = $item;
return $this->render(
- $this->getTemplateFolder() . '/delete.html.twig',
+ $this->getTemplateFolder().'/delete.html.twig',
$this->assignation,
null,
$this->getTemplateNamespace()
);
}
- /**
- * @param PersistableInterface $item
- * @return bool
- */
abstract protected function supports(PersistableInterface $item): bool;
/**
- * @return string Namespace is used for composing messages and translations.
+ * @return string namespace is used for composing messages and translations
*/
abstract protected function getNamespace(): string;
- /**
- * @param Request $request
- * @return PersistableInterface
- */
abstract protected function createEmptyItem(Request $request): PersistableInterface;
- /**
- * @return string
- */
abstract protected function getTemplateFolder(): string;
- /**
- * @return string
- */
abstract protected function getRequiredRole(): string;
/**
@@ -358,7 +329,6 @@ abstract protected function getEntityClass(): string;
abstract protected function getFormType(): string;
/**
- * @param Request $request
* @return class-string
*/
protected function getFormTypeFromRequest(Request $request): string
@@ -370,6 +340,7 @@ protected function getFormTypeFromRequest(Request $request): string
if (!class_exists($type)) {
throw new InvalidConfigurationException(\sprintf('Route uses non-existent %s form type class.', $type));
}
+
return (string) $type;
}
@@ -377,27 +348,16 @@ protected function getFormTypeFromRequest(Request $request): string
return $this->getFormType();
}
- /**
- * @param Request $request
- * @return array
- */
protected function getDefaultCriteria(Request $request): array
{
return [];
}
- /**
- * @param Request $request
- * @return array
- */
protected function getDefaultOrder(Request $request): array
{
return [];
}
- /**
- * @return string
- */
abstract protected function getDefaultRouteName(): string;
/**
@@ -408,21 +368,12 @@ protected function getDefaultRouteParameters(): array
return [];
}
- /**
- * @return string
- */
abstract protected function getEditRouteName(): string;
- /**
- * @param PersistableInterface $item
- * @param bool $forceDefaultEditRoute
- * @param Request|null $request
- * @return Response
- */
protected function getPostSubmitResponse(
PersistableInterface $item,
bool $forceDefaultEditRoute = false,
- ?Request $request = null
+ ?Request $request = null,
): Response {
if (null === $request) {
// Redirect to default route if no request provided
@@ -439,9 +390,9 @@ protected function getPostSubmitResponse(
* Force redirect to avoid resending form when refreshing page
*/
if (
- \is_string($referrer) &&
- $referrer !== '' &&
- (new UnicodeString($referrer))->trim()->startsWith('/')
+ \is_string($referrer)
+ && '' !== $referrer
+ && (new UnicodeString($referrer))->trim()->startsWith('/')
) {
return $this->redirect($referrer);
}
@@ -450,9 +401,9 @@ protected function getPostSubmitResponse(
* Try to redirect to same route as defined in Request attribute
*/
if (
- false === $forceDefaultEditRoute &&
- \is_string($route) &&
- $route !== ''
+ false === $forceDefaultEditRoute
+ && \is_string($route)
+ && '' !== $route
) {
return $this->redirect($this->urlGenerator->generate(
$route,
@@ -466,21 +417,13 @@ protected function getPostSubmitResponse(
));
}
- /**
- * @param PersistableInterface $item
- * @return array
- */
protected function getEditRouteParameters(PersistableInterface $item): array
{
return [
- 'id' => $item->getId()
+ 'id' => $item->getId(),
];
}
- /**
- * @param PersistableInterface $item
- * @return Response
- */
protected function getPostDeleteResponse(PersistableInterface $item): Response
{
return $this->redirect($this->urlGenerator->generate(
@@ -491,7 +434,9 @@ protected function getPostDeleteResponse(PersistableInterface $item): Response
/**
* @template T of object|Event
+ *
* @param T|iterable|array|null $event
+ *
* @return T|iterable|array|null
*/
protected function dispatchSingleOrMultipleEvent(mixed $event): object|array|null
@@ -512,13 +457,13 @@ protected function dispatchSingleOrMultipleEvent(mixed $event): object|array|nul
$events[] = $returningEvent;
}
}
+
return $events;
}
throw new \InvalidArgumentException('Event must be null, Event or array of Event');
}
/**
- * @param PersistableInterface $item
* @return Event|Event[]|null
*/
protected function createCreateEvent(PersistableInterface $item)
@@ -527,7 +472,6 @@ protected function createCreateEvent(PersistableInterface $item)
}
/**
- * @param PersistableInterface $item
* @return Event|Event[]|null
*/
protected function createPostCreateEvent(PersistableInterface $item)
@@ -536,7 +480,6 @@ protected function createPostCreateEvent(PersistableInterface $item)
}
/**
- * @param PersistableInterface $item
* @return Event|Event[]|null
*/
protected function createUpdateEvent(PersistableInterface $item)
@@ -545,7 +488,6 @@ protected function createUpdateEvent(PersistableInterface $item)
}
/**
- * @param PersistableInterface $item
* @return Event|Event[]|null
*/
protected function createPostUpdateEvent(PersistableInterface $item)
@@ -554,7 +496,6 @@ protected function createPostUpdateEvent(PersistableInterface $item)
}
/**
- * @param PersistableInterface $item
* @return Event|Event[]|null
*/
protected function createDeleteEvent(PersistableInterface $item)
@@ -563,7 +504,6 @@ protected function createDeleteEvent(PersistableInterface $item)
}
/**
- * @param PersistableInterface $item
* @return Event|Event[]|null
*/
protected function createPostDeleteEvent(PersistableInterface $item)
@@ -571,15 +511,8 @@ protected function createPostDeleteEvent(PersistableInterface $item)
return null;
}
- /**
- * @param PersistableInterface $item
- * @return string
- */
abstract protected function getEntityName(PersistableInterface $item): string;
- /**
- * @param PersistableInterface $item
- */
protected function denyAccessUnlessItemGranted(PersistableInterface $item): void
{
// Do nothing
diff --git a/src/Controllers/AbstractAdminWithBulkController.php b/src/Controllers/AbstractAdminWithBulkController.php
index 1efa45a5..4b349cff 100644
--- a/src/Controllers/AbstractAdminWithBulkController.php
+++ b/src/Controllers/AbstractAdminWithBulkController.php
@@ -20,7 +20,7 @@ abstract class AbstractAdminWithBulkController extends AbstractAdminController
public function __construct(
protected readonly FormFactoryInterface $formFactory,
SerializerInterface $serializer,
- UrlGeneratorInterface $urlGenerator
+ UrlGeneratorInterface $urlGenerator,
) {
parent::__construct($serializer, $urlGenerator);
}
@@ -63,17 +63,18 @@ protected function getBulkPublishRouteName(): ?string
{
return null;
}
+
protected function getBulkUnpublishRouteName(): ?string
{
return null;
}
+
protected function getBulkDeleteRouteName(): ?string
{
return null;
}
/**
- * @param FormInterface|null $form
* @return array
*/
protected function parseFormBulkIds(?FormInterface $form): array
@@ -99,16 +100,9 @@ protected function parseFormBulkIds(?FormInterface $form): array
}
/**
- * @param Request $request
- * @param string $requiredRole
- * @param FormInterface $bulkForm
- * @param FormInterface $form
- * @param callable(string): FormInterface $createBulkFormWithIds
- * @param string $templatePath
- * @param string $confirmMessageTemplate
+ * @param callable(string): FormInterface $createBulkFormWithIds
* @param callable(PersistableInterface, FormInterface): void $alterItemCallable
- * @param string $bulkFormName
- * @return Response
+ *
* @throws \Twig\Error\RuntimeError
*/
protected function bulkAction(
@@ -120,7 +114,7 @@ protected function bulkAction(
string $templatePath,
string $confirmMessageTemplate,
callable $alterItemCallable,
- string $bulkFormName
+ string $bulkFormName,
): Response {
$this->denyAccessUnlessGranted($requiredRole);
$bulkForm->handleRequest($request);
@@ -164,13 +158,14 @@ protected function bulkAction(
$confirmMessageTemplate,
[
'%item%' => $this->getEntityName($item),
- '%namespace%' => $this->getTranslator()->trans($this->getNamespace())
+ '%namespace%' => $this->getTranslator()->trans($this->getNamespace()),
]
);
$this->publishConfirmMessage($request, $msg, $item);
}
}
$this->em()->flush();
+
return $this->redirect($this->urlGenerator->generate(
$this->getDefaultRouteName(),
$this->getDefaultRouteParameters()
@@ -191,6 +186,7 @@ protected function bulkAction(
public function bulkDeleteAction(Request $request): Response
{
$this->additionalAssignation($request);
+
return $this->bulkAction(
$request,
$this->getRequiredDeletionRole(),
@@ -201,7 +197,7 @@ function (string $ids) {
'id' => $ids,
]);
},
- $this->getTemplateFolder() . '/bulk_delete.html.twig',
+ $this->getTemplateFolder().'/bulk_delete.html.twig',
'%namespace%.%item%.was_deleted',
function (PersistableInterface $item) {
$this->removeItem($item);
@@ -213,6 +209,7 @@ function (PersistableInterface $item) {
public function bulkPublishAction(Request $request): Response
{
$this->additionalAssignation($request);
+
return $this->bulkAction(
$request,
$this->getRequiredRole(),
@@ -223,7 +220,7 @@ function (string $ids) {
'id' => $ids,
]);
},
- $this->getTemplateFolder() . '/bulk_publish.html.twig',
+ $this->getTemplateFolder().'/bulk_publish.html.twig',
'%namespace%.%item%.was_published',
function (PersistableInterface $item) {
$this->setPublishedAt($item, new \DateTime('now'));
@@ -235,6 +232,7 @@ function (PersistableInterface $item) {
public function bulkUnpublishAction(Request $request): Response
{
$this->additionalAssignation($request);
+
return $this->bulkAction(
$request,
$this->getRequiredRole(),
@@ -245,7 +243,7 @@ function (string $ids) {
'id' => $ids,
]);
},
- $this->getTemplateFolder() . '/bulk_unpublish.html.twig',
+ $this->getTemplateFolder().'/bulk_unpublish.html.twig',
'%namespace%.%item%.was_unpublished',
function (PersistableInterface $item) {
$this->setPublishedAt($item, null);
@@ -258,7 +256,7 @@ protected function createBulkForm(
?string $routeName,
string $formName,
bool $get = false,
- ?array $data = null
+ ?array $data = null,
): FormInterface {
if (null === $routeName) {
throw new \RuntimeException('Bulk delete route name is not defined.');
@@ -275,11 +273,12 @@ protected function createBulkForm(
'method' => 'POST',
];
}
+
return $this->formFactory->createNamedBuilder($formName, FormType::class, $data, $options)
->add('id', HiddenType::class, [
'attr' => [
- 'class' => 'bulk-form-value'
- ]
+ 'class' => 'bulk-form-value',
+ ],
])->getForm();
}
diff --git a/src/Controllers/Attributes/AttributeController.php b/src/Controllers/Attributes/AttributeController.php
index 49883ec6..19b5baa7 100644
--- a/src/Controllers/Attributes/AttributeController.php
+++ b/src/Controllers/Attributes/AttributeController.php
@@ -25,14 +25,11 @@ public function __construct(
private readonly AttributeImporter $attributeImporter,
FormFactoryInterface $formFactory,
SerializerInterface $serializer,
- UrlGeneratorInterface $urlGenerator
+ UrlGeneratorInterface $urlGenerator,
) {
parent::__construct($formFactory, $serializer, $urlGenerator);
}
- /**
- * @inheritDoc
- */
protected function supports(PersistableInterface $item): bool
{
return $item instanceof Attribute;
@@ -43,68 +40,44 @@ protected function getBulkDeleteRouteName(): ?string
return 'attributesBulkDeletePage';
}
- /**
- * @inheritDoc
- */
protected function getNamespace(): string
{
return 'attribute';
}
- /**
- * @inheritDoc
- */
protected function createEmptyItem(Request $request): PersistableInterface
{
$item = new Attribute();
$item->setCode('new_attribute');
+
return $item;
}
- /**
- * @inheritDoc
- */
protected function getTemplateFolder(): string
{
return '@RoadizRozier/attributes';
}
- /**
- * @inheritDoc
- */
protected function getRequiredRole(): string
{
return 'ROLE_ACCESS_ATTRIBUTES';
}
- /**
- * @inheritDoc
- */
protected function getRequiredDeletionRole(): string
{
return 'ROLE_ACCESS_ATTRIBUTES_DELETE';
}
-
- /**
- * @inheritDoc
- */
protected function getEntityClass(): string
{
return Attribute::class;
}
- /**
- * @inheritDoc
- */
protected function getFormType(): string
{
return AttributeType::class;
}
- /**
- * @inheritDoc
- */
protected function getDefaultOrder(Request $request): array
{
return [
@@ -113,36 +86,25 @@ protected function getDefaultOrder(Request $request): array
];
}
- /**
- * @inheritDoc
- */
protected function getDefaultRouteName(): string
{
return 'attributesHomePage';
}
- /**
- * @inheritDoc
- */
protected function getEditRouteName(): string
{
return 'attributesEditPage';
}
- /**
- * @inheritDoc
- */
protected function getEntityName(PersistableInterface $item): string
{
if ($item instanceof Attribute) {
return $item->getCode();
}
- throw new \InvalidArgumentException('Item should be instance of ' . $this->getEntityClass());
+ throw new \InvalidArgumentException('Item should be instance of '.$this->getEntityClass());
}
/**
- * @param Request $request
- * @return Response
* @throws RuntimeError
*/
public function importAction(Request $request): Response
@@ -168,10 +130,11 @@ public function importAction(Request $request): Response
$msg = $this->getTranslator()->trans(
'%namespace%.imported',
[
- '%namespace%' => $this->getTranslator()->trans($this->getNamespace())
+ '%namespace%' => $this->getTranslator()->trans($this->getNamespace()),
]
);
$this->publishConfirmMessage($request, $msg);
+
return $this->redirectToRoute('attributesHomePage');
}
$form->addError(new FormError($this->getTranslator()->trans('file.not_uploaded')));
diff --git a/src/Controllers/Attributes/AttributeGroupController.php b/src/Controllers/Attributes/AttributeGroupController.php
index 5fc541c3..b4e7b3d5 100644
--- a/src/Controllers/Attributes/AttributeGroupController.php
+++ b/src/Controllers/Attributes/AttributeGroupController.php
@@ -12,92 +12,59 @@
class AttributeGroupController extends AbstractAdminController
{
- /**
- * @inheritDoc
- */
protected function supports(PersistableInterface $item): bool
{
return $item instanceof AttributeGroup;
}
- /**
- * @inheritDoc
- */
protected function getNamespace(): string
{
return 'attribute_group';
}
- /**
- * @inheritDoc
- */
protected function createEmptyItem(Request $request): PersistableInterface
{
return new AttributeGroup();
}
- /**
- * @inheritDoc
- */
protected function getTemplateFolder(): string
{
return '@RoadizRozier/attributes/groups';
}
- /**
- * @inheritDoc
- */
protected function getRequiredRole(): string
{
return 'ROLE_ACCESS_ATTRIBUTES';
}
- /**
- * @inheritDoc
- */
protected function getEntityClass(): string
{
return AttributeGroup::class;
}
- /**
- * @inheritDoc
- */
protected function getFormType(): string
{
return AttributeGroupType::class;
}
- /**
- * @inheritDoc
- */
protected function getDefaultRouteName(): string
{
return 'attributeGroupsHomePage';
}
- /**
- * @inheritDoc
- */
protected function getEditRouteName(): string
{
return 'attributeGroupsEditPage';
}
- /**
- * @inheritDoc
- */
protected function getEntityName(PersistableInterface $item): string
{
if ($item instanceof AttributeGroup) {
return $item->getName();
}
- throw new \InvalidArgumentException('Item should be instance of ' . $this->getEntityClass());
+ throw new \InvalidArgumentException('Item should be instance of '.$this->getEntityClass());
}
- /**
- * @inheritDoc
- */
protected function getDefaultOrder(Request $request): array
{
return ['canonicalName' => 'ASC'];
diff --git a/src/Controllers/CacheController.php b/src/Controllers/CacheController.php
index 0020827d..60fb3d74 100644
--- a/src/Controllers/CacheController.php
+++ b/src/Controllers/CacheController.php
@@ -16,7 +16,7 @@ final class CacheController extends RozierApp
{
public function __construct(
private readonly CacheClearerInterface $cacheClearer,
- private readonly LoggerInterface $logger
+ private readonly LoggerInterface $logger,
) {
}
@@ -54,9 +54,6 @@ public function deleteDoctrineCache(Request $request): Response
}
/**
- * @param Request $request
- *
- * @return Response
* @throws \Twig\Error\RuntimeError
*/
public function deleteAssetsCache(Request $request): Response
diff --git a/src/Controllers/CustomForms/CustomFormAnswersController.php b/src/Controllers/CustomForms/CustomFormAnswersController.php
index 7aea9cfe..7d6a1f0c 100644
--- a/src/Controllers/CustomForms/CustomFormAnswersController.php
+++ b/src/Controllers/CustomForms/CustomFormAnswersController.php
@@ -21,10 +21,6 @@ class CustomFormAnswersController extends RozierApp
/**
* List every node-types.
*
- * @param Request $request
- * @param int $customFormId
- *
- * @return Response
* @throws RuntimeError
*/
public function listAction(Request $request, int $customFormId): Response
@@ -41,8 +37,8 @@ public function listAction(Request $request, int $customFormId): Response
$listManager = $this->createEntityListManager(
CustomFormAnswer::class,
- ["customForm" => $customForm],
- ["submittedAt" => "DESC"]
+ ['customForm' => $customForm],
+ ['submittedAt' => 'DESC']
);
$listManager->setDisplayingNotPublishedNodes(true);
$listManager->handle();
@@ -56,10 +52,6 @@ public function listAction(Request $request, int $customFormId): Response
/**
* Return a deletion form for requested node-type.
*
- * @param Request $request
- * @param int $customFormAnswerId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $customFormAnswerId): Response
@@ -77,20 +69,21 @@ public function deleteAction(Request $request, int $customFormAnswerId): Respons
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid()
+ $form->isSubmitted()
+ && $form->isValid()
) {
$this->em()->remove($customFormAnswer);
$this->em()->flush();
$msg = $this->getTranslator()->trans('customFormAnswer.%id%.deleted', ['%id%' => $customFormAnswer->getId()]);
$this->publishConfirmMessage($request, $msg, $customFormAnswer);
+
/*
* Redirect to update schema page
*/
return $this->redirectToRoute(
'customFormAnswersHomePage',
- ["customFormId" => $customFormAnswer->getCustomForm()->getId()]
+ ['customFormId' => $customFormAnswer->getCustomForm()->getId()]
);
}
@@ -99,11 +92,6 @@ public function deleteAction(Request $request, int $customFormAnswerId): Respons
return $this->render('@RoadizRozier/custom-form-answers/delete.html.twig', $this->assignation);
}
- /**
- * @param CustomFormAnswer $customFormAnswer
- *
- * @return FormInterface
- */
private function buildDeleteForm(CustomFormAnswer $customFormAnswer): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/CustomForms/CustomFormFieldAttributesController.php b/src/Controllers/CustomForms/CustomFormFieldAttributesController.php
index e5747a84..eb066ec6 100644
--- a/src/Controllers/CustomForms/CustomFormFieldAttributesController.php
+++ b/src/Controllers/CustomForms/CustomFormFieldAttributesController.php
@@ -16,10 +16,6 @@ class CustomFormFieldAttributesController extends RozierApp
/**
* List every node-types.
*
- * @param Request $request
- * @param int $customFormAnswerId
- *
- * @return Response
* @throws RuntimeError
*/
public function listAction(Request $request, int $customFormAnswerId): Response
@@ -40,10 +36,6 @@ public function listAction(Request $request, int $customFormAnswerId): Response
return $this->render('@RoadizRozier/custom-form-field-attributes/list.html.twig', $this->assignation);
}
- /**
- * @param iterable $answers
- * @return array
- */
protected function getAnswersByGroups(iterable $answers): array
{
$fieldsArray = [];
@@ -51,7 +43,7 @@ protected function getAnswersByGroups(iterable $answers): array
/** @var CustomFormFieldAttribute $answer */
foreach ($answers as $answer) {
$groupName = $answer->getCustomFormField()->getGroupName();
- if (\is_string($groupName) && $groupName !== '') {
+ if (\is_string($groupName) && '' !== $groupName) {
if (!isset($fieldsArray[$groupName]) || !\is_array($fieldsArray[$groupName])) {
$fieldsArray[$groupName] = [];
}
diff --git a/src/Controllers/CustomForms/CustomFormFieldsController.php b/src/Controllers/CustomForms/CustomFormFieldsController.php
index 66e63255..d47935e3 100644
--- a/src/Controllers/CustomForms/CustomFormFieldsController.php
+++ b/src/Controllers/CustomForms/CustomFormFieldsController.php
@@ -4,7 +4,6 @@
namespace Themes\Rozier\Controllers\CustomForms;
-use Exception;
use RZ\Roadiz\CoreBundle\Entity\CustomForm;
use RZ\Roadiz\CoreBundle\Entity\CustomFormField;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
@@ -23,9 +22,6 @@ class CustomFormFieldsController extends RozierApp
/**
* List every node-type-fields.
*
- * @param int $customFormId
- *
- * @return Response
* @throws RuntimeError
*/
public function listAction(int $customFormId): Response
@@ -34,7 +30,7 @@ public function listAction(int $customFormId): Response
$customForm = $this->em()->find(CustomForm::class, $customFormId);
- if ($customForm !== null) {
+ if (null !== $customForm) {
$fields = $customForm->getFields();
$this->assignation['customForm'] = $customForm;
@@ -49,10 +45,6 @@ public function listAction(int $customFormId): Response
/**
* Return an edition form for requested node-type.
*
- * @param Request $request
- * @param int $customFormFieldId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $customFormFieldId): Response
@@ -62,7 +54,7 @@ public function editAction(Request $request, int $customFormFieldId): Response
/** @var CustomFormField|null $field */
$field = $this->em()->find(CustomFormField::class, $customFormFieldId);
- if ($field === null) {
+ if (null === $field) {
throw new ResourceNotFoundException();
}
@@ -96,10 +88,6 @@ public function editAction(Request $request, int $customFormFieldId): Response
/**
* Return a creation form for requested node-type.
*
- * @param Request $request
- * @param int $customFormId
- *
- * @return Response
* @throws RuntimeError
*/
public function addAction(Request $request, int $customFormId): Response
@@ -107,7 +95,7 @@ public function addAction(Request $request, int $customFormId): Response
$this->denyAccessUnlessGranted('ROLE_ACCESS_CUSTOMFORMS');
$customForm = $this->em()->find(CustomForm::class, $customFormId);
- if ($customForm === null) {
+ if (null === $customForm) {
throw new ResourceNotFoundException();
}
@@ -139,9 +127,10 @@ public function addAction(Request $request, int $customFormId): Response
'customFormId' => $customFormId,
]
);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
$msg = $e->getMessage();
$this->publishErrorMessage($request, $msg, $field);
+
/*
* Redirect to add page
*/
@@ -160,10 +149,6 @@ public function addAction(Request $request, int $customFormId): Response
/**
* Return a deletion form for requested node.
*
- * @param Request $request
- * @param int $customFormFieldId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $customFormFieldId): Response
@@ -172,7 +157,7 @@ public function deleteAction(Request $request, int $customFormFieldId): Response
$field = $this->em()->find(CustomFormField::class, $customFormFieldId);
- if ($field === null) {
+ if (null === $field) {
throw new ResourceNotFoundException();
}
@@ -181,9 +166,9 @@ public function deleteAction(Request $request, int $customFormFieldId): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- $form->getData()['customFormFieldId'] == $field->getId()
+ $form->isSubmitted()
+ && $form->isValid()
+ && $form->getData()['customFormFieldId'] == $field->getId()
) {
$customFormId = $field->getCustomForm()->getId();
@@ -215,11 +200,6 @@ public function deleteAction(Request $request, int $customFormFieldId): Response
return $this->render('@RoadizRozier/custom-form-fields/delete.html.twig', $this->assignation);
}
- /**
- * @param CustomFormField $field
- *
- * @return FormInterface
- */
private function buildDeleteForm(CustomFormField $field): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/CustomForms/CustomFormsController.php b/src/Controllers/CustomForms/CustomFormsController.php
index 042983c8..b5fe1e3e 100644
--- a/src/Controllers/CustomForms/CustomFormsController.php
+++ b/src/Controllers/CustomForms/CustomFormsController.php
@@ -67,7 +67,7 @@ protected function getEntityName(PersistableInterface $item): string
if ($item instanceof CustomForm) {
return $item->getName();
}
- throw new \InvalidArgumentException('Item should be instance of ' . $this->getEntityClass());
+ throw new \InvalidArgumentException('Item should be instance of '.$this->getEntityClass());
}
protected function getBulkDeleteRouteName(): ?string
diff --git a/src/Controllers/CustomForms/CustomFormsUtilsController.php b/src/Controllers/CustomForms/CustomFormsUtilsController.php
index 535da55d..7b61a6d1 100644
--- a/src/Controllers/CustomForms/CustomFormsUtilsController.php
+++ b/src/Controllers/CustomForms/CustomFormsUtilsController.php
@@ -22,17 +22,13 @@ public function __construct(
private readonly ManagerRegistry $managerRegistry,
private readonly TranslatorInterface $translator,
private readonly CustomFormAnswerSerializer $customFormAnswerSerializer,
- private readonly SerializerInterface $serializer
+ private readonly SerializerInterface $serializer,
) {
}
/**
* Export all custom form's answers in a CSV file.
*
- * @param Request $request
- * @param int $id
- *
- * @return Response
* @throws Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
@@ -53,12 +49,12 @@ public function exportAction(Request $request, int $id): Response
$keys = [
'ip',
'submitted.date',
- ...$fields
+ ...$fields,
];
$response = new StreamedResponse(function () use ($answersArray, $keys) {
echo $this->serializer->serialize($answersArray, 'csv', [
- 'csv_headers' => $keys
+ 'csv_headers' => $keys,
]);
});
$response->headers->set('Content-Type', 'text/csv');
@@ -66,7 +62,7 @@ public function exportAction(Request $request, int $id): Response
'Content-Disposition',
$response->headers->makeDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
- $customForm->getName() . '.csv'
+ $customForm->getName().'.csv'
)
);
@@ -76,11 +72,7 @@ public function exportAction(Request $request, int $id): Response
}
/**
- * Duplicate custom form by ID
- *
- * @param Request $request
- * @param int $id
- * @return Response
+ * Duplicate custom form by ID.
*/
public function duplicateAction(Request $request, int $id): Response
{
@@ -103,7 +95,7 @@ public function duplicateAction(Request $request, int $id): Response
$em->persist($newCustomForm);
$em->flush();
- $msg = $this->translator->trans("duplicated.custom.form.%name%", [
+ $msg = $this->translator->trans('duplicated.custom.form.%name%', [
'%name%' => $existingCustomForm->getDisplayName(),
]);
@@ -111,12 +103,12 @@ public function duplicateAction(Request $request, int $id): Response
return $this->redirectToRoute(
'customFormsEditPage',
- ["id" => $newCustomForm->getId()]
+ ['id' => $newCustomForm->getId()]
);
} catch (\Exception $e) {
$this->publishErrorMessage(
$request,
- $this->translator->trans("impossible.duplicate.custom.form.%name%", [
+ $this->translator->trans('impossible.duplicate.custom.form.%name%', [
'%name%' => $existingCustomForm->getDisplayName(),
]),
$newCustomForm
@@ -125,7 +117,7 @@ public function duplicateAction(Request $request, int $id): Response
return $this->redirectToRoute(
'customFormsEditPage',
- ["id" => $existingCustomForm->getId()]
+ ['id' => $existingCustomForm->getId()]
);
}
}
diff --git a/src/Controllers/DashboardController.php b/src/Controllers/DashboardController.php
index 5a28614c..d9ebf051 100644
--- a/src/Controllers/DashboardController.php
+++ b/src/Controllers/DashboardController.php
@@ -13,9 +13,8 @@
class DashboardController extends RozierApp
{
/**
- * @param Request $request
- *
* @return Response $response
+ *
* @throws RuntimeError
*/
public function indexAction(Request $request): Response
@@ -28,7 +27,6 @@ public function indexAction(Request $request): Response
->getRepository(Log::class)
->findLatestByNodesSources(8);
-
return $this->render('@RoadizRozier/dashboard/index.html.twig', $this->assignation);
}
}
diff --git a/src/Controllers/Documents/DocumentTranslationsController.php b/src/Controllers/Documents/DocumentTranslationsController.php
index e8c1138f..69c20484 100644
--- a/src/Controllers/Documents/DocumentTranslationsController.php
+++ b/src/Controllers/Documents/DocumentTranslationsController.php
@@ -4,7 +4,6 @@
namespace Themes\Rozier\Controllers\Documents;
-use Exception;
use RZ\Roadiz\Core\AbstractEntities\PersistableInterface;
use RZ\Roadiz\Core\AbstractEntities\TranslationInterface;
use RZ\Roadiz\CoreBundle\Entity\Document;
@@ -28,11 +27,6 @@ class DocumentTranslationsController extends RozierApp
use VersionedControllerTrait;
/**
- * @param Request $request
- * @param int $documentId
- * @param int|null $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $documentId, ?int $translationId = null): Response
@@ -59,11 +53,11 @@ public function editAction(Request $request, int $documentId, ?int $translationI
->getRepository(DocumentTranslation::class)
->findOneBy(['document' => $documentId, 'translation' => $translationId]);
- if ($documentTr === null && $document !== null && $translation !== null) {
+ if (null === $documentTr && null !== $document && null !== $translation) {
$documentTr = $this->createDocumentTranslation($document, $translation);
}
- if ($documentTr === null || $document === null) {
+ if (null === $documentTr || null === $document) {
throw new ResourceNotFoundException();
}
@@ -71,7 +65,7 @@ public function editAction(Request $request, int $documentId, ?int $translationI
$this->assignation['translation'] = $translation;
$this->assignation['documentTr'] = $documentTr;
- /**
+ /*
* Versioning
*/
if ($this->isGranted('ROLE_ACCESS_VERSIONS')) {
@@ -99,7 +93,7 @@ public function editAction(Request $request, int $documentId, ?int $translationI
if ($form->get('referer')->getData()) {
$routeParams = array_merge($routeParams, [
- 'referer' => $form->get('referer')->getData()
+ 'referer' => $form->get('referer')->getData(),
]);
}
@@ -120,7 +114,7 @@ public function editAction(Request $request, int $documentId, ?int $translationI
protected function createDocumentTranslation(
Document $document,
- TranslationInterface $translation
+ TranslationInterface $translation,
): DocumentTranslation {
$dt = new DocumentTranslation();
$dt->setDocument($document);
@@ -134,11 +128,6 @@ protected function createDocumentTranslation(
/**
* Return an deletion form for requested document.
*
- * @param Request $request
- * @param int $documentId
- * @param int $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $documentId, int $translationId): Response
@@ -152,8 +141,8 @@ public function deleteAction(Request $request, int $documentId, int $translation
->find(Document::class, $documentId);
if (
- $documentTr !== null &&
- $document !== null
+ null !== $documentTr
+ && null !== $document
) {
$this->assignation['documentTr'] = $documentTr;
$this->assignation['document'] = $document;
@@ -161,9 +150,9 @@ public function deleteAction(Request $request, int $documentId, int $translation
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- $form->getData()['documentId'] == $documentTr->getId()
+ $form->isSubmitted()
+ && $form->isValid()
+ && $form->getData()['documentId'] == $documentTr->getId()
) {
try {
$this->em()->remove($documentTr);
@@ -174,13 +163,14 @@ public function deleteAction(Request $request, int $documentId, int $translation
['%name%' => (string) $document]
);
$this->publishConfirmMessage($request, $msg, $document);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
$msg = $this->getTranslator()->trans(
'document.translation.%name%.cannot_delete',
['%name%' => (string) $document]
);
$this->publishErrorMessage($request, $msg, $document);
}
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -235,14 +225,15 @@ protected function onPostUpdate(PersistableInterface $entity, Request $request):
protected function getPostUpdateRedirection(PersistableInterface $entity): ?Response
{
if (
- $entity instanceof DocumentTranslation &&
- $entity->getDocument() instanceof Document &&
- $entity->getTranslation() instanceof Translation
+ $entity instanceof DocumentTranslation
+ && $entity->getDocument() instanceof Document
+ && $entity->getTranslation() instanceof Translation
) {
$routeParams = [
'documentId' => $entity->getDocument()->getId(),
'translationId' => $entity->getTranslation()->getId(),
];
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -251,6 +242,7 @@ protected function getPostUpdateRedirection(PersistableInterface $entity): ?Resp
$routeParams
);
}
+
return null;
}
}
diff --git a/src/Controllers/Documents/DocumentsController.php b/src/Controllers/Documents/DocumentsController.php
index 47dac637..26356da6 100644
--- a/src/Controllers/Documents/DocumentsController.php
+++ b/src/Controllers/Documents/DocumentsController.php
@@ -75,14 +75,11 @@ public function __construct(
private readonly RandomImageFinder $randomImageFinder,
private readonly DocumentFactory $documentFactory,
private readonly ?string $googleServerId = null,
- private readonly ?string $soundcloudClientId = null
+ private readonly ?string $soundcloudClientId = null,
) {
}
/**
- * @param Request $request
- * @param int|null $folderId
- * @return Response
* @throws RuntimeError
*/
public function indexAction(Request $request, ?int $folderId = null): Response
@@ -99,8 +96,8 @@ public function indexAction(Request $request, ?int $folderId = null): Response
];
if (
- null !== $folderId &&
- $folderId > 0
+ null !== $folderId
+ && $folderId > 0
) {
$folder = $this->em()
->find(Folder::class, $folderId);
@@ -110,13 +107,13 @@ public function indexAction(Request $request, ?int $folderId = null): Response
}
$type = $request->query->get('type', null);
- if (\is_string($type) && trim($type) !== '') {
+ if (\is_string($type) && '' !== trim($type)) {
$prefilters['mimeType'] = trim($type);
$this->assignation['mimeType'] = trim($type);
}
$embedPlatform = $request->query->get('embedPlatform', null);
- if (\is_string($embedPlatform) && trim($embedPlatform) !== '') {
+ if (\is_string($embedPlatform) && '' !== trim($embedPlatform)) {
$prefilters['embedPlatform'] = trim($embedPlatform);
$this->assignation['embedPlatform'] = trim($embedPlatform);
}
@@ -176,9 +173,6 @@ public function indexAction(Request $request, ?int $folderId = null): Response
}
/**
- * @param Request $request
- * @param int $documentId
- * @return Response
* @throws RuntimeError
* @throws FilesystemException
*/
@@ -188,7 +182,7 @@ public function adjustAction(Request $request, int $documentId): Response
/** @var Document|null $document */
$document = $this->em()->find(Document::class, $documentId);
- if ($document === null) {
+ if (null === $document) {
throw new ResourceNotFoundException();
}
if (!$document->isLocal()) {
@@ -222,7 +216,7 @@ public function adjustAction(Request $request, int $documentId): Response
* Prefix document filename with unique id to avoid overriding original
* if already existing.
*/
- $cloneDocument->setFilename('original_' . uniqid() . '_' . $cloneDocument);
+ $cloneDocument->setFilename('original_'.uniqid().'_'.$cloneDocument);
$newPath = $cloneDocument->getMountPath();
$this->documentsStorage->move($oldPath, $newPath);
@@ -253,7 +247,7 @@ public function adjustAction(Request $request, int $documentId): Response
return new JsonResponse([
'message' => $msg,
- 'path' => $this->documentsStorage->publicUrl($document->getMountPath()) . '?' . \random_int(10, 999),
+ 'path' => $this->documentsStorage->publicUrl($document->getMountPath()).'?'.\random_int(10, 999),
]);
}
@@ -264,9 +258,6 @@ public function adjustAction(Request $request, int $documentId): Response
}
/**
- * @param Request $request
- * @param int $documentId
- * @return Response
* @throws FilesystemException
* @throws RuntimeError
*/
@@ -276,7 +267,7 @@ public function editAction(Request $request, int $documentId): Response
/** @var Document|null $document */
$document = $this->em()->find(Document::class, $documentId);
- if ($document === null) {
+ if (null === $document) {
throw new ResourceNotFoundException();
}
@@ -308,7 +299,7 @@ public function editAction(Request $request, int $documentId): Response
}
$msg = $this->getTranslator()->trans('document.%name%.updated', [
- '%name%' => (string) $document,
+ '%name%' => (string) $document,
]);
$this->publishConfirmMessage($request, $msg, $document);
$this->em()->flush();
@@ -322,9 +313,10 @@ public function editAction(Request $request, int $documentId): Response
if ($form->get('referer')->getData()) {
$routeParams = array_merge($routeParams, [
- 'referer' => $form->get('referer')->getData(),
+ 'referer' => $form->get('referer')->getData(),
]);
}
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -349,9 +341,6 @@ public function editAction(Request $request, int $documentId): Response
/**
* Return an deletion form for requested document.
*
- * @param Request $request
- * @param int $documentId
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $documentId): Response
@@ -361,7 +350,7 @@ public function deleteAction(Request $request, int $documentId): Response
/** @var Document|null $document */
$document = $this->em()->find(Document::class, $documentId);
- if ($document === null) {
+ if (null === $document) {
throw new ResourceNotFoundException();
}
@@ -370,9 +359,9 @@ public function deleteAction(Request $request, int $documentId): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- $form->getData()['documentId'] == $document->getId()
+ $form->isSubmitted()
+ && $form->isValid()
+ && $form->getData()['documentId'] == $document->getId()
) {
try {
$this->dispatchEvent(
@@ -381,16 +370,17 @@ public function deleteAction(Request $request, int $documentId): Response
$this->em()->remove($document);
$this->em()->flush();
$msg = $this->getTranslator()->trans('document.%name%.deleted', [
- '%name%' => (string) $document
+ '%name%' => (string) $document,
]);
$this->publishConfirmMessage($request, $msg, $document);
} catch (\Exception $e) {
$msg = $this->getTranslator()->trans('document.%name%.cannot_delete', [
- '%name%' => (string) $document
+ '%name%' => (string) $document,
]);
$this->logger->error($e->getMessage());
$this->publishErrorMessage($request, $msg, $document);
}
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -405,8 +395,6 @@ public function deleteAction(Request $request, int $documentId): Response
/**
* Return an deletion form for multiple docs.
*
- * @param Request $request
- * @return Response
* @throws RuntimeError
*/
public function bulkDeleteAction(Request $request): Response
@@ -448,7 +436,7 @@ public function bulkDeleteAction(Request $request): Response
return $this->redirectToRoute('documentsHomePage');
}
$this->assignation['form'] = $form->createView();
- $this->assignation['action'] = '?' . http_build_query(['documents' => $documentsIds]);
+ $this->assignation['action'] = '?'.http_build_query(['documents' => $documentsIds]);
$this->assignation['thumbnailFormat'] = $this->thumbnailFormat;
return $this->render('@RoadizRozier/documents/bulkDelete.html.twig', $this->assignation);
@@ -457,9 +445,6 @@ public function bulkDeleteAction(Request $request): Response
/**
* Embed external document page.
*
- * @param Request $request
- * @param int|null $folderId
- * @return Response
* @throws RuntimeError
*/
public function embedAction(Request $request, ?int $folderId = null): Response
@@ -503,12 +488,13 @@ public function embedAction(Request $request, ?int $folderId = null): Response
new DocumentCreatedEvent($document)
);
}
+
/*
* Force redirect to avoid resending form when refreshing page
*/
return $this->redirectToRoute('documentsHomePage', ['folderId' => $folderId]);
} catch (RequestException $e) {
- $this->logger->error($e->getRequest()->getUri() . ' failed.');
+ $this->logger->error($e->getRequest()->getUri().' failed.');
if (null !== $e->getResponse() && in_array($e->getResponse()->getStatusCode(), [401, 403, 404])) {
$form->addError(new FormError(
$this->getTranslator()->trans('document.media_not_found_or_private')
@@ -533,9 +519,6 @@ public function embedAction(Request $request, ?int $folderId = null): Response
/**
* Get random external document page.
*
- * @param Request $request
- * @param int|null $folderId
- * @return Response
* @throws FilesystemException
*/
public function randomAction(Request $request, ?int $folderId = null): Response
@@ -559,6 +542,7 @@ public function randomAction(Request $request, ?int $folderId = null): Response
$this->getTranslator()->trans($e->getMessage())
);
}
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -568,9 +552,6 @@ public function randomAction(Request $request, ?int $folderId = null): Response
/**
* Download document file.
*
- * @param Request $request
- * @param int $documentId
- * @return Response
* @throws FilesystemException
*/
public function downloadAction(Request $request, int $documentId): Response
@@ -580,7 +561,7 @@ public function downloadAction(Request $request, int $documentId): Response
/** @var Document|null $document */
$document = $this->em()->find(Document::class, $documentId);
- if ($document !== null) {
+ if (null !== $document) {
/** @var DocumentHandler $handler */
$handler = $this->handlerFactory->getHandler($document);
@@ -593,9 +574,6 @@ public function downloadAction(Request $request, int $documentId): Response
/**
* Download document file inline.
*
- * @param Request $request
- * @param int $documentId
- * @return Response
* @throws FilesystemException
*/
public function downloadInlineAction(Request $request, int $documentId): Response
@@ -605,7 +583,7 @@ public function downloadInlineAction(Request $request, int $documentId): Respons
/** @var Document|null $document */
$document = $this->em()->find(Document::class, $documentId);
- if ($document !== null) {
+ if (null !== $document) {
/** @var DocumentHandler $handler */
$handler = $this->handlerFactory->getHandler($document);
@@ -616,10 +594,6 @@ public function downloadInlineAction(Request $request, int $documentId): Respons
}
/**
- * @param Request $request
- * @param int|null $folderId
- * @param string $_format
- * @return Response
* @throws RuntimeError
*/
public function uploadAction(Request $request, ?int $folderId = null, string $_format = 'html'): Response
@@ -653,10 +627,11 @@ public function uploadAction(Request $request, ?int $folderId = null, string $_f
new DocumentCreatedEvent($document)
);
- if ($_format === 'json' || $request->isXmlHttpRequest()) {
+ if ('json' === $_format || $request->isXmlHttpRequest()) {
$documentModel = $this->explorerItemFactory->createForEntity(
$document
);
+
return new JsonResponse([
'success' => true,
'document' => $documentModel->toArray(),
@@ -668,13 +643,13 @@ public function uploadAction(Request $request, ?int $folderId = null, string $_f
$msg = $this->getTranslator()->trans('document.cannot_persist');
$this->publishErrorMessage($request, $msg, $document);
- if ($_format === 'json' || $request->isXmlHttpRequest()) {
+ if ('json' === $_format || $request->isXmlHttpRequest()) {
throw $this->createNotFoundException($msg);
} else {
return $this->redirectToRoute('documentsHomePage', ['folderId' => $folderId]);
}
}
- } elseif ($_format === 'json' || $request->isXmlHttpRequest()) {
+ } elseif ('json' === $_format || $request->isXmlHttpRequest()) {
/*
* Bad form submitted
*/
@@ -688,9 +663,10 @@ public function uploadAction(Request $request, ?int $folderId = null, string $_f
}
}
}
+
return new JsonResponse(
[
- "errors" => $errorPerForm,
+ 'errors' => $errorPerForm,
],
Response::HTTP_BAD_REQUEST
);
@@ -705,9 +681,6 @@ public function uploadAction(Request $request, ?int $folderId = null, string $_f
/**
* Return a node list using this document.
*
- * @param Request $request
- * @param int $documentId
- * @return Response
* @throws RuntimeError
*/
public function usageAction(Request $request, int $documentId): Response
@@ -716,7 +689,7 @@ public function usageAction(Request $request, int $documentId): Response
/** @var Document|null $document */
$document = $this->em()->find(Document::class, $documentId);
- if ($document === null) {
+ if (null === $document) {
throw new ResourceNotFoundException();
}
@@ -734,10 +707,6 @@ public function usageAction(Request $request, int $documentId): Response
return $this->render('@RoadizRozier/documents/usage.html.twig', $this->assignation);
}
- /**
- * @param Document $doc
- * @return FormInterface
- */
private function buildDeleteForm(Document $doc): FormInterface
{
$defaults = [
@@ -755,17 +724,13 @@ private function buildDeleteForm(Document $doc): FormInterface
return $builder->getForm();
}
- /**
- * @param array $documentsIds
- * @return FormInterface
- */
private function buildBulkDeleteForm(array $documentsIds): FormInterface
{
$defaults = [
'checksum' => md5(serialize($documentsIds)),
];
$builder = $this->createFormBuilder($defaults, [
- 'action' => '?' . http_build_query(['documents' => $documentsIds]),
+ 'action' => '?'.http_build_query(['documents' => $documentsIds]),
])
->add('checksum', HiddenType::class, [
'constraints' => [
@@ -777,9 +742,6 @@ private function buildBulkDeleteForm(array $documentsIds): FormInterface
return $builder->getForm();
}
- /**
- * @return FormInterface
- */
private function buildFileForm(): FormInterface
{
$defaults = [
@@ -798,15 +760,11 @@ private function buildFileForm(): FormInterface
return $builder->getForm();
}
- /**
- * @param int|null $folderId
- * @return FormInterface
- */
private function buildUploadForm(?int $folderId = null): FormInterface
{
$builder = $this->createFormBuilder([], [
- 'csrf_protection' => false,
- ])
+ 'csrf_protection' => false,
+ ])
->add('attachment', FileType::class, [
'label' => 'choose.documents.to_upload',
'constraints' => [
@@ -815,8 +773,8 @@ private function buildUploadForm(?int $folderId = null): FormInterface
]);
if (
- null !== $folderId &&
- $folderId > 0
+ null !== $folderId
+ && $folderId > 0
) {
$builder->add('folderId', HiddenType::class, [
'data' => $folderId,
@@ -826,9 +784,6 @@ private function buildUploadForm(?int $folderId = null): FormInterface
return $builder->getForm();
}
- /**
- * @return FormInterface
- */
private function buildLinkFoldersForm(): FormInterface
{
$builder = $this->createNamedFormBuilder('folderForm')
@@ -855,7 +810,7 @@ private function buildLinkFoldersForm(): FormInterface
'attr' => [
'class' => 'uk-button uk-button-primary',
'title' => 'link.folders',
- 'data-uk-tooltip' => "{animation:true}",
+ 'data-uk-tooltip' => '{animation:true}',
],
])
->add('submitUnfolder', SubmitType::class, [
@@ -863,7 +818,7 @@ private function buildLinkFoldersForm(): FormInterface
'attr' => [
'class' => 'uk-button',
'title' => 'unlink.folders',
- 'data-uk-tooltip' => "{animation:true}",
+ 'data-uk-tooltip' => '{animation:true}',
],
]);
@@ -872,6 +827,7 @@ private function buildLinkFoldersForm(): FormInterface
/**
* @param array $data
+ *
* @return string Status message
*/
private function joinFolder($data): string
@@ -879,8 +835,8 @@ private function joinFolder($data): string
$msg = $this->getTranslator()->trans('no_documents.linked_to.folders');
if (
- !empty($data['documentsId']) &&
- !empty($data['folderPaths'])
+ !empty($data['documentsId'])
+ && !empty($data['folderPaths'])
) {
$documentsIds = explode(',', $data['documentsId']);
@@ -925,6 +881,7 @@ private function joinFolder($data): string
/**
* @param array $data
+ *
* @return string Status message
*/
private function leaveFolder($data): string
@@ -932,8 +889,8 @@ private function leaveFolder($data): string
$msg = $this->getTranslator()->trans('no_documents.removed_from.folders');
if (
- !empty($data['documentsId']) &&
- !empty($data['folderPaths'])
+ !empty($data['documentsId'])
+ && !empty($data['folderPaths'])
) {
$documentsIds = explode(',', $data['documentsId']);
@@ -978,10 +935,10 @@ private function leaveFolder($data): string
}
/**
- * @param array $data
- * @param int|null $folderId
+ * @param array $data
*
* @return DocumentInterface|array
+ *
* @throws \Exception
* @throws EntityAlreadyExistsException
*/
@@ -990,9 +947,9 @@ private function embedDocument($data, ?int $folderId = null)
$handlers = $this->documentPlatforms;
if (
- isset($data['embedId']) &&
- isset($data['embedPlatform']) &&
- in_array($data['embedPlatform'], array_keys($handlers))
+ isset($data['embedId'])
+ && isset($data['embedPlatform'])
+ && in_array($data['embedPlatform'], array_keys($handlers))
) {
$class = $handlers[$data['embedPlatform']];
@@ -1009,18 +966,16 @@ private function embedDocument($data, ?int $folderId = null)
$finder->setKey($this->soundcloudClientId);
}
$finder->setEmbedId($data['embedId']);
+
return $this->createDocumentFromFinder($finder, $folderId);
} else {
- throw new \RuntimeException("bad.request", 1);
+ throw new \RuntimeException('bad.request', 1);
}
}
/**
* Download a random document.
*
- * @param int|null $folderId
- *
- * @return DocumentInterface|null
* @throws FilesystemException
*/
private function randomDocument(?int $folderId = null): ?DocumentInterface
@@ -1033,15 +988,15 @@ private function randomDocument(?int $folderId = null): ?DocumentInterface
if (is_array($document) && isset($document[0])) {
return $document[0];
}
+
return null;
}
- throw new \RuntimeException('Random image finder must be instance of ' . AbstractEmbedFinder::class);
+ throw new \RuntimeException('Random image finder must be instance of '.AbstractEmbedFinder::class);
}
/**
- * @param AbstractEmbedFinder $finder
- * @param int|null $folderId
* @return DocumentInterface|array
+ *
* @throws FilesystemException
*/
private function createDocumentFromFinder(AbstractEmbedFinder $finder, ?int $folderId = null): DocumentInterface|array
@@ -1071,9 +1026,6 @@ private function createDocumentFromFinder(AbstractEmbedFinder $finder, ?int $fol
/**
* Handle upload form data to create a Document.
*
- * @param FormInterface $data
- * @param int|null $folderId
- * @return DocumentInterface|null
* @throws FilesystemException
*/
private function uploadDocument(FormInterface $data, ?int $folderId = null): ?DocumentInterface
@@ -1092,6 +1044,7 @@ private function uploadDocument(FormInterface $data, ?int $folderId = null): ?Do
if (null !== $document = $this->documentFactory->getDocument()) {
$this->em()->flush();
+
return $document;
}
}
@@ -1101,9 +1054,10 @@ private function uploadDocument(FormInterface $data, ?int $folderId = null): ?Do
private function getListingTemplate(Request $request): string
{
- if ($request->query->get('list') === '1') {
+ if ('1' === $request->query->get('list')) {
return '@RoadizRozier/documents/list-table.html.twig';
}
+
return '@RoadizRozier/documents/list.html.twig';
}
}
diff --git a/src/Controllers/FoldersController.php b/src/Controllers/FoldersController.php
index c3e866b5..0451e41f 100644
--- a/src/Controllers/FoldersController.php
+++ b/src/Controllers/FoldersController.php
@@ -48,10 +48,6 @@ public function indexAction(Request $request): Response
/**
* Return a creation form for requested folder.
*
- * @param Request $request
- * @param int|null $parentFolderId
- *
- * @return Response
* @throws RuntimeError
*/
public function addAction(Request $request, ?int $parentFolderId = null): Response
@@ -106,10 +102,6 @@ public function addAction(Request $request, ?int $parentFolderId = null): Respon
/**
* Return a deletion form for requested folder.
*
- * @param Request $request
- * @param int $folderId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $folderId): Response
@@ -158,10 +150,6 @@ public function deleteAction(Request $request, int $folderId): Response
/**
* Return an edition form for requested folder.
*
- * @param Request $request
- * @param int $folderId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $folderId): Response
@@ -171,7 +159,7 @@ public function editAction(Request $request, int $folderId): Response
/** @var Folder|null $folder */
$folder = $this->em()->find(Folder::class, $folderId);
- if ($folder === null) {
+ if (null === $folder) {
throw new ResourceNotFoundException();
}
@@ -212,11 +200,6 @@ public function editAction(Request $request, int $folderId): Response
}
/**
- * @param Request $request
- * @param int $folderId
- * @param int $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function editTranslationAction(Request $request, int $folderId, int $translationId): Response
@@ -261,9 +244,9 @@ public function editTranslationAction(Request $request, int $folderId, int $tran
$newFolderName = StringHandler::slugify($folderTranslation->getName());
if ($folder->getFolderName() !== $newFolderName) {
if (
- !$folder->isLocked() &&
- $translation->isDefaultTranslation() &&
- !$this->folderNameExists($newFolderName)
+ !$folder->isLocked()
+ && $translation->isDefaultTranslation()
+ && !$this->folderNameExists($newFolderName)
) {
$folder->setFolderName($folderTranslation->getName());
}
@@ -300,23 +283,15 @@ public function editTranslationAction(Request $request, int $folderId, int $tran
return $this->render('@RoadizRozier/folders/edit.html.twig', $this->assignation);
}
- /**
- * @param string $name
- *
- * @return bool
- */
protected function folderNameExists(string $name): bool
{
$entity = $this->em()->getRepository(Folder::class)->findOneByFolderName($name);
- return (null !== $entity);
+
+ return null !== $entity;
}
/**
* Return a ZipArchive of requested folder.
- *
- * @param int $folderId
- *
- * @return Response
*/
public function downloadAction(int $folderId): Response
{
@@ -325,7 +300,7 @@ public function downloadAction(int $folderId): Response
/** @var Folder|null $folder */
$folder = $this->em()->find(Folder::class, $folderId);
- if ($folder === null) {
+ if (null === $folder) {
throw new ResourceNotFoundException();
}
@@ -337,7 +312,7 @@ public function downloadAction(int $folderId): Response
return $this->documentArchiver->archiveAndServe(
$documents,
- $folder->getFolderName() . '_' . date('YmdHi'),
+ $folder->getFolderName().'_'.date('YmdHi'),
true
);
}
diff --git a/src/Controllers/GroupsController.php b/src/Controllers/GroupsController.php
index c4b9e949..0608e899 100644
--- a/src/Controllers/GroupsController.php
+++ b/src/Controllers/GroupsController.php
@@ -22,92 +22,59 @@
class GroupsController extends AbstractAdminController
{
- /**
- * @inheritDoc
- */
protected function supports(PersistableInterface $item): bool
{
return $item instanceof Group;
}
- /**
- * @inheritDoc
- */
protected function getNamespace(): string
{
return 'group';
}
- /**
- * @inheritDoc
- */
protected function createEmptyItem(Request $request): PersistableInterface
{
return new Group();
}
- /**
- * @inheritDoc
- */
protected function getTemplateFolder(): string
{
return '@RoadizRozier/groups';
}
- /**
- * @inheritDoc
- */
protected function getRequiredRole(): string
{
return 'ROLE_ACCESS_GROUPS';
}
- /**
- * @inheritDoc
- */
protected function getEntityClass(): string
{
return Group::class;
}
- /**
- * @inheritDoc
- */
protected function getFormType(): string
{
return GroupType::class;
}
- /**
- * @inheritDoc
- */
protected function getDefaultRouteName(): string
{
return 'groupsHomePage';
}
- /**
- * @inheritDoc
- */
protected function getEditRouteName(): string
{
return 'groupsEditPage';
}
- /**
- * @inheritDoc
- */
protected function getEntityName(PersistableInterface $item): string
{
if ($item instanceof Group) {
return $item->getName();
}
- throw new \InvalidArgumentException('Item should be instance of ' . $this->getEntityClass());
+ throw new \InvalidArgumentException('Item should be instance of '.$this->getEntityClass());
}
- /**
- * @inheritDoc
- */
protected function denyAccessUnlessItemGranted(PersistableInterface $item): void
{
$this->denyAccessUnlessGranted($item);
@@ -116,9 +83,6 @@ protected function denyAccessUnlessItemGranted(PersistableInterface $item): void
/**
* Return an edition form for requested group.
*
- * @param Request $request
- * @param int $id
- * @return Response
* @throws RuntimeError
*/
public function editRolesAction(Request $request, int $id): Response
@@ -140,7 +104,7 @@ public function editRolesAction(Request $request, int $id): Response
if ($form->isSubmitted() && $form->isValid()) {
$role = $this->em()->find(Role::class, (int) $form->get('roleId')->getData());
- if ($role !== null) {
+ if (null !== $role) {
$item->addRoleEntity($role);
$this->em()->flush();
$msg = $this->getTranslator()->trans('role.%role%.linked_group.%group%', [
@@ -163,11 +127,6 @@ public function editRolesAction(Request $request, int $id): Response
}
/**
- * @param Request $request
- * @param int $id
- * @param int $roleId
- *
- * @return Response
* @throws RuntimeError
*/
public function removeRolesAction(Request $request, int $id, int $roleId): Response
@@ -217,10 +176,6 @@ public function removeRolesAction(Request $request, int $id, int $roleId): Respo
}
/**
- * @param Request $request
- * @param int $id
- *
- * @return Response
* @throws RuntimeError
*/
public function editUsersAction(Request $request, int $id): Response
@@ -244,7 +199,7 @@ public function editUsersAction(Request $request, int $id): Response
/** @var User|null $user */
$user = $this->em()->find(User::class, (int) $form->get('userId')->getData());
- if ($user !== null) {
+ if (null !== $user) {
$user->addGroup($item);
$this->em()->flush();
$msg = $this->getTranslator()->trans('user.%user%.linked.group.%group%', [
@@ -267,11 +222,6 @@ public function editUsersAction(Request $request, int $id): Response
}
/**
- * @param Request $request
- * @param int $id
- * @param int $userId
- *
- * @return Response
* @throws RuntimeError
*/
public function removeUsersAction(Request $request, int $id, int $userId): Response
@@ -311,7 +261,7 @@ public function removeUsersAction(Request $request, int $id, int $userId): Respo
return $this->redirectToRoute(
'groupsEditUsersPage',
[
- 'id' => $item->getId()
+ 'id' => $item->getId(),
]
);
}
@@ -321,11 +271,6 @@ public function removeUsersAction(Request $request, int $id, int $userId): Respo
return $this->render('@RoadizRozier/groups/removeUser.html.twig', $this->assignation);
}
- /**
- * @param Group $group
- *
- * @return FormInterface
- */
private function buildEditRolesForm(Group $group): FormInterface
{
$builder = $this->createFormBuilder()
@@ -342,11 +287,6 @@ private function buildEditRolesForm(Group $group): FormInterface
return $builder->getForm();
}
- /**
- * @param Group $group
- *
- * @return FormInterface
- */
private function buildEditUsersForm(Group $group): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/GroupsUtilsController.php b/src/Controllers/GroupsUtilsController.php
index 25e6be3e..8d15f5dc 100644
--- a/src/Controllers/GroupsUtilsController.php
+++ b/src/Controllers/GroupsUtilsController.php
@@ -22,16 +22,12 @@ class GroupsUtilsController extends RozierApp
{
public function __construct(
private readonly SerializerInterface $serializer,
- private readonly GroupsImporter $groupsImporter
+ private readonly GroupsImporter $groupsImporter,
) {
}
/**
* Export all Group data and roles in a Json file (.json).
- *
- * @param Request $request
- *
- * @return Response
*/
public function exportAllAction(Request $request): Response
{
@@ -49,7 +45,7 @@ public function exportAllAction(Request $request): Response
),
Response::HTTP_OK,
[
- 'Content-Disposition' => sprintf('attachment; filename="%s"', 'group-all-' . date("YmdHis") . '.json'),
+ 'Content-Disposition' => sprintf('attachment; filename="%s"', 'group-all-'.date('YmdHis').'.json'),
],
true
);
@@ -57,11 +53,6 @@ public function exportAllAction(Request $request): Response
/**
* Export a Group in a Json file (.json).
- *
- * @param Request $request
- * @param int $id
- *
- * @return Response
*/
public function exportAction(Request $request, int $id): Response
{
@@ -81,7 +72,7 @@ public function exportAction(Request $request, int $id): Response
),
Response::HTTP_OK,
[
- 'Content-Disposition' => sprintf('attachment; filename="%s"', 'group-' . $existingGroup->getName() . '-' . date("YmdHis") . '.json'),
+ 'Content-Disposition' => sprintf('attachment; filename="%s"', 'group-'.$existingGroup->getName().'-'.date('YmdHis').'.json'),
],
true
);
@@ -90,9 +81,6 @@ public function exportAction(Request $request, int $id): Response
/**
* Import a Json file (.rzt) containing Group datas and roles.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function importJsonFileAction(Request $request): Response
@@ -104,9 +92,9 @@ public function importJsonFileAction(Request $request): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- !empty($form['group_file'])
+ $form->isSubmitted()
+ && $form->isValid()
+ && !empty($form['group_file'])
) {
/** @var UploadedFile $file */
$file = $form['group_file']->getData();
@@ -140,9 +128,6 @@ public function importJsonFileAction(Request $request): Response
return $this->render('@RoadizRozier/groups/import.html.twig', $this->assignation);
}
- /**
- * @return FormInterface
- */
private function buildImportJsonFileForm(): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/HistoryController.php b/src/Controllers/HistoryController.php
index acc480ca..6e39db01 100644
--- a/src/Controllers/HistoryController.php
+++ b/src/Controllers/HistoryController.php
@@ -19,22 +19,19 @@
class HistoryController extends RozierApp
{
public static array $levelToHuman = [
- Logger::EMERGENCY => "emergency",
- Logger::CRITICAL => "critical",
- Logger::ALERT => "alert",
- Logger::ERROR => "error",
- Logger::WARNING => "warning",
- Logger::NOTICE => "notice",
- Logger::INFO => "info",
- Logger::DEBUG => "debug",
+ Logger::EMERGENCY => 'emergency',
+ Logger::CRITICAL => 'critical',
+ Logger::ALERT => 'alert',
+ Logger::ERROR => 'error',
+ Logger::WARNING => 'warning',
+ Logger::NOTICE => 'notice',
+ Logger::INFO => 'info',
+ Logger::DEBUG => 'debug',
];
/**
* List all logs action.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function indexAction(Request $request): Response
@@ -63,10 +60,6 @@ public function indexAction(Request $request): Response
/**
* List user logs action.
*
- * @param Request $request
- * @param int|string $userId
- *
- * @return Response
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
diff --git a/src/Controllers/LoginController.php b/src/Controllers/LoginController.php
index 7dea01cb..0b9f906f 100644
--- a/src/Controllers/LoginController.php
+++ b/src/Controllers/LoginController.php
@@ -18,7 +18,7 @@ class LoginController extends RozierApp
public function __construct(
private readonly DocumentUrlGeneratorInterface $documentUrlGenerator,
private readonly RandomImageFinder $randomImageFinder,
- private readonly Settings $settingsBag
+ private readonly Settings $settingsBag,
) {
}
@@ -30,9 +30,9 @@ public function imageAction(Request $request): Response
if (null !== $document = $this->settingsBag->getDocument('login_image')) {
if (
- $document instanceof Document &&
- !$document->isPrivate() &&
- $document->isProcessable()
+ $document instanceof Document
+ && !$document->isPrivate()
+ && $document->isProcessable()
) {
$this->documentUrlGenerator->setDocument($document);
$this->documentUrlGenerator->setOptions([
@@ -41,8 +41,9 @@ public function imageAction(Request $request): Response
'quality' => 80,
'sharpen' => 5,
]);
+
return $response->setData([
- 'url' => $this->documentUrlGenerator->getUrl()
+ 'url' => $this->documentUrlGenerator->getUrl(),
]);
}
}
@@ -53,8 +54,9 @@ public function imageAction(Request $request): Response
if (null !== $feed) {
$url = $feed['url'] ?? $feed['urls']['regular'] ?? $feed['urls']['full'] ?? $feed['urls']['raw'] ?? null;
}
+
return $response->setData([
- 'url' => $url ?? '/themes/Rozier/static/assets/img/default_login.jpg'
+ 'url' => $url ?? '/themes/Rozier/static/assets/img/default_login.jpg',
]);
}
}
diff --git a/src/Controllers/LoginResetController.php b/src/Controllers/LoginResetController.php
index d3cd05e1..67de8312 100644
--- a/src/Controllers/LoginResetController.php
+++ b/src/Controllers/LoginResetController.php
@@ -16,10 +16,6 @@ class LoginResetController extends RozierApp
use LoginResetTrait;
/**
- * @param Request $request
- * @param string $token
- *
- * @return Response
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
diff --git a/src/Controllers/NodeTypeFieldsController.php b/src/Controllers/NodeTypeFieldsController.php
index 4bdcd44b..1138dd2d 100644
--- a/src/Controllers/NodeTypeFieldsController.php
+++ b/src/Controllers/NodeTypeFieldsController.php
@@ -4,7 +4,6 @@
namespace Themes\Rozier\Controllers;
-use Exception;
use RZ\Roadiz\CoreBundle\Entity\NodeType;
use RZ\Roadiz\CoreBundle\Entity\NodeTypeField;
use RZ\Roadiz\CoreBundle\Message\UpdateNodeTypeSchemaMessage;
@@ -23,15 +22,11 @@ class NodeTypeFieldsController extends RozierApp
{
public function __construct(
private readonly bool $allowNodeTypeEdition,
- private readonly MessageBusInterface $messageBus
+ private readonly MessageBusInterface $messageBus,
) {
}
/**
- * @param Request $request
- * @param int $nodeTypeId
- *
- * @return Response
* @throws RuntimeError
*/
public function listAction(Request $request, int $nodeTypeId): Response
@@ -41,7 +36,7 @@ public function listAction(Request $request, int $nodeTypeId): Response
/** @var NodeType|null $nodeType */
$nodeType = $this->em()->find(NodeType::class, $nodeTypeId);
- if ($nodeType === null) {
+ if (null === $nodeType) {
throw new ResourceNotFoundException();
}
@@ -54,10 +49,6 @@ public function listAction(Request $request, int $nodeTypeId): Response
}
/**
- * @param Request $request
- * @param int $nodeTypeFieldId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $nodeTypeFieldId): Response
@@ -67,7 +58,7 @@ public function editAction(Request $request, int $nodeTypeFieldId): Response
/** @var NodeTypeField|null $field */
$field = $this->em()->find(NodeTypeField::class, $nodeTypeFieldId);
- if ($field === null) {
+ if (null === $field) {
throw new ResourceNotFoundException();
}
@@ -105,10 +96,6 @@ public function editAction(Request $request, int $nodeTypeFieldId): Response
}
/**
- * @param Request $request
- * @param int $nodeTypeId
- *
- * @return Response
* @throws RuntimeError
*/
public function addAction(Request $request, int $nodeTypeId): Response
@@ -119,7 +106,7 @@ public function addAction(Request $request, int $nodeTypeId): Response
/** @var NodeType|null $nodeType */
$nodeType = $this->em()->find(NodeType::class, $nodeTypeId);
- if ($nodeType === null) {
+ if (null === $nodeType) {
throw new ResourceNotFoundException();
}
@@ -134,7 +121,7 @@ public function addAction(Request $request, int $nodeTypeId): Response
$this->assignation['field'] = $field;
$form = $this->createForm(NodeTypeFieldType::class, $field, [
- 'disabled' => !$this->allowNodeTypeEdition
+ 'disabled' => !$this->allowNodeTypeEdition,
]);
$form->handleRequest($request);
@@ -161,7 +148,7 @@ public function addAction(Request $request, int $nodeTypeId): Response
'nodeTypeId' => $nodeTypeId,
]
);
- } catch (Exception $e) {
+ } catch (\Exception $e) {
$form->addError(new FormError($e->getMessage()));
}
}
@@ -173,10 +160,6 @@ public function addAction(Request $request, int $nodeTypeId): Response
}
/**
- * @param Request $request
- * @param int $nodeTypeFieldId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $nodeTypeFieldId): Response
@@ -186,7 +169,7 @@ public function deleteAction(Request $request, int $nodeTypeFieldId): Response
/** @var NodeTypeField|null $field */
$field = $this->em()->find(NodeTypeField::class, $nodeTypeFieldId);
- if ($field === null) {
+ if (null === $field) {
throw new ResourceNotFoundException();
}
diff --git a/src/Controllers/NodeTypes/NodeTypesController.php b/src/Controllers/NodeTypes/NodeTypesController.php
index 58720914..1f5f68ef 100644
--- a/src/Controllers/NodeTypes/NodeTypesController.php
+++ b/src/Controllers/NodeTypes/NodeTypesController.php
@@ -23,7 +23,7 @@ class NodeTypesController extends RozierApp
{
public function __construct(
private readonly bool $allowNodeTypeEdition,
- private readonly MessageBusInterface $messageBus
+ private readonly MessageBusInterface $messageBus,
) {
}
@@ -55,9 +55,6 @@ public function indexAction(Request $request): Response
}
/**
- * @param Request $request
- * @param int $nodeTypeId
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $nodeTypeId): Response
@@ -83,7 +80,7 @@ public function editAction(Request $request, int $nodeTypeId): Response
$this->publishConfirmMessage($request, $msg, $nodeType);
return $this->redirectToRoute('nodeTypesEditPage', [
- 'nodeTypeId' => $nodeTypeId
+ 'nodeTypeId' => $nodeTypeId,
]);
} catch (EntityAlreadyExistsException $e) {
$form->addError(new FormError($e->getMessage()));
@@ -97,9 +94,6 @@ public function editAction(Request $request, int $nodeTypeId): Response
}
/**
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function addAction(Request $request): Response
@@ -108,7 +102,7 @@ public function addAction(Request $request): Response
$nodeType = new NodeType();
$form = $this->createForm(NodeTypeType::class, $nodeType, [
- 'disabled' => !$this->allowNodeTypeEdition
+ 'disabled' => !$this->allowNodeTypeEdition,
]);
$form->handleRequest($request);
@@ -126,7 +120,7 @@ public function addAction(Request $request): Response
$this->publishConfirmMessage($request, $msg, $nodeType);
return $this->redirectToRoute('nodeTypesEditPage', [
- 'nodeTypeId' => $nodeType->getId()
+ 'nodeTypeId' => $nodeType->getId(),
]);
} catch (EntityAlreadyExistsException $e) {
$form->addError(new FormError($e->getMessage()));
@@ -141,10 +135,6 @@ public function addAction(Request $request): Response
}
/**
- * @param Request $request
- * @param int $nodeTypeId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $nodeTypeId): Response
diff --git a/src/Controllers/NodeTypes/NodeTypesUtilsController.php b/src/Controllers/NodeTypes/NodeTypesUtilsController.php
index 059a6b13..91d2689c 100644
--- a/src/Controllers/NodeTypes/NodeTypesUtilsController.php
+++ b/src/Controllers/NodeTypes/NodeTypesUtilsController.php
@@ -33,17 +33,12 @@ public function __construct(
private readonly SerializerInterface $serializer,
private readonly NodeTypes $nodeTypesBag,
private readonly NodeTypesImporter $nodeTypesImporter,
- private readonly MessageBusInterface $messageBus
+ private readonly MessageBusInterface $messageBus,
) {
}
/**
* Export a Json file containing NodeType data and fields.
- *
- * @param Request $request
- * @param int $nodeTypeId
- *
- * @return JsonResponse
*/
public function exportJsonFileAction(Request $request, int $nodeTypeId): JsonResponse
{
@@ -64,15 +59,13 @@ public function exportJsonFileAction(Request $request, int $nodeTypeId): JsonRes
),
Response::HTTP_OK,
[
- 'Content-Disposition' => sprintf('attachment; filename="%s"', $nodeType->getName() . '.json'),
+ 'Content-Disposition' => sprintf('attachment; filename="%s"', $nodeType->getName().'.json'),
],
true
);
}
/**
- * @param Request $request
- * @return BinaryFileResponse
* @throws RuntimeError
*/
public function exportDocumentationAction(Request $request): BinaryFileResponse
@@ -81,14 +74,14 @@ public function exportDocumentationAction(Request $request): BinaryFileResponse
$documentationGenerator = new DocumentationGenerator($this->nodeTypesBag, $this->getTranslator());
- $tmpfname = tempnam(sys_get_temp_dir(), date('Y-m-d-H-i-s') . '.zip');
+ $tmpfname = tempnam(sys_get_temp_dir(), date('Y-m-d-H-i-s').'.zip');
if (false === $tmpfname) {
throw new RuntimeError('Unable to create temporary file.');
}
unlink($tmpfname); // Deprecated: ZipArchive::open(): Using empty file as ZipArchive is deprecated
- $zipArchive = new ZipArchive();
- $zipArchive->open($tmpfname, ZipArchive::CREATE);
+ $zipArchive = new \ZipArchive();
+ $zipArchive->open($tmpfname, \ZipArchive::CREATE);
$zipArchive->addFromString(
'_sidebar.md',
@@ -113,18 +106,13 @@ public function exportDocumentationAction(Request $request): BinaryFileResponse
$response = new BinaryFileResponse($tmpfname);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
- 'documentation-' . date('Y-m-d-H-i-s') . '.zip'
+ 'documentation-'.date('Y-m-d-H-i-s').'.zip'
);
$response->deleteFileAfterSend(true);
return $response;
}
- /**
- * @param Request $request
- *
- * @return Response
- */
public function exportTypeScriptDeclarationAction(Request $request): Response
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODETYPES');
@@ -133,12 +121,13 @@ public function exportTypeScriptDeclarationAction(Request $request): Response
new DeclarationGeneratorFactory($this->nodeTypesBag)
);
- $fileName = 'roadiz-app-' . date('Ymd-His') . '.d.ts';
+ $fileName = 'roadiz-app-'.date('Ymd-His').'.d.ts';
$response = new Response($documentationGenerator->getContents(), Response::HTTP_OK, [
'Content-type' => 'application/x-typescript',
- 'Content-Disposition' => 'attachment; filename="' . $fileName . '"',
+ 'Content-Disposition' => 'attachment; filename="'.$fileName.'"',
]);
$response->prepare($request);
+
return $response;
}
@@ -150,18 +139,18 @@ public function exportAllAction(Request $request): BinaryFileResponse
->getRepository(NodeType::class)
->findAll();
- $zipArchive = new ZipArchive();
- $tmpfname = tempnam(sys_get_temp_dir(), date('Y-m-d-H-i-s') . '.zip');
+ $zipArchive = new \ZipArchive();
+ $tmpfname = tempnam(sys_get_temp_dir(), date('Y-m-d-H-i-s').'.zip');
if (false === $tmpfname) {
throw new RuntimeError('Unable to create temporary file.');
}
unlink($tmpfname); // Deprecated: ZipArchive::open(): Using empty file as ZipArchive is deprecated
- $zipArchive->open($tmpfname, ZipArchive::CREATE);
+ $zipArchive->open($tmpfname, \ZipArchive::CREATE);
/** @var NodeType $nodeType */
foreach ($nodeTypes as $nodeType) {
$zipArchive->addFromString(
- $nodeType->getName() . '.json',
+ $nodeType->getName().'.json',
$this->serializer->serialize(
$nodeType,
'json',
@@ -174,7 +163,7 @@ public function exportAllAction(Request $request): BinaryFileResponse
$response = new BinaryFileResponse($tmpfname);
$response->setContentDisposition(
ResponseHeaderBag::DISPOSITION_ATTACHMENT,
- 'nodetypes-' . date('Y-m-d-H-i-s') . '.zip'
+ 'nodetypes-'.date('Y-m-d-H-i-s').'.zip'
);
$response->deleteFileAfterSend(true);
@@ -184,9 +173,6 @@ public function exportAllAction(Request $request): BinaryFileResponse
/**
* Import a Json file (.json) containing NodeType datas and fields.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function importJsonFileAction(Request $request): Response
@@ -198,9 +184,9 @@ public function importJsonFileAction(Request $request): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- !empty($form['node_type_file'])
+ $form->isSubmitted()
+ && $form->isValid()
+ && !empty($form['node_type_file'])
) {
$file = $form['node_type_file']->getData();
@@ -232,9 +218,6 @@ public function importJsonFileAction(Request $request): Response
return $this->render('@RoadizRozier/node-types/import.html.twig', $this->assignation);
}
- /**
- * @return FormInterface
- */
private function buildImportJsonFileForm(): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/Nodes/ExportController.php b/src/Controllers/Nodes/ExportController.php
index 3b1f02ef..4f4e5c02 100644
--- a/src/Controllers/Nodes/ExportController.php
+++ b/src/Controllers/Nodes/ExportController.php
@@ -19,17 +19,12 @@ class ExportController extends RozierApp
{
public function __construct(
private readonly ManagerRegistry $managerRegistry,
- private readonly SerializerInterface $serializer
+ private readonly SerializerInterface $serializer,
) {
}
/**
* Export all Node in a CSV file.
- *
- * @param int $translationId
- * @param int|null $parentNodeId
- *
- * @return Response
*/
public function exportAllAction(int $translationId, ?int $parentNodeId = null): Response
{
@@ -42,9 +37,9 @@ public function exportAllAction(int $translationId, ?int $parentNodeId = null):
->getRepository(Translation::class)
->findDefault();
}
- $criteria = ["translation" => $translation];
+ $criteria = ['translation' => $translation];
$order = ['node.nodeType' => 'ASC'];
- $filename = 'nodes-' . date("YmdHis") . '.' . $translation->getLocale() . '.csv';
+ $filename = 'nodes-'.date('YmdHis').'.'.$translation->getLocale().'.csv';
if (null !== $parentNodeId) {
/** @var Node|null $parentNode */
@@ -56,7 +51,7 @@ public function exportAllAction(int $translationId, ?int $parentNodeId = null):
}
$this->denyAccessUnlessGranted(NodeVoter::READ, $parentNode);
$criteria['node.parent'] = $parentNode;
- $filename = $parentNode->getNodeName() . '-' . date("YmdHis") . '.' . $translation->getLocale() . '.csv';
+ $filename = $parentNode->getNodeName().'-'.date('YmdHis').'.'.$translation->getLocale().'.csv';
} else {
$this->denyAccessUnlessGranted(NodeVoter::READ_AT_ROOT);
}
diff --git a/src/Controllers/Nodes/HistoryController.php b/src/Controllers/Nodes/HistoryController.php
index 6915d67e..2c4ad7b4 100644
--- a/src/Controllers/Nodes/HistoryController.php
+++ b/src/Controllers/Nodes/HistoryController.php
@@ -20,9 +20,6 @@
class HistoryController extends RozierApp
{
/**
- * @param Request $request
- * @param int $nodeId
- * @return Response
* @throws RuntimeError
*/
public function historyAction(Request $request, int $nodeId): Response
@@ -45,7 +42,7 @@ public function historyAction(Request $request, int $nodeId): Response
$queryBuilder->expr()->like('obj.message', ':search'),
$queryBuilder->expr()->like('obj.channel', ':search')
));
- $queryBuilder->setParameter('search', '%' . $search . '%');
+ $queryBuilder->setParameter('search', '%'.$search.'%');
});
$listManager->setDisplayingNotPublishedNodes(true);
$listManager->setDisplayingAllNodesStatuses(true);
diff --git a/src/Controllers/Nodes/NodesAttributesController.php b/src/Controllers/Nodes/NodesAttributesController.php
index f1dfe96e..f500034e 100644
--- a/src/Controllers/Nodes/NodesAttributesController.php
+++ b/src/Controllers/Nodes/NodesAttributesController.php
@@ -29,16 +29,11 @@ class NodesAttributesController extends RozierApp
{
public function __construct(
private readonly FormFactoryInterface $formFactory,
- private readonly FormErrorSerializer $formErrorSerializer
+ private readonly FormErrorSerializer $formErrorSerializer,
) {
}
/**
- * @param Request $request
- * @param int $nodeId
- * @param int $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $nodeId, int $translationId): Response
@@ -74,9 +69,9 @@ public function editAction(Request $request, int $nodeId, int $translationId): R
}
$isJson =
- $request->isXmlHttpRequest() ||
- $request->getRequestFormat('html') === 'json' ||
- \in_array(
+ $request->isXmlHttpRequest()
+ || 'json' === $request->getRequestFormat('html')
+ || \in_array(
'application/json',
$request->getAcceptableContentTypes()
);
@@ -93,7 +88,7 @@ public function editAction(Request $request, int $nodeId, int $translationId): R
);
/** @var AttributeValue $attributeValue */
foreach ($attributeValues as $attributeValue) {
- $name = $node->getNodeName() . '_attribute_' . $attributeValue->getId();
+ $name = $node->getNodeName().'_attribute_'.$attributeValue->getId();
$attributeValueTranslation = $attributeValue->getAttributeValueTranslation($translation);
if (null === $attributeValueTranslation) {
$attributeValueTranslation = new AttributeValueTranslation();
@@ -132,6 +127,7 @@ public function editAction(Request $request, int $nodeId, int $translationId): R
'message' => $msg,
], Response::HTTP_ACCEPTED);
}
+
return $this->redirectToRoute('nodesEditAttributesPage', [
'nodeId' => $node->getId(),
'translationId' => $translation->getId(),
@@ -180,16 +176,10 @@ protected function isAttributable(Node $node): bool
if ($nodeType instanceof NodeType) {
return $nodeType->isAttributable();
}
+
return false;
}
- /**
- * @param Request $request
- * @param Node $node
- * @param Translation $translation
- *
- * @return RedirectResponse|null
- */
protected function handleAddAttributeForm(Request $request, Node $node, Translation $translation): ?RedirectResponse
{
if (!$this->isAttributable($node)) {
@@ -232,19 +222,13 @@ protected function handleAddAttributeForm(Request $request, Node $node, Translat
}
/**
- * @param Request $request
- * @param int $nodeId
- * @param int $translationId
- * @param int $attributeValueId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $nodeId, int $translationId, int $attributeValueId): Response
{
/** @var AttributeValue|null $item */
$item = $this->em()->find(AttributeValue::class, $attributeValueId);
- if ($item === null) {
+ if (null === $item) {
throw $this->createNotFoundException('AttributeValue does not exist.');
}
/** @var Translation|null $translation */
@@ -305,11 +289,6 @@ public function deleteAction(Request $request, int $nodeId, int $translationId,
}
/**
- * @param Request $request
- * @param int $nodeId
- * @param int $translationId
- * @param int $attributeValueId
- * @return Response
* @throws RuntimeError
*/
public function resetAction(Request $request, int $nodeId, int $translationId, int $attributeValueId): Response
@@ -319,9 +298,9 @@ public function resetAction(Request $request, int $nodeId, int $translationId, i
->getRepository(AttributeValueTranslation::class)
->findOneBy([
'attributeValue' => $attributeValueId,
- 'translation' => $translationId
+ 'translation' => $translationId,
]);
- if ($item === null) {
+ if (null === $item) {
throw $this->createNotFoundException('AttributeValueTranslation does not exist.');
}
/** @var Translation|null $translation */
diff --git a/src/Controllers/Nodes/NodesController.php b/src/Controllers/Nodes/NodesController.php
index 482e097f..38b652fe 100644
--- a/src/Controllers/Nodes/NodesController.php
+++ b/src/Controllers/Nodes/NodesController.php
@@ -44,13 +44,6 @@ final class NodesController extends RozierApp
use NodesTrait;
/**
- * @param NodeChrootResolver $nodeChrootResolver
- * @param NodeMover $nodeMover
- * @param Registry $workflowRegistry
- * @param HandlerFactoryInterface $handlerFactory
- * @param UniqueNodeGenerator $uniqueNodeGenerator
- * @param NodeFactory $nodeFactory
- * @param NodeOffspringResolverInterface $nodeOffspringResolver
* @param class-string $nodeFormTypeClass
* @param class-string $addNodeFormTypeClass
*/
@@ -63,7 +56,7 @@ public function __construct(
private readonly NodeFactory $nodeFactory,
private readonly NodeOffspringResolverInterface $nodeOffspringResolver,
private readonly string $nodeFormTypeClass,
- private readonly string $addNodeFormTypeClass
+ private readonly string $addNodeFormTypeClass,
) {
}
@@ -75,10 +68,6 @@ protected function getNodeFactory(): NodeFactory
/**
* List every node.
*
- * @param Request $request
- * @param string|null $filter
- *
- * @return Response
* @throws RuntimeError
*/
public function indexAction(Request $request, ?string $filter = null): Response
@@ -121,7 +110,7 @@ public function indexAction(Request $request, ?string $filter = null): Response
}
if (null !== $user) {
- $arrayFilter["chroot"] = $this->nodeChrootResolver->getChroot($user);
+ $arrayFilter['chroot'] = $this->nodeChrootResolver->getChroot($user);
}
/*
@@ -159,11 +148,6 @@ public function indexAction(Request $request, ?string $filter = null): Response
/**
* Return an edition form for requested node.
*
- * @param Request $request
- * @param int $nodeId
- * @param int|null $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $nodeId, ?int $translationId = null): Response
@@ -194,6 +178,7 @@ public function editAction(Request $request, int $nodeId, ?int $translationId =
]
);
$this->publishConfirmMessage($request, $msg, $node);
+
return $this->redirectToRoute(
'nodesEditPage',
['nodeId' => $node->getId()]
@@ -235,6 +220,7 @@ public function editAction(Request $request, int $nodeId, ?int $translationId =
'%name%' => $node->getNodeName(),
]);
$this->publishConfirmMessage($request, $msg, $node->getNodeSources()->first() ?: $node);
+
return $this->redirectToRoute(
'nodesEditPage',
['nodeId' => $node->getId()]
@@ -261,12 +247,6 @@ public function editAction(Request $request, int $nodeId, ?int $translationId =
return $this->render('@RoadizRozier/nodes/edit.html.twig', $this->assignation);
}
- /**
- * @param Request $request
- * @param int $nodeId
- * @param int $typeId
- * @return Response
- */
public function removeStackTypeAction(Request $request, int $nodeId, int $typeId): Response
{
/** @var Node|null $node */
@@ -300,11 +280,6 @@ public function removeStackTypeAction(Request $request, int $nodeId, int $typeId
/**
* Handle node creation pages.
*
- * @param Request $request
- * @param int $nodeTypeId
- * @param int|null $translationId
- *
- * @return Response
* @throws RuntimeError
* @throws ORMException
* @throws OptimisticLockException
@@ -315,17 +290,17 @@ public function addAction(Request $request, int $nodeTypeId, ?int $translationId
/** @var NodeType|null $type */
$type = $this->em()->find(NodeType::class, $nodeTypeId);
- if ($type === null) {
+ if (null === $type) {
throw new ResourceNotFoundException(sprintf('Node-type #%s does not exist.', $nodeTypeId));
}
/** @var Translation|null $translation */
$translation = $this->em()->getRepository(Translation::class)->findDefault();
- if ($translationId !== null) {
+ if (null !== $translationId) {
$translation = $this->em()->find(Translation::class, $translationId);
}
- if ($translation === null) {
+ if (null === $translation) {
throw new ResourceNotFoundException(sprintf('Translation #%s does not exist.', $translationId));
}
@@ -363,7 +338,7 @@ public function addAction(Request $request, int $nodeTypeId, ?int $translationId
'nodesEditSourcePage',
[
'nodeId' => $node->getId(),
- 'translationId' => $translation->getId()
+ 'translationId' => $translation->getId(),
]
);
} catch (EntityAlreadyExistsException $e) {
@@ -384,11 +359,6 @@ public function addAction(Request $request, int $nodeTypeId, ?int $translationId
/**
* Handle node creation pages.
*
- * @param Request $request
- * @param int|null $nodeId
- * @param int|null $translationId
- *
- * @return Response
* @throws ORMException
* @throws OptimisticLockException
* @throws RuntimeError
@@ -453,7 +423,7 @@ public function addChildAction(Request $request, ?int $nodeId = null, ?int $tran
'nodesEditSourcePage',
[
'nodeId' => $node->getId(),
- 'translationId' => $translation->getId()
+ 'translationId' => $translation->getId(),
]
);
} catch (EntityAlreadyExistsException $e) {
@@ -474,10 +444,6 @@ public function addChildAction(Request $request, ?int $nodeId = null, ?int $tran
/**
* Return an deletion form for requested node.
*
- * @param Request $request
- * @param int $nodeId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $nodeId): Response
@@ -494,11 +460,12 @@ public function deleteAction(Request $request, int $nodeId): Response
$workflow = $this->workflowRegistry->get($node);
if (!$workflow->can($node, 'delete')) {
$this->publishErrorMessage($request, sprintf('Node #%s cannot be deleted.', $nodeId), $node);
+
return $this->redirectToRoute(
'nodesEditSourcePage',
[
'nodeId' => $node->getId(),
- 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId()
+ 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId(),
]
);
}
@@ -508,9 +475,9 @@ public function deleteAction(Request $request, int $nodeId): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- $form->getData()['nodeId'] == $node->getId()
+ $form->isSubmitted()
+ && $form->isValid()
+ && $form->getData()['nodeId'] == $node->getId()
) {
/** @var Node|null $parent */
$parent = $node->getParent();
@@ -532,8 +499,8 @@ public function deleteAction(Request $request, int $nodeId): Response
$referrer = $request->query->get('referer');
if (
- \is_string($referrer) &&
- (new UnicodeString($referrer))->trim()->startsWith('/')
+ \is_string($referrer)
+ && (new UnicodeString($referrer))->trim()->startsWith('/')
) {
return $this->redirect($referrer);
}
@@ -542,22 +509,21 @@ public function deleteAction(Request $request, int $nodeId): Response
'nodesEditSourcePage',
[
'nodeId' => $parent->getId(),
- 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId()
+ 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId(),
]
);
}
+
return $this->redirectToRoute('nodesHomePage');
}
$this->assignation['form'] = $form->createView();
+
return $this->render('@RoadizRozier/nodes/delete.html.twig', $this->assignation);
}
/**
* Empty trash action.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function emptyTrashAction(Request $request): Response
@@ -571,8 +537,8 @@ public function emptyTrashAction(Request $request): Response
$criteria = ['status' => Node::DELETED];
/** @var Node|null $chroot */
$chroot = $this->nodeChrootResolver->getChroot($this->getUser());
- if ($chroot !== null) {
- $criteria["parent"] = $this->nodeOffspringResolver->getAllOffspringIds($chroot);
+ if (null !== $chroot) {
+ $criteria['parent'] = $this->nodeOffspringResolver->getAllOffspringIds($chroot);
}
$nodes = $this->em()
@@ -606,10 +572,6 @@ public function emptyTrashAction(Request $request): Response
/**
* Return an deletion form for requested node.
*
- * @param Request $request
- * @param int $nodeId
- *
- * @return Response
* @throws RuntimeError
*/
public function undeleteAction(Request $request, int $nodeId): Response
@@ -626,11 +588,12 @@ public function undeleteAction(Request $request, int $nodeId): Response
$workflow = $this->workflowRegistry->get($node);
if (!$workflow->can($node, 'undelete')) {
$this->publishErrorMessage($request, sprintf('Node #%s cannot be undeleted.', $nodeId), $node);
+
return $this->redirectToRoute(
'nodesEditSourcePage',
[
'nodeId' => $node->getId(),
- 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId()
+ 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId(),
]
);
}
@@ -652,6 +615,7 @@ public function undeleteAction(Request $request, int $nodeId): Response
['%name%' => $node->getNodeName()]
);
$this->publishConfirmMessage($request, $msg, $node->getNodeSources()->first() ?: $node);
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -665,10 +629,6 @@ public function undeleteAction(Request $request, int $nodeId): Response
return $this->render('@RoadizRozier/nodes/undelete.html.twig', $this->assignation);
}
- /**
- * @param Request $request
- * @return RedirectResponse
- */
public function generateAndAddNodeAction(Request $request): RedirectResponse
{
$this->denyAccessUnlessGranted('ROLE_ACCESS_NODES');
@@ -686,7 +646,7 @@ public function generateAndAddNodeAction(Request $request): RedirectResponse
'nodesEditSourcePage',
[
'nodeId' => $source->getNode()->getId(),
- 'translationId' => $translation->getId()
+ 'translationId' => $translation->getId(),
]
);
} catch (\Exception $e) {
@@ -696,9 +656,6 @@ public function generateAndAddNodeAction(Request $request): RedirectResponse
}
/**
- * @param Request $request
- * @param int $nodeId
- * @return Response
* @throws RuntimeError
*/
public function publishAllAction(Request $request, int $nodeId): Response
@@ -714,11 +671,12 @@ public function publishAllAction(Request $request, int $nodeId): Response
$workflow = $this->workflowRegistry->get($node);
if (!$workflow->can($node, 'publish')) {
$this->publishErrorMessage($request, sprintf('Node #%s cannot be published.', $nodeId), $node);
+
return $this->redirectToRoute(
'nodesEditSourcePage',
[
'nodeId' => $node->getId(),
- 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId()
+ 'translationId' => $this->em()->getRepository(Translation::class)->findDefault()->getId(),
]
);
}
diff --git a/src/Controllers/Nodes/NodesSourcesController.php b/src/Controllers/Nodes/NodesSourcesController.php
index 980ed5f3..eed80d0f 100644
--- a/src/Controllers/Nodes/NodesSourcesController.php
+++ b/src/Controllers/Nodes/NodesSourcesController.php
@@ -36,18 +36,13 @@ class NodesSourcesController extends RozierApp
public function __construct(
private readonly JwtExtension $jwtExtension,
- private readonly FormErrorSerializer $formErrorSerializer
+ private readonly FormErrorSerializer $formErrorSerializer,
) {
}
/**
* Return an edition form for requested node.
*
- * @param Request $request
- * @param int $nodeId
- * @param int $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function editSourceAction(Request $request, int $nodeId, int $translationId): Response
@@ -86,7 +81,7 @@ public function editSourceAction(Request $request, int $nodeId, int $translation
$node = $source->getNode();
- /**
+ /*
* Versioning
*/
if ($this->isGranted('ROLE_ACCESS_VERSIONS')) {
@@ -108,8 +103,8 @@ public function editSourceAction(Request $request, int $nodeId, int $translation
);
$form->handleRequest($request);
$isJsonRequest =
- $request->isXmlHttpRequest() ||
- \in_array('application/json', $request->getAcceptableContentTypes())
+ $request->isXmlHttpRequest()
+ || \in_array('application/json', $request->getAcceptableContentTypes())
;
if ($form->isSubmitted()) {
@@ -126,31 +121,31 @@ public function editSourceAction(Request $request, int $nodeId, int $translation
$previewUrl = $this->generateUrl($source, [
'canonicalScheme' => $this->getSettingsBag()->get('custom_preview_scheme'),
'token' => $jwtToken,
- NodeRouter::NO_CACHE_PARAMETER => true
+ NodeRouter::NO_CACHE_PARAMETER => true,
], UrlGeneratorInterface::ABSOLUTE_URL);
} elseif ($this->getSettingsBag()->get('custom_public_scheme')) {
$previewUrl = $this->generateUrl($source, [
'canonicalScheme' => $this->getSettingsBag()->get('custom_public_scheme'),
'_preview' => 1,
'token' => $jwtToken,
- NodeRouter::NO_CACHE_PARAMETER => true
+ NodeRouter::NO_CACHE_PARAMETER => true,
], UrlGeneratorInterface::ABSOLUTE_URL);
} else {
$previewUrl = $this->generateUrl($source, [
'_preview' => 1,
'token' => $jwtToken,
- NodeRouter::NO_CACHE_PARAMETER => true
+ NodeRouter::NO_CACHE_PARAMETER => true,
]);
}
if ($this->getSettingsBag()->get('custom_public_scheme')) {
$publicUrl = $this->generateUrl($source, [
'canonicalScheme' => $this->getSettingsBag()->get('custom_public_scheme'),
- NodeRouter::NO_CACHE_PARAMETER => true
+ NodeRouter::NO_CACHE_PARAMETER => true,
], UrlGeneratorInterface::ABSOLUTE_URL);
} else {
$publicUrl = $this->generateUrl($source, [
- NodeRouter::NO_CACHE_PARAMETER => true
+ NodeRouter::NO_CACHE_PARAMETER => true,
]);
}
@@ -171,6 +166,7 @@ public function editSourceAction(Request $request, int $nodeId, int $translation
*/
if ($isJsonRequest) {
$errors = $this->formErrorSerializer->getErrorsAsArray($form);
+
return new JsonResponse([
'status' => 'fail',
'errors' => $errors,
@@ -196,10 +192,6 @@ public function editSourceAction(Request $request, int $nodeId, int $translation
/**
* Return a remove form for requested nodeSource.
*
- * @param Request $request
- * @param int $nodeSourceId
- *
- * @return Response
* @throws RuntimeError
*/
public function removeAction(Request $request, int $nodeSourceId): Response
@@ -262,11 +254,11 @@ public function removeAction(Request $request, int $nodeSourceId): Response
return $this->redirectToRoute(
'nodesEditSourcePage',
- ['nodeId' => $node->getId(), "translationId" => $ns->getTranslation()->getId()]
+ ['nodeId' => $node->getId(), 'translationId' => $ns->getTranslation()->getId()]
);
}
- $this->assignation["nodeSource"] = $ns;
+ $this->assignation['nodeSource'] = $ns;
$this->assignation['form'] = $form->createView();
return $this->render('@RoadizRozier/nodes/deleteSource.html.twig', $this->assignation);
@@ -301,11 +293,12 @@ protected function getPostUpdateRedirection(PersistableInterface $entity): ?Resp
/** @var Translation $translation */
$translation = $entity->getTranslation();
+
return $this->redirectToRoute(
'nodesEditSourcePage',
[
'nodeId' => $entity->getNode()->getId(),
- 'translationId' => $translation->getId()
+ 'translationId' => $translation->getId(),
]
);
}
diff --git a/src/Controllers/Nodes/NodesTreesController.php b/src/Controllers/Nodes/NodesTreesController.php
index 7604d5b6..6bd770a5 100644
--- a/src/Controllers/Nodes/NodesTreesController.php
+++ b/src/Controllers/Nodes/NodesTreesController.php
@@ -37,16 +37,11 @@ public function __construct(
private readonly TreeWidgetFactory $treeWidgetFactory,
private readonly FormFactoryInterface $formFactory,
private readonly HandlerFactoryInterface $handlerFactory,
- private readonly Registry $workflowRegistry
+ private readonly Registry $workflowRegistry,
) {
}
/**
- * @param Request $request
- * @param int|null $nodeId
- * @param int|null $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function treeAction(Request $request, ?int $nodeId = null, ?int $translationId = null): Response
@@ -83,8 +78,8 @@ public function treeAction(Request $request, ?int $nodeId = null, ?int $translat
$widget = $this->treeWidgetFactory->createNodeTree($node, $translation);
if (
- $request->get('tagId') &&
- $request->get('tagId') > 0
+ $request->get('tagId')
+ && $request->get('tagId') > 0
) {
$filterTag = $this->em()->find(Tag::class, (int) $request->get('tagId'));
$this->assignation['filterTag'] = $filterTag;
@@ -92,7 +87,7 @@ public function treeAction(Request $request, ?int $nodeId = null, ?int $translat
}
$widget->setStackTree(true);
- $widget->getNodes(); //pre-fetch nodes for enable filters
+ $widget->getNodes(); // pre-fetch nodes for enable filters
if (null !== $node) {
$this->assignation['node'] = $node;
@@ -159,8 +154,6 @@ public function treeAction(Request $request, ?int $nodeId = null, ?int $translat
}
/**
- * @param Request $request
- * @return Response
* @throws RuntimeError
*/
public function bulkDeleteAction(Request $request): Response
@@ -181,7 +174,7 @@ public function bulkDeleteAction(Request $request): Response
'id' => $nodesIds,
]);
- if (count($nodes) === 0) {
+ if (0 === count($nodes)) {
throw new ResourceNotFoundException();
}
@@ -216,9 +209,6 @@ public function bulkDeleteAction(Request $request): Response
}
/**
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function bulkStatusAction(Request $request): Response
@@ -239,7 +229,7 @@ public function bulkStatusAction(Request $request): Response
'id' => $nodesIds,
]);
- if (count($nodes) === 0) {
+ if (0 === count($nodes)) {
throw new ResourceNotFoundException();
}
@@ -276,15 +266,9 @@ public function bulkStatusAction(Request $request): Response
return $this->render('@RoadizRozier/nodes/bulkStatus.html.twig', $this->assignation);
}
- /**
- * @param null|string $referer
- * @param array $nodesIds
- *
- * @return FormInterface
- */
private function buildBulkDeleteForm(
?string $referer = null,
- array $nodesIds = []
+ array $nodesIds = [],
): FormInterface {
/** @var FormBuilder $builder */
$builder = $this->formFactory
@@ -308,8 +292,6 @@ private function buildBulkDeleteForm(
}
/**
- * @param array $data
- *
* @return string
*/
private function bulkDeleteNodes(array $data)
@@ -364,6 +346,7 @@ private function bulkStatusNodes(array $data): string
}
}
$this->em()->flush();
+
return $this->getTranslator()->trans('nodes.bulk.status.changed');
}
@@ -398,7 +381,7 @@ private function buildBulkTagForm(): FormInterface
'attr' => [
'class' => 'uk-button uk-button-primary',
'title' => 'link.tags',
- 'data-uk-tooltip' => "{animation:true}",
+ 'data-uk-tooltip' => '{animation:true}',
],
])
->add('submitUntag', SubmitType::class, [
@@ -406,7 +389,7 @@ private function buildBulkTagForm(): FormInterface
'attr' => [
'class' => 'uk-button',
'title' => 'unlink.tags',
- 'data-uk-tooltip' => "{animation:true}",
+ 'data-uk-tooltip' => '{animation:true}',
],
])
;
@@ -415,7 +398,6 @@ private function buildBulkTagForm(): FormInterface
}
/**
- * @param array $data
* @return string
*/
private function tagNodes(array $data)
@@ -423,8 +405,8 @@ private function tagNodes(array $data)
$msg = $this->getTranslator()->trans('nodes.bulk.not_tagged');
if (
- !empty($data['tagsPaths']) &&
- !empty($data['nodesIds'])
+ !empty($data['tagsPaths'])
+ && !empty($data['nodesIds'])
) {
$nodesIds = explode(',', $data['nodesIds']);
$nodesIds = array_filter($nodesIds);
@@ -458,7 +440,6 @@ private function tagNodes(array $data)
}
/**
- * @param array $data
* @return string
*/
private function untagNodes(array $data)
@@ -466,8 +447,8 @@ private function untagNodes(array $data)
$msg = $this->getTranslator()->trans('nodes.bulk.not_untagged');
if (
- !empty($data['tagsPaths']) &&
- !empty($data['nodesIds'])
+ !empty($data['tagsPaths'])
+ && !empty($data['nodesIds'])
) {
$nodesIds = explode(',', $data['nodesIds']);
$nodesIds = array_filter($nodesIds);
@@ -502,17 +483,10 @@ private function untagNodes(array $data)
return $msg;
}
- /**
- * @param null|string $referer
- * @param array $nodesIds
- * @param string $status
- *
- * @return FormInterface
- */
private function buildBulkStatusForm(
?string $referer = null,
array $nodesIds = [],
- string $status = 'reject'
+ string $status = 'reject',
): FormInterface {
/** @var FormBuilder $builder */
$builder = $this->formFactory
diff --git a/src/Controllers/Nodes/NodesUtilsController.php b/src/Controllers/Nodes/NodesUtilsController.php
index cf73e9fc..227f534b 100644
--- a/src/Controllers/Nodes/NodesUtilsController.php
+++ b/src/Controllers/Nodes/NodesUtilsController.php
@@ -21,12 +21,7 @@ public function __construct(private readonly NodeNamePolicyInterface $nodeNamePo
}
/**
- * Duplicate node by ID
- *
- * @param Request $request
- * @param int $nodeId
- *
- * @return Response
+ * Duplicate node by ID.
*/
public function duplicateAction(Request $request, int $nodeId): Response
{
@@ -53,7 +48,7 @@ public function duplicateAction(Request $request, int $nodeId): Response
$this->dispatchEvent(new NodeCreatedEvent($newNode));
$this->dispatchEvent(new NodeDuplicatedEvent($newNode));
- $msg = $this->getTranslator()->trans("duplicated.node.%name%", [
+ $msg = $this->getTranslator()->trans('duplicated.node.%name%', [
'%name%' => $existingNode->getNodeName(),
]);
@@ -61,12 +56,12 @@ public function duplicateAction(Request $request, int $nodeId): Response
return $this->redirectToRoute(
'nodesEditPage',
- ["nodeId" => $newNode->getId()]
+ ['nodeId' => $newNode->getId()]
);
} catch (\Exception $e) {
$this->publishErrorMessage(
$request,
- $this->getTranslator()->trans("impossible.duplicate.node.%name%", [
+ $this->getTranslator()->trans('impossible.duplicate.node.%name%', [
'%name%' => $existingNode->getNodeName(),
]),
$existingNode
@@ -74,7 +69,7 @@ public function duplicateAction(Request $request, int $nodeId): Response
return $this->redirectToRoute(
'nodesEditPage',
- ["nodeId" => $existingNode->getId()]
+ ['nodeId' => $existingNode->getId()]
);
}
}
diff --git a/src/Controllers/Nodes/TranstypeController.php b/src/Controllers/Nodes/TranstypeController.php
index 7e3326ae..25264f51 100644
--- a/src/Controllers/Nodes/TranstypeController.php
+++ b/src/Controllers/Nodes/TranstypeController.php
@@ -24,10 +24,6 @@ public function __construct(private readonly NodeTranstyper $nodeTranstyper)
}
/**
- * @param Request $request
- * @param int $nodeId
- *
- * @return Response
* @throws RuntimeError
* @throws \Exception
*/
diff --git a/src/Controllers/RedirectionsController.php b/src/Controllers/RedirectionsController.php
index b2819ef5..fbf2bcbd 100644
--- a/src/Controllers/RedirectionsController.php
+++ b/src/Controllers/RedirectionsController.php
@@ -15,92 +15,59 @@
class RedirectionsController extends AbstractAdminWithBulkController
{
- /**
- * @inheritDoc
- */
protected function supports(PersistableInterface $item): bool
{
return $item instanceof Redirection;
}
- /**
- * @inheritDoc
- */
protected function getNamespace(): string
{
return 'redirection';
}
- /**
- * @inheritDoc
- */
protected function createEmptyItem(Request $request): PersistableInterface
{
return new Redirection();
}
- /**
- * @inheritDoc
- */
protected function getTemplateFolder(): string
{
return '@RoadizRozier/redirections';
}
- /**
- * @inheritDoc
- */
protected function getRequiredRole(): string
{
return 'ROLE_ACCESS_REDIRECTIONS';
}
- /**
- * @inheritDoc
- */
protected function getEntityClass(): string
{
return Redirection::class;
}
- /**
- * @inheritDoc
- */
protected function getFormType(): string
{
return RedirectionType::class;
}
- /**
- * @inheritDoc
- */
protected function getDefaultRouteName(): string
{
return 'redirectionsHomePage';
}
- /**
- * @inheritDoc
- */
protected function getEditRouteName(): string
{
return 'redirectionsEditPage';
}
- /**
- * @inheritDoc
- */
protected function getEntityName(PersistableInterface $item): string
{
if ($item instanceof Redirection) {
return (string) $item->getQuery();
}
- throw new \InvalidArgumentException('Item should be instance of ' . $this->getEntityClass());
+ throw new \InvalidArgumentException('Item should be instance of '.$this->getEntityClass());
}
- /**
- * @inheritDoc
- */
protected function getDefaultOrder(Request $request): array
{
return ['query' => 'ASC'];
@@ -109,24 +76,27 @@ protected function getDefaultOrder(Request $request): array
protected function createPostCreateEvent(PersistableInterface $item): RedirectionEvent
{
if (!($item instanceof Redirection)) {
- throw new \InvalidArgumentException('Item should be instance of ' . Redirection::class);
+ throw new \InvalidArgumentException('Item should be instance of '.Redirection::class);
}
+
return new PostCreatedRedirectionEvent($item);
}
protected function createPostUpdateEvent(PersistableInterface $item): RedirectionEvent
{
if (!($item instanceof Redirection)) {
- throw new \InvalidArgumentException('Item should be instance of ' . Redirection::class);
+ throw new \InvalidArgumentException('Item should be instance of '.Redirection::class);
}
+
return new PostUpdatedRedirectionEvent($item);
}
protected function createDeleteEvent(PersistableInterface $item): RedirectionEvent
{
if (!($item instanceof Redirection)) {
- throw new \InvalidArgumentException('Item should be instance of ' . Redirection::class);
+ throw new \InvalidArgumentException('Item should be instance of '.Redirection::class);
}
+
return new PostDeletedRedirectionEvent($item);
}
diff --git a/src/Controllers/RolesController.php b/src/Controllers/RolesController.php
index 06a6c78e..f0cb580c 100644
--- a/src/Controllers/RolesController.php
+++ b/src/Controllers/RolesController.php
@@ -15,100 +15,64 @@
class RolesController extends AbstractAdminController
{
- /**
- * @inheritDoc
- */
protected function supports(PersistableInterface $item): bool
{
return $item instanceof Role;
}
- /**
- * @inheritDoc
- */
protected function getNamespace(): string
{
return 'role';
}
- /**
- * @inheritDoc
- */
protected function createEmptyItem(Request $request): PersistableInterface
{
return new Role('ROLE_EXAMPLE');
}
- /**
- * @inheritDoc
- */
protected function getTemplateFolder(): string
{
return '@RoadizRozier/roles';
}
- /**
- * @inheritDoc
- */
protected function getRequiredRole(): string
{
return 'ROLE_ACCESS_ROLES';
}
- /**
- * @inheritDoc
- */
protected function getEntityClass(): string
{
return Role::class;
}
- /**
- * @inheritDoc
- */
protected function getFormType(): string
{
return RoleType::class;
}
- /**
- * @inheritDoc
- */
protected function getDefaultRouteName(): string
{
return 'rolesHomePage';
}
- /**
- * @inheritDoc
- */
protected function getEditRouteName(): string
{
return 'rolesEditPage';
}
- /**
- * @inheritDoc
- */
protected function getEntityName(PersistableInterface $item): string
{
if ($item instanceof Role) {
return $item->getRole();
}
- throw new \InvalidArgumentException('Item should be instance of ' . $this->getEntityClass());
+ throw new \InvalidArgumentException('Item should be instance of '.$this->getEntityClass());
}
- /**
- * @inheritDoc
- */
protected function getDefaultOrder(Request $request): array
{
return ['name' => 'ASC'];
}
- /**
- * @inheritDoc
- */
protected function denyAccessUnlessItemGranted(PersistableInterface $item): void
{
if ($item instanceof Role) {
@@ -116,36 +80,30 @@ protected function denyAccessUnlessItemGranted(PersistableInterface $item): void
}
}
- /**
- * @inheritDoc
- */
protected function createCreateEvent(PersistableInterface $item): ?Event
{
if ($item instanceof Role) {
return new PreCreatedRoleEvent($item);
}
+
return null;
}
- /**
- * @inheritDoc
- */
protected function createUpdateEvent(PersistableInterface $item): ?Event
{
if ($item instanceof Role) {
return new PreUpdatedRoleEvent($item);
}
+
return null;
}
- /**
- * @inheritDoc
- */
protected function createDeleteEvent(PersistableInterface $item): ?Event
{
if ($item instanceof Role) {
return new PreDeletedRoleEvent($item);
}
+
return null;
}
}
diff --git a/src/Controllers/RolesUtilsController.php b/src/Controllers/RolesUtilsController.php
index 4cc08dc7..9b4aa6aa 100644
--- a/src/Controllers/RolesUtilsController.php
+++ b/src/Controllers/RolesUtilsController.php
@@ -7,8 +7,8 @@
use Doctrine\Common\Cache\CacheProvider;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerInterface;
-use RZ\Roadiz\CoreBundle\Importer\RolesImporter;
use RZ\Roadiz\CoreBundle\Entity\Role;
+use RZ\Roadiz\CoreBundle\Importer\RolesImporter;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormInterface;
@@ -22,17 +22,12 @@ class RolesUtilsController extends RozierApp
{
public function __construct(
private readonly SerializerInterface $serializer,
- private readonly RolesImporter $rolesImporter
+ private readonly RolesImporter $rolesImporter,
) {
}
/**
- * Export a Role in a Json file
- *
- * @param Request $request
- * @param int $id
- *
- * @return Response
+ * Export a Role in a Json file.
*/
public function exportAction(Request $request, int $id): Response
{
@@ -53,7 +48,7 @@ public function exportAction(Request $request, int $id): Response
),
Response::HTTP_OK,
[
- 'Content-Disposition' => sprintf('attachment; filename="%s"', 'role-' . $existingRole->getName() . '-' . date("YmdHis") . '.json'),
+ 'Content-Disposition' => sprintf('attachment; filename="%s"', 'role-'.$existingRole->getName().'-'.date('YmdHis').'.json'),
],
true
);
@@ -62,9 +57,6 @@ public function exportAction(Request $request, int $id): Response
/**
* Import a Json file containing Roles.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function importJsonFileAction(Request $request): Response
@@ -75,9 +67,9 @@ public function importJsonFileAction(Request $request): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- !empty($form['role_file'])
+ $form->isSubmitted()
+ && $form->isValid()
+ && !empty($form['role_file'])
) {
$file = $form['role_file']->getData();
@@ -117,9 +109,6 @@ public function importJsonFileAction(Request $request): Response
return $this->render('@RoadizRozier/roles/import.html.twig', $this->assignation);
}
- /**
- * @return FormInterface
- */
private function buildImportJsonFileForm(): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/SearchController.php b/src/Controllers/SearchController.php
index 34529eb9..943acdad 100644
--- a/src/Controllers/SearchController.php
+++ b/src/Controllers/SearchController.php
@@ -4,7 +4,6 @@
namespace Themes\Rozier\Controllers;
-use DateTime;
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\Core\AbstractEntities\AbstractField;
use RZ\Roadiz\CoreBundle\Entity\Node;
@@ -48,159 +47,135 @@ class SearchController extends RozierApp
public function __construct(
protected readonly ManagerRegistry $managerRegistry,
protected readonly FormFactoryInterface $formFactory,
- protected readonly SerializerInterface $serializer
+ protected readonly SerializerInterface $serializer,
) {
}
- /**
- * @param mixed $var
- * @return bool
- */
public function isBlank(mixed $var): bool
{
return empty($var) && !is_numeric($var);
}
- /**
- * @param mixed $var
- * @return bool
- */
public function notBlank(mixed $var): bool
{
return !$this->isBlank($var);
}
- /**
- * @param array $data
- * @param string $fieldName
- *
- * @return array
- */
protected function appendDateTimeCriteria(array &$data, string $fieldName): array
{
$date = $data[$fieldName]['compareDatetime'];
- if ($date instanceof DateTime) {
+ if ($date instanceof \DateTime) {
$date = $date->format('Y-m-d H:i:s');
}
$data[$fieldName] = [
$data[$fieldName]['compareOp'],
$date,
];
+
return $data;
}
- /**
- * @param array $data
- * @param string $prefix
- * @return array
- */
- protected function processCriteria(array $data, string $prefix = ""): array
+ protected function processCriteria(array $data, string $prefix = ''): array
{
- if (!empty($data[$prefix . "nodeName"])) {
- if (!isset($data[$prefix . "nodeName_exact"]) || $data[$prefix . "nodeName_exact"] !== true) {
- $data[$prefix . "nodeName"] = ["LIKE", "%" . $data[$prefix . "nodeName"] . "%"];
+ if (!empty($data[$prefix.'nodeName'])) {
+ if (!isset($data[$prefix.'nodeName_exact']) || true !== $data[$prefix.'nodeName_exact']) {
+ $data[$prefix.'nodeName'] = ['LIKE', '%'.$data[$prefix.'nodeName'].'%'];
}
}
- if (key_exists($prefix . "nodeName_exact", $data)) {
- unset($data[$prefix . "nodeName_exact"]);
+ if (key_exists($prefix.'nodeName_exact', $data)) {
+ unset($data[$prefix.'nodeName_exact']);
}
- if (isset($data[$prefix . 'parent']) && !$this->isBlank($data[$prefix . "parent"])) {
- if ($data[$prefix . "parent"] == "null" || $data[$prefix . "parent"] == 0) {
- $data[$prefix . "parent"] = null;
+ if (isset($data[$prefix.'parent']) && !$this->isBlank($data[$prefix.'parent'])) {
+ if ('null' == $data[$prefix.'parent'] || 0 == $data[$prefix.'parent']) {
+ $data[$prefix.'parent'] = null;
}
}
- if (isset($data[$prefix . 'visible'])) {
- $data[$prefix . 'visible'] = (bool) $data[$prefix . 'visible'];
+ if (isset($data[$prefix.'visible'])) {
+ $data[$prefix.'visible'] = (bool) $data[$prefix.'visible'];
}
- if (isset($data[$prefix . 'createdAt'])) {
- $this->appendDateTimeCriteria($data, $prefix . 'createdAt');
+ if (isset($data[$prefix.'createdAt'])) {
+ $this->appendDateTimeCriteria($data, $prefix.'createdAt');
}
- if (isset($data[$prefix . 'updatedAt'])) {
- $this->appendDateTimeCriteria($data, $prefix . 'updatedAt');
+ if (isset($data[$prefix.'updatedAt'])) {
+ $this->appendDateTimeCriteria($data, $prefix.'updatedAt');
}
- if (isset($data[$prefix . "limitResult"])) {
+ if (isset($data[$prefix.'limitResult'])) {
$this->pagination = false;
- $this->itemPerPage = (int) $data[$prefix . "limitResult"];
- unset($data[$prefix . "limitResult"]);
+ $this->itemPerPage = (int) $data[$prefix.'limitResult'];
+ unset($data[$prefix.'limitResult']);
}
/*
* no need to prefix tags
*/
- if (isset($data["tags"])) {
- $data["tags"] = array_map('trim', explode(',', $data["tags"]));
- foreach ($data["tags"] as $key => $value) {
- $data["tags"][$key] = $this->managerRegistry->getRepository(Tag::class)->findByPath($value);
+ if (isset($data['tags'])) {
+ $data['tags'] = array_map('trim', explode(',', $data['tags']));
+ foreach ($data['tags'] as $key => $value) {
+ $data['tags'][$key] = $this->managerRegistry->getRepository(Tag::class)->findByPath($value);
}
- array_filter($data["tags"]);
+ array_filter($data['tags']);
}
return $data;
}
- /**
- * @param array $data
- * @param NodeType $nodetype
- * @return array
- */
protected function processCriteriaNodetype(array $data, NodeType $nodetype): array
{
$fields = $nodetype->getFields();
foreach ($data as $key => $value) {
- if ($key === 'title') {
- $data['title'] = ["LIKE", "%" . $value . "%"];
- if (isset($data[$key . '_exact'])) {
- if ($data[$key . '_exact'] === true) {
+ if ('title' === $key) {
+ $data['title'] = ['LIKE', '%'.$value.'%'];
+ if (isset($data[$key.'_exact'])) {
+ if (true === $data[$key.'_exact']) {
$data['title'] = $value;
}
}
- } elseif ($key === 'publishedAt') {
+ } elseif ('publishedAt' === $key) {
$this->appendDateTimeCriteria($data, 'publishedAt');
} else {
/** @var NodeTypeField $field */
foreach ($fields as $field) {
if ($key == $field->getName()) {
if (
- $field->getType() === AbstractField::MARKDOWN_T
- || $field->getType() === AbstractField::STRING_T
- || $field->getType() === AbstractField::YAML_T
- || $field->getType() === AbstractField::JSON_T
- || $field->getType() === AbstractField::TEXT_T
- || $field->getType() === AbstractField::EMAIL_T
- || $field->getType() === AbstractField::CSS_T
+ AbstractField::MARKDOWN_T === $field->getType()
+ || AbstractField::STRING_T === $field->getType()
+ || AbstractField::YAML_T === $field->getType()
+ || AbstractField::JSON_T === $field->getType()
+ || AbstractField::TEXT_T === $field->getType()
+ || AbstractField::EMAIL_T === $field->getType()
+ || AbstractField::CSS_T === $field->getType()
) {
- $data[$field->getVarName()] = ["LIKE", "%" . $value . "%"];
- if (isset($data[$key . '_exact']) && $data[$key . '_exact'] === true) {
+ $data[$field->getVarName()] = ['LIKE', '%'.$value.'%'];
+ if (isset($data[$key.'_exact']) && true === $data[$key.'_exact']) {
$data[$field->getVarName()] = $value;
}
- } elseif ($field->getType() === AbstractField::BOOLEAN_T) {
+ } elseif (AbstractField::BOOLEAN_T === $field->getType()) {
$data[$field->getVarName()] = (bool) $value;
- } elseif ($field->getType() === AbstractField::MULTIPLE_T) {
- $data[$field->getVarName()] = implode(",", $value);
- } elseif ($field->getType() === AbstractField::DATETIME_T) {
+ } elseif (AbstractField::MULTIPLE_T === $field->getType()) {
+ $data[$field->getVarName()] = implode(',', $value);
+ } elseif (AbstractField::DATETIME_T === $field->getType()) {
$this->appendDateTimeCriteria($data, $key);
- } elseif ($field->getType() === AbstractField::DATE_T) {
+ } elseif (AbstractField::DATE_T === $field->getType()) {
$this->appendDateTimeCriteria($data, $key);
}
}
}
}
- if (key_exists($key . '_exact', $data)) {
- unset($data[$key . '_exact']);
+ if (key_exists($key.'_exact', $data)) {
+ unset($data[$key.'_exact']);
}
}
+
return $data;
}
/**
- * @param Request $request
- * @return Response
* @throws RuntimeError
*/
public function searchNodeAction(Request $request): Response
@@ -217,6 +192,7 @@ public function searchNodeAction(Request $request): Response
if (null !== $response = $this->handleNodeTypeForm($nodeTypeForm)) {
$response->prepare($request);
+
return $response->send();
}
@@ -224,8 +200,8 @@ public function searchNodeAction(Request $request): Response
$data = [];
foreach ($form->getData() as $key => $value) {
if (
- (!is_array($value) && $this->notBlank($value)) ||
- (is_array($value) && isset($value["compareDatetime"]))
+ (!is_array($value) && $this->notBlank($value))
+ || (is_array($value) && isset($value['compareDatetime']))
) {
$data[$key] = $value;
}
@@ -238,7 +214,7 @@ public function searchNodeAction(Request $request): Response
$listManager->setDisplayingNotPublishedNodes(true);
$listManager->setDisplayingAllNodesStatuses(true);
- if ($this->pagination === false) {
+ if (false === $this->pagination) {
$listManager->setItemPerPage($this->itemPerPage ?? 999);
$listManager->disablePagination();
}
@@ -256,10 +232,6 @@ public function searchNodeAction(Request $request): Response
}
/**
- * @param Request $request
- * @param int $nodetypeId
- *
- * @return Response
* @throws RuntimeError
*/
public function searchNodeSourceAction(Request $request, int $nodetypeId): Response
@@ -267,7 +239,7 @@ public function searchNodeSourceAction(Request $request, int $nodetypeId): Respo
/** @var NodeType|null $nodetype */
$nodetype = $this->managerRegistry->getRepository(NodeType::class)->find($nodetypeId);
- $builder = $this->buildSimpleForm("__node__");
+ $builder = $this->buildSimpleForm('__node__');
$this->extendForm($builder, $nodetype);
$this->addButtons($builder, true);
@@ -295,19 +267,16 @@ public function searchNodeSourceAction(Request $request, int $nodetypeId): Respo
/**
* Build node-type selection form.
- *
- * @param int|null $nodetypeId
- * @return FormBuilderInterface
*/
protected function buildNodeTypeForm(?int $nodetypeId = null): FormBuilderInterface
{
- $builderNodeType = $this->formFactory->createNamedBuilder('nodeTypeForm', FormType::class, [], ["method" => "get"]);
+ $builderNodeType = $this->formFactory->createNamedBuilder('nodeTypeForm', FormType::class, [], ['method' => 'get']);
$builderNodeType->add(
- "nodetype",
+ 'nodetype',
NodeTypesType::class,
[
'label' => 'nodeType',
- 'placeholder' => "ignore",
+ 'placeholder' => 'ignore',
'required' => false,
'data' => $nodetypeId,
'showInvisible' => true,
@@ -317,12 +286,6 @@ protected function buildNodeTypeForm(?int $nodetypeId = null): FormBuilderInterf
return $builderNodeType;
}
- /**
- * @param FormBuilderInterface $builder
- * @param bool $export
- *
- * @return FormBuilderInterface
- */
protected function addButtons(FormBuilderInterface $builder, bool $export = false): FormBuilderInterface
{
$builder->add('search', SubmitType::class, [
@@ -344,11 +307,6 @@ protected function addButtons(FormBuilderInterface $builder, bool $export = fals
return $builder;
}
- /**
- * @param FormInterface $nodeTypeForm
- *
- * @return null|RedirectResponse
- */
protected function handleNodeTypeForm(FormInterface $nodeTypeForm): ?RedirectResponse
{
if ($nodeTypeForm->isSubmitted() && $nodeTypeForm->isValid()) {
@@ -358,7 +316,7 @@ protected function handleNodeTypeForm(FormInterface $nodeTypeForm): ?RedirectRes
return $this->redirectToRoute(
'searchNodeSourcePage',
[
- "nodetypeId" => $nodeTypeForm->getData()['nodetype'],
+ 'nodetypeId' => $nodeTypeForm->getData()['nodetype'],
]
);
}
@@ -367,12 +325,6 @@ protected function handleNodeTypeForm(FormInterface $nodeTypeForm): ?RedirectRes
return null;
}
- /**
- * @param FormInterface $form
- * @param NodeType $nodetype
- *
- * @return null|Response
- */
protected function handleNodeForm(FormInterface $form, NodeType $nodetype): ?Response
{
if (!$form->isSubmitted() || !$form->isValid()) {
@@ -382,20 +334,20 @@ protected function handleNodeForm(FormInterface $form, NodeType $nodetype): ?Res
foreach ($form->getData() as $key => $value) {
if (
(!is_array($value) && $this->notBlank($value))
- || (is_array($value) && isset($value["compareDatetime"]))
- || (is_array($value) && isset($value["compareDate"]))
- || (is_array($value) && $value != [] && !isset($value["compareOp"]))
+ || (is_array($value) && isset($value['compareDatetime']))
+ || (is_array($value) && isset($value['compareDate']))
+ || (is_array($value) && [] != $value && !isset($value['compareOp']))
) {
- if (\is_string($key) & \str_contains($key, "__node__")) {
+ if (\is_string($key) & \str_contains($key, '__node__')) {
/** @var string $newKey */
- $newKey = \str_replace("__node__", "node.", $key);
+ $newKey = \str_replace('__node__', 'node.', $key);
$data[$newKey] = $value;
} else {
$data[$key] = $value;
}
}
}
- $data = $this->processCriteria($data, "node.");
+ $data = $this->processCriteria($data, 'node.');
$data = $this->processCriteriaNodetype($data, $nodetype);
$listManager = $this->createEntityListManager(
@@ -404,7 +356,7 @@ protected function handleNodeForm(FormInterface $form, NodeType $nodetype): ?Res
);
$listManager->setDisplayingNotPublishedNodes(true);
$listManager->setDisplayingAllNodesStatuses(true);
- if ($this->pagination === false) {
+ if (false === $this->pagination) {
$listManager->setItemPerPage($this->itemPerPage ?? 999);
$listManager->disablePagination();
}
@@ -421,7 +373,7 @@ protected function handleNodeForm(FormInterface $form, NodeType $nodetype): ?Res
*/
$button = $form->get('export');
if ($button instanceof ClickableInterface && $button->isClicked()) {
- $filename = 'search-' . $nodetype->getName() . '-' . date("YmdHis") . '.csv';
+ $filename = 'search-'.$nodetype->getName().'-'.date('YmdHis').'.csv';
$response = new StreamedResponse(function () use ($entities) {
echo $this->serializer->serialize($entities, 'csv', [
'groups' => [
@@ -440,6 +392,7 @@ protected function handleNodeForm(FormInterface $form, NodeType $nodetype): ?Res
$filename
)
);
+
return $response;
}
@@ -450,16 +403,12 @@ protected function handleNodeForm(FormInterface $form, NodeType $nodetype): ?Res
return null;
}
- /**
- * @param string $prefix
- * @return FormBuilderInterface
- */
protected function buildSimpleForm(string $prefix = ''): FormBuilderInterface
{
/** @var FormBuilder $builder */
- $builder = $this->createFormBuilder([], ["method" => "get"]);
+ $builder = $this->createFormBuilder([], ['method' => 'get']);
- $builder->add($prefix . 'status', NodeStatesType::class, [
+ $builder->add($prefix.'status', NodeStatesType::class, [
'label' => 'node.status',
'required' => false,
]);
@@ -472,37 +421,37 @@ protected function buildSimpleForm(string $prefix = ''): FormBuilderInterface
'class' => 'form-col-status-group',
],
])
- ->add($prefix . 'visible', ExtendedBooleanType::class, [
+ ->add($prefix.'visible', ExtendedBooleanType::class, [
'label' => 'visible',
])
- ->add($prefix . 'locked', ExtendedBooleanType::class, [
+ ->add($prefix.'locked', ExtendedBooleanType::class, [
'label' => 'locked',
])
- ->add($prefix . 'sterile', ExtendedBooleanType::class, [
+ ->add($prefix.'sterile', ExtendedBooleanType::class, [
'label' => 'sterile-status',
])
- ->add($prefix . 'hideChildren', ExtendedBooleanType::class, [
+ ->add($prefix.'hideChildren', ExtendedBooleanType::class, [
'label' => 'hiding-children',
])
);
$builder->add(
- $this->createTextSearchForm($builder, $prefix . 'nodeName', 'nodeName')
+ $this->createTextSearchForm($builder, $prefix.'nodeName', 'nodeName')
);
- $builder->add($prefix . 'parent', TextType::class, [
- 'label' => 'node.id.parent',
- 'required' => false,
- ])
- ->add($prefix . 'createdAt', CompareDatetimeType::class, [
+ $builder->add($prefix.'parent', TextType::class, [
+ 'label' => 'node.id.parent',
+ 'required' => false,
+ ])
+ ->add($prefix.'createdAt', CompareDatetimeType::class, [
'label' => 'created.at',
'inherit_data' => false,
'required' => false,
])
- ->add($prefix . 'updatedAt', CompareDatetimeType::class, [
+ ->add($prefix.'updatedAt', CompareDatetimeType::class, [
'label' => 'updated.at',
'inherit_data' => false,
'required' => false,
])
- ->add($prefix . 'limitResult', NumberType::class, [
+ ->add($prefix.'limitResult', NumberType::class, [
'label' => 'node.limit.result',
'required' => false,
'constraints' => [
@@ -525,51 +474,40 @@ protected function buildSimpleForm(string $prefix = ''): FormBuilderInterface
return $builder;
}
- /**
- * @param FormBuilderInterface $builder
- * @param string $formName
- * @param string $label
- *
- * @return FormBuilderInterface
- */
protected function createTextSearchForm(
FormBuilderInterface $builder,
string $formName,
- string $label
+ string $label,
): FormBuilderInterface {
- return $builder->create($formName . '_group', FormType::class, [
- 'label' => false,
- 'inherit_data' => true,
- 'mapped' => false,
- 'attr' => [
- 'class' => 'form-col-search-group',
- ],
- ])
+ return $builder->create($formName.'_group', FormType::class, [
+ 'label' => false,
+ 'inherit_data' => true,
+ 'mapped' => false,
+ 'attr' => [
+ 'class' => 'form-col-search-group',
+ ],
+ ])
->add($formName, TextType::class, [
'label' => $label,
'required' => false,
])
- ->add($formName . '_exact', CheckboxType::class, [
+ ->add($formName.'_exact', CheckboxType::class, [
'label' => 'exact_search',
'required' => false,
])
;
}
- /**
- * @param FormBuilderInterface $builder
- * @param NodeType $nodetype
- */
private function extendForm(FormBuilderInterface $builder, NodeType $nodetype): void
{
$fields = $nodetype->getFields();
$builder->add(
- "nodetypefield",
+ 'nodetypefield',
SeparatorType::class,
[
'label' => 'nodetypefield',
- 'attr' => ["class" => "label-separator"],
+ 'attr' => ['class' => 'label-separator'],
]
);
$builder->add(
@@ -577,7 +515,7 @@ private function extendForm(FormBuilderInterface $builder, NodeType $nodetype):
);
if ($nodetype->isPublishable()) {
$builder->add(
- "publishedAt",
+ 'publishedAt',
CompareDatetimeType::class,
[
'label' => 'publishedAt',
@@ -587,7 +525,7 @@ private function extendForm(FormBuilderInterface $builder, NodeType $nodetype):
}
foreach ($fields as $field) {
- $option = ["label" => $field->getLabel()];
+ $option = ['label' => $field->getLabel()];
$option['required'] = false;
if ($field->isVirtual()) {
continue;
@@ -596,56 +534,56 @@ private function extendForm(FormBuilderInterface $builder, NodeType $nodetype):
* Prevent searching on complex fields
*/
if (
- $field->isMultipleProvider() ||
- $field->isSingleProvider() ||
- $field->isCollection() ||
- $field->isManyToMany() ||
- $field->isManyToOne()
+ $field->isMultipleProvider()
+ || $field->isSingleProvider()
+ || $field->isCollection()
+ || $field->isManyToMany()
+ || $field->isManyToOne()
) {
continue;
}
- if ($field->getType() === AbstractField::ENUM_T) {
+ if (AbstractField::ENUM_T === $field->getType()) {
$choices = explode(',', $field->getDefaultValues() ?? '');
$choices = array_map('trim', $choices);
$choices = array_combine(array_values($choices), array_values($choices));
$type = ChoiceType::class;
$option['placeholder'] = 'ignore';
$option['required'] = false;
- $option["expanded"] = false;
+ $option['expanded'] = false;
if (count($choices) < 4) {
- $option["expanded"] = true;
+ $option['expanded'] = true;
}
- $option["choices"] = $choices;
- } elseif ($field->getType() === AbstractField::MULTIPLE_T) {
+ $option['choices'] = $choices;
+ } elseif (AbstractField::MULTIPLE_T === $field->getType()) {
$choices = explode(',', $field->getDefaultValues() ?? '');
$choices = array_map('trim', $choices);
$choices = array_combine(array_values($choices), array_values($choices));
$type = ChoiceType::class;
- $option["choices"] = $choices;
+ $option['choices'] = $choices;
$option['placeholder'] = 'ignore';
$option['required'] = false;
- $option["multiple"] = true;
- $option["expanded"] = false;
+ $option['multiple'] = true;
+ $option['expanded'] = false;
if (count($choices) < 4) {
- $option["expanded"] = true;
+ $option['expanded'] = true;
}
- } elseif ($field->getType() === AbstractField::DATETIME_T) {
+ } elseif (AbstractField::DATETIME_T === $field->getType()) {
$type = CompareDatetimeType::class;
- } elseif ($field->getType() === AbstractField::DATE_T) {
+ } elseif (AbstractField::DATE_T === $field->getType()) {
$type = CompareDateType::class;
} else {
$type = NodeSourceType::getFormTypeFromFieldType($field);
}
if (
- $field->getType() === AbstractField::MARKDOWN_T ||
- $field->getType() === AbstractField::STRING_T ||
- $field->getType() === AbstractField::TEXT_T ||
- $field->getType() === AbstractField::EMAIL_T ||
- $field->getType() === AbstractField::JSON_T ||
- $field->getType() === AbstractField::YAML_T ||
- $field->getType() === AbstractField::CSS_T
+ AbstractField::MARKDOWN_T === $field->getType()
+ || AbstractField::STRING_T === $field->getType()
+ || AbstractField::TEXT_T === $field->getType()
+ || AbstractField::EMAIL_T === $field->getType()
+ || AbstractField::JSON_T === $field->getType()
+ || AbstractField::YAML_T === $field->getType()
+ || AbstractField::CSS_T === $field->getType()
) {
$builder->add(
$this->createTextSearchForm($builder, $field->getVarName(), $field->getLabel())
diff --git a/src/Controllers/SettingGroupsController.php b/src/Controllers/SettingGroupsController.php
index 5f87b52d..18bf442b 100644
--- a/src/Controllers/SettingGroupsController.php
+++ b/src/Controllers/SettingGroupsController.php
@@ -11,92 +11,59 @@
class SettingGroupsController extends AbstractAdminController
{
- /**
- * @inheritDoc
- */
protected function supports(PersistableInterface $item): bool
{
return $item instanceof SettingGroup;
}
- /**
- * @inheritDoc
- */
protected function getNamespace(): string
{
return 'settingGroup';
}
- /**
- * @inheritDoc
- */
protected function createEmptyItem(Request $request): PersistableInterface
{
return new SettingGroup();
}
- /**
- * @inheritDoc
- */
protected function getTemplateFolder(): string
{
return '@RoadizRozier/settingGroups';
}
- /**
- * @inheritDoc
- */
protected function getRequiredRole(): string
{
return 'ROLE_ACCESS_SETTINGS';
}
- /**
- * @inheritDoc
- */
protected function getEntityClass(): string
{
return SettingGroup::class;
}
- /**
- * @inheritDoc
- */
protected function getFormType(): string
{
return SettingGroupType::class;
}
- /**
- * @inheritDoc
- */
protected function getDefaultRouteName(): string
{
return 'settingGroupsHomePage';
}
- /**
- * @inheritDoc
- */
protected function getEditRouteName(): string
{
return 'settingGroupsEditPage';
}
- /**
- * @inheritDoc
- */
protected function getEntityName(PersistableInterface $item): string
{
if ($item instanceof SettingGroup) {
return $item->getName();
}
- throw new \InvalidArgumentException('Item should be instance of ' . $this->getEntityClass());
+ throw new \InvalidArgumentException('Item should be instance of '.$this->getEntityClass());
}
- /**
- * @inheritDoc
- */
protected function getDefaultOrder(Request $request): array
{
return ['name' => 'ASC'];
diff --git a/src/Controllers/SettingsController.php b/src/Controllers/SettingsController.php
index 4a12ba8d..92d68df5 100644
--- a/src/Controllers/SettingsController.php
+++ b/src/Controllers/SettingsController.php
@@ -30,16 +30,13 @@ class SettingsController extends RozierApp
{
public function __construct(
private readonly FormFactoryInterface $formFactory,
- private readonly FormErrorSerializer $formErrorSerializer
+ private readonly FormErrorSerializer $formErrorSerializer,
) {
}
/**
* List every setting.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function indexAction(Request $request): Response
@@ -54,10 +51,6 @@ public function indexAction(Request $request): Response
}
/**
- * @param Request $request
- * @param int $settingGroupId
- *
- * @return Response
* @throws RuntimeError
*/
public function byGroupAction(Request $request, int $settingGroupId): Response
@@ -67,7 +60,7 @@ public function byGroupAction(Request $request, int $settingGroupId): Response
/** @var SettingGroup|null $settingGroup */
$settingGroup = $this->em()->find(SettingGroup::class, $settingGroupId);
- if ($settingGroup === null) {
+ if (null === $settingGroup) {
throw new ResourceNotFoundException();
}
@@ -80,13 +73,7 @@ public function byGroupAction(Request $request, int $settingGroupId): Response
return $this->render('@RoadizRozier/settings/list.html.twig', $this->assignation);
}
- /**
- * @param Request $request
- * @param SettingGroup|null $settingGroup
- *
- * @return Response|null
- */
- protected function commonSettingList(Request $request, SettingGroup $settingGroup = null): ?Response
+ protected function commonSettingList(Request $request, ?SettingGroup $settingGroup = null): ?Response
{
$criteria = [];
if (null !== $settingGroup) {
@@ -114,9 +101,9 @@ protected function commonSettingList(Request $request, SettingGroup $settingGrou
$settings = $listManager->getEntities();
$this->assignation['settings'] = [];
$isJson =
- $request->isXmlHttpRequest() ||
- $request->getRequestFormat('html') === 'json' ||
- \in_array(
+ $request->isXmlHttpRequest()
+ || 'json' === $request->getRequestFormat('html')
+ || \in_array(
'application/json',
$request->getAcceptableContentTypes()
);
@@ -176,7 +163,7 @@ protected function commonSettingList(Request $request, SettingGroup $settingGrou
}
$document = null;
- if ($setting->getType() == AbstractField::DOCUMENTS_T) {
+ if (AbstractField::DOCUMENTS_T == $setting->getType()) {
$document = $this->getSettingsBag()->getDocument($setting->getName());
}
@@ -193,10 +180,6 @@ protected function commonSettingList(Request $request, SettingGroup $settingGrou
/**
* Return an edition form for requested setting.
*
- * @param Request $request
- * @param int $settingId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $settingId): Response
@@ -205,14 +188,14 @@ public function editAction(Request $request, int $settingId): Response
/** @var Setting|null $setting */
$setting = $this->em()->find(Setting::class, $settingId);
- if ($setting === null) {
+ if (null === $setting) {
throw $this->createNotFoundException();
}
$this->assignation['setting'] = $setting;
$form = $this->createForm(SettingType::class, $setting, [
- 'shortEdit' => false
+ 'shortEdit' => false,
]);
$form->handleRequest($request);
@@ -223,6 +206,7 @@ public function editAction(Request $request, int $settingId): Response
$this->em()->flush();
$msg = $this->getTranslator()->trans('setting.%name%.updated', ['%name%' => $setting->getName()]);
$this->publishConfirmMessage($request, $msg, $setting);
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -252,9 +236,6 @@ protected function resetSettingsCache(): void
/**
* Return a creation form for requested setting.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function addAction(Request $request): Response
@@ -293,10 +274,6 @@ public function addAction(Request $request): Response
/**
* Return a deletion form for requested setting.
*
- * @param Request $request
- * @param int $settingId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $settingId): Response
diff --git a/src/Controllers/SettingsUtilsController.php b/src/Controllers/SettingsUtilsController.php
index 8d963eb4..5ebba989 100644
--- a/src/Controllers/SettingsUtilsController.php
+++ b/src/Controllers/SettingsUtilsController.php
@@ -23,17 +23,12 @@ class SettingsUtilsController extends RozierApp
{
public function __construct(
private readonly SerializerInterface $serializer,
- private readonly SettingsImporter $settingsImporter
+ private readonly SettingsImporter $settingsImporter,
) {
}
/**
* Export all settings in a Json file.
- *
- * @param Request $request
- * @param int|null $settingGroupId
- *
- * @return Response
*/
public function exportAllAction(Request $request, ?int $settingGroupId = null): Response
{
@@ -45,12 +40,12 @@ public function exportAllAction(Request $request, ?int $settingGroupId = null):
if (null === $group) {
throw $this->createNotFoundException();
}
- $fileName = 'settings-' . \mb_strtolower(StringHandler::cleanForFilename($group->getName())) . '-' . date("YmdHis") . '.json';
+ $fileName = 'settings-'.\mb_strtolower(StringHandler::cleanForFilename($group->getName())).'-'.date('YmdHis').'.json';
$settings = $this->em()
->getRepository(Setting::class)
->findBySettingGroup($group);
} else {
- $fileName = 'settings-' . date("YmdHis") . '.json';
+ $fileName = 'settings-'.date('YmdHis').'.json';
$settings = $this->em()
->getRepository(Setting::class)
->findAll();
@@ -73,9 +68,6 @@ public function exportAllAction(Request $request, ?int $settingGroupId = null):
/**
* Import a Json file (.rzt) containing setting and setting group.
*
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function importJsonFileAction(Request $request): Response
@@ -87,9 +79,9 @@ public function importJsonFileAction(Request $request): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- !empty($form['setting_file'])
+ $form->isSubmitted()
+ && $form->isValid()
+ && !empty($form['setting_file'])
) {
$file = $form['setting_file']->getData();
@@ -123,9 +115,6 @@ public function importJsonFileAction(Request $request): Response
return $this->render('@RoadizRozier/settings/import.html.twig', $this->assignation);
}
- /**
- * @return FormInterface
- */
private function buildImportJsonFileForm(): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/Tags/TagMultiCreationController.php b/src/Controllers/Tags/TagMultiCreationController.php
index fa8632b9..4298dc73 100644
--- a/src/Controllers/Tags/TagMultiCreationController.php
+++ b/src/Controllers/Tags/TagMultiCreationController.php
@@ -22,9 +22,6 @@ public function __construct(private readonly TagFactory $tagFactory)
}
/**
- * @param Request $request
- * @param int $parentTagId
- * @return Response
* @throws \Twig\Error\RuntimeError
*/
public function addChildAction(Request $request, int $parentTagId): Response
diff --git a/src/Controllers/Tags/TagsController.php b/src/Controllers/Tags/TagsController.php
index 9a766e71..740a40bd 100644
--- a/src/Controllers/Tags/TagsController.php
+++ b/src/Controllers/Tags/TagsController.php
@@ -44,16 +44,12 @@ public function __construct(
private readonly FormFactoryInterface $formFactory,
private readonly FormErrorSerializer $formErrorSerializer,
private readonly HandlerFactoryInterface $handlerFactory,
- private readonly TreeWidgetFactory $treeWidgetFactory
+ private readonly TreeWidgetFactory $treeWidgetFactory,
) {
}
/**
* List every tags.
- *
- * @param Request $request
- *
- * @return Response
*/
public function indexAction(Request $request): Response
{
@@ -85,11 +81,6 @@ public function indexAction(Request $request): Response
/**
* Return an edition form for current translated tag.
*
- * @param Request $request
- * @param int $tagId
- * @param int|null $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function editTranslatedAction(Request $request, int $tagId, ?int $translationId = null): Response
@@ -133,13 +124,13 @@ public function editTranslatedAction(Request $request, int $tagId, ?int $transla
if (false !== $baseTranslation) {
$tagTranslation->setName($baseTranslation->getName());
} else {
- $tagTranslation->setName('tag_' . $tag->getId());
+ $tagTranslation->setName('tag_'.$tag->getId());
}
$this->em()->persist($tagTranslation);
$this->em()->flush();
}
- /**
+ /*
* Versioning
*/
if ($this->isGranted('ROLE_ACCESS_VERSIONS')) {
@@ -154,8 +145,8 @@ public function editTranslatedAction(Request $request, int $tagId, ?int $transla
]);
$form->handleRequest($request);
$isJsonRequest =
- $request->isXmlHttpRequest() ||
- \in_array('application/json', $request->getAcceptableContentTypes())
+ $request->isXmlHttpRequest()
+ || \in_array('application/json', $request->getAcceptableContentTypes())
;
if ($form->isSubmitted()) {
@@ -167,9 +158,9 @@ public function editTranslatedAction(Request $request, int $tagId, ?int $transla
$newTagName = StringHandler::slugify($tagTranslation->getName());
if ($tag->getTagName() !== $newTagName) {
if (
- !$tag->isLocked() &&
- $translation->isDefaultTranslation() &&
- !$this->tagNameExists($newTagName)
+ !$tag->isLocked()
+ && $translation->isDefaultTranslation()
+ && !$this->tagNameExists($newTagName)
) {
$tag->setTagName($tagTranslation->getName());
}
@@ -205,6 +196,7 @@ public function editTranslatedAction(Request $request, int $tagId, ?int $transla
*/
if ($isJsonRequest) {
$errors = $this->formErrorSerializer->getErrorsAsArray($form);
+
return new JsonResponse([
'status' => 'fail',
'errors' => $errors,
@@ -226,22 +218,14 @@ public function editTranslatedAction(Request $request, int $tagId, ?int $transla
return $this->render('@RoadizRozier/tags/edit.html.twig', $this->assignation);
}
- /**
- * @param string $name
- *
- * @return bool
- */
protected function tagNameExists(string $name): bool
{
$entity = $this->em()->getRepository(Tag::class)->findOneByTagName($name);
- return (null !== $entity);
+ return null !== $entity;
}
/**
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function bulkDeleteAction(Request $request): Response
@@ -293,8 +277,6 @@ public function bulkDeleteAction(Request $request): Response
}
/**
- * @param Request $request
- * @return Response
* @throws RuntimeError
*/
public function addAction(Request $request): Response
@@ -304,7 +286,7 @@ public function addAction(Request $request): Response
$tag = new Tag();
$translation = $this->em()->getRepository(Translation::class)->findDefault();
- if ($translation !== null) {
+ if (null !== $translation) {
$this->assignation['tag'] = $tag;
$form = $this->createForm(TagType::class, $tag);
$form->handleRequest($request);
@@ -332,6 +314,7 @@ public function addAction(Request $request): Response
$msg = $this->getTranslator()->trans('tag.%name%.created', ['%name%' => $tag->getTagName()]);
$this->publishConfirmMessage($request, $msg, $tag);
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -347,10 +330,6 @@ public function addAction(Request $request): Response
}
/**
- * @param Request $request
- * @param int $tagId
- *
- * @return Response
* @throws RuntimeError
*/
public function editSettingsAction(Request $request, int $tagId): Response
@@ -362,7 +341,7 @@ public function editSettingsAction(Request $request, int $tagId): Response
/** @var Tag|null $tag */
$tag = $this->em()->find(Tag::class, $tagId);
- if ($tag === null) {
+ if (null === $tag) {
throw new ResourceNotFoundException();
}
@@ -372,8 +351,8 @@ public function editSettingsAction(Request $request, int $tagId): Response
$form->handleRequest($request);
$isJsonRequest =
- $request->isXmlHttpRequest() ||
- \in_array('application/json', $request->getAcceptableContentTypes())
+ $request->isXmlHttpRequest()
+ || \in_array('application/json', $request->getAcceptableContentTypes())
;
if ($form->isSubmitted()) {
@@ -400,6 +379,7 @@ public function editSettingsAction(Request $request, int $tagId): Response
*/
if ($isJsonRequest) {
$errors = $this->formErrorSerializer->getErrorsAsArray($form);
+
return new JsonResponse([
'status' => 'fail',
'errors' => $errors,
@@ -416,11 +396,6 @@ public function editSettingsAction(Request $request, int $tagId): Response
}
/**
- * @param Request $request
- * @param int $tagId
- * @param int|null $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function treeAction(Request $request, int $tagId, ?int $translationId = null): Response
@@ -452,10 +427,6 @@ public function treeAction(Request $request, int $tagId, ?int $translationId = n
/**
* Return a deletion form for requested tag.
*
- * @param Request $request
- * @param int $tagId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $tagId): Response
@@ -466,8 +437,8 @@ public function deleteAction(Request $request, int $tagId): Response
$tag = $this->em()->find(Tag::class, $tagId);
if (
- $tag !== null &&
- !$tag->isLocked()
+ null !== $tag
+ && !$tag->isLocked()
) {
$this->assignation['tag'] = $tag;
@@ -475,9 +446,9 @@ public function deleteAction(Request $request, int $tagId): Response
$form->handleRequest($request);
if (
- $form->isSubmitted() &&
- $form->isValid() &&
- $form->getData()['tagId'] == $tag->getId()
+ $form->isSubmitted()
+ && $form->isValid()
+ && $form->getData()['tagId'] == $tag->getId()
) {
/*
* Dispatch event
@@ -511,11 +482,6 @@ public function deleteAction(Request $request, int $tagId): Response
/**
* Handle tag creation pages.
*
- * @param Request $request
- * @param int $tagId
- * @param int|null $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function addChildAction(Request $request, int $tagId, ?int $translationId = null): Response
@@ -524,7 +490,7 @@ public function addChildAction(Request $request, int $tagId, ?int $translationId
$translation = $this->em()->getRepository(Translation::class)->findDefault();
- if ($translationId !== null) {
+ if (null !== $translationId) {
$translation = $this->em()->find(Translation::class, $translationId);
}
$parentTag = $this->em()->find(Tag::class, $tagId);
@@ -532,8 +498,8 @@ public function addChildAction(Request $request, int $tagId, ?int $translationId
$tag->setParent($parentTag);
if (
- $translation !== null &&
- $parentTag !== null
+ null !== $translation
+ && null !== $parentTag
) {
$form = $this->createForm(TagType::class, $tag);
$form->handleRequest($request);
@@ -584,10 +550,6 @@ public function addChildAction(Request $request, int $tagId, ?int $translationId
/**
* Handle tag nodes page.
*
- * @param Request $request
- * @param int $tagId
- *
- * @return Response
* @throws RuntimeError
*/
public function editNodesAction(Request $request, int $tagId): Response
@@ -623,11 +585,6 @@ public function editNodesAction(Request $request, int $tagId): Response
throw new ResourceNotFoundException();
}
- /**
- * @param Tag $tag
- *
- * @return FormInterface
- */
private function buildDeleteForm(Tag $tag): FormInterface
{
$builder = $this->createFormBuilder()
@@ -642,15 +599,9 @@ private function buildDeleteForm(Tag $tag): FormInterface
return $builder->getForm();
}
- /**
- * @param null|string $referer
- * @param array $tagsIds
- *
- * @return FormInterface
- */
private function buildBulkDeleteForm(
?string $referer = null,
- array $tagsIds = []
+ array $tagsIds = [],
): FormInterface {
$builder = $this->formFactory
->createNamedBuilder('deleteForm')
@@ -672,11 +623,6 @@ private function buildBulkDeleteForm(
return $builder->getForm();
}
- /**
- * @param array $data
- *
- * @return string
- */
private function bulkDeleteTags(array $data): string
{
if (!empty($data['tagsIds'])) {
@@ -730,14 +676,16 @@ protected function getPostUpdateRedirection(PersistableInterface $entity): ?Resp
if ($entity instanceof TagTranslation) {
/** @var Translation $translation */
$translation = $entity->getTranslation();
+
return $this->redirectToRoute(
'tagsEditTranslatedPage',
[
'tagId' => $entity->getTag()->getId(),
- 'translationId' => $translation->getId()
+ 'translationId' => $translation->getId(),
]
);
}
+
return null;
}
}
diff --git a/src/Controllers/Tags/TagsUtilsController.php b/src/Controllers/Tags/TagsUtilsController.php
index 71f96693..e6c5e4ed 100644
--- a/src/Controllers/Tags/TagsUtilsController.php
+++ b/src/Controllers/Tags/TagsUtilsController.php
@@ -19,11 +19,7 @@ public function __construct(private readonly SerializerInterface $serializer)
}
/**
- * Export a Tag in a Json file
- *
- * @param Request $request
- * @param int $tagId
- * @return JsonResponse
+ * Export a Tag in a Json file.
*/
public function exportAction(Request $request, int $tagId): JsonResponse
{
@@ -41,7 +37,7 @@ public function exportAction(Request $request, int $tagId): JsonResponse
[
'Content-Disposition' => sprintf(
'attachment; filename="%s"',
- 'tag-' . $existingTag->getTagName() . '-' . date("YmdHis") . '.json'
+ 'tag-'.$existingTag->getTagName().'-'.date('YmdHis').'.json'
),
],
true
@@ -49,12 +45,7 @@ public function exportAction(Request $request, int $tagId): JsonResponse
}
/**
- * Export a Tag in a Json file
- *
- * @param Request $request
- * @param int $tagId
- *
- * @return JsonResponse
+ * Export a Tag in a Json file.
*/
public function exportAllAction(Request $request, int $tagId): JsonResponse
{
@@ -62,7 +53,7 @@ public function exportAllAction(Request $request, int $tagId): JsonResponse
$existingTags = $this->em()
->getRepository(Tag::class)
- ->findBy(["parent" => null]);
+ ->findBy(['parent' => null]);
return new JsonResponse(
$this->serializer->serialize(
@@ -74,7 +65,7 @@ public function exportAllAction(Request $request, int $tagId): JsonResponse
[
'Content-Disposition' => sprintf(
'attachment; filename="%s"',
- 'tag-all-' . date("YmdHis") . '.json'
+ 'tag-all-'.date('YmdHis').'.json'
),
],
true
diff --git a/src/Controllers/TranslationsController.php b/src/Controllers/TranslationsController.php
index 601c24b1..93b5006c 100644
--- a/src/Controllers/TranslationsController.php
+++ b/src/Controllers/TranslationsController.php
@@ -28,9 +28,6 @@ public function __construct(private readonly HandlerFactoryInterface $handlerFac
}
/**
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function indexAction(Request $request): Response
@@ -51,7 +48,7 @@ public function indexAction(Request $request): Response
/** @var Translation $translation */
foreach ($translations as $translation) {
// Make default forms
- $form = $this->createNamedFormBuilder('default_trans_' . $translation->getId(), $translation)->getForm();
+ $form = $this->createNamedFormBuilder('default_trans_'.$translation->getId(), $translation)->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
/** @var TranslationHandler $handler */
@@ -60,6 +57,7 @@ public function indexAction(Request $request): Response
$msg = $this->getTranslator()->trans('translation.%name%.made_default', ['%name%' => $translation->getName()]);
$this->publishConfirmMessage($request, $msg, $translation);
$this->dispatchEvent(new TranslationUpdatedEvent($translation));
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -78,10 +76,6 @@ public function indexAction(Request $request): Response
}
/**
- * @param Request $request
- * @param int $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function editAction(Request $request, int $translationId): Response
@@ -91,7 +85,7 @@ public function editAction(Request $request, int $translationId): Response
/** @var Translation|null $translation */
$translation = $this->em()->find(Translation::class, $translationId);
- if ($translation === null) {
+ if (null === $translation) {
throw new ResourceNotFoundException();
}
@@ -106,6 +100,7 @@ public function editAction(Request $request, int $translationId): Response
$this->publishConfirmMessage($request, $msg, $translation);
$this->dispatchEvent(new TranslationUpdatedEvent($translation));
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -121,9 +116,6 @@ public function editAction(Request $request, int $translationId): Response
}
/**
- * @param Request $request
- *
- * @return Response
* @throws RuntimeError
*/
public function addAction(Request $request): Response
@@ -144,6 +136,7 @@ public function addAction(Request $request): Response
$this->publishConfirmMessage($request, $msg, $translation);
$this->dispatchEvent(new TranslationCreatedEvent($translation));
+
/*
* Force redirect to avoid resending form when refreshing page
*/
@@ -156,10 +149,6 @@ public function addAction(Request $request): Response
}
/**
- * @param Request $request
- * @param int $translationId
- *
- * @return Response
* @throws RuntimeError
*/
public function deleteAction(Request $request, int $translationId): Response
diff --git a/src/Controllers/Users/UsersController.php b/src/Controllers/Users/UsersController.php
index a2ded208..2403de25 100644
--- a/src/Controllers/Users/UsersController.php
+++ b/src/Controllers/Users/UsersController.php
@@ -24,12 +24,11 @@ public function __construct(
FormFactoryInterface $formFactory,
SerializerInterface $serializer,
UrlGeneratorInterface $urlGenerator,
- private readonly bool $useGravatar
+ private readonly bool $useGravatar,
) {
parent::__construct($formFactory, $serializer, $urlGenerator);
}
-
protected function supports(PersistableInterface $item): bool
{
return $item instanceof User;
@@ -44,6 +43,7 @@ protected function createEmptyItem(Request $request): User
{
$user = new User();
$user->sendCreationConfirmationEmail(true);
+
return $user;
}
@@ -104,14 +104,14 @@ protected function denyAccessUnlessItemGranted(PersistableInterface $item): void
$requestUser = $this->getUser();
if (
!(
- $this->isGranted('ROLE_ACCESS_USERS') ||
- ($requestUser instanceof User && $requestUser->getId() === $item->getId())
+ $this->isGranted('ROLE_ACCESS_USERS')
+ || ($requestUser instanceof User && $requestUser->getId() === $item->getId())
)
) {
throw $this->createAccessDeniedException("You don't have access to this page: ROLE_ACCESS_USERS");
}
if (!$this->isGranted(Role::ROLE_SUPERADMIN) && $item->isSuperAdmin()) {
- throw $this->createAccessDeniedException("You cannot edit a super admin.");
+ throw $this->createAccessDeniedException('You cannot edit a super admin.');
}
}
@@ -120,6 +120,7 @@ protected function getEntityName(PersistableInterface $item): string
if (!$item instanceof User) {
throw new \RuntimeException('Invalid item type.');
}
+
return $item->getUsername();
}
@@ -136,7 +137,7 @@ protected function createUpdateEvent(PersistableInterface $item)
/*
* If pictureUrl is empty, use default Gravatar image.
*/
- if ($item->getPictureUrl() == '' && $this->useGravatar) {
+ if ('' == $item->getPictureUrl() && $this->useGravatar) {
$item->setPictureUrl($item->getGravatarUrl());
}
@@ -144,10 +145,6 @@ protected function createUpdateEvent(PersistableInterface $item)
}
/**
- * @param Request $request
- * @param int $id
- *
- * @return Response
* @throws RuntimeError
*/
public function editDetailsAction(Request $request, int $id): Response
@@ -186,7 +183,7 @@ public function editDetailsAction(Request $request, int $id): Response
'%namespace%.%item%.was_updated',
[
'%item%' => $this->getEntityName($item),
- '%namespace%' => $this->getTranslator()->trans($this->getNamespace())
+ '%namespace%' => $this->getTranslator()->trans($this->getNamespace()),
]
);
$this->publishConfirmMessage($request, $msg, $item);
@@ -204,15 +201,13 @@ public function editDetailsAction(Request $request, int $id): Response
$this->assignation['item'] = $item;
return $this->render(
- $this->getTemplateFolder() . '/editDetails.html.twig',
+ $this->getTemplateFolder().'/editDetails.html.twig',
$this->assignation,
null,
$this->getTemplateNamespace()
);
}
-
-
protected function additionalAssignation(Request $request): void
{
parent::additionalAssignation($request);
@@ -276,7 +271,7 @@ function (string $ids) {
'id' => $ids,
]);
},
- $this->getTemplateFolder() . '/bulk_enable.html.twig',
+ $this->getTemplateFolder().'/bulk_enable.html.twig',
'%namespace%.%item%.was_enabled',
function (PersistableInterface $item) {
if (!$item instanceof User) {
@@ -300,7 +295,7 @@ function (string $ids) {
'id' => $ids,
]);
},
- $this->getTemplateFolder() . '/bulk_disable.html.twig',
+ $this->getTemplateFolder().'/bulk_disable.html.twig',
'%namespace%.%item%.was_disabled',
function (PersistableInterface $item) {
if (!$item instanceof User) {
diff --git a/src/Controllers/Users/UsersGroupsController.php b/src/Controllers/Users/UsersGroupsController.php
index 62103ffc..5180e3d1 100644
--- a/src/Controllers/Users/UsersGroupsController.php
+++ b/src/Controllers/Users/UsersGroupsController.php
@@ -27,7 +27,7 @@ public function editGroupsAction(Request $request, int $userId): Response
/** @var User|null $user */
$user = $this->em()->find(User::class, $userId);
- if ($user === null) {
+ if (null === $user) {
throw new ResourceNotFoundException();
}
@@ -47,7 +47,7 @@ public function editGroupsAction(Request $request, int $userId): Response
$group = null;
}
- if ($group !== null) {
+ if (null !== $group) {
$user->addGroup($group);
$this->em()->flush();
@@ -84,10 +84,10 @@ public function removeGroupAction(Request $request, int $userId, int $groupId):
/** @var Group|null $group */
$group = $this->em()->find(Group::class, $groupId);
- if ($user === null) {
+ if (null === $user) {
throw new ResourceNotFoundException();
}
- if ($group === null) {
+ if (null === $group) {
throw new ResourceNotFoundException();
}
@@ -127,11 +127,6 @@ public function removeGroupAction(Request $request, int $userId, int $groupId):
return $this->render('@RoadizRozier/users/removeGroup.html.twig', $this->assignation);
}
- /**
- * @param User $user
- *
- * @return FormInterface
- */
private function buildEditGroupsForm(User $user): FormInterface
{
$defaults = [
@@ -153,7 +148,7 @@ private function buildEditGroupsForm(User $user): FormInterface
'group',
GroupsType::class,
[
- 'label' => 'Group'
+ 'label' => 'Group',
]
)
;
diff --git a/src/Controllers/Users/UsersRolesController.php b/src/Controllers/Users/UsersRolesController.php
index ba80f0af..aa402279 100644
--- a/src/Controllers/Users/UsersRolesController.php
+++ b/src/Controllers/Users/UsersRolesController.php
@@ -19,10 +19,6 @@
class UsersRolesController extends RozierApp
{
/**
- * @param Request $request
- * @param int $userId
- *
- * @return Response
* @throws RuntimeError
*/
public function editRolesAction(Request $request, int $userId): Response
@@ -32,7 +28,7 @@ public function editRolesAction(Request $request, int $userId): Response
/** @var User|null $user */
$user = $this->em()->find(User::class, $userId);
- if ($user === null) {
+ if (null === $user) {
throw new ResourceNotFoundException();
}
@@ -74,11 +70,6 @@ public function editRolesAction(Request $request, int $userId): Response
/**
* Return a deletion form for requested role depending on the user.
*
- * @param Request $request
- * @param int $userId
- * @param int $roleId
- *
- * @return Response
* @throws RuntimeError
*/
public function removeRoleAction(Request $request, int $userId, int $roleId): Response
@@ -87,13 +78,13 @@ public function removeRoleAction(Request $request, int $userId, int $roleId): Re
/** @var User|null $user */
$user = $this->em()->find(User::class, $userId);
- if ($user === null) {
+ if (null === $user) {
throw new ResourceNotFoundException();
}
/** @var Role|null $role */
$role = $this->em()->find(Role::class, $roleId);
- if ($role === null) {
+ if (null === $role) {
throw new ResourceNotFoundException();
}
@@ -130,11 +121,6 @@ public function removeRoleAction(Request $request, int $userId, int $roleId): Re
return $this->render('@RoadizRozier/users/removeRole.html.twig', $this->assignation);
}
- /**
- * @param User $user
- *
- * @return FormInterface
- */
private function buildEditRolesForm(User $user): FormInterface
{
$builder = $this->createFormBuilder()
diff --git a/src/Controllers/Users/UsersSecurityController.php b/src/Controllers/Users/UsersSecurityController.php
index 35949690..df84e8e7 100644
--- a/src/Controllers/Users/UsersSecurityController.php
+++ b/src/Controllers/Users/UsersSecurityController.php
@@ -15,10 +15,6 @@
class UsersSecurityController extends RozierApp
{
/**
- * @param Request $request
- * @param int $userId
- *
- * @return Response
* @throws RuntimeError
*/
public function securityAction(Request $request, int $userId): Response
@@ -28,13 +24,13 @@ public function securityAction(Request $request, int $userId): Response
/** @var User|null $user */
$user = $this->em()->find(User::class, $userId);
- if ($user === null) {
+ if (null === $user) {
throw new ResourceNotFoundException();
}
$this->assignation['user'] = $user;
$form = $this->createForm(UserSecurityType::class, $user, [
- 'canChroot' => $this->isGranted("ROLE_SUPERADMIN")
+ 'canChroot' => $this->isGranted('ROLE_SUPERADMIN'),
]);
$form->handleRequest($request);
diff --git a/src/Controllers/WebhookController.php b/src/Controllers/WebhookController.php
index 60bccc70..c5930fb8 100644
--- a/src/Controllers/WebhookController.php
+++ b/src/Controllers/WebhookController.php
@@ -23,7 +23,7 @@ public function __construct(
private readonly WebhookDispatcher $webhookDispatcher,
FormFactoryInterface $formFactory,
SerializerInterface $serializer,
- UrlGeneratorInterface $urlGenerator
+ UrlGeneratorInterface $urlGenerator,
) {
parent::__construct($formFactory, $serializer, $urlGenerator);
}
@@ -64,7 +64,7 @@ public function triggerAction(Request $request, string $id): Response
));
} catch (TooManyWebhookTriggeredException $e) {
$form->addError(new FormError('webhook.too_many_triggered_in_period', null, [
- '%time%' => $e->getDoNotTriggerBefore()->format('H:i:s')
+ '%time%' => $e->getDoNotTriggerBefore()->format('H:i:s'),
], null, $e));
}
}
@@ -73,7 +73,7 @@ public function triggerAction(Request $request, string $id): Response
$this->assignation['item'] = $item;
return $this->render(
- $this->getTemplateFolder() . '/trigger.html.twig',
+ $this->getTemplateFolder().'/trigger.html.twig',
$this->assignation,
null,
$this->getTemplateNamespace()
@@ -130,8 +130,10 @@ protected function getEntityName(PersistableInterface $item): string
if ($item instanceof Webhook) {
return (string) $item;
}
+
return '';
}
+
protected function getBulkDeleteRouteName(): ?string
{
return 'webhooksBulkDeletePage';
diff --git a/src/Explorer/ConfigurableExplorerItem.php b/src/Explorer/ConfigurableExplorerItem.php
index 754e9d45..b5c83ca2 100644
--- a/src/Explorer/ConfigurableExplorerItem.php
+++ b/src/Explorer/ConfigurableExplorerItem.php
@@ -18,17 +18,11 @@ public function __construct(
) {
}
- /**
- * @inheritDoc
- */
public function getId(): int|string
{
return $this->entity->getId() ?? throw new \RuntimeException('Entity must have an ID');
}
- /**
- * @inheritDoc
- */
public function getAlternativeDisplayable(): ?string
{
$alt = $this->configuration['classname'];
@@ -41,12 +35,10 @@ public function getAlternativeDisplayable(): ?string
}
}
}
+
return (new UnicodeString($alt ?? ''))->truncate(30, '…')->toString();
}
- /**
- * @inheritDoc
- */
public function getDisplayable(): string
{
$displayableCallable = [$this->entity, $this->configuration['displayable']];
@@ -56,12 +48,10 @@ public function getDisplayable(): string
$displayable = $displayable->format('c');
}
}
+
return (new UnicodeString($displayable ?? ''))->truncate(30, '…')->toString();
}
- /**
- * @inheritDoc
- */
public function getOriginal(): PersistableInterface
{
return $this->entity;
diff --git a/src/Explorer/CustomFormExplorerItem.php b/src/Explorer/CustomFormExplorerItem.php
index 915f169b..93f37f10 100644
--- a/src/Explorer/CustomFormExplorerItem.php
+++ b/src/Explorer/CustomFormExplorerItem.php
@@ -14,7 +14,7 @@ final class CustomFormExplorerItem extends AbstractExplorerItem
public function __construct(
private readonly CustomForm $customForm,
private readonly UrlGeneratorInterface $urlGenerator,
- private readonly TranslatorInterface $translator
+ private readonly TranslatorInterface $translator,
) {
}
@@ -28,7 +28,7 @@ public function getAlternativeDisplayable(): ?string
return strip_tags($this->translator->trans(
'{0} no.customFormField|{1} 1.customFormField|]1,Inf] %count%.customFormFields',
[
- '%count%' => $this->customForm->getFields()->count()
+ '%count%' => $this->customForm->getFields()->count(),
]
));
}
@@ -46,7 +46,7 @@ public function getOriginal(): CustomForm
protected function getEditItemPath(): ?string
{
return $this->urlGenerator->generate('customFormsEditPage', [
- 'id' => $this->customForm->getId()
+ 'id' => $this->customForm->getId(),
]);
}
diff --git a/src/Explorer/DocumentExplorerItem.php b/src/Explorer/DocumentExplorerItem.php
index 19c81b9b..0870b7e4 100644
--- a/src/Explorer/DocumentExplorerItem.php
+++ b/src/Explorer/DocumentExplorerItem.php
@@ -18,17 +18,17 @@
final class DocumentExplorerItem extends AbstractExplorerItem
{
public static array $thumbnail80Array = [
- "fit" => "80x80",
- "quality" => 50,
- "sharpen" => 5,
- "inline" => false,
+ 'fit' => '80x80',
+ 'quality' => 50,
+ 'sharpen' => 5,
+ 'inline' => false,
];
public static array $previewArray = [
- "width" => 1440,
- "quality" => 80,
- "inline" => false,
- "picture" => true,
- "embed" => true,
+ 'width' => 1440,
+ 'quality' => 80,
+ 'inline' => false,
+ 'picture' => true,
+ 'embed' => true,
];
public function __construct(
@@ -36,7 +36,7 @@ public function __construct(
private readonly RendererInterface $renderer,
private readonly DocumentUrlGeneratorInterface $documentUrlGenerator,
private readonly UrlGeneratorInterface $urlGenerator,
- private readonly ?EmbedFinderFactory $embedFinderFactory = null
+ private readonly ?EmbedFinderFactory $embedFinderFactory = null,
) {
}
@@ -45,6 +45,7 @@ public function getId(): string|int
if ($this->document instanceof PersistableInterface) {
return $this->document->getId();
}
+
return 0;
}
@@ -56,12 +57,13 @@ public function getAlternativeDisplayable(): ?string
public function getDisplayable(): string
{
if (
- $this->document instanceof Document &&
- $this->document->getDocumentTranslations()->first() &&
- $this->document->getDocumentTranslations()->first()->getName()
+ $this->document instanceof Document
+ && $this->document->getDocumentTranslations()->first()
+ && $this->document->getDocumentTranslations()->first()->getName()
) {
return $this->document->getDocumentTranslations()->first()->getName();
}
+
return (string) $this->document;
}
@@ -75,8 +77,9 @@ protected function getEditItemPath(): ?string
if (!($this->document instanceof PersistableInterface)) {
return null;
}
+
return $this->urlGenerator->generate('documentsEditPage', [
- 'documentId' => $this->document->getId()
+ 'documentId' => $this->document->getId(),
]);
}
@@ -85,10 +88,10 @@ protected function getColor(): ?string
if ($this->document instanceof AdvancedDocumentInterface) {
return $this->document->getImageAverageColor();
}
+
return null;
}
-
public function toArray(): array
{
$thumbnail80Url = null;
@@ -97,10 +100,10 @@ public function toArray(): array
$hasThumbnail = false;
if (
- $this->document instanceof HasThumbnailInterface &&
- $this->document->needsThumbnail() &&
- $this->document->hasThumbnails() &&
- false !== $thumbnail = $this->document->getThumbnails()->first()
+ $this->document instanceof HasThumbnailInterface
+ && $this->document->needsThumbnail()
+ && $this->document->hasThumbnails()
+ && false !== $thumbnail = $this->document->getThumbnails()->first()
) {
$this->documentUrlGenerator->setDocument($thumbnail);
$hasThumbnail = true;
@@ -121,7 +124,7 @@ public function toArray(): array
...parent::toArray(),
'hasThumbnail' => $hasThumbnail,
'isImage' => $this->document->isImage(),
- 'isWebp' => $this->document->getMimeType() === 'image/webp',
+ 'isWebp' => 'image/webp' === $this->document->getMimeType(),
'isVideo' => $this->document->isVideo(),
'isSvg' => $this->document->isSvg(),
'isEmbed' => $this->document->isEmbed(),
diff --git a/src/Explorer/ExplorerItemFactory.php b/src/Explorer/ExplorerItemFactory.php
index 4b5b2627..6582e6d4 100644
--- a/src/Explorer/ExplorerItemFactory.php
+++ b/src/Explorer/ExplorerItemFactory.php
@@ -22,15 +22,15 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
-final class ExplorerItemFactory implements ExplorerItemFactoryInterface
+final readonly class ExplorerItemFactory implements ExplorerItemFactoryInterface
{
public function __construct(
- private readonly RendererInterface $renderer,
- private readonly DocumentUrlGeneratorInterface $documentUrlGenerator,
- private readonly UrlGeneratorInterface $urlGenerator,
- private readonly EmbedFinderFactory $embedFinderFactory,
- private readonly Security $security,
- private readonly TranslatorInterface $translator
+ private RendererInterface $renderer,
+ private DocumentUrlGeneratorInterface $documentUrlGenerator,
+ private UrlGeneratorInterface $urlGenerator,
+ private EmbedFinderFactory $embedFinderFactory,
+ private Security $security,
+ private TranslatorInterface $translator,
) {
}
diff --git a/src/Explorer/FolderExplorerItem.php b/src/Explorer/FolderExplorerItem.php
index f2ffe508..4cc25a9d 100644
--- a/src/Explorer/FolderExplorerItem.php
+++ b/src/Explorer/FolderExplorerItem.php
@@ -12,21 +12,15 @@ final class FolderExplorerItem extends AbstractExplorerItem
{
public function __construct(
private readonly Folder $folder,
- private readonly UrlGeneratorInterface $urlGenerator
+ private readonly UrlGeneratorInterface $urlGenerator,
) {
}
- /**
- * @inheritDoc
- */
public function getId(): int|string
{
return $this->folder->getId() ?? throw new \RuntimeException('Entity must have an ID');
}
- /**
- * @inheritDoc
- */
public function getAlternativeDisplayable(): ?string
{
/** @var Folder|null $parent */
@@ -36,12 +30,10 @@ public function getAlternativeDisplayable(): ?string
$parent->getTranslatedFolders()->first()->getName() :
$parent->getName();
}
+
return '';
}
- /**
- * @inheritDoc
- */
public function getDisplayable(): string
{
return $this->folder->getTranslatedFolders()->first() ?
@@ -49,9 +41,6 @@ public function getDisplayable(): string
$this->folder->getName();
}
- /**
- * @inheritDoc
- */
public function getOriginal(): Folder
{
return $this->folder;
@@ -60,7 +49,7 @@ public function getOriginal(): Folder
protected function getEditItemPath(): ?string
{
return $this->urlGenerator->generate('foldersEditPage', [
- 'folderId' => $this->folder->getId()
+ 'folderId' => $this->folder->getId(),
]);
}
}
diff --git a/src/Explorer/FoldersProvider.php b/src/Explorer/FoldersProvider.php
index e1f58a41..9d7cb0e3 100644
--- a/src/Explorer/FoldersProvider.php
+++ b/src/Explorer/FoldersProvider.php
@@ -24,10 +24,7 @@ protected function getDefaultOrdering(): array
return ['folderName' => 'ASC'];
}
- /**
- * @inheritDoc
- */
- public function supports($item): bool
+ public function supports(mixed $item): bool
{
if ($item instanceof Folder) {
return true;
diff --git a/src/Explorer/NodeExplorerItem.php b/src/Explorer/NodeExplorerItem.php
index bfaefe87..90946545 100644
--- a/src/Explorer/NodeExplorerItem.php
+++ b/src/Explorer/NodeExplorerItem.php
@@ -19,7 +19,7 @@ final class NodeExplorerItem extends AbstractExplorerItem
public function __construct(
private readonly Node $node,
private readonly UrlGeneratorInterface $urlGenerator,
- private readonly Security $security
+ private readonly Security $security,
) {
}
@@ -55,6 +55,7 @@ public function getDisplayable(): string
{
/** @var NodesSources|false $nodeSource */
$nodeSource = $this->node->getNodeSources()->first();
+
return false !== $nodeSource ?
($nodeSource->getTitle() ?? $this->node->getNodeName()) :
$this->node->getNodeName();
@@ -76,6 +77,7 @@ public function getEditItemPath(): ?string
'nodeId' => $this->node->getId(),
]);
}
+
return null;
}
@@ -88,6 +90,7 @@ public function getEditItemPath(): ?string
'translationId' => $translation->getId(),
]);
}
+
return null;
}
@@ -97,6 +100,7 @@ public function getThumbnail(): ?DocumentInterface
$nodeSource = $this->node->getNodeSources()->first();
/** @var NodesSourcesDocuments|false $thumbnail */
$thumbnail = false !== $nodeSource ? $nodeSource->getDocumentsByFields()->first() : false;
+
return $thumbnail ? $thumbnail->getDocument() : null;
}
diff --git a/src/Explorer/NodeSourceExplorerItem.php b/src/Explorer/NodeSourceExplorerItem.php
index 3d2dbd38..f52e0d22 100644
--- a/src/Explorer/NodeSourceExplorerItem.php
+++ b/src/Explorer/NodeSourceExplorerItem.php
@@ -18,7 +18,7 @@ final class NodeSourceExplorerItem extends AbstractExplorerItem
public function __construct(
private readonly NodesSources $nodeSource,
private readonly UrlGeneratorInterface $urlGenerator,
- private readonly Security $security
+ private readonly Security $security,
) {
}
@@ -67,6 +67,7 @@ public function getEditItemPath(): ?string
'translationId' => $translation->getId(),
]);
}
+
return null;
}
@@ -74,6 +75,7 @@ public function getThumbnail(): ?DocumentInterface
{
/** @var NodesSourcesDocuments|false $thumbnail */
$thumbnail = $this->nodeSource->getDocumentsByFields()->first();
+
return $thumbnail ? $thumbnail->getDocument() : null;
}
diff --git a/src/Explorer/NodeTypeExplorerItem.php b/src/Explorer/NodeTypeExplorerItem.php
index 91607473..e6a280b9 100644
--- a/src/Explorer/NodeTypeExplorerItem.php
+++ b/src/Explorer/NodeTypeExplorerItem.php
@@ -12,7 +12,7 @@ final class NodeTypeExplorerItem extends AbstractExplorerItem
{
public function __construct(
private readonly NodeType $nodeType,
- private readonly UrlGeneratorInterface $urlGenerator
+ private readonly UrlGeneratorInterface $urlGenerator,
) {
}
@@ -39,7 +39,7 @@ public function getOriginal(): NodeType
protected function getEditItemPath(): ?string
{
return $this->urlGenerator->generate('nodeTypesEditPage', [
- 'nodeTypeId' => $this->nodeType->getId()
+ 'nodeTypeId' => $this->nodeType->getId(),
]);
}
diff --git a/src/Explorer/SettingExplorerItem.php b/src/Explorer/SettingExplorerItem.php
index 9145f861..16d336eb 100644
--- a/src/Explorer/SettingExplorerItem.php
+++ b/src/Explorer/SettingExplorerItem.php
@@ -12,40 +12,29 @@ final class SettingExplorerItem extends AbstractExplorerItem
{
public function __construct(
private readonly Setting $setting,
- private readonly UrlGeneratorInterface $urlGenerator
+ private readonly UrlGeneratorInterface $urlGenerator,
) {
}
- /**
- * @inheritDoc
- */
public function getId(): int|string
{
return $this->setting->getId() ?? throw new \RuntimeException('Entity must have an ID');
}
- /**
- * @inheritDoc
- */
public function getAlternativeDisplayable(): ?string
{
if (null !== $this->setting->getSettingGroup()) {
return $this->setting->getSettingGroup()->getName();
}
+
return '';
}
- /**
- * @inheritDoc
- */
public function getDisplayable(): string
{
return $this->setting->getName();
}
- /**
- * @inheritDoc
- */
public function getOriginal(): Setting
{
return $this->setting;
@@ -54,7 +43,7 @@ public function getOriginal(): Setting
protected function getEditItemPath(): ?string
{
return $this->urlGenerator->generate('settingsEditPage', [
- 'settingId' => $this->setting->getId()
+ 'settingId' => $this->setting->getId(),
]);
}
}
diff --git a/src/Explorer/SettingsProvider.php b/src/Explorer/SettingsProvider.php
index f6809cc3..860b7f64 100644
--- a/src/Explorer/SettingsProvider.php
+++ b/src/Explorer/SettingsProvider.php
@@ -24,10 +24,7 @@ protected function getDefaultOrdering(): array
return ['name' => 'ASC'];
}
- /**
- * @inheritDoc
- */
- public function supports($item): bool
+ public function supports(mixed $item): bool
{
if ($item instanceof Setting) {
return true;
diff --git a/src/Explorer/TagExplorerItem.php b/src/Explorer/TagExplorerItem.php
index b69ec482..3765c297 100644
--- a/src/Explorer/TagExplorerItem.php
+++ b/src/Explorer/TagExplorerItem.php
@@ -12,14 +12,14 @@ final class TagExplorerItem extends AbstractExplorerItem
{
public function __construct(
private readonly Tag $tag,
- private readonly UrlGeneratorInterface $urlGenerator
+ private readonly UrlGeneratorInterface $urlGenerator,
) {
}
protected function getEditItemPath(): ?string
{
return $this->urlGenerator->generate('tagsEditPage', [
- 'tagId' => $this->tag->getId()
+ 'tagId' => $this->tag->getId(),
]);
}
@@ -55,11 +55,6 @@ public function getOriginal(): Tag
return $this->tag;
}
- /**
- * @param Tag $tag
- * @param bool $slash
- * @return string
- */
private function getTagParents(Tag $tag, bool $slash = false): string
{
$result = '';
@@ -74,7 +69,7 @@ private function getTagParents(Tag $tag, bool $slash = false): string
$name = $firstTrans->getName();
}
- $result = $superParent . $name;
+ $result = $superParent.$name;
if ($slash) {
$result .= ' / ';
diff --git a/src/Explorer/UserExplorerItem.php b/src/Explorer/UserExplorerItem.php
index 60b1a32a..1bee803b 100644
--- a/src/Explorer/UserExplorerItem.php
+++ b/src/Explorer/UserExplorerItem.php
@@ -12,45 +12,34 @@ final class UserExplorerItem extends AbstractExplorerItem
{
public function __construct(
private readonly User $user,
- private readonly UrlGeneratorInterface $urlGenerator
+ private readonly UrlGeneratorInterface $urlGenerator,
) {
}
- /**
- * @inheritDoc
- */
public function getId(): int|string
{
return $this->user->getId() ?? throw new \RuntimeException('Entity must have an ID');
}
- /**
- * @inheritDoc
- */
public function getAlternativeDisplayable(): ?string
{
return $this->user->getEmail();
}
- /**
- * @inheritDoc
- */
public function getDisplayable(): string
{
$fullName = trim(
- ($this->user->getFirstName() ?? '') .
- ' ' .
+ ($this->user->getFirstName() ?? '').
+ ' '.
($this->user->getLastName() ?? '')
);
- if ($fullName !== '') {
+ if ('' !== $fullName) {
return $fullName;
}
+
return $this->user->getUsername();
}
- /**
- * @inheritDoc
- */
public function getOriginal(): User
{
return $this->user;
@@ -59,7 +48,7 @@ public function getOriginal(): User
protected function getEditItemPath(): ?string
{
return $this->urlGenerator->generate('usersEditPage', [
- 'id' => $this->user->getId()
+ 'id' => $this->user->getId(),
]);
}
}
diff --git a/src/Explorer/UsersProvider.php b/src/Explorer/UsersProvider.php
index 102252a0..48578772 100644
--- a/src/Explorer/UsersProvider.php
+++ b/src/Explorer/UsersProvider.php
@@ -24,10 +24,7 @@ protected function getDefaultOrdering(): array
return ['username' => 'ASC'];
}
- /**
- * @inheritDoc
- */
- public function supports($item): bool
+ public function supports(mixed $item): bool
{
if ($item instanceof User) {
return true;
diff --git a/src/Forms/AddUserType.php b/src/Forms/AddUserType.php
index 2cbff0d7..63cc27e0 100644
--- a/src/Forms/AddUserType.php
+++ b/src/Forms/AddUserType.php
@@ -14,11 +14,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
parent::buildForm($builder, $options);
$builder->add('groups', GroupsType::class, [
- 'label' => 'user.groups',
- 'required' => false,
- 'multiple' => true,
- 'expanded' => true,
- ])
+ 'label' => 'user.groups',
+ 'required' => false,
+ 'multiple' => true,
+ 'expanded' => true,
+ ])
;
}
diff --git a/src/Forms/CustomFormFieldType.php b/src/Forms/CustomFormFieldType.php
index f0e25cd8..957404c4 100644
--- a/src/Forms/CustomFormFieldType.php
+++ b/src/Forms/CustomFormFieldType.php
@@ -19,12 +19,11 @@
class CustomFormFieldType extends AbstractType
{
public function __construct(
- private readonly CustomFormFieldRepository $customFormFieldRepository
+ private readonly CustomFormFieldRepository $customFormFieldRepository,
) {
}
/**
- * @param CustomFormField $field
* @return string[]
*/
protected function getAllGroupsNames(CustomFormField $field): array
@@ -35,9 +34,9 @@ protected function getAllGroupsNames(CustomFormField $field): array
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('label', TextType::class, [
- 'label' => 'label',
- 'empty_data' => '',
- ])
+ 'label' => 'label',
+ 'empty_data' => '',
+ ])
->add('description', MarkdownType::class, [
'label' => 'description',
'required' => false,
@@ -115,7 +114,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
],
'placeholder' => 'autocomplete.no_autocomplete',
'choice_label' => function ($choice, $key, $value) {
- return 'autocomplete.' . $value;
+ return 'autocomplete.'.$value;
},
'required' => false,
]);
diff --git a/src/Forms/CustomFormType.php b/src/Forms/CustomFormType.php
index 57858f3b..cf805eed 100644
--- a/src/Forms/CustomFormType.php
+++ b/src/Forms/CustomFormType.php
@@ -23,9 +23,6 @@ class CustomFormType extends AbstractType
{
protected Security $security;
- /**
- * @param Security $security
- */
public function __construct(Security $security)
{
$this->security = $security;
@@ -66,7 +63,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'customForm.retentionTime',
'help' => 'customForm.retentionTime.help',
'required' => false,
- 'placeholder' => 'customForm.retentionTime.always',
+ 'placeholder' => 'customForm.retentionTime.always',
'choices' => [
'customForm.retentionTime.one_week' => 'P7D',
'customForm.retentionTime.two_weeks' => 'P14D',
@@ -75,13 +72,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'customForm.retentionTime.six_months' => 'P6M',
'customForm.retentionTime.one_year' => 'P1Y',
'customForm.retentionTime.two_years' => 'P2Y',
- ]
+ ],
]);
}
$builder->add('open', CheckboxType::class, [
- 'label' => 'customForm.open',
- 'required' => false,
- ])
+ 'label' => 'customForm.open',
+ 'required' => false,
+ ])
->add('closeDate', DateTimeType::class, [
'label' => 'customForm.closeDate',
'required' => false,
diff --git a/src/Forms/DataTransformer/TagTransformer.php b/src/Forms/DataTransformer/TagTransformer.php
index f90162b2..0d9fad58 100644
--- a/src/Forms/DataTransformer/TagTransformer.php
+++ b/src/Forms/DataTransformer/TagTransformer.php
@@ -13,9 +13,6 @@ class TagTransformer implements DataTransformerInterface
{
private ObjectManager $manager;
- /**
- * @param ObjectManager $manager
- */
public function __construct(ObjectManager $manager)
{
$this->manager = $manager;
@@ -23,6 +20,7 @@ public function __construct(ObjectManager $manager)
/**
* @param iterable|null $tags
+ *
* @return array|string
*/
public function transform($tags)
@@ -35,11 +33,13 @@ public function transform($tags)
foreach ($tags as $tag) {
$ids[] = $tag->getId();
}
+
return $ids;
}
/**
* @param string|array $tagIds
+ *
* @return array
*/
public function reverseTransform($tagIds)
@@ -61,10 +61,7 @@ public function reverseTransform($tagIds)
->find($tagId)
;
if (null === $tag) {
- throw new TransformationFailedException(sprintf(
- 'A tag with id "%s" does not exist!',
- $tagId
- ));
+ throw new TransformationFailedException(sprintf('A tag with id "%s" does not exist!', $tagId));
}
$tags[] = $tag;
diff --git a/src/Forms/DocumentEditType.php b/src/Forms/DocumentEditType.php
index b016ee93..a5f19d06 100644
--- a/src/Forms/DocumentEditType.php
+++ b/src/Forms/DocumentEditType.php
@@ -8,6 +8,7 @@
use RZ\Roadiz\CoreBundle\Form\ColorType;
use RZ\Roadiz\CoreBundle\Form\Constraint\UniqueFilename;
use RZ\Roadiz\CoreBundle\Form\DocumentCollectionType;
+use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
@@ -17,7 +18,6 @@
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
-use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Validator\Constraints\File;
use Symfony\Component\Validator\Constraints\LessThanOrEqual;
use Symfony\Component\Validator\Constraints\NotBlank;
@@ -33,9 +33,6 @@ public function __construct(Security $security)
$this->security = $security;
}
- /**
- * @inheritDoc
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
/** @var Document $document */
@@ -54,8 +51,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
new NotBlank(),
new Regex([
'pattern' => '/\.[a-z0-9]+$/i',
- 'htmlPattern' => ".[a-z0-9]+$",
- 'message' => 'value_is_not_a_valid_filename'
+ 'htmlPattern' => '.[a-z0-9]+$',
+ 'message' => 'value_is_not_a_valid_filename',
]),
new UniqueFilename([
'document' => $document,
@@ -80,13 +77,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
}
$builder->add('newDocument', FileType::class, [
- 'label' => 'overwrite.document',
- 'required' => false,
- 'mapped' => false,
- 'constraints' => [
- new File()
- ],
- ])
+ 'label' => 'overwrite.document',
+ 'required' => false,
+ 'mapped' => false,
+ 'constraints' => [
+ new File(),
+ ],
+ ])
->add('embed', DocumentEmbedType::class, [
'label' => 'document.embed',
'required' => false,
@@ -103,18 +100,18 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
if ($document->isImage() || $document->isVideo() || $document->isEmbed()) {
$builder->add('imageWidth', IntegerType::class, [
'label' => 'document.width',
- 'required' => false
+ 'required' => false,
]);
$builder->add('imageHeight', IntegerType::class, [
'label' => 'document.height',
- 'required' => false
+ 'required' => false,
]);
}
if ($document->isAudio() || $document->isVideo() || $document->isEmbed()) {
$builder->add('mediaDuration', IntegerType::class, [
'label' => 'document.duration',
- 'required' => false
+ 'required' => false,
]);
}
@@ -133,14 +130,14 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder->add('thumbnails', DocumentCollectionType::class, [
'label' => 'document.thumbnails',
'multiple' => true,
- 'required' => false
+ 'required' => false,
]);
}
$builder->add('folders', FolderCollectionType::class, [
'label' => 'folders',
'multiple' => true,
- 'required' => false
+ 'required' => false,
]);
if ($this->security->isGranted('ROLE_ACCESS_DOCUMENTS_CREATION_DATE')) {
@@ -160,18 +157,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'constraints' => [
new LessThanOrEqual($builder->getData()->getUpdatedAt()),
new LessThanOrEqual('now'),
- ]
+ ],
]);
}
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
- 'data_class' => Document::class
+ 'data_class' => Document::class,
]);
$resolver->setRequired('referer');
@@ -181,10 +175,6 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('document_platforms', ['array']);
}
-
- /**
- * @inheritDoc
- */
public function getBlockPrefix(): string
{
return 'document_edit';
diff --git a/src/Forms/DocumentEmbedType.php b/src/Forms/DocumentEmbedType.php
index 74073030..660533c7 100644
--- a/src/Forms/DocumentEmbedType.php
+++ b/src/Forms/DocumentEmbedType.php
@@ -12,9 +12,6 @@
class DocumentEmbedType extends AbstractType
{
- /**
- * @inheritDoc
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$services = [];
@@ -32,18 +29,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'document.platform',
'required' => true,
'choices' => $services,
- 'placeholder' => 'document.no_embed_platform'
+ 'placeholder' => 'document.no_embed_platform',
])
;
- if ($options['required'] === false) {
+ if (false === $options['required']) {
$builder->get('embedId')->setRequired(false);
$builder->get('embedPlatform')->setRequired(false);
}
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('required', true);
@@ -51,10 +45,6 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('document_platforms', ['array']);
}
-
- /**
- * @inheritDoc
- */
public function getBlockPrefix(): string
{
return 'document_embed';
diff --git a/src/Forms/DocumentTranslationType.php b/src/Forms/DocumentTranslationType.php
index ea1fd10a..b9a1c4d9 100644
--- a/src/Forms/DocumentTranslationType.php
+++ b/src/Forms/DocumentTranslationType.php
@@ -17,9 +17,9 @@ class DocumentTranslationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('referer', HiddenType::class, [
- 'data' => $options['referer'],
- 'mapped' => false,
- ])
+ 'data' => $options['referer'],
+ 'mapped' => false,
+ ])
->add('name', TextType::class, [
'label' => 'name',
'required' => false,
@@ -38,13 +38,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
]);
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
- 'data_class' => DocumentTranslation::class
+ 'data_class' => DocumentTranslation::class,
]);
$resolver->setRequired('referer');
diff --git a/src/Forms/DynamicType.php b/src/Forms/DynamicType.php
index dbaf6999..000e8994 100644
--- a/src/Forms/DynamicType.php
+++ b/src/Forms/DynamicType.php
@@ -11,24 +11,16 @@
class DynamicType extends AbstractType
{
- /**
- * {@inheritdoc}
- */
public function getParent(): ?string
{
return TextareaType::class;
}
- /**
- * {@inheritdoc}
- */
+
public function getBlockPrefix(): string
{
return 'dynamic';
}
- /**
- * {@inheritdoc}
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
@@ -37,8 +29,8 @@ public function configureOptions(OptionsResolver $resolver): void
'class' => 'dynamic_textarea',
],
'constraints' => [
- new ValidYaml()
- ]
+ new ValidYaml(),
+ ],
]);
}
}
diff --git a/src/Forms/FolderCollectionType.php b/src/Forms/FolderCollectionType.php
index c580bf84..51d0cf08 100644
--- a/src/Forms/FolderCollectionType.php
+++ b/src/Forms/FolderCollectionType.php
@@ -7,7 +7,7 @@
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\CoreBundle\Entity\Folder;
use RZ\Roadiz\CoreBundle\Form\DataTransformer\FolderCollectionTransformer;
-use Symfony\Component\Form\AbstractType as AbstractType;
+use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
@@ -21,11 +21,6 @@ public function __construct(private readonly ManagerRegistry $managerRegistry)
{
}
- /**
- * @param FormView $view
- * @param FormInterface $form
- * @param array $options
- */
public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);
@@ -33,9 +28,6 @@ public function buildView(FormView $view, FormInterface $form, array $options):
$view->vars['provider_class'] = FoldersProvider::class;
}
- /**
- * {@inheritdoc}
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
@@ -46,12 +38,6 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * {@inheritdoc}
- *
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addModelTransformer(new FolderCollectionTransformer(
@@ -60,17 +46,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
));
}
- /**
- * {@inheritdoc}
- */
public function getParent(): ?string
{
return TextType::class;
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'folders';
diff --git a/src/Forms/GeoJsonType.php b/src/Forms/GeoJsonType.php
index 7cefd14c..49c8ec55 100644
--- a/src/Forms/GeoJsonType.php
+++ b/src/Forms/GeoJsonType.php
@@ -20,9 +20,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
}));
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'geojson';
diff --git a/src/Forms/GroupType.php b/src/Forms/GroupType.php
index 51e21a2c..b91e59b8 100644
--- a/src/Forms/GroupType.php
+++ b/src/Forms/GroupType.php
@@ -12,9 +12,6 @@
class GroupType extends AbstractType
{
- /**
- * @inheritDoc
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
@@ -23,9 +20,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
]);
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
diff --git a/src/Forms/ImageCropAlignmentType.php b/src/Forms/ImageCropAlignmentType.php
index 5a79bd2d..dce7100b 100644
--- a/src/Forms/ImageCropAlignmentType.php
+++ b/src/Forms/ImageCropAlignmentType.php
@@ -27,7 +27,7 @@ public function configureOptions(OptionsResolver $resolver): void
'image_crop_alignment.bottom-left' => 'bottom-left',
'image_crop_alignment.bottom' => 'bottom',
'image_crop_alignment.bottom-right' => 'bottom-right',
- ]
+ ],
]);
}
@@ -36,7 +36,6 @@ public function getBlockPrefix(): string
return 'image_crop_alignment';
}
-
public function getParent(): string
{
return ChoiceType::class;
diff --git a/src/Forms/LoginType.php b/src/Forms/LoginType.php
index 3f88811c..52e94899 100644
--- a/src/Forms/LoginType.php
+++ b/src/Forms/LoginType.php
@@ -22,25 +22,18 @@ class LoginType extends AbstractType
protected UrlGeneratorInterface $urlGenerator;
protected RequestStack $requestStack;
- /**
- * @param UrlGeneratorInterface $urlGenerator
- * @param RequestStack $requestStack
- */
public function __construct(UrlGeneratorInterface $urlGenerator, RequestStack $requestStack)
{
$this->urlGenerator = $urlGenerator;
$this->requestStack = $requestStack;
}
- /**
- * @inheritDoc
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('_username', TextType::class, [
'label' => 'username',
'attr' => [
- 'autocomplete' => 'username'
+ 'autocomplete' => 'username',
],
'constraints' => [
new NotNull(),
@@ -50,7 +43,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('_password', PasswordType::class, [
'label' => 'password',
'attr' => [
- 'autocomplete' => 'current-password'
+ 'autocomplete' => 'current-password',
],
'constraints' => [
new NotNull(),
@@ -61,20 +54,17 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'label' => 'keep_me_logged_in',
'required' => false,
'attr' => [
- 'checked' => true
+ 'checked' => true,
],
]);
if ($this->requestStack->getMainRequest()?->query->has('_home')) {
$builder->add('_target_path', HiddenType::class, [
- 'data' => $this->urlGenerator->generate('adminHomePage')
+ 'data' => $this->urlGenerator->generate('adminHomePage'),
]);
}
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setNormalizer('action', function (Options $options) {
@@ -82,9 +72,6 @@ public function configureOptions(OptionsResolver $resolver): void
});
}
- /**
- * @inheritDoc
- */
public function getBlockPrefix(): string
{
/*
diff --git a/src/Forms/Node/AddNodeType.php b/src/Forms/Node/AddNodeType.php
index ffc863f6..886aacd0 100644
--- a/src/Forms/Node/AddNodeType.php
+++ b/src/Forms/Node/AddNodeType.php
@@ -24,18 +24,11 @@ class AddNodeType extends AbstractType
{
protected ManagerRegistry $managerRegistry;
- /**
- * @param ManagerRegistry $managerRegistry
- */
public function __construct(ManagerRegistry $managerRegistry)
{
$this->managerRegistry = $managerRegistry;
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('title', TextType::class, [
@@ -46,12 +39,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
new NotNull(),
new NotBlank(),
new Length([
- 'max' => 255
- ])
+ 'max' => 255,
+ ]),
],
]);
- if ($options['showNodeType'] === true) {
+ if (true === $options['showNodeType']) {
$builder->add('nodeType', NodeTypesType::class, [
'label' => 'nodeType',
'constraints' => [
@@ -112,17 +105,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
});
}
- /**
- * @return string
- */
public function getBlockPrefix(): string
{
return 'childnode';
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
diff --git a/src/Forms/NodeSource/AbstractConfigurableNodeSourceFieldType.php b/src/Forms/NodeSource/AbstractConfigurableNodeSourceFieldType.php
index 752fe133..928ee059 100644
--- a/src/Forms/NodeSource/AbstractConfigurableNodeSourceFieldType.php
+++ b/src/Forms/NodeSource/AbstractConfigurableNodeSourceFieldType.php
@@ -6,17 +6,9 @@
use Symfony\Component\Yaml\Yaml;
-/**
- * @package RZ\Roadiz\CMS\Forms\NodeSource
- */
abstract class AbstractConfigurableNodeSourceFieldType extends AbstractNodeSourceFieldType
{
- /**
- * @param array $options
- *
- * @return mixed
- */
- protected function getFieldConfiguration(array $options)
+ protected function getFieldConfiguration(array $options): mixed
{
return Yaml::parse($options['nodeTypeField']->getDefaultValues() ?? '');
}
diff --git a/src/Forms/NodeSource/AbstractNodeSourceFieldType.php b/src/Forms/NodeSource/AbstractNodeSourceFieldType.php
index b8ad2c6d..5b16afb9 100644
--- a/src/Forms/NodeSource/AbstractNodeSourceFieldType.php
+++ b/src/Forms/NodeSource/AbstractNodeSourceFieldType.php
@@ -17,9 +17,6 @@ abstract class AbstractNodeSourceFieldType extends AbstractType
{
protected ManagerRegistry $managerRegistry;
- /**
- * @param ManagerRegistry $managerRegistry
- */
public function __construct(ManagerRegistry $managerRegistry)
{
$this->managerRegistry = $managerRegistry;
@@ -27,10 +24,6 @@ public function __construct(ManagerRegistry $managerRegistry)
/**
* Pass nodeSource to form twig template.
- *
- * @param FormView $view
- * @param FormInterface $form
- * @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options): void
{
@@ -40,9 +33,6 @@ public function buildView(FormView $view, FormInterface $form, array $options):
$view->vars['nodeTypeField'] = $options['nodeTypeField'];
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -56,10 +46,6 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('nodeTypeField', [NodeTypeField::class]);
}
-
- /**
- * {@inheritdoc}
- */
public function getParent(): ?string
{
return HiddenType::class;
diff --git a/src/Forms/NodeSource/NodeSourceBaseType.php b/src/Forms/NodeSource/NodeSourceBaseType.php
index 755a2f78..4ca983f4 100644
--- a/src/Forms/NodeSource/NodeSourceBaseType.php
+++ b/src/Forms/NodeSource/NodeSourceBaseType.php
@@ -15,10 +15,6 @@
final class NodeSourceBaseType extends AbstractType
{
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('title', TextType::class, [
@@ -26,24 +22,24 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'empty_data' => '',
'required' => false,
'attr' => [
- 'data-dev-name' => '{{ nodeSource.' . StringHandler::camelCase('title') . ' }}',
+ 'data-dev-name' => '{{ nodeSource.'.StringHandler::camelCase('title').' }}',
'lang' => \mb_strtolower(str_replace('_', '-', $options['translation']->getLocale())),
'dir' => $options['translation']->isRtl() ? 'rtl' : 'ltr',
],
'constraints' => [
new Length([
'max' => 255,
- ])
- ]
+ ]),
+ ],
]);
- if ($options['publishable'] === true) {
+ if (true === $options['publishable']) {
$builder->add('publishedAt', DateTimeType::class, [
'label' => 'publishedAt',
'required' => false,
'attr' => [
'class' => 'rz-datetime-field',
- 'data-dev-name' => '{{ nodeSource.' . StringHandler::camelCase('publishedAt') . ' }}',
+ 'data-dev-name' => '{{ nodeSource.'.StringHandler::camelCase('publishedAt').' }}',
],
'date_widget' => 'single_text',
'date_format' => 'yyyy-MM-dd',
@@ -55,17 +51,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
}
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'nodesourcebase';
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
diff --git a/src/Forms/NodeSource/NodeSourceCollectionType.php b/src/Forms/NodeSource/NodeSourceCollectionType.php
index 583d01e6..7a548399 100644
--- a/src/Forms/NodeSource/NodeSourceCollectionType.php
+++ b/src/Forms/NodeSource/NodeSourceCollectionType.php
@@ -11,9 +11,6 @@
final class NodeSourceCollectionType extends CollectionType
{
- /**
- * @inheritDoc
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
parent::buildForm($builder, $options);
diff --git a/src/Forms/NodeSource/NodeSourceCustomFormType.php b/src/Forms/NodeSource/NodeSourceCustomFormType.php
index be552197..5e9fb0f9 100644
--- a/src/Forms/NodeSource/NodeSourceCustomFormType.php
+++ b/src/Forms/NodeSource/NodeSourceCustomFormType.php
@@ -14,22 +14,15 @@
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @package RZ\Roadiz\CMS\Forms\NodeSource
- */
final class NodeSourceCustomFormType extends AbstractNodeSourceFieldType
{
public function __construct(
ManagerRegistry $managerRegistry,
- private readonly NodeHandler $nodeHandler
+ private readonly NodeHandler $nodeHandler,
) {
parent::__construct($managerRegistry);
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(
@@ -43,9 +36,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
;
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -59,17 +49,11 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'custom_forms';
}
- /**
- * @param FormEvent $event
- */
public function onPreSetData(FormEvent $event): void
{
/** @var NodesSources $nodeSource */
@@ -83,9 +67,6 @@ public function onPreSetData(FormEvent $event): void
->findByNodeAndFieldName($nodeSource->getNode(), $nodeTypeField->getName()));
}
- /**
- * @param FormEvent $event
- */
public function onPostSubmit(FormEvent $event): void
{
/** @var NodesSources $nodeSource */
@@ -104,11 +85,11 @@ public function onPostSubmit(FormEvent $event): void
/** @var CustomForm|null $tempCForm */
$tempCForm = $manager->find(CustomForm::class, (int) $customFormId);
- if ($tempCForm !== null) {
+ if (null !== $tempCForm) {
$this->nodeHandler->addCustomFormForField($tempCForm, $nodeTypeField, false, $position);
- $position++;
+ ++$position;
} else {
- throw new \RuntimeException('Custom form #' . $customFormId . ' was not found during relationship creation.');
+ throw new \RuntimeException('Custom form #'.$customFormId.' was not found during relationship creation.');
}
}
}
diff --git a/src/Forms/NodeSource/NodeSourceDocumentType.php b/src/Forms/NodeSource/NodeSourceDocumentType.php
index efcce674..48eff69e 100644
--- a/src/Forms/NodeSource/NodeSourceDocumentType.php
+++ b/src/Forms/NodeSource/NodeSourceDocumentType.php
@@ -14,22 +14,15 @@
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @package RZ\Roadiz\CMS\Forms\NodeSource
- */
final class NodeSourceDocumentType extends AbstractNodeSourceFieldType
{
public function __construct(
ManagerRegistry $managerRegistry,
- private readonly NodesSourcesHandler $nodesSourcesHandler
+ private readonly NodesSourcesHandler $nodesSourcesHandler,
) {
parent::__construct($managerRegistry);
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(
@@ -43,9 +36,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
;
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -63,17 +53,11 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'documents';
}
- /**
- * @param FormEvent $event
- */
public function onPreSetData(FormEvent $event): void
{
/** @var NodesSources $nodeSource */
@@ -90,8 +74,6 @@ public function onPreSetData(FormEvent $event): void
}
/**
- * @param FormEvent $event
- *
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
@@ -113,11 +95,11 @@ public function onPostSubmit(FormEvent $event): void
/** @var Document|null $tempDoc */
$tempDoc = $manager->find(Document::class, (int) $documentId);
- if ($tempDoc !== null) {
+ if (null !== $tempDoc) {
$this->nodesSourcesHandler->addDocumentForField($tempDoc, $nodeTypeField, false, $position);
- $position++;
+ ++$position;
} else {
- throw new \RuntimeException('Document #' . $documentId . ' was not found during relationship creation.');
+ throw new \RuntimeException('Document #'.$documentId.' was not found during relationship creation.');
}
}
}
diff --git a/src/Forms/NodeSource/NodeSourceJoinType.php b/src/Forms/NodeSource/NodeSourceJoinType.php
index b7810c44..88da3918 100644
--- a/src/Forms/NodeSource/NodeSourceJoinType.php
+++ b/src/Forms/NodeSource/NodeSourceJoinType.php
@@ -14,9 +14,6 @@
final class NodeSourceJoinType extends AbstractConfigurableNodeSourceFieldType
{
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -27,10 +24,6 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefault('multiple', true);
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$configuration = $this->getFieldConfiguration($options);
@@ -44,10 +37,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
/**
* Pass data to form twig template.
- *
- * @param FormView $view
- * @param FormInterface $form
- * @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options): void
{
@@ -93,9 +82,6 @@ public function buildView(FormView $view, FormInterface $form, array $options):
$view->vars['data'] = $displayableData;
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'join';
diff --git a/src/Forms/NodeSource/NodeSourceNodeType.php b/src/Forms/NodeSource/NodeSourceNodeType.php
index 779badd0..d59bed96 100644
--- a/src/Forms/NodeSource/NodeSourceNodeType.php
+++ b/src/Forms/NodeSource/NodeSourceNodeType.php
@@ -15,9 +15,6 @@
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
-/**
- * @package RZ\Roadiz\CMS\Forms\NodeSource
- */
final class NodeSourceNodeType extends AbstractNodeSourceFieldType
{
public function __construct(ManagerRegistry $managerRegistry, private readonly NodeHandler $nodeHandler)
@@ -25,10 +22,6 @@ public function __construct(ManagerRegistry $managerRegistry, private readonly N
parent::__construct($managerRegistry);
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(
@@ -42,9 +35,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
;
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -58,17 +48,11 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'nodes';
}
- /**
- * @param FormEvent $event
- */
public function onPreSetData(FormEvent $event): void
{
/** @var NodesSources $nodeSource */
@@ -87,9 +71,6 @@ public function onPreSetData(FormEvent $event): void
));
}
- /**
- * @param FormEvent $event
- */
public function onPostSubmit(FormEvent $event): void
{
/** @var NodesSources $nodeSource */
@@ -108,11 +89,11 @@ public function onPostSubmit(FormEvent $event): void
/** @var Node|null $tempNode */
$tempNode = $manager->find(Node::class, (int) $nodeId);
- if ($tempNode !== null) {
+ if (null !== $tempNode) {
$this->nodeHandler->addNodeForField($tempNode, $nodeTypeField, false, $position);
- $position++;
+ ++$position;
} else {
- throw new \RuntimeException('Node #' . $nodeId . ' was not found during relationship creation.');
+ throw new \RuntimeException('Node #'.$nodeId.' was not found during relationship creation.');
}
}
}
diff --git a/src/Forms/NodeSource/NodeSourceProviderType.php b/src/Forms/NodeSource/NodeSourceProviderType.php
index 7d3a1c63..acaee5e3 100644
--- a/src/Forms/NodeSource/NodeSourceProviderType.php
+++ b/src/Forms/NodeSource/NodeSourceProviderType.php
@@ -23,9 +23,6 @@ public function __construct(ManagerRegistry $managerRegistry, private readonly C
parent::__construct($managerRegistry);
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
@@ -40,14 +37,11 @@ public function configureOptions(OptionsResolver $resolver): void
if ($nodeTypeField->isMultipleProvider()) {
return true;
}
+
return false;
});
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$configuration = $this->getFieldConfiguration($options);
@@ -74,10 +68,6 @@ protected function getProvider(array $configuration, array $options): ExplorerPr
/**
* Pass data to form twig template.
- *
- * @param FormView $view
- * @param FormInterface $form
- * @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options): void
{
@@ -126,9 +116,6 @@ public function buildView(FormView $view, FormInterface $form, array $options):
}
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'provider';
diff --git a/src/Forms/NodeSource/NodeSourceSeoType.php b/src/Forms/NodeSource/NodeSourceSeoType.php
index c102d487..6bb9c28f 100644
--- a/src/Forms/NodeSource/NodeSourceSeoType.php
+++ b/src/Forms/NodeSource/NodeSourceSeoType.php
@@ -13,30 +13,23 @@
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
-/**
- * @package RZ\Roadiz\CMS\Forms\NodeSource
- */
final class NodeSourceSeoType extends AbstractType
{
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('metaTitle', TextType::class, [
- 'label' => 'metaTitle',
- 'help' => 'nodeSource.metaTitle.help',
- 'required' => false,
- 'attr' => [
- 'data-max-length' => 80,
- ],
- 'constraints' => [
- new Length([
- 'max' => 80
- ])
- ]
- ])
+ 'label' => 'metaTitle',
+ 'help' => 'nodeSource.metaTitle.help',
+ 'required' => false,
+ 'attr' => [
+ 'data-max-length' => 80,
+ ],
+ 'constraints' => [
+ new Length([
+ 'max' => 80,
+ ]),
+ ],
+ ])
->add('metaDescription', TextareaType::class, [
'label' => 'metaDescription',
'help' => 'nodeSource.metaDescription.help',
@@ -50,9 +43,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
;
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
diff --git a/src/Forms/NodeSource/NodeSourceType.php b/src/Forms/NodeSource/NodeSourceType.php
index 22aab62a..c2417880 100644
--- a/src/Forms/NodeSource/NodeSourceType.php
+++ b/src/Forms/NodeSource/NodeSourceType.php
@@ -43,20 +43,18 @@ final class NodeSourceType extends AbstractType
{
public function __construct(
private readonly ManagerRegistry $managerRegistry,
- private readonly Security $security
+ private readonly Security $security,
) {
}
/**
- * @param FormBuilderInterface $builder
- * @param array $options
* @throws \ReflectionException
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$fields = $this->getFieldsForSource($builder->getData(), $options['nodeType']);
- if ($options['withTitle'] === true) {
+ if (true === $options['withTitle']) {
$builder->add('base', NodeSourceBaseType::class, [
'publishable' => $options['nodeType']->isPublishable(),
'translation' => $builder->getData()->getTranslation(),
@@ -67,7 +65,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
if (!$this->security->isGranted(NodeTypeFieldVoter::VIEW, $field)) {
continue;
}
- if ($options['withVirtual'] === true || !$field->isVirtual()) {
+ if (true === $options['withVirtual'] || !$field->isVirtual()) {
$builder->add(
$field->getVarName(),
self::getFormTypeFromFieldType($field),
@@ -77,9 +75,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
}
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
@@ -97,17 +92,12 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('class', 'string');
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'source';
}
/**
- * @param NodesSources $source
- * @param NodeType $nodeType
* @return array
*/
private function getFieldsForSource(NodesSources $source, NodeType $nodeType): array
@@ -128,19 +118,11 @@ private function getFieldsForSource(NodesSources $source, NodeType $nodeType): a
return $this->managerRegistry->getRepository(NodeTypeField::class)->findBy($criteria, $position);
}
- /**
- * @param NodesSources $source
- * @return bool
- */
private function needsUniversalFields(NodesSources $source): bool
{
- return ($source->getTranslation()->isDefaultTranslation() || !$this->hasDefaultTranslation($source));
+ return $source->getTranslation()->isDefaultTranslation() || !$this->hasDefaultTranslation($source);
}
- /**
- * @param NodesSources $source
- * @return bool
- */
private function hasDefaultTranslation(NodesSources $source): bool
{
/** @var Translation $defaultTranslation */
@@ -155,13 +137,12 @@ private function hasDefaultTranslation(NodesSources $source): bool
'translation' => $defaultTranslation,
]);
- return $sourceCount === 1;
+ return 1 === $sourceCount;
}
/**
* Returns a Symfony Form type according to a node-type field.
*
- * @param AbstractField $field
* @return class-string
*/
public static function getFormTypeFromFieldType(AbstractField $field): string
@@ -256,10 +237,8 @@ public static function getFormTypeFromFieldType(AbstractField $field): string
* Returns an option array for creating a Symfony Form
* according to a node-type field.
*
- * @param NodesSources $nodeSource
- * @param NodeTypeField $field
- * @param array $formOptions
* @return array
+ *
* @throws \ReflectionException
*/
public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeField $field, array &$formOptions)
@@ -287,7 +266,7 @@ public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeFi
'data-nodetypes' => json_encode(explode(
',',
$field->getDefaultValues() ?? ''
- ))
+ )),
],
]);
break;
@@ -327,8 +306,8 @@ public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeFi
'constraints' => [
new Email(),
new Length([
- 'max' => 255
- ])
+ 'max' => 255,
+ ]),
],
]);
break;
@@ -336,8 +315,8 @@ public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeFi
$options = array_merge_recursive($options, [
'constraints' => [
new Length([
- 'max' => 255
- ])
+ 'max' => 255,
+ ]),
],
]);
break;
@@ -366,7 +345,7 @@ public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeFi
case AbstractField::CHILDREN_T:
$options = array_merge_recursive($options, [
'nodeSource' => $nodeSource,
- 'nodeTypeField' => $field
+ 'nodeTypeField' => $field,
]);
break;
case AbstractField::COUNTRY_T:
@@ -376,7 +355,7 @@ public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeFi
if ('' !== $field->getPlaceholder()) {
$options['placeholder'] = $field->getPlaceholder();
}
- if ($field->getDefaultValues() !== '') {
+ if ('' !== $field->getDefaultValues()) {
$countries = explode(',', $field->getDefaultValues() ?? '');
$countries = array_map('trim', $countries);
$options = array_merge_recursive($options, [
@@ -390,11 +369,11 @@ public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeFi
'allow_add' => true,
'allow_delete' => true,
'attr' => [
- 'class' => 'rz-collection-form-type'
+ 'class' => 'rz-collection-form-type',
],
'entry_options' => [
'label' => false,
- ]
+ ],
];
if (isset($configuration['entry_type'])) {
$reflectionClass = new \ReflectionClass($configuration['entry_type']);
@@ -411,16 +390,11 @@ public function getFormOptionsFromFieldType(NodesSources $nodeSource, NodeTypeFi
/**
* Get common options for your node-type field form components.
- *
- * @param NodesSources $nodeSource
- * @param NodeTypeField $field
- * @param array $formOptions
- * @return array
*/
public function getDefaultOptions(NodesSources $nodeSource, NodeTypeField $field, array &$formOptions): array
{
$label = $field->getLabel();
- $devName = '{{ nodeSource.' . $field->getVarName() . ' }}';
+ $devName = '{{ nodeSource.'.$field->getVarName().' }}';
$options = [
'label' => $label,
'required' => false,
@@ -429,8 +403,8 @@ public function getDefaultOptions(NodesSources $nodeSource, NodeTypeField $field
$field->getGroupName() :
'default',
'data-field-group-canonical' => (
- null !== $field->getGroupNameCanonical() &&
- '' != $field->getGroupNameCanonical()
+ null !== $field->getGroupNameCanonical()
+ && '' != $field->getGroupNameCanonical()
) ? $field->getGroupNameCanonical() : 'default',
'data-dev-name' => $devName,
'autocomplete' => 'off',
@@ -454,22 +428,22 @@ public function getDefaultOptions(NodesSources $nodeSource, NodeTypeField $field
$options['attr']['data-max-length'] = $field->getMaxLength();
}
if (
- $field->isVirtual() &&
- $field->getType() !== AbstractField::MANY_TO_ONE_T &&
- $field->getType() !== AbstractField::MANY_TO_MANY_T
+ $field->isVirtual()
+ && AbstractField::MANY_TO_ONE_T !== $field->getType()
+ && AbstractField::MANY_TO_MANY_T !== $field->getType()
) {
$options['mapped'] = false;
}
if (
in_array($field->getType(), [
- AbstractField::MANY_TO_ONE_T,
- AbstractField::MANY_TO_MANY_T,
- AbstractField::DOCUMENTS_T,
- AbstractField::NODES_T,
- AbstractField::CUSTOM_FORMS_T,
- AbstractField::MULTI_PROVIDER_T,
- AbstractField::SINGLE_PROVIDER_T,
+ AbstractField::MANY_TO_ONE_T,
+ AbstractField::MANY_TO_MANY_T,
+ AbstractField::DOCUMENTS_T,
+ AbstractField::NODES_T,
+ AbstractField::CUSTOM_FORMS_T,
+ AbstractField::MULTI_PROVIDER_T,
+ AbstractField::SINGLE_PROVIDER_T,
])
) {
$options['nodeTypeField'] = $field;
@@ -477,7 +451,7 @@ public function getDefaultOptions(NodesSources $nodeSource, NodeTypeField $field
unset($options['attr']['dir']);
}
- if ($field->getType() === AbstractField::CHILDREN_T) {
+ if (AbstractField::CHILDREN_T === $field->getType()) {
unset($options['attr']['dir']);
}
diff --git a/src/Forms/NodeTreeType.php b/src/Forms/NodeTreeType.php
index b1cbc3d9..71bded78 100644
--- a/src/Forms/NodeTreeType.php
+++ b/src/Forms/NodeTreeType.php
@@ -32,17 +32,11 @@ class NodeTreeType extends AbstractType
protected ManagerRegistry $managerRegistry;
protected TreeWidgetFactory $treeWidgetFactory;
- /**
- * @param AuthorizationCheckerInterface $authorizationChecker
- * @param RequestStack $requestStack
- * @param ManagerRegistry $managerRegistry
- * @param TreeWidgetFactory $treeWidgetFactory
- */
public function __construct(
AuthorizationCheckerInterface $authorizationChecker,
RequestStack $requestStack,
ManagerRegistry $managerRegistry,
- TreeWidgetFactory $treeWidgetFactory
+ TreeWidgetFactory $treeWidgetFactory,
) {
$this->authorizationChecker = $authorizationChecker;
$this->requestStack = $requestStack;
@@ -50,19 +44,12 @@ public function __construct(
$this->managerRegistry = $managerRegistry;
}
- /**
- * {@inheritdoc}
- *
- * @param FormView $view
- * @param FormInterface $form
- * @param array $options
- */
public function finishView(FormView $view, FormInterface $form, array $options): void
{
parent::finishView($view, $form, $options);
- if ($options['nodeTypeField']->getType() !== AbstractField::CHILDREN_T) {
- throw new \RuntimeException("Given field is not a NodeTypeField::CHILDREN_T field.", 1);
+ if (AbstractField::CHILDREN_T !== $options['nodeTypeField']->getType()) {
+ throw new \RuntimeException('Given field is not a NodeTypeField::CHILDREN_T field.', 1);
}
$view->vars['authorizationChecker'] = $this->authorizationChecker;
@@ -97,7 +84,7 @@ public function finishView(FormView $view, FormInterface $form, array $options):
*/
if (is_array($nodeTypes) && count($nodeTypes) > 0) {
$nodeTree->setAdditionalCriteria([
- 'nodeType' => $nodeTypes
+ 'nodeType' => $nodeTypes,
]);
}
@@ -110,24 +97,17 @@ public function finishView(FormView $view, FormInterface $form, array $options):
Node::getStatusLabel(Node::DELETED) => Node::DELETED,
];
}
- /**
- * {@inheritdoc}
- */
+
public function getParent(): ?string
{
return HiddenType::class;
}
- /**
- * {@inheritdoc}
- */
+
public function getBlockPrefix(): string
{
return 'childrennodes';
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setRequired([
diff --git a/src/Forms/NodeType.php b/src/Forms/NodeType.php
index 9cf491af..0f394e2a 100644
--- a/src/Forms/NodeType.php
+++ b/src/Forms/NodeType.php
@@ -18,10 +18,10 @@ class NodeType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('nodeName', TextType::class, [
- 'label' => 'nodeName',
- 'empty_data' => '',
- 'help' => 'node.nodeName.help',
- ])
+ 'label' => 'nodeName',
+ 'empty_data' => '',
+ 'help' => 'node.nodeName.help',
+ ])
->add('dynamicNodeName', CheckboxType::class, [
'label' => 'node.dynamicNodeName',
'required' => false,
@@ -41,9 +41,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
}
$builder->add('childrenOrder', ChoiceType::class, [
- 'label' => 'node.childrenOrder',
- 'choices' => Node::$orderingFields,
- ])
+ 'label' => 'node.childrenOrder',
+ 'choices' => Node::$orderingFields,
+ ])
->add('childrenOrderDirection', ChoiceType::class, [
'label' => 'node.childrenOrderDirection',
'choices' => [
diff --git a/src/Forms/NodeTypeFieldSerializationType.php b/src/Forms/NodeTypeFieldSerializationType.php
index 38079b02..c151f0c3 100644
--- a/src/Forms/NodeTypeFieldSerializationType.php
+++ b/src/Forms/NodeTypeFieldSerializationType.php
@@ -17,9 +17,6 @@
final class NodeTypeFieldSerializationType extends AbstractType
{
- /**
- * {@inheritdoc}
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('excludedFromSerialization', CheckboxType::class, [
@@ -35,8 +32,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
],
'constraints' => [
new GreaterThan([
- 'value' => 0
- ])
+ 'value' => 0,
+ ]),
],
])
->add('serializationExclusionExpression', TextareaType::class, [
@@ -45,7 +42,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'help' => 'exclude_this_field_from_api_serialization_if_expression_result_is_true',
'attr' => [
'placeholder' => 'enter_symfony_expression_language_with_object_as_var_name',
- ]
+ ],
])
->add('serializationGroups', CollectionType::class, [
'label' => 'nodeTypeField.serializationGroups',
@@ -53,12 +50,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'allow_add' => true,
'allow_delete' => true,
'attr' => [
- 'class' => 'rz-collection-form-type'
+ 'class' => 'rz-collection-form-type',
],
'entry_options' => [
'label' => false,
],
- 'entry_type' => TextType::class
+ 'entry_type' => TextType::class,
]);
}
@@ -70,17 +67,11 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return '';
}
- /**
- * {@inheritdoc}
- */
public function getParent(): ?string
{
return FormType::class;
diff --git a/src/Forms/NodeTypeFieldType.php b/src/Forms/NodeTypeFieldType.php
index 2d779998..d8192854 100644
--- a/src/Forms/NodeTypeFieldType.php
+++ b/src/Forms/NodeTypeFieldType.php
@@ -113,7 +113,7 @@ public function configureOptions(OptionsResolver $resolver): void
'data_class' => NodeTypeField::class,
'attr' => [
'class' => 'uk-form node-type-field-form',
- ]
+ ],
]);
}
}
diff --git a/src/Forms/RedirectionType.php b/src/Forms/RedirectionType.php
index 1839e8ce..278b6f41 100644
--- a/src/Forms/RedirectionType.php
+++ b/src/Forms/RedirectionType.php
@@ -20,11 +20,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder->add('query', TextType::class, [
'label' => (!$options['only_query']) ? 'redirection.query' : false,
'attr' => [
- 'placeholder' => $options['placeholder']
+ 'placeholder' => $options['placeholder'],
],
'empty_data' => '',
]);
- if ($options['only_query'] === false) {
+ if (false === $options['only_query']) {
$builder->add('redirectUri', TextareaType::class, [
'label' => 'redirection.redirect_uri',
'required' => false,
@@ -34,7 +34,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'choices' => [
'redirection.moved_permanently' => Response::HTTP_MOVED_PERMANENTLY,
'redirection.moved_temporarily' => Response::HTTP_FOUND,
- ]
+ ],
]);
}
}
@@ -52,7 +52,7 @@ public function configureOptions(OptionsResolver $resolver): void
'placeholder' => null,
'attr' => [
'class' => 'uk-form redirection-form',
- ]
+ ],
]);
}
}
diff --git a/src/Forms/RoleType.php b/src/Forms/RoleType.php
index 5fcebdca..a485ed8c 100644
--- a/src/Forms/RoleType.php
+++ b/src/Forms/RoleType.php
@@ -12,9 +12,6 @@
class RoleType extends AbstractType
{
- /**
- * {@inheritdoc}
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
@@ -23,17 +20,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
]);
}
- /**
- * {@inheritdoc}
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('data_class', Role::class);
}
- /**
- * {@inheritdoc}
- */
public function getBlockPrefix(): string
{
return 'role';
diff --git a/src/Forms/SettingGroupType.php b/src/Forms/SettingGroupType.php
index 9badaa0c..4fde99b8 100644
--- a/src/Forms/SettingGroupType.php
+++ b/src/Forms/SettingGroupType.php
@@ -13,9 +13,6 @@
class SettingGroupType extends AbstractType
{
- /**
- * @inheritDoc
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add(
@@ -36,9 +33,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
);
}
- /**
- * @inheritDoc
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('data_class', SettingGroup::class);
diff --git a/src/Forms/TagTranslationType.php b/src/Forms/TagTranslationType.php
index da47e861..8030002c 100644
--- a/src/Forms/TagTranslationType.php
+++ b/src/Forms/TagTranslationType.php
@@ -20,17 +20,17 @@ class TagTranslationType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
- 'label' => 'name',
- 'empty_data' => '',
- 'constraints' => [
- new NotNull(),
- new NotBlank(),
- // Allow users to rename Tag the same, but tag slug must be different!
- new Length([
- 'max' => 255,
- ])
- ],
- ])
+ 'label' => 'name',
+ 'empty_data' => '',
+ 'constraints' => [
+ new NotNull(),
+ new NotBlank(),
+ // Allow users to rename Tag the same, but tag slug must be different!
+ new Length([
+ 'max' => 255,
+ ]),
+ ],
+ ])
->add('description', MarkdownType::class, [
'label' => 'description',
'required' => false,
diff --git a/src/Forms/TagType.php b/src/Forms/TagType.php
index 914520cb..df3a9085 100644
--- a/src/Forms/TagType.php
+++ b/src/Forms/TagType.php
@@ -48,8 +48,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
->add('childrenOrderDirection', ChoiceType::class, [
'label' => 'tag.childrenOrderDirection',
'choices' => [
- 'ascendant' => 'ASC',
- 'descendant' => 'DESC',
+ 'ascendant' => 'ASC',
+ 'descendant' => 'DESC',
],
]);
}
diff --git a/src/Forms/TranslationType.php b/src/Forms/TranslationType.php
index b19592dd..f8333b36 100644
--- a/src/Forms/TranslationType.php
+++ b/src/Forms/TranslationType.php
@@ -31,7 +31,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
])
->add('overrideLocale', TextType::class, [
'label' => 'overrideLocale',
- 'required' => false
+ 'required' => false,
]);
}
diff --git a/src/Forms/TranstypeType.php b/src/Forms/TranstypeType.php
index bb32d3b5..0c502d76 100644
--- a/src/Forms/TranstypeType.php
+++ b/src/Forms/TranstypeType.php
@@ -18,18 +18,11 @@ class TranstypeType extends AbstractType
{
protected ManagerRegistry $managerRegistry;
- /**
- * @param ManagerRegistry $managerRegistry
- */
public function __construct(ManagerRegistry $managerRegistry)
{
$this->managerRegistry = $managerRegistry;
}
- /**
- * @param FormBuilderInterface $builder
- * @param array $options
- */
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add(
@@ -46,17 +39,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
);
}
- /**
- * @return string
- */
public function getBlockPrefix(): string
{
return 'transtype';
}
- /**
- * @param OptionsResolver $resolver
- */
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
@@ -74,10 +61,6 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('currentType', NodeType::class);
}
- /**
- * @param NodeType $currentType
- * @return array
- */
protected function getAvailableTypes(NodeType $currentType): array
{
$qb = $this->managerRegistry->getManager()->createQueryBuilder();
diff --git a/src/Forms/UserDetailsType.php b/src/Forms/UserDetailsType.php
index b2add740..81c6c733 100644
--- a/src/Forms/UserDetailsType.php
+++ b/src/Forms/UserDetailsType.php
@@ -25,15 +25,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
])
->add('firstName', TextType::class, [
'label' => 'firstName',
- 'required' => false
+ 'required' => false,
])
->add('lastName', TextType::class, [
'label' => 'lastName',
- 'required' => false
+ 'required' => false,
])
->add('phone', TextType::class, [
'label' => 'phone',
- 'required' => false
+ 'required' => false,
])
->add('facebookName', TextType::class, [
'label' => 'facebookName',
@@ -41,18 +41,18 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
])
->add('company', TextType::class, [
'label' => 'company',
- 'required' => false
+ 'required' => false,
])
->add('job', TextType::class, [
'label' => 'job',
- 'required' => false
+ 'required' => false,
])
->add('birthday', DateType::class, [
'label' => 'birthday',
'placeholder' => [
'year' => 'year',
'month' => 'month',
- 'day' => 'day'
+ 'day' => 'day',
],
'required' => false,
'years' => range(1920, ((int) date('Y')) - 6),
@@ -64,13 +64,13 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
])
->add('pictureUrl', TextType::class, [
'label' => 'pictureUrl',
- 'required' => false
+ 'required' => false,
])
->add('locale', ChoiceType::class, [
'label' => 'user.backoffice.language',
'required' => false,
'choices' => RozierApp::$backendLanguages,
- 'placeholder' => 'use.website.default_language'
+ 'placeholder' => 'use.website.default_language',
])
;
}
diff --git a/src/Forms/UserSecurityType.php b/src/Forms/UserSecurityType.php
index df26f076..c92e181b 100644
--- a/src/Forms/UserSecurityType.php
+++ b/src/Forms/UserSecurityType.php
@@ -19,9 +19,9 @@ class UserSecurityType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('enabled', CheckboxType::class, [
- 'label' => 'user.enabled',
- 'required' => false,
- ])
+ 'label' => 'user.enabled',
+ 'required' => false,
+ ])
->add('locked', CheckboxType::class, [
'label' => 'user.locked',
'required' => false,
@@ -55,7 +55,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
],
]);
- if ($options['canChroot'] === true) {
+ if (true === $options['canChroot']) {
$builder->add('chroot', NodesType::class, [
'label' => 'chroot',
'required' => false,
@@ -65,12 +65,14 @@ function (mixed $mixedEntities) {
if ($mixedEntities instanceof Node) {
return [$mixedEntities];
}
+
return [];
},
function (mixed $mixedIds) {
- if (\is_array($mixedIds) && count($mixedIds) === 1) {
+ if (\is_array($mixedIds) && 1 === count($mixedIds)) {
return $mixedIds[0];
}
+
return null;
}
));
diff --git a/src/Forms/UserType.php b/src/Forms/UserType.php
index 0f4f8c9b..1920b596 100644
--- a/src/Forms/UserType.php
+++ b/src/Forms/UserType.php
@@ -17,9 +17,9 @@ class UserType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('email', EmailType::class, [
- 'label' => 'email',
- 'empty_data' => '',
- ])
+ 'label' => 'email',
+ 'empty_data' => '',
+ ])
->add('username', TextType::class, [
'label' => 'username',
'empty_data' => '',
@@ -45,7 +45,7 @@ public function configureOptions(OptionsResolver $resolver): void
'data_class' => User::class,
'attr' => [
'class' => 'uk-form user-form',
- ]
+ ],
]);
}
}
diff --git a/src/Models/ModelInterface.php b/src/Models/ModelInterface.php
index c058a827..ea573e0f 100644
--- a/src/Models/ModelInterface.php
+++ b/src/Models/ModelInterface.php
@@ -5,14 +5,12 @@
namespace Themes\Rozier\Models;
/**
- * @deprecated Use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemInterface instead.
+ * @deprecated use RZ\Roadiz\CoreBundle\Explorer\ExplorerItemInterface instead
*/
interface ModelInterface
{
/**
* Return a structured array of data.
- *
- * @return array
*/
public function toArray(): array;
}
diff --git a/src/RozierApp.php b/src/RozierApp.php
index 5eef7c8d..ea7376fc 100644
--- a/src/RozierApp.php
+++ b/src/RozierApp.php
@@ -25,7 +25,7 @@
use Twig\Error\RuntimeError;
/**
- * Rozier main theme application
+ * Rozier main theme application.
*/
class RozierApp extends AppController
{
@@ -68,9 +68,6 @@ public static function getSubscribedServices(): array
]);
}
- /**
- * @inheritDoc
- */
public function createEntityListManager(string $entity, array $criteria = [], array $ordering = []): EntityListManagerInterface
{
return parent::createEntityListManager($entity, $criteria, $ordering)
@@ -79,19 +76,15 @@ public function createEntityListManager(string $entity, array $criteria = [], ar
/**
* Returns a fully qualified view path for Twig rendering.
- *
- * @param string $view
- * @param string $namespace
- * @return string
*/
protected function getNamespacedView(string $view, string $namespace = ''): string
{
- if ($namespace !== "" && $namespace !== "/") {
- $view = '@' . $namespace . '/' . $view;
- } elseif ($namespace !== "/") {
+ if ('' !== $namespace && '/' !== $namespace) {
+ $view = '@'.$namespace.'/'.$view;
+ } elseif ('/' !== $namespace) {
// when no namespace is used
// use current theme directory
- $view = '@RoadizRozier/' . $view;
+ $view = '@RoadizRozier/'.$view;
}
return $view;
@@ -111,9 +104,9 @@ public function prepareBaseAssignation(): static
* Switch this to true to use uncompressed JS and CSS files
*/
$this->assignation['head']['backDevMode'] = false;
- $this->assignation['head']['siteTitle'] = $this->getSettingsBag()->get('site_name') . ' backstage';
+ $this->assignation['head']['siteTitle'] = $this->getSettingsBag()->get('site_name').' backstage';
$this->assignation['head']['mapsLocation'] = $this->getSettingsBag()->get('maps_default_location') ? $this->getSettingsBag()->get('maps_default_location') : null;
- $this->assignation['head']['googleClientId'] = $this->getSettingsBag()->get('google_client_id', "");
+ $this->assignation['head']['googleClientId'] = $this->getSettingsBag()->get('google_client_id', '');
$this->assignation['head']['themeName'] = static::$themeName;
$this->assignation['head']['ajaxToken'] = $tokenManager->getToken(static::AJAX_TOKEN_INTENTION);
/** @var UserActionsMenuEvent $userActionsMenuEvent */
@@ -132,8 +125,8 @@ public function prepareBaseAssignation(): static
}
/**
- * @param Request $request
* @return Response $response
+ *
* @throws RuntimeError
*/
public function indexAction(Request $request): Response
diff --git a/src/RozierServiceRegistry.php b/src/RozierServiceRegistry.php
index 3adc5264..0a5eb340 100644
--- a/src/RozierServiceRegistry.php
+++ b/src/RozierServiceRegistry.php
@@ -27,7 +27,7 @@ public function __construct(
private readonly ManagerRegistry $managerRegistry,
private readonly TreeWidgetFactory $treeWidgetFactory,
private readonly NodeChrootResolver $chrootResolver,
- private readonly array $backofficeMenuEntries
+ private readonly array $backofficeMenuEntries,
) {
}
@@ -50,6 +50,7 @@ public function getSettingGroups(): array
['name' => 'ASC']
);
}
+
return $this->settingGroups;
}
@@ -58,6 +59,7 @@ public function getTagTree(): TagTreeWidget
if (null === $this->tagTree) {
$this->tagTree = $this->treeWidgetFactory->createTagTree();
}
+
return $this->tagTree;
}
@@ -66,6 +68,7 @@ public function getFolderTree(): FolderTreeWidget
if (null === $this->folderTree) {
$this->folderTree = $this->treeWidgetFactory->createFolderTree();
}
+
return $this->folderTree;
}
@@ -76,6 +79,7 @@ public function getNodeTree(mixed $user): NodeTreeWidget
$this->chrootResolver->getChroot($user)
);
}
+
return $this->nodeTree;
}
diff --git a/src/Serialization/DocumentThumbnailSerializeSubscriber.php b/src/Serialization/DocumentThumbnailSerializeSubscriber.php
index a8e81000..bdf237f0 100644
--- a/src/Serialization/DocumentThumbnailSerializeSubscriber.php
+++ b/src/Serialization/DocumentThumbnailSerializeSubscriber.php
@@ -32,12 +32,12 @@ public function onPostSerialize(ObjectEvent $event): void
$context = $event->getContext();
if (
- $visitor instanceof SerializationVisitorInterface &&
- $document instanceof Document &&
- !$document->isPrivate() &&
- $context->hasAttribute('groups') &&
- \is_array($context->getAttribute('groups')) &&
- in_array('explorer_thumbnail', $context->getAttribute('groups'))
+ $visitor instanceof SerializationVisitorInterface
+ && $document instanceof Document
+ && !$document->isPrivate()
+ && $context->hasAttribute('groups')
+ && \is_array($context->getAttribute('groups'))
+ && in_array('explorer_thumbnail', $context->getAttribute('groups'))
) {
$visitor->visitProperty(
new StaticPropertyMetadata('boolean', 'processable', []),
diff --git a/src/Traits/NodesTrait.php b/src/Traits/NodesTrait.php
index 672baad0..45aff99d 100644
--- a/src/Traits/NodesTrait.php
+++ b/src/Traits/NodesTrait.php
@@ -19,19 +19,11 @@ trait NodesTrait
{
abstract protected function getNodeFactory(): NodeFactory;
- /**
- * @param string $title
- * @param TranslationInterface $translation
- * @param Node|null $node
- * @param NodeTypeInterface|null $type
- *
- * @return Node
- */
protected function createNode(
string $title,
TranslationInterface $translation,
- Node $node = null,
- NodeTypeInterface $type = null
+ ?Node $node = null,
+ ?NodeTypeInterface $type = null,
): Node {
$factory = $this->getNodeFactory();
$node = $factory->create($title, $type, $translation, $node);
@@ -44,15 +36,12 @@ protected function createNode(
/**
* @param array $data
- * @param Node $node
- *
- * @return NodeType|null
*/
public function addStackType($data, Node $node): ?NodeType
{
if (
- $data['nodeId'] == $node->getId() &&
- !empty($data['nodeTypeId'])
+ $data['nodeId'] == $node->getId()
+ && !empty($data['nodeTypeId'])
) {
$nodeType = $this->em()->find(NodeType::class, (int) $data['nodeTypeId']);
@@ -67,11 +56,6 @@ public function addStackType($data, Node $node): ?NodeType
return null;
}
- /**
- * @param Node $node
- *
- * @return FormInterface|null
- */
public function buildStackTypesForm(Node $node): ?FormInterface
{
if ($node->isHidingChildren()) {
@@ -95,14 +79,9 @@ public function buildStackTypesForm(Node $node): ?FormInterface
}
}
- /**
- * @param Node $node
- *
- * @return FormInterface
- */
protected function buildDeleteForm(Node $node): FormInterface
{
- $builder = $this->createNamedFormBuilder('delete_node_' . $node->getId())
+ $builder = $this->createNamedFormBuilder('delete_node_'.$node->getId())
->add('nodeId', HiddenType::class, [
'data' => $node->getId(),
'constraints' => [
@@ -114,12 +93,10 @@ protected function buildDeleteForm(Node $node): FormInterface
return $builder->getForm();
}
- /**
- * @return FormInterface
- */
protected function buildEmptyTrashForm(): FormInterface
{
$builder = $this->createFormBuilder();
+
return $builder->getForm();
}
}
diff --git a/src/Traits/VersionedControllerTrait.php b/src/Traits/VersionedControllerTrait.php
index 7319702c..b7dab54d 100644
--- a/src/Traits/VersionedControllerTrait.php
+++ b/src/Traits/VersionedControllerTrait.php
@@ -17,16 +17,12 @@ trait VersionedControllerTrait
{
protected bool $isReadOnly = false;
- /**
- * @return bool
- */
public function isReadOnly(): bool
{
return $this->isReadOnly;
}
/**
- * @param bool $isReadOnly
* @return self
*/
public function setIsReadOnly(bool $isReadOnly)
@@ -44,8 +40,8 @@ protected function handleVersions(Request $request, PersistableInterface $entity
$versionNumber = $request->get('version', null);
if (
- \is_numeric($versionNumber) &&
- intval($versionNumber) > 0
+ \is_numeric($versionNumber)
+ && intval($versionNumber) > 0
) {
try {
$versionNumber = intval($versionNumber);
diff --git a/src/Widgets/AbstractWidget.php b/src/Widgets/AbstractWidget.php
index f9e48096..915f6eea 100644
--- a/src/Widgets/AbstractWidget.php
+++ b/src/Widgets/AbstractWidget.php
@@ -21,25 +21,20 @@ abstract class AbstractWidget
public function __construct(
protected RequestStack $requestStack,
- protected ManagerRegistry $managerRegistry
+ protected ManagerRegistry $managerRegistry,
) {
}
- /**
- * @return Request
- */
protected function getRequest(): Request
{
$request = $this->requestStack->getCurrentRequest() ?? $this->requestStack->getMainRequest();
if (null === $request) {
throw new \RuntimeException('Request cannot be found.');
}
+
return $request;
}
- /**
- * @return ManagerRegistry
- */
protected function getManagerRegistry(): ManagerRegistry
{
return $this->managerRegistry;
diff --git a/src/Widgets/FolderTreeWidget.php b/src/Widgets/FolderTreeWidget.php
index 08bad9d7..5efe6bfd 100644
--- a/src/Widgets/FolderTreeWidget.php
+++ b/src/Widgets/FolderTreeWidget.php
@@ -25,19 +25,13 @@ public function __construct(
parent::__construct($requestStack, $managerRegistry);
}
- /**
- * @param Folder $parent
- * @return array
- */
public function getChildrenFolders(Folder $parent): array
{
return $this->folders = $this->getManagerRegistry()
->getRepository(Folder::class)
->findByParentAndTranslation($parent, $this->getTranslation());
}
- /**
- * @return Folder|null
- */
+
public function getRootFolder(): ?Folder
{
return $this->parentFolder;
@@ -53,12 +47,10 @@ public function getFolders(): iterable
->getRepository(Folder::class)
->findByParentAndTranslation($this->getRootFolder(), $this->getTranslation());
}
+
return $this->folders;
}
- /**
- * @return TranslationInterface
- */
public function getTranslation(): TranslationInterface
{
return $this->translation ?? parent::getTranslation();
diff --git a/src/Widgets/NodeTreeWidget.php b/src/Widgets/NodeTreeWidget.php
index f863cd51..31c070ef 100644
--- a/src/Widgets/NodeTreeWidget.php
+++ b/src/Widgets/NodeTreeWidget.php
@@ -33,33 +33,25 @@ final class NodeTreeWidget extends AbstractWidget
private array $additionalCriteria = [];
/**
- * @param RequestStack $requestStack
- * @param ManagerRegistry $managerRegistry
- * @param Node|null $parentNode Entry point of NodeTreeWidget, set null if it's root
+ * @param Node|null $parentNode Entry point of NodeTreeWidget, set null if it's root
* @param TranslationInterface|null $translation NodeTree translation
- * @param bool $includeRootNode
*/
public function __construct(
RequestStack $requestStack,
ManagerRegistry $managerRegistry,
private readonly ?Node $parentNode = null,
private readonly ?TranslationInterface $translation = null,
- private readonly bool $includeRootNode = false
+ private readonly bool $includeRootNode = false,
) {
parent::__construct($requestStack, $managerRegistry);
}
- /**
- * @return Tag|null
- */
public function getTag(): ?Tag
{
return $this->tag;
}
/**
- * @param Tag|null $tag
- *
* @return $this
*/
public function setTag(?Tag $tag): NodeTreeWidget
@@ -69,17 +61,12 @@ public function setTag(?Tag $tag): NodeTreeWidget
return $this;
}
- /**
- * @return bool
- */
public function isStackTree(): bool
{
return $this->stackTree;
}
/**
- * @param bool $stackTree
- *
* @return $this
*/
public function setStackTree(bool $stackTree): NodeTreeWidget
@@ -91,6 +78,7 @@ public function setStackTree(bool $stackTree): NodeTreeWidget
/**
* Fill twig assignation array with NodeTree entities.
+ *
* @throws \ReflectionException
*/
protected function getRootListManager(): NodeTreeDtoListManager
@@ -101,31 +89,18 @@ protected function getRootListManager(): NodeTreeDtoListManager
return $this->getListManager($this->parentNode, false, $this->additionalCriteria);
}
- /**
- * @return array
- */
public function getAdditionalCriteria(): array
{
return $this->additionalCriteria;
}
- /**
- * @param array $additionalCriteria
- *
- * @return NodeTreeWidget
- */
public function setAdditionalCriteria(array $additionalCriteria): NodeTreeWidget
{
$this->additionalCriteria = $additionalCriteria;
+
return $this;
}
- /**
- * @param NodeInterface|null $parent
- * @param bool $subRequest
- *
- * @return bool
- */
protected function canOrderByParent(?NodeInterface $parent = null, bool $subRequest = false): bool
{
if (true === $subRequest || null === $parent) {
@@ -133,9 +108,9 @@ protected function canOrderByParent(?NodeInterface $parent = null, bool $subRequ
}
if (
- $parent->getChildrenOrder() !== 'position' &&
- in_array($parent->getChildrenOrder(), Node::$orderingFields) &&
- in_array($parent->getChildrenOrderDirection(), ['ASC', 'DESC'])
+ 'position' !== $parent->getChildrenOrder()
+ && in_array($parent->getChildrenOrder(), Node::$orderingFields)
+ && in_array($parent->getChildrenOrderDirection(), ['ASC', 'DESC'])
) {
return true;
}
@@ -144,16 +119,15 @@ protected function canOrderByParent(?NodeInterface $parent = null, bool $subRequ
}
/**
- * @param NodeInterface|null $parent
- * @param bool $subRequest Default: false
+ * @param bool $subRequest Default: false
* @param array $additionalCriteria Default: []
- * @return NodeTreeDtoListManager
+ *
* @throws \ReflectionException
*/
protected function getListManager(
?NodeInterface $parent = null,
bool $subRequest = false,
- array $additionalCriteria = []
+ array $additionalCriteria = [],
): NodeTreeDtoListManager {
$criteria = array_merge($additionalCriteria, [
'parent' => $parent?->getId() ?? null,
@@ -206,20 +180,22 @@ protected function getListManager(
}
/**
- * @param NodeInterface|null $parent
* @param bool $subRequest Default: false
+ *
* @return array
+ *
* @throws \ReflectionException
*/
- public function getChildrenNodes(NodeInterface|null $parent = null, bool $subRequest = false): array
+ public function getChildrenNodes(?NodeInterface $parent = null, bool $subRequest = false): array
{
return $this->getListManager($parent, $subRequest)->getEntities();
}
/**
- * @param NodeInterface|null $parent
* @param bool $subRequest Default: false
+ *
* @return array
+ *
* @throws \ReflectionException
*/
public function getReachableChildrenNodes(?NodeInterface $parent = null, bool $subRequest = false): array
@@ -229,9 +205,6 @@ public function getReachableChildrenNodes(?NodeInterface $parent = null, bool $s
])->getEntities();
}
- /**
- * @return Node|null
- */
public function getRootNode(): ?Node
{
return $this->parentNode;
@@ -241,17 +214,12 @@ public function getRootNode(): ?Node
* Get entity list manager filters.
*
* Call getNodes() first to populate this.
- *
- * @return array|null
*/
public function getFilters(): ?array
{
return $this->filters;
}
- /**
- * @return TranslationInterface
- */
public function getTranslation(): TranslationInterface
{
return $this->translation ?? parent::getTranslation();
@@ -272,6 +240,7 @@ public function getAvailableTranslations(): array
/**
* @return array
+ *
* @throws \ReflectionException
*/
public function getNodes(): array
@@ -296,8 +265,9 @@ public function getTags(?NodeInterface $node): array
if (null === $node) {
return [];
}
+
return $this->managerRegistry->getRepository(Tag::class)->findByAsTagTreeDto([
- "nodes" => $node->getId(),
+ 'nodes' => $node->getId(),
], [
'position' => 'ASC',
], null, null, $this->getTranslation());
@@ -315,8 +285,6 @@ public function getOneDisplayableDocument(NodeTreeDto $node): ?Document
/**
* Gets the value of canReorder.
- *
- * @return bool
*/
public function getCanReorder(): bool
{
diff --git a/src/Widgets/TagTreeWidget.php b/src/Widgets/TagTreeWidget.php
index 0821b38c..7a5e8a42 100644
--- a/src/Widgets/TagTreeWidget.php
+++ b/src/Widgets/TagTreeWidget.php
@@ -23,7 +23,7 @@ public function __construct(
ManagerRegistry $managerRegistry,
private readonly ?Tag $parentTag = null,
private readonly ?TranslationInterface $translation = null,
- private readonly bool $forceTranslation = false
+ private readonly bool $forceTranslation = false,
) {
parent::__construct($requestStack, $managerRegistry);
}
@@ -37,9 +37,9 @@ protected function getTagTreeAssignationForParent(): void
'position' => 'ASC',
];
if (
- null !== $this->parentTag &&
- $this->parentTag->getChildrenOrder() !== 'order' &&
- $this->parentTag->getChildrenOrder() !== 'position'
+ null !== $this->parentTag
+ && 'order' !== $this->parentTag->getChildrenOrder()
+ && 'position' !== $this->parentTag->getChildrenOrder()
) {
$ordering = [
$this->parentTag->getChildrenOrder() => $this->parentTag->getChildrenOrderDirection(),
@@ -56,19 +56,17 @@ protected function getTagTreeAssignationForParent(): void
}
/**
- * @param Tag|null $parent
- *
* @return iterable|null
*/
public function getChildrenTags(?Tag $parent): ?iterable
{
- if ($parent !== null) {
+ if (null !== $parent) {
$ordering = [
'position' => 'ASC',
];
if (
- $parent->getChildrenOrder() !== 'order' &&
- $parent->getChildrenOrder() !== 'position'
+ 'order' !== $parent->getChildrenOrder()
+ && 'position' !== $parent->getChildrenOrder()
) {
$ordering = [
$parent->getChildrenOrder() => $parent->getChildrenOrderDirection(),
@@ -89,9 +87,7 @@ public function getChildrenTags(?Tag $parent): ?iterable
return null;
}
- /**
- * @return Tag|null
- */
+
public function getRootTag(): ?Tag
{
return $this->parentTag;
@@ -102,15 +98,13 @@ public function getRootTag(): ?Tag
*/
public function getTags(): iterable
{
- if ($this->tags === null) {
+ if (null === $this->tags) {
$this->getTagTreeAssignationForParent();
}
+
return $this->tags;
}
- /**
- * @return TagRepository
- */
protected function getTagRepository(): TagRepository
{
return $this->getManagerRegistry()->getRepository(Tag::class);
@@ -118,17 +112,12 @@ protected function getTagRepository(): TagRepository
/**
* Gets the value of canReorder.
- *
- * @return bool
*/
public function getCanReorder(): bool
{
return $this->canReorder;
}
- /**
- * @return TranslationInterface
- */
public function getTranslation(): TranslationInterface
{
return $this->translation ?? parent::getTranslation();
diff --git a/src/Widgets/TreeWidgetFactory.php b/src/Widgets/TreeWidgetFactory.php
index 818f6cce..c2a1bc84 100644
--- a/src/Widgets/TreeWidgetFactory.php
+++ b/src/Widgets/TreeWidgetFactory.php
@@ -15,7 +15,7 @@ final class TreeWidgetFactory
{
public function __construct(
private readonly RequestStack $requestStack,
- private readonly ManagerRegistry $managerRegistry
+ private readonly ManagerRegistry $managerRegistry,
) {
}