diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8d260672a6..2c6f1bb1af 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,77 +1,11 @@ parameters: ignoreErrors: - - - message: '#^Call to an undefined method Symfony\\Component\\Console\\Helper\\HelperInterface\:\:progress\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Command/CompileAssetsCommand.php - - - - message: '#^Call to an undefined method Symfony\\Component\\Console\\Helper\\HelperInterface\:\:start\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Command/CompileAssetsCommand.php - - - - message: '#^Call to an undefined method Symfony\\Component\\Console\\Helper\\HelperInterface\:\:stop\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Command/CompileAssetsCommand.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Command\\CompileAssetsCommand\:\:execute\(\) should return int but returns int\|null\.$#' - identifier: return.type - count: 1 - path: src/bundle/Command/CompileAssetsCommand.php - - - - message: '#^Cannot call method getClientOriginalName\(\) on Symfony\\Component\\HttpFoundation\\File\\UploadedFile\|null\.$#' - identifier: method.nonObject - count: 3 - path: src/bundle/Controller/AssetController.php - - - - message: '#^Cannot call method getRealPath\(\) on Symfony\\Component\\HttpFoundation\\File\\UploadedFile\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/bundle/Controller/AssetController.php - - - - message: '#^Cannot call method getSize\(\) on Symfony\\Component\\HttpFoundation\\File\\UploadedFile\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/bundle/Controller/AssetController.php - - message: '#^Parameter \#2 \$languageCode of class Ibexa\\AdminUi\\Form\\Data\\Asset\\ImageAssetUploadData constructor expects string\|null, bool\|float\|int\|string\|null given\.$#' identifier: argument.type count: 1 path: src/bundle/Controller/AssetController.php - - - message: '#^Parameter \#3 \$languageCode of method Ibexa\\Core\\FieldType\\ImageAsset\\AssetMapper\:\:createAsset\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/AssetController.php - - - - message: '#^Parameter \#3 \$content of class Ibexa\\AdminUi\\REST\\Value\\OperationResponse constructor expects string\|null, string\|false given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/BulkOperation/BulkOperationController.php - - - - message: '#^Parameter \#1 \$array of function array_shift expects array, iterable\ given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/Content/VersionDraftConflictController.php - - - - message: '#^Parameter \#1 \$locationId of method Ibexa\\Contracts\\Core\\Repository\\LocationService\:\:loadLocation\(\) expects int, int\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/Content/VersionDraftConflictController.php - - message: '#^Anonymous function should return Symfony\\Component\\HttpFoundation\\Response but returns Symfony\\Component\\HttpFoundation\\Response\|null\.$#' identifier: return.type @@ -85,51 +19,45 @@ parameters: path: src/bundle/Controller/ContentController.php - - message: '#^Cannot access property \$contentInfo on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Content\|null\.$#' - identifier: property.nonObject - count: 1 - path: src/bundle/Controller/ContentController.php - - - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' + message: '#^Cannot access property \$isHidden on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' identifier: property.nonObject count: 4 path: src/bundle/Controller/ContentController.php - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + message: '#^Cannot access property \$name on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' identifier: property.nonObject - count: 2 + count: 1 path: src/bundle/Controller/ContentController.php - - message: '#^Cannot access property \$identifier on Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\|null\.$#' - identifier: property.nonObject - count: 2 + message: '#^Cannot call method getContentInfo\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Content\|null\.$#' + identifier: method.nonObject + count: 1 path: src/bundle/Controller/ContentController.php - - message: '#^Cannot access property \$isHidden on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' + identifier: method.nonObject count: 4 path: src/bundle/Controller/ContentController.php - - message: '#^Cannot access property \$languageCode on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' - identifier: property.nonObject - count: 5 + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + identifier: method.nonObject + count: 2 path: src/bundle/Controller/ContentController.php - - message: '#^Cannot access property \$mainLocationId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject - count: 2 + message: '#^Cannot call method getLanguageCode\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' + identifier: method.nonObject + count: 5 path: src/bundle/Controller/ContentController.php - - message: '#^Cannot access property \$name on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject - count: 1 + message: '#^Cannot call method getMainLocationId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' + identifier: method.nonObject + count: 2 path: src/bundle/Controller/ContentController.php - @@ -174,12 +102,6 @@ parameters: count: 1 path: src/bundle/Controller/ContentController.php - - - message: '#^Parameter \#1 \$contentType of method Ibexa\\AdminUi\\Specification\\ContentType\\ContentTypeIsUser\:\:isSatisfiedBy\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType, Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/ContentController.php - - message: '#^Parameter \#1 \$location of method Ibexa\\AdminUi\\Siteaccess\\SiteaccessResolverInterface\:\:getSiteAccessesListForLocation\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|false given\.$#' identifier: argument.type @@ -241,7 +163,7 @@ parameters: path: src/bundle/Controller/ContentTypeController.php - - message: '#^Call to an undefined method Symfony\\Component\\Form\\FormInterface\:\:getClickedButton\(\)\.$#' + message: '#^Call to an undefined method Symfony\\Component\\Form\\FormInterface\\:\:getClickedButton\(\)\.$#' identifier: method.notFound count: 2 path: src/bundle/Controller/ContentTypeController.php @@ -261,7 +183,7 @@ parameters: - message: '#^Cannot access property \$languageCode on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' identifier: property.nonObject - count: 4 + count: 1 path: src/bundle/Controller/ContentTypeController.php - @@ -276,6 +198,12 @@ parameters: count: 1 path: src/bundle/Controller/ContentTypeController.php + - + message: '#^Cannot call method getLanguageCode\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' + identifier: method.nonObject + count: 3 + path: src/bundle/Controller/ContentTypeController.php + - message: '#^Cannot call method getName\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\ContentType\|null\.$#' identifier: method.nonObject @@ -289,14 +217,8 @@ parameters: path: src/bundle/Controller/ContentTypeController.php - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentTypeController\:\:createDeleteForm\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 - path: src/bundle/Controller/ContentTypeController.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentTypeController\:\:createUpdateForm\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' - identifier: missingType.generics + message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentTypeController\:\:addAction\(\) never returns Symfony\\Component\\HttpFoundation\\RedirectResponse so it can be removed from the return type\.$#' + identifier: return.unusedType count: 1 path: src/bundle/Controller/ContentTypeController.php @@ -354,12 +276,6 @@ parameters: count: 2 path: src/bundle/Controller/ContentTypeGroupController.php - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentTypeGroupController\:\:getContentTypeGroupsNumbers\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/ContentTypeGroupController.php - - message: '#^PHPDoc tag @var with type Symfony\\Component\\Form\\Form is not subtype of native type Symfony\\Component\\Form\\FormInterface\.$#' identifier: varTag.nativeType @@ -402,84 +318,48 @@ parameters: count: 1 path: src/bundle/Controller/ContentTypeGroupController.php - - - message: '#^Call to an undefined method Ibexa\\Contracts\\Core\\Repository\\PermissionResolver\:\:sudo\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/bundle/Controller/ContentViewController.php - - message: '#^Cannot call method getContentInfo\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' identifier: method.nonObject - count: 3 - path: src/bundle/Controller/ContentViewController.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentViewController\:\:createContentEditForm\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' - identifier: missingType.generics - count: 1 + count: 2 path: src/bundle/Controller/ContentViewController.php - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentViewController\:\:getInvitationForm\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' - identifier: missingType.generics + message: '#^Cannot call method getLanguageCodes\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\VersionInfo\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/ContentViewController.php - - message: '#^Parameter \#1 \$array of function array_column expects array, iterable\ given\.$#' - identifier: argument.type + message: '#^Expression on left side of \?\? is not nullable\.$#' + identifier: nullCoalesce.expr count: 1 path: src/bundle/Controller/ContentViewController.php - - message: '#^Parameter \#1 \$array of function array_shift expects array, iterable\ given\.$#' - identifier: argument.type + message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentViewController\:\:createContentEditForm\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' + identifier: missingType.generics count: 1 path: src/bundle/Controller/ContentViewController.php - - message: '#^Parameter \#1 \$location of method Ibexa\\AdminUi\\UI\\Service\\PathService\:\:loadPathLocations\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null given\.$#' - identifier: argument.type + message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ContentViewController\:\:getInvitationForm\(\) return type with generic interface Symfony\\Component\\Form\\FormInterface does not specify its types\: TData$#' + identifier: missingType.generics count: 1 path: src/bundle/Controller/ContentViewController.php - - message: '#^Parameter \#1 \$value of function count expects array\|Countable, iterable\ given\.$#' + message: '#^Parameter \#1 \$array of function array_column expects array, iterable\ given\.$#' identifier: argument.type count: 1 path: src/bundle/Controller/ContentViewController.php - - - message: '#^Property Ibexa\\Bundle\\AdminUi\\Controller\\ContentViewController\:\:\$contentService is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/bundle/Controller/ContentViewController.php - - - - message: '#^PHPDoc tag @throws has invalid value \(\\Ibexa\\Contracts\\Core\\Repository\\Exceptions\\InvalidArgumentException;\)\: Unexpected token ";", expected TOKEN_HORIZONTAL_WS at offset 289 on line 6$#' - identifier: phpDoc.parseError - count: 1 - path: src/bundle/Controller/DownloadImageController.php - - - - message: '#^PHPDoc tag @throws has invalid value \(\\Ibexa\\Contracts\\Core\\Repository\\Exceptions\\InvalidCriterionArgumentException;\)\: Unexpected token ";", expected TOKEN_HORIZONTAL_WS at offset 383 on line 7$#' - identifier: phpDoc.parseError - count: 1 - path: src/bundle/Controller/DownloadImageController.php - - message: '#^Parameter \#2 \$fieldDefinition of method Ibexa\\Contracts\\Core\\Repository\\ContentTypeService\:\:updateFieldDefinition\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\FieldDefinition, Ibexa\\Contracts\\Core\\Repository\\Values\\ContentType\\FieldDefinition\|null given\.$#' identifier: argument.type count: 1 path: src/bundle/Controller/FieldDefinitionController.php - - - message: '#^Parameter \#2 \$fieldTypeIdentifier of method Ibexa\\Contracts\\Core\\Repository\\ContentTypeService\:\:newFieldDefinitionCreateStruct\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/FieldDefinitionController.php - - message: '#^Argument of an invalid type array\|null supplied for foreach, only iterables are supported\.$#' identifier: foreach.nonIterable @@ -487,14 +367,8 @@ parameters: path: src/bundle/Controller/LanguageController.php - - message: '#^Cannot access property \$name on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' - identifier: property.nonObject - count: 1 - path: src/bundle/Controller/LanguageController.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\LanguageController\:\:getLanguagesNumbers\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot call method getName\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/LanguageController.php @@ -511,35 +385,23 @@ parameters: path: src/bundle/Controller/LanguageController.php - - message: '#^Parameter \#2 \$handler of method Ibexa\\AdminUi\\Form\\SubmitHandler\:\:handle\(\) expects callable\(mixed\)\: \(Symfony\\Component\\HttpFoundation\\Response\|null\), Closure\(Ibexa\\AdminUi\\Form\\Data\\Language\\LanguageDeleteData\)\: void given\.$#' + message: '#^Parameter \#1 \$languages of class Ibexa\\AdminUi\\Form\\Data\\Language\\LanguagesDeleteData constructor expects array\, array\ given\.$#' identifier: argument.type count: 1 path: src/bundle/Controller/LanguageController.php - - message: '#^Parameter \#2 \$handler of method Ibexa\\AdminUi\\Form\\SubmitHandler\:\:handle\(\) expects callable\(mixed\)\: \(Symfony\\Component\\HttpFoundation\\Response\|null\), Closure\(Ibexa\\AdminUi\\Form\\Data\\Language\\LanguagesDeleteData\)\: void given\.$#' + message: '#^Parameter \#2 \$handler of method Ibexa\\AdminUi\\Form\\SubmitHandler\:\:handle\(\) expects callable\(mixed\)\: \(Symfony\\Component\\HttpFoundation\\Response\|null\), Closure\(Ibexa\\AdminUi\\Form\\Data\\Language\\LanguageDeleteData\)\: void given\.$#' identifier: argument.type count: 1 path: src/bundle/Controller/LanguageController.php - - message: '#^Parameter \#2 \$newName of method Ibexa\\Contracts\\Core\\Repository\\LanguageService\:\:updateLanguageName\(\) expects string, string\|null given\.$#' + message: '#^Parameter \#2 \$handler of method Ibexa\\AdminUi\\Form\\SubmitHandler\:\:handle\(\) expects callable\(mixed\)\: \(Symfony\\Component\\HttpFoundation\\Response\|null\), Closure\(Ibexa\\AdminUi\\Form\\Data\\Language\\LanguagesDeleteData\)\: void given\.$#' identifier: argument.type count: 1 path: src/bundle/Controller/LanguageController.php - - - message: '#^Access to protected property Ibexa\\Contracts\\Core\\Repository\\Values\\URL\\URL\:\:\$id\.$#' - identifier: property.protected - count: 2 - path: src/bundle/Controller/LinkManagerController.php - - - - message: '#^Access to protected property Ibexa\\Contracts\\Core\\Repository\\Values\\URL\\URL\:\:\$url\.$#' - identifier: property.protected - count: 1 - path: src/bundle/Controller/LinkManagerController.php - - message: '#^PHPDoc tag @var with type Symfony\\Component\\Form\\Form is not subtype of native type Symfony\\Component\\Form\\FormInterface\.$#' identifier: varTag.nativeType @@ -547,57 +409,51 @@ parameters: path: src/bundle/Controller/LinkManagerController.php - - message: '#^Cannot access property \$contentId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' - identifier: property.nonObject - count: 3 - path: src/bundle/Controller/LocationController.php - - - - message: '#^Cannot access property \$contentInfo on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + message: '#^Cannot access property \$parentLocationId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' identifier: property.nonObject count: 1 path: src/bundle/Controller/LocationController.php - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject - count: 2 + message: '#^Cannot call method getContent\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + identifier: method.nonObject + count: 3 path: src/bundle/Controller/LocationController.php - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getContentId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + identifier: method.nonObject count: 3 path: src/bundle/Controller/LocationController.php - - message: '#^Cannot access property \$mainLocationId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject - count: 2 + message: '#^Cannot call method getContentInfo\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + identifier: method.nonObject + count: 12 path: src/bundle/Controller/LocationController.php - - message: '#^Cannot access property \$name on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Section\|null\.$#' - identifier: property.nonObject - count: 1 + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' + identifier: method.nonObject + count: 2 path: src/bundle/Controller/LocationController.php - - message: '#^Cannot access property \$parentLocationId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' - identifier: property.nonObject - count: 1 + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + identifier: method.nonObject + count: 3 path: src/bundle/Controller/LocationController.php - - message: '#^Cannot call method getContent\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + message: '#^Cannot call method getMainLocationId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' identifier: method.nonObject - count: 3 + count: 2 path: src/bundle/Controller/LocationController.php - - message: '#^Cannot call method getContentInfo\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + message: '#^Cannot call method getName\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Section\|null\.$#' identifier: method.nonObject - count: 11 + count: 1 path: src/bundle/Controller/LocationController.php - @@ -666,18 +522,6 @@ parameters: count: 1 path: src/bundle/Controller/LocationController.php - - - message: '#^Property Ibexa\\Bundle\\AdminUi\\Controller\\LocationController\:\:\$contentTypeService is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/bundle/Controller/LocationController.php - - - - message: '#^Property Ibexa\\Bundle\\AdminUi\\Controller\\LocationController\:\:\$permissionResolver is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/bundle/Controller/LocationController.php - - message: '#^Parameter \#1 \$content of class Symfony\\Component\\HttpFoundation\\Response constructor expects string\|null, string\|false given\.$#' identifier: argument.type @@ -708,18 +552,6 @@ parameters: count: 1 path: src/bundle/Controller/ObjectStateController.php - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ObjectStateController\:\:getObjectStatesIds\(\) has parameter \$states with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/ObjectStateController.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ObjectStateController\:\:getObjectStatesIds\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/ObjectStateController.php - - message: '#^PHPDoc tag @var with type Symfony\\Component\\Form\\Form is not subtype of native type Symfony\\Component\\Form\\FormInterface\.$#' identifier: varTag.nativeType @@ -732,12 +564,6 @@ parameters: count: 1 path: src/bundle/Controller/ObjectStateController.php - - - message: '#^Parameter \#1 \$identifier of method Ibexa\\Contracts\\Core\\Repository\\ObjectStateService\:\:newObjectStateCreateStruct\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/ObjectStateController.php - - message: '#^Parameter \#1 \$objectState of method Ibexa\\Contracts\\Core\\Repository\\ObjectStateService\:\:updateObjectState\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\ObjectState\\ObjectState, Ibexa\\Contracts\\Core\\Repository\\Values\\ObjectState\\ObjectState\|null given\.$#' identifier: argument.type @@ -810,12 +636,6 @@ parameters: count: 1 path: src/bundle/Controller/ObjectStateGroupController.php - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\ObjectStateGroupController\:\:getObjectStateGroupsIds\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/ObjectStateGroupController.php - - message: '#^PHPDoc tag @var with type Symfony\\Component\\Form\\Form is not subtype of native type Symfony\\Component\\Form\\FormInterface\.$#' identifier: varTag.nativeType @@ -877,15 +697,9 @@ parameters: path: src/bundle/Controller/PolicyController.php - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\PolicyController\:\:getPoliciesNumbers\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/PolicyController.php - - - - message: '#^PHPDoc tag @var with type Symfony\\Component\\Form\\Form is not subtype of native type Symfony\\Component\\Form\\FormInterface\.$#' - identifier: varTag.nativeType - count: 1 + message: '#^Call to an undefined method Symfony\\Component\\Form\\FormInterface\:\:getClickedButton\(\)\.$#' + identifier: method.notFound + count: 2 path: src/bundle/Controller/PolicyController.php - @@ -912,12 +726,6 @@ parameters: count: 1 path: src/bundle/Controller/RoleAssignmentController.php - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\RoleAssignmentController\:\:getRoleAssignmentsNumbers\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Controller/RoleAssignmentController.php - - message: '#^Parameter \#1 \$roleAssignment of method Ibexa\\Contracts\\Core\\Repository\\RoleService\:\:removeRoleAssignment\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\User\\RoleAssignment, Ibexa\\Contracts\\Core\\Repository\\Values\\User\\RoleAssignment\|null given\.$#' identifier: argument.type @@ -955,20 +763,20 @@ parameters: path: src/bundle/Controller/SectionController.php - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Section\|null\.$#' + message: '#^Cannot access property \$name on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Section\|null\.$#' identifier: property.nonObject count: 1 path: src/bundle/Controller/SectionController.php - - message: '#^Cannot access property \$name on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Section\|null\.$#' - identifier: property.nonObject - count: 2 + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Section\|null\.$#' + identifier: method.nonObject + count: 1 path: src/bundle/Controller/SectionController.php - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Controller\\SectionController\:\:getSectionsNumbers\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot call method getName\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Section\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/SectionController.php @@ -997,31 +805,31 @@ parameters: path: src/bundle/Controller/SectionController.php - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getContentInfo\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/TranslationController.php - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/TranslationController.php - - message: '#^Cannot access property \$languageCode on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/TranslationController.php - - message: '#^Cannot access property \$mainLocationId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getLanguageCode\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/TranslationController.php - - message: '#^Cannot call method getContentInfo\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Location\|null\.$#' + message: '#^Cannot call method getMainLocationId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' identifier: method.nonObject count: 1 path: src/bundle/Controller/TranslationController.php @@ -1050,18 +858,6 @@ parameters: count: 2 path: src/bundle/Controller/URLWildcardController.php - - - message: '#^Parameter \#1 \$sourceUrl of method Ibexa\\Contracts\\Core\\Repository\\URLWildcardService\:\:create\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/URLWildcardController.php - - - - message: '#^Parameter \#2 \$destinationUrl of method Ibexa\\Contracts\\Core\\Repository\\URLWildcardService\:\:create\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/URLWildcardController.php - - message: '#^Parameter \#2 \$handler of method Ibexa\\AdminUi\\Form\\SubmitHandler\:\:handle\(\) expects callable\(mixed\)\: \(Symfony\\Component\\HttpFoundation\\Response\|null\), Closure\(Ibexa\\AdminUi\\Form\\Data\\URLWildcard\\URLWildcardDeleteData\)\: void given\.$#' identifier: argument.type @@ -1087,8 +883,8 @@ parameters: path: src/bundle/Controller/URLWildcardController.php - - message: '#^Cannot access property \$languageCode on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getLanguageCode\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Language\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/UrlAliasController.php @@ -1110,48 +906,12 @@ parameters: count: 1 path: src/bundle/Controller/UrlAliasController.php - - - message: '#^Parameter \#1 \$enabled of class Ibexa\\Contracts\\AdminUi\\Event\\FocusModeChangedEvent constructor expects bool, bool\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/User/FocusModeController.php - - - - message: '#^Cannot access property \$name on Ibexa\\Core\\MVC\\Symfony\\SiteAccess\|null\.$#' - identifier: property.nonObject - count: 1 - path: src/bundle/Controller/User/InvitationController.php - - - - message: '#^Property Ibexa\\Bundle\\AdminUi\\Controller\\User\\InvitationController\:\:\$twig is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/bundle/Controller/User/InvitationController.php - - message: '#^Call to an undefined method Symfony\\Component\\Form\\ClickableInterface\|Symfony\\Component\\Form\\FormInterface\:\:getName\(\)\.$#' identifier: method.notFound count: 1 path: src/bundle/Controller/User/ProfileEditController.php - - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject - count: 1 - path: src/bundle/Controller/User/UserDeleteController.php - - - - message: '#^Cannot access property \$mainLocationId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject - count: 1 - path: src/bundle/Controller/User/UserDeleteController.php - - - - message: '#^Parameter \#1 \$locationId of method Ibexa\\Contracts\\Core\\Repository\\LocationService\:\:loadLocation\(\) expects int, int\|null given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Controller/User/UserDeleteController.php - - message: '#^Call to an undefined method Symfony\\Component\\Form\\FormInterface\\:\:getClickedButton\(\)\.$#' identifier: method.notFound @@ -1164,24 +924,6 @@ parameters: count: 1 path: src/bundle/Controller/UserOnTheFlyController.php - - - message: '#^Property Ibexa\\Bundle\\AdminUi\\Controller\\UserOnTheFlyController\:\:\$contentService is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/bundle/Controller/UserOnTheFlyController.php - - - - message: '#^Property Ibexa\\Bundle\\AdminUi\\Controller\\UserOnTheFlyController\:\:\$contentTypeService is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/bundle/Controller/UserOnTheFlyController.php - - - - message: '#^Property Ibexa\\Bundle\\AdminUi\\Controller\\UserOnTheFlyController\:\:\$userLanguagePreferenceProvider is never read, only written\.$#' - identifier: property.onlyWritten - count: 1 - path: src/bundle/Controller/UserOnTheFlyController.php - - message: '#^Result of && is always false\.$#' identifier: booleanAnd.alwaysFalse @@ -1207,14 +949,14 @@ parameters: path: src/bundle/Controller/VersionController.php - - message: '#^Cannot access property \$id on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/VersionController.php - - message: '#^Cannot access property \$mainLocationId on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' - identifier: property.nonObject + message: '#^Cannot call method getMainLocationId\(\) on Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\ContentInfo\|null\.$#' + identifier: method.nonObject count: 1 path: src/bundle/Controller/VersionController.php @@ -1231,122 +973,8 @@ parameters: path: src/bundle/Controller/VersionController.php - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\AdminUiForms\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\AdminUiForms\:\:postMap\(\) has parameter \$config with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\AdminUiForms\:\:processContentEditFormTemplates\(\) has parameter \$formTemplates with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\AdminUiForms\:\:processContentEditFormTemplates\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\Assets\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Assets.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\ContentType\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/ContentType.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\LocationIds\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/LocationIds.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\Module\\ContentTree\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Module/ContentTree.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\Module\\Subitems\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Module/Subitems.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\Module\\UniversalDiscoveryWidget\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Module/UniversalDiscoveryWidget.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\Notifications\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Notifications.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\Pagination\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Pagination.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\Security\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/Security.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\SubtreeOperations\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/SubtreeOperations.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\SubtreePath\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/SubtreePath.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\Configuration\\Parser\\UserGroupIdentifier\:\:mapConfig\(\) has parameter \$scopeSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration/Parser/UserGroupIdentifier.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\DependencyInjection\\IbexaAdminUiExtension\:\:load\(\) has parameter \$configs with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/IbexaAdminUiExtension.php - - - - message: '#^Parameter \#1 \$input of static method Symfony\\Component\\Yaml\\Yaml\:\:parse\(\) expects string, string\|false given\.$#' - identifier: argument.type - count: 3 - path: src/bundle/DependencyInjection/IbexaAdminUiExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\ComponentExtension\:\:renderComponent\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/ComponentExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\ComponentExtension\:\:renderComponentGroup\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Property Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\ComponentExtension\:\:\$registry is never read, only written\.$#' + identifier: property.onlyWritten count: 1 path: src/bundle/Templating/Twig/ComponentExtension.php @@ -1356,72 +984,12 @@ parameters: count: 1 path: src/bundle/Templating/Twig/FieldEditRenderingExtension.php - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\FieldEditRenderingExtension\:\:renderFieldDefinitionEdit\(\) has parameter \$params with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/FieldEditRenderingExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\PathStringExtension\:\:getFunctions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/PathStringExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\UiConfigExtension\:\:getGlobals\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/UiConfigExtension.php - - message: '#^Parameter \#2 \$initializer of method ProxyManager\\Factory\\LazyLoadingValueHolderFactory\:\:createProxy\(\) expects Closure\(Ibexa\\AdminUi\\UI\\Config\\ConfigWrapper\|null\=, Ibexa\\AdminUi\\UI\\Config\\ConfigWrapper&ProxyManager\\Proxy\\ValueHolderInterface\&ProxyManager\\Proxy\\VirtualProxyInterface\=, string\=, array\\=, Closure\|null\=\)\: bool, Closure\(mixed, ProxyManager\\Proxy\\LazyLoadingInterface, mixed, array, mixed\)\: true given\.$#' identifier: argument.type count: 1 path: src/bundle/Templating/Twig/UiConfigExtension.php - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\UniversalDiscoveryExtension\:\:getFunctions\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/UniversalDiscoveryExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\UniversalDiscoveryExtension\:\:recursiveConfigurationArrayNormalize\(\) has parameter \$config with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/UniversalDiscoveryExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\UniversalDiscoveryExtension\:\:recursiveConfigurationArrayNormalize\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/UniversalDiscoveryExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\UniversalDiscoveryExtension\:\:renderUniversalDiscoveryWidgetConfig\(\) has parameter \$context with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/UniversalDiscoveryExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\UniversalDiscoveryExtension\:\:renderUniversalDiscoveryWidgetConfig\(\) should return string but returns string\|false\.$#' - identifier: return.type - count: 1 - path: src/bundle/Templating/Twig/UniversalDiscoveryExtension.php - - - - message: '#^Parameter \#1 \$separator of function explode expects non\-empty\-string, string given\.$#' - identifier: argument.type - count: 1 - path: src/bundle/Templating/Twig/UniversalDiscoveryExtension.php - - - - message: '#^Method Ibexa\\Bundle\\AdminUi\\Templating\\Twig\\UserPreferencesGlobalExtension\:\:getGlobals\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/Templating/Twig/UserPreferencesGlobalExtension.php - - message: '#^Method Ibexa\\Contracts\\AdminUi\\Component\\Renderer\\RendererInterface\:\:renderGroup\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -6792,18 +6360,6 @@ parameters: count: 1 path: src/lib/Limitation/Templating/LimitationBlockRenderer.php - - - message: '#^Method Ibexa\\AdminUi\\Limitation\\Templating\\LimitationBlockRenderer\:\:renderLimitationValue\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Limitation/Templating/LimitationBlockRenderer.php - - - - message: '#^Method Ibexa\\AdminUi\\Limitation\\Templating\\LimitationBlockRendererInterface\:\:renderLimitationValue\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Limitation/Templating/LimitationBlockRendererInterface.php - - message: '#^Method Ibexa\\AdminUi\\Menu\\Admin\\ContentType\\ContentTypeGroupCreateRightSidebarBuilder\:\:createStructure\(\) has parameter \$options with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue diff --git a/src/bundle/Command/CompileAssetsCommand.php b/src/bundle/Command/CompileAssetsCommand.php index 8c1f358bf9..f2126c9828 100644 --- a/src/bundle/Command/CompileAssetsCommand.php +++ b/src/bundle/Command/CompileAssetsCommand.php @@ -21,16 +21,14 @@ name: self::COMMAND_NAME, description: 'Compiles all assets using Webpack Encore' )] -class CompileAssetsCommand extends Command +final class CompileAssetsCommand extends Command { - public const COMMAND_NAME = 'ibexa:encore:compile'; - public const COMMAND_DEFAULT_TIMEOUT = 300; + public const string COMMAND_NAME = 'ibexa:encore:compile'; + public const int COMMAND_DEFAULT_TIMEOUT = 300; - private int $timeout; - - public function __construct(int $timeout = self::COMMAND_DEFAULT_TIMEOUT) - { - $this->timeout = $timeout; + public function __construct( + private readonly int $timeout = self::COMMAND_DEFAULT_TIMEOUT + ) { parent::__construct(); } @@ -96,11 +94,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!empty($frontendConfigsName)) { $frontendConfigsNameArr = explode(',', $frontendConfigsName); $yarnEncoreCommand = implode(' && ', array_map( - fn (string $configName) => "{$yarnBaseEncoreCommand} --config {$this->getFrontendConfigPath($configName)}", + fn (string $configName): string => "{$yarnBaseEncoreCommand} --config {$this->getFrontendConfigPath($configName)}", $frontendConfigsNameArr )); } + /** @var \Symfony\Component\Console\Helper\DebugFormatterHelper $debugFormatter */ $debugFormatter = $this->getHelper('debug_formatter'); $process = Process::fromShellCommandline( @@ -138,6 +137,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int ) ); - return $process->getExitCode(); + return $process->getExitCode() ?? Command::FAILURE; } } diff --git a/src/bundle/Controller/ApplicationConfigController.php b/src/bundle/Controller/ApplicationConfigController.php index d4551e9902..3426654530 100644 --- a/src/bundle/Controller/ApplicationConfigController.php +++ b/src/bundle/Controller/ApplicationConfigController.php @@ -14,11 +14,8 @@ final class ApplicationConfigController extends Controller { - private Aggregator $aggregator; - - public function __construct(Aggregator $aggregator) + public function __construct(private readonly Aggregator $aggregator) { - $this->aggregator = $aggregator; } public function loadConfigAction(): ApplicationConfig diff --git a/src/bundle/Controller/AssetController.php b/src/bundle/Controller/AssetController.php index 62b875b5ca..fc0e3ae53e 100644 --- a/src/bundle/Controller/AssetController.php +++ b/src/bundle/Controller/AssetController.php @@ -12,7 +12,6 @@ use Ibexa\AdminUi\Form\Data\Asset\ImageAssetUploadData; use Ibexa\Contracts\AdminUi\Controller\Controller; use Ibexa\Core\FieldType\Image\Value as ImageValue; -use Ibexa\Core\FieldType\ImageAsset\AssetMapper; use Ibexa\Core\FieldType\ImageAsset\AssetMapper as ImageAssetMapper; use JMS\TranslationBundle\Annotation\Desc; use Symfony\Component\HttpFoundation\JsonResponse; @@ -24,92 +23,69 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Contracts\Translation\TranslatorInterface; -class AssetController extends Controller +final class AssetController extends Controller { - public const CSRF_TOKEN_HEADER = 'X-CSRF-Token'; + public const string CSRF_TOKEN_HEADER = 'X-CSRF-Token'; - public const LANGUAGE_CODE_KEY = 'languageCode'; - public const FILE_KEY = 'file'; + public const string LANGUAGE_CODE_KEY = 'languageCode'; + public const string FILE_KEY = 'file'; - private ValidatorInterface $validator; - - private CsrfTokenManagerInterface $csrfTokenManager; - - private AssetMapper $imageAssetMapper; - - private TranslatorInterface $translator; - - /** - * @param \Symfony\Component\Validator\Validator\ValidatorInterface $validator - * @param \Symfony\Component\Security\Csrf\CsrfTokenManagerInterface $csrfTokenManager - * @param \Ibexa\Core\FieldType\ImageAsset\AssetMapper $imageAssetMapper - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - */ public function __construct( - ValidatorInterface $validator, - CsrfTokenManagerInterface $csrfTokenManager, - ImageAssetMapper $imageAssetMapper, - TranslatorInterface $translator + private readonly ValidatorInterface $validator, + private readonly CsrfTokenManagerInterface $csrfTokenManager, + private readonly ImageAssetMapper $imageAssetMapper, + private readonly TranslatorInterface $translator ) { - $this->validator = $validator; - $this->csrfTokenManager = $csrfTokenManager; - $this->imageAssetMapper = $imageAssetMapper; - $this->translator = $translator; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentType - */ public function uploadImageAction(Request $request): Response { - if ($this->isValidCsrfToken($request)) { - $data = new ImageAssetUploadData( - $request->files->get(self::FILE_KEY), - $request->request->get(self::LANGUAGE_CODE_KEY) - ); - - $errors = $this->validator->validate($data); - if ($errors->count() === 0) { - try { - $file = $data->getFile(); - - $content = $this->imageAssetMapper->createAsset( - $file->getClientOriginalName(), - new ImageValue([ - 'inputUri' => $file->getRealPath(), - 'fileSize' => $file->getSize(), - 'fileName' => $file->getClientOriginalName(), - 'alternativeText' => $file->getClientOriginalName(), - ]), - $data->getLanguageCode() - ); - - return new JsonResponse([ - 'destinationContent' => [ - 'id' => $content->contentInfo->id, - 'name' => $content->getName(), - 'locationId' => $content->contentInfo->mainLocationId, - ], - 'value' => $this->imageAssetMapper->getAssetValue($content), - ]); - } catch (Exception $e) { - return $this->createGenericErrorResponse($e->getMessage()); + if (!$this->isValidCsrfToken($request)) { + return $this->createInvalidCsrfResponse(); + } + + $data = new ImageAssetUploadData( + $request->files->get(self::FILE_KEY), + $request->request->get(self::LANGUAGE_CODE_KEY) + ); + + $errors = $this->validator->validate($data); + if ($errors->count() === 0) { + try { + $file = $data->getFile(); + if ($file === null) { + throw new Exception('File is missing in the request.'); } - } else { - return $this->createInvalidInputResponse($errors); + + $content = $this->imageAssetMapper->createAsset( + $file->getClientOriginalName(), + new ImageValue([ + 'inputUri' => $file->getRealPath(), + 'fileSize' => $file->getSize(), + 'fileName' => $file->getClientOriginalName(), + 'alternativeText' => $file->getClientOriginalName(), + ]), + $data->getLanguageCode() ?? '' + ); + + $contentInfo = $content->getContentInfo(); + + return new JsonResponse([ + 'destinationContent' => [ + 'id' => $contentInfo->getId(), + 'name' => $content->getName(), + 'locationId' => $contentInfo->getMainLocationId(), + ], + 'value' => $this->imageAssetMapper->getAssetValue($content), + ]); + } catch (Exception $e) { + return $this->createGenericErrorResponse($e->getMessage()); } + } else { + return $this->createInvalidInputResponse($errors); } - - return $this->createInvalidCsrfResponse(); } - /** - * @return \Symfony\Component\HttpFoundation\JsonResponse - */ private function createInvalidCsrfResponse(): JsonResponse { $errorMessage = $this->translator->trans( @@ -122,11 +98,6 @@ private function createInvalidCsrfResponse(): JsonResponse return $this->createGenericErrorResponse($errorMessage); } - /** - * @param \Symfony\Component\Validator\ConstraintViolationListInterface $errors - * - * @return \Symfony\Component\HttpFoundation\JsonResponse - */ private function createInvalidInputResponse(ConstraintViolationListInterface $errors): JsonResponse { $errorMessages = []; @@ -137,11 +108,6 @@ private function createInvalidInputResponse(ConstraintViolationListInterface $er return $this->createGenericErrorResponse(implode(', ', $errorMessages)); } - /** - * @param string $errorMessage - * - * @return \Symfony\Component\HttpFoundation\JsonResponse - */ private function createGenericErrorResponse(string $errorMessage): JsonResponse { return new JsonResponse( @@ -154,11 +120,6 @@ private function createGenericErrorResponse(string $errorMessage): JsonResponse ); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return bool - */ private function isValidCsrfToken(Request $request): bool { $csrfTokenValue = $request->headers->get(self::CSRF_TOKEN_HEADER); diff --git a/src/bundle/Controller/BookmarkController.php b/src/bundle/Controller/BookmarkController.php index e4f96c517d..e4a2b9c55d 100644 --- a/src/bundle/Controller/BookmarkController.php +++ b/src/bundle/Controller/BookmarkController.php @@ -23,41 +23,18 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class BookmarkController extends Controller +final class BookmarkController extends Controller { - private BookmarkService $bookmarkService; - - private DatasetFactory $datasetFactory; - - private FormFactory $formFactory; - - private LocationService $locationService; - - private SubmitHandler $submitHandler; - - private ConfigResolverInterface $configResolver; - public function __construct( - BookmarkService $bookmarkService, - DatasetFactory $datasetFactory, - FormFactory $formFactory, - LocationService $locationService, - SubmitHandler $submitHandler, - ConfigResolverInterface $configResolver + private readonly BookmarkService $bookmarkService, + private readonly DatasetFactory $datasetFactory, + private readonly FormFactory $formFactory, + private readonly LocationService $locationService, + private readonly SubmitHandler $submitHandler, + private readonly ConfigResolverInterface $configResolver ) { - $this->bookmarkService = $bookmarkService; - $this->datasetFactory = $datasetFactory; - $this->formFactory = $formFactory; - $this->locationService = $locationService; - $this->submitHandler = $submitHandler; - $this->configResolver = $configResolver; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function listAction(Request $request): Response { /** @phpstan-var int<0, max> $page */ @@ -67,7 +44,9 @@ public function listAction(Request $request): Response new BookmarkAdapter($this->bookmarkService, $this->datasetFactory) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.bookmark_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.bookmark_limit') + ); $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); $editForm = $this->formFactory->contentEdit( @@ -75,7 +54,9 @@ public function listAction(Request $request): Response ); $removeBookmarkForm = $this->formFactory->removeBookmark( - new BookmarkRemoveData($this->getChoices(iterator_to_array($pagerfanta->getCurrentPageResults()))) + new BookmarkRemoveData( + $this->getChoices(iterator_to_array($pagerfanta->getCurrentPageResults())) + ) ); return $this->render( @@ -88,11 +69,6 @@ public function listAction(Request $request): Response ); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function removeAction(Request $request): Response { $form = $this->formFactory->removeBookmark( @@ -101,15 +77,18 @@ public function removeAction(Request $request): Response $form->handleRequest($request); if ($form->isSubmitted()) { - $result = $this->submitHandler->handle($form, function (BookmarkRemoveData $data): RedirectResponse { - foreach ($data->getBookmarks() as $locationId => $selected) { - $this->bookmarkService->deleteBookmark( - $this->locationService->loadLocation($locationId) - ); + $result = $this->submitHandler->handle( + $form, + function (BookmarkRemoveData $data): RedirectResponse { + foreach ($data->getBookmarks() as $locationId => $selected) { + $this->bookmarkService->deleteBookmark( + $this->locationService->loadLocation($locationId) + ); + } + + return $this->redirectToRoute('ibexa.bookmark.list'); } - - return $this->redirectToRoute('ibexa.bookmark.list'); - }); + ); if ($result instanceof Response) { return $result; diff --git a/src/bundle/Controller/BulkOperation/BulkOperationController.php b/src/bundle/Controller/BulkOperation/BulkOperationController.php index 6a3efbd0aa..49147f733d 100644 --- a/src/bundle/Controller/BulkOperation/BulkOperationController.php +++ b/src/bundle/Controller/BulkOperation/BulkOperationController.php @@ -16,24 +16,14 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; -class BulkOperationController extends RestController +final class BulkOperationController extends RestController { - private HttpKernelInterface $httpKernel; - - /** - * @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel - */ public function __construct( - HttpKernelInterface $httpKernel + private readonly HttpKernelInterface $httpKernel ) { - $this->httpKernel = $httpKernel; } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Ibexa\AdminUi\REST\Value\BulkOperationResponse - * * @throws \Exception */ public function bulkAction(Request $request): BulkOperationResponse @@ -56,19 +46,13 @@ public function bulkAction(Request $request): BulkOperationResponse $responses[$operationId] = new OperationResponse( $response->getStatusCode(), $response->headers->all(), - $response->getContent() + $response->getContent() ?: '', ); } return new BulkOperationResponse($responses); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\AdminUi\REST\Value\Operation $operation - * - * @return \Symfony\Component\HttpFoundation\Request - */ private function buildSubRequest(Request $request, Operation $operation): Request { $subRequest = Request::create( diff --git a/src/bundle/Controller/Content/ContentTreeController.php b/src/bundle/Controller/Content/ContentTreeController.php index 95f4b66982..951834f8a4 100644 --- a/src/bundle/Controller/Content/ContentTreeController.php +++ b/src/bundle/Controller/Content/ContentTreeController.php @@ -32,40 +32,19 @@ /** * @phpstan-import-type TPermissionRestrictions from \Ibexa\AdminUi\REST\Value\ContentTree\NodeExtendedInfo */ -class ContentTreeController extends RestController +final class ContentTreeController extends RestController { - private const ROOT_LOCATION_ID = 1; - - private LocationService $locationService; - - private LookupLimitationsTransformer $lookupLimitationsTransformer; - - private NodeFactory $contentTreeNodeFactory; - - private PermissionResolver $permissionResolver; - - private ConfigResolverInterface $configResolver; - - private SiteaccessResolverInterface $siteaccessResolver; - - private LimitationResolverInterface $limitationResolver; + private const int ROOT_LOCATION_ID = 1; public function __construct( - LocationService $locationService, - LookupLimitationsTransformer $lookupLimitationsTransformer, - NodeFactory $contentTreeNodeFactory, - PermissionResolver $permissionResolver, - ConfigResolverInterface $configResolver, - SiteaccessResolverInterface $siteaccessResolver, - LimitationResolverInterface $limitationResolver + private readonly LocationService $locationService, + private readonly LookupLimitationsTransformer $lookupLimitationsTransformer, + private readonly NodeFactory $contentTreeNodeFactory, + private readonly PermissionResolver $permissionResolver, + private readonly ConfigResolverInterface $configResolver, + private readonly SiteaccessResolverInterface $siteaccessResolver, + private readonly LimitationResolverInterface $limitationResolver ) { - $this->locationService = $locationService; - $this->lookupLimitationsTransformer = $lookupLimitationsTransformer; - $this->contentTreeNodeFactory = $contentTreeNodeFactory; - $this->permissionResolver = $permissionResolver; - $this->configResolver = $configResolver; - $this->siteaccessResolver = $siteaccessResolver; - $this->limitationResolver = $limitationResolver; } /** @@ -98,10 +77,6 @@ public function loadChildrenAction( } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Ibexa\AdminUi\REST\Value\ContentTree\Root - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException @@ -187,7 +162,7 @@ public function loadNodeExtendedInfoAction(Location $location): NodeExtendedInfo $content = $location->getContent(); $versionInfo = $content->getVersionInfo(); - $translations = $versionInfo->languageCodes; + $translations = $versionInfo->getLanguageCodes(); $previewableTranslations = array_filter( $translations, fn (string $languageCode): bool => $this->isPreviewable($location, $content, $languageCode) @@ -248,8 +223,9 @@ private function canUserRemoveContent(Location $location): bool { $content = $location->getContent(); $contentType = $content->getContentType(); - $contentIsUser = (new ContentTypeIsUser($this->configResolver->getParameter('user_content_type_identifier'))) - ->isSatisfiedBy($contentType); + $contentIsUser = (new ContentTypeIsUser( + $this->configResolver->getParameter('user_content_type_identifier') + ))->isSatisfiedBy($contentType); $translations = $content->getVersionInfo()->getLanguageCodes(); $target = (new Target\Version())->deleteTranslations($translations); diff --git a/src/bundle/Controller/Content/VersionDraftConflictController.php b/src/bundle/Controller/Content/VersionDraftConflictController.php index 863d71143b..2e12b71c17 100644 --- a/src/bundle/Controller/Content/VersionDraftConflictController.php +++ b/src/bundle/Controller/Content/VersionDraftConflictController.php @@ -17,49 +17,22 @@ use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\UserService; use JMS\TranslationBundle\Annotation\Desc; +use RuntimeException; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; -class VersionDraftConflictController extends Controller +final class VersionDraftConflictController extends Controller { - private LocationService $locationService; - - private ContentService $contentService; - - private DatasetFactory $datasetFactory; - - private UserService $userService; - - private TranslatorInterface $translator; - - /** - * @param \Ibexa\Contracts\Core\Repository\LocationService $locationService - * @param \Ibexa\Contracts\Core\Repository\ContentService $contentService - * @param \Ibexa\AdminUi\UI\Dataset\DatasetFactory $datasetFactory - * @param \Ibexa\Contracts\Core\Repository\UserService $userService - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - */ public function __construct( - LocationService $locationService, - ContentService $contentService, - DatasetFactory $datasetFactory, - UserService $userService, - TranslatorInterface $translator + private readonly LocationService $locationService, + private readonly ContentService $contentService, + private readonly DatasetFactory $datasetFactory, + private readonly UserService $userService, + private readonly TranslatorInterface $translator ) { - $this->locationService = $locationService; - $this->contentService = $contentService; - $this->datasetFactory = $datasetFactory; - $this->userService = $userService; - $this->translator = $translator; } /** - * @param int $contentId - * @param string $languageCode - * @param int|null $locationId - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException @@ -70,10 +43,12 @@ public function draftHasNoConflictAction( ?int $locationId = null ): Response { $content = $this->contentService->loadContent($contentId); - $contentInfo = $content->contentInfo; + $contentInfo = $content->getContentInfo(); try { - $contentDraftHasConflict = (new ContentDraftHasConflict($this->contentService, $languageCode))->isSatisfiedBy($contentInfo); + $contentDraftHasConflict = ( + new ContentDraftHasConflict($this->contentService, $languageCode) + )->isSatisfiedBy($contentInfo); } catch (UnauthorizedException $e) { $error = $this->translator->trans( /** @Desc("Cannot check if the draft has conflicts with other drafts. %error%.") */ @@ -88,13 +63,25 @@ public function draftHasNoConflictAction( if ($contentDraftHasConflict) { $versionsDataset = $this->datasetFactory->versions(); $versionsDataset->load($contentInfo); - $conflictedDrafts = $versionsDataset->getConflictedDraftVersions($contentInfo->currentVersionNo, $languageCode); - $locationId = $locationId ?? $contentInfo->mainLocationId; + $conflictedDrafts = $versionsDataset->getConflictedDraftVersions( + $contentInfo->currentVersionNo, + $languageCode + ); + + $locationId = $locationId ?? $contentInfo->getMainLocationId(); + if ($locationId === null) { + throw new RuntimeException( + 'Location ID is required to load the version draft conflict modal.' + ); + } + try { $location = $this->locationService->loadLocation($locationId); - } catch (UnauthorizedException $e) { + } catch (UnauthorizedException) { // Will return list of locations user has *read* access to, or empty array if none - $availableLocations = $this->locationService->loadLocations($contentInfo); + $availableLocations = iterator_to_array( + $this->locationService->loadLocations($contentInfo) + ); // will return null if array of availableLocations is empty $location = array_shift($availableLocations); } diff --git a/src/bundle/Controller/ContentController.php b/src/bundle/Controller/ContentController.php index 3fa51673ca..71d69f0f4a 100644 --- a/src/bundle/Controller/ContentController.php +++ b/src/bundle/Controller/ContentController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -30,7 +31,6 @@ use Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface; use Ibexa\Contracts\Core\Limitation\Target; use Ibexa\Contracts\Core\Repository\ContentService; -use Ibexa\Contracts\Core\Repository\Exceptions as ApiException; use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException; use Ibexa\Contracts\Core\Repository\LocationService; use Ibexa\Contracts\Core\Repository\PermissionResolver; @@ -50,83 +50,30 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; -class ContentController extends Controller +final class ContentController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private ContentService $contentService; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private ContentMainLocationUpdateMapper $contentMainLocationUpdateMapper; - - private SiteaccessResolverInterface $siteaccessResolver; - - private LocationService $locationService; - - private UserService $userService; - - private PermissionResolver $permissionResolver; - - private LookupLimitationsTransformer $lookupLimitationsTransformer; - - private TranslationHelper $translationHelper; - - private ConfigResolverInterface $configResolver; - - private SiteAccessNameGeneratorInterface $siteAccessNameGenerator; - - private EventDispatcherInterface $eventDispatcher; - - private FormFactoryInterface $baseFormFactory; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - ContentService $contentService, - FormFactory $formFactory, - SubmitHandler $submitHandler, - ContentMainLocationUpdateMapper $contentMetadataUpdateMapper, - SiteaccessResolverInterface $siteaccessResolver, - LocationService $locationService, - UserService $userService, - PermissionResolver $permissionResolver, - LookupLimitationsTransformer $lookupLimitationsTransformer, - TranslationHelper $translationHelper, - ConfigResolverInterface $configResolver, - SiteAccessNameGeneratorInterface $siteAccessNameGenerator, - EventDispatcherInterface $eventDispatcher, - FormFactoryInterface $baseFormFactory + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly ContentService $contentService, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly ContentMainLocationUpdateMapper $contentMainLocationUpdateMapper, + private readonly SiteaccessResolverInterface $siteaccessResolver, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly LookupLimitationsTransformer $lookupLimitationsTransformer, + private readonly TranslationHelper $translationHelper, + private readonly ConfigResolverInterface $configResolver, + private readonly SiteAccessNameGeneratorInterface $siteAccessNameGenerator, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly FormFactoryInterface $baseFormFactory ) { - $this->notificationHandler = $notificationHandler; - $this->contentService = $contentService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->contentMainLocationUpdateMapper = $contentMetadataUpdateMapper; - $this->siteaccessResolver = $siteaccessResolver; - $this->locationService = $locationService; - $this->userService = $userService; - $this->permissionResolver = $permissionResolver; - $this->translationHelper = $translationHelper; - $this->lookupLimitationsTransformer = $lookupLimitationsTransformer; - $this->configResolver = $configResolver; - $this->siteAccessNameGenerator = $siteAccessNameGenerator; - $this->eventDispatcher = $eventDispatcher; - $this->baseFormFactory = $baseFormFactory; } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException - * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - * @throws ApiException\ContentValidationException - * @throws ApiException\ContentFieldValidationException */ public function createAction(Request $request): Response { @@ -137,21 +84,31 @@ public function createAction(Request $request): Response if ($form->isSubmitted()) { $result = $this->submitHandler->handle($form, function (ContentCreateData $data): RedirectResponse { $contentType = $data->getContentType(); + if ($contentType === null) { + throw new BadStateException( + '$contentType', + 'Content type is not set' + ); + } + $language = $data->getLanguage(); $parentLocation = $data->getParentLocation(); - if ((new ContentTypeIsUser($this->configResolver->getParameter('user_content_type_identifier')))->isSatisfiedBy($contentType)) { + if ( + (new ContentTypeIsUser($this->configResolver->getParameter('user_content_type_identifier'))) + ->isSatisfiedBy($contentType) + ) { return $this->redirectToRoute('ibexa.user.create', [ - 'contentTypeIdentifier' => $contentType->identifier, - 'language' => $language->languageCode, - 'parentLocationId' => $parentLocation->id, + 'contentTypeIdentifier' => $contentType->getIdentifier(), + 'language' => $language->getLanguageCode(), + 'parentLocationId' => $parentLocation->getId(), ]); } return $this->redirectToRoute('ibexa.content.create.proxy', [ - 'contentTypeIdentifier' => $contentType->identifier, - 'languageCode' => $language->languageCode, - 'parentLocationId' => $parentLocation->id, + 'contentTypeIdentifier' => $contentType->getIdentifier(), + 'languageCode' => $language->getLanguageCode(), + 'parentLocationId' => $parentLocation->getId(), ]); }); @@ -184,19 +141,14 @@ public function proxyCreateAction( // Fallback to "nodraft" return $this->redirectToRoute('ibexa.content.create_no_draft', [ - 'contentTypeIdentifier' => $contentType->identifier, + 'contentTypeIdentifier' => $contentType->getIdentifier(), 'language' => $languageCode, 'parentLocationId' => $parentLocationId, ]); } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function editAction(Request $request): Response @@ -218,15 +170,15 @@ public function editAction(Request $request): Response $language = $data->getLanguage(); $location = $data->getLocation(); - $content = $this->contentService->loadContent($contentInfo->id); + $content = $this->contentService->loadContent($contentInfo->getId()); $versionInfo = $data->getVersionInfo() ?? $content->getVersionInfo(); - $versionNo = $versionInfo->versionNo; + $versionNo = $versionInfo->getVersionNo(); if ((new ContentIsUser($this->userService))->isSatisfiedBy($content)) { return $this->redirectToRoute('ibexa.user.update', [ - 'contentId' => $contentInfo->id, + 'contentId' => $contentInfo->getId(), 'versionNo' => $versionNo, - 'language' => $language->languageCode, + 'language' => $language->getLanguageCode(), ]); } @@ -235,7 +187,7 @@ public function editAction(Request $request): Response new ContentEditEvent( $content, $versionInfo, - $language->languageCode + $language->getLanguageCode() ) ); @@ -245,7 +197,7 @@ public function editAction(Request $request): Response if (!$versionInfo->isDraft()) { $contentDraft = $this->contentService->createContentDraft($contentInfo, $versionInfo, null, $language); - $versionNo = $contentDraft->getVersionInfo()->versionNo; + $versionNo = $contentDraft->getVersionInfo()->getVersionNo(); $this->notificationHandler->success( /** @Desc("Created a new draft for '%name%'.") */ @@ -256,12 +208,12 @@ public function editAction(Request $request): Response } return $this->redirectToRoute('ibexa.content.draft.edit', [ - 'contentId' => $contentInfo->id, + 'contentId' => $contentInfo->getId(), 'versionNo' => $versionNo, - 'language' => $language->languageCode, + 'language' => $language->getLanguageCode(), 'locationId' => null !== $location - ? $location->id - : $contentInfo->mainLocationId, + ? $location->getId() + : $contentInfo->getMainLocationId(), ]); }); @@ -276,8 +228,8 @@ public function editAction(Request $request): Response if (null !== $contentInfo) { return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), ]); } @@ -285,15 +237,8 @@ public function editAction(Request $request): Response } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * - * @throws \Ibexa\AdminUi\Exception\InvalidArgumentException * @throws \InvalidArgumentException * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException */ public function updateMainLocationAction(Request $request): Response @@ -317,8 +262,8 @@ public function updateMainLocationAction(Request $request): Response ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => 'ibexa-tab-location-view-locations', ])); }); @@ -334,8 +279,8 @@ public function updateMainLocationAction(Request $request): Response if (null !== $contentInfo) { return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => 'ibexa-tab-location-view-locations', ])); } @@ -343,14 +288,6 @@ public function updateMainLocationAction(Request $request): Response return $this->redirectToRoute('ibexa.dashboard'); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Content $content - * @param string|null $languageCode - * @param int|null $versionNo - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function previewAction( Request $request, Content $content, @@ -361,19 +298,21 @@ public function previewAction( $referrer = $request->query->get('referrer'); if (null === $languageCode) { - $languageCode = $content->contentInfo->mainLanguageCode; + $languageCode = $content->getContentInfo()->getMainLanguageCode(); } // nonpublished content should use parent location instead because location doesn't exist yet - if (!$content->contentInfo->published && null === $content->contentInfo->mainLocationId) { - $versionInfo = $this->contentService->loadVersionInfo($content->contentInfo, $versionNo); + if (!$content->getContentInfo()->isPublished() && null === $content->getContentInfo()->getMainLocationId()) { + $versionInfo = $this->contentService->loadVersionInfo($content->getContentInfo(), $versionNo); $parentLocations = $this->locationService->loadParentLocationsForDraftContent($versionInfo); $location = reset($parentLocations); $versionNo = null; } if (null === $location) { - $location = $this->locationService->loadLocation($content->contentInfo->mainLocationId); + $location = $this->locationService->loadLocation( + $content->getContentInfo()->getMainLocationId() + ); } $siteAccesses = $this->siteaccessResolver->getSiteAccessesListForLocation($location, $versionNo, $languageCode); @@ -399,8 +338,8 @@ public function previewAction( $urlValue = $this->generateUrl( 'ibexa.version.preview', [ - 'contentId' => $content->id, - 'versionNo' => $versionNo ?? $content->getVersionInfo()->versionNo, + 'contentId' => $content->getId(), + 'versionNo' => $versionNo ?? $content->getVersionInfo()->getVersionNo(), 'language' => $languageCode, 'siteAccessName' => $preselectedSiteAccess, ] @@ -412,7 +351,7 @@ public function previewAction( [ 'location' => $location, 'content' => $content, - 'versionNo' => $versionNo ?? $content->getVersionInfo()->versionNo, + 'versionNo' => $versionNo ?? $content->getVersionInfo()->getVersionNo(), 'languageCode' => $languageCode, ] ); @@ -423,17 +362,12 @@ public function previewAction( 'language_code' => $languageCode, 'siteaccesses' => $siteAccessesList, 'site_access_form' => $siteAccessSelector, - 'version_no' => $versionNo ?? $content->getVersionInfo()->versionNo, + 'version_no' => $versionNo ?? $content->getVersionInfo()->getVersionNo(), 'preselected_site_access' => $preselectedSiteAccess, 'referrer' => $referrer ?? 'content_draft_edit', ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateMainTranslationAction(Request $request): Response { $form = $this->createForm(MainTranslationUpdateType::class, new MainTranslationUpdateData()); @@ -442,7 +376,7 @@ public function updateMainTranslationAction(Request $request): Response if ($form->isSubmitted()) { $result = $this->submitHandler->handle($form, function (MainTranslationUpdateData $data): RedirectResponse { $content = $data->getContent(); - $contentInfo = $content->contentInfo; + $contentInfo = $content->getContentInfo(); $mapper = new MainTranslationUpdateMapper(); $contentMetadataUpdateStruct = $mapper->reverseMap($data); $this->contentService->updateContentMetadata($contentInfo, $contentMetadataUpdateStruct); @@ -454,8 +388,8 @@ public function updateMainTranslationAction(Request $request): Response ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => 'ibexa-tab-location-view-translations', ])); }); @@ -468,8 +402,8 @@ public function updateMainTranslationAction(Request $request): Response $contentInfo = $data->getContentInfo(); if (null !== $contentInfo) { return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => 'ibexa-tab-location-view-translations', ])); } @@ -477,11 +411,6 @@ public function updateMainTranslationAction(Request $request): Response return $this->redirectToRoute('ibexa.dashboard'); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateVisibilityAction(Request $request): Response { $formName = $request->query->get('formName'); @@ -544,11 +473,6 @@ public function updateVisibilityAction(Request $request): Response } /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Content $content - * @param string|null $languageCode - * - * @return \Symfony\Component\HttpFoundation\JsonResponse - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ @@ -597,7 +521,7 @@ public function relationViewAction(int $contentId): Response { try { $content = $this->contentService->loadContent($contentId); - } catch (UnauthorizedException $exception) { + } catch (UnauthorizedException) { return $this->render('@ibexadesign/content/relation_unauthorized.html.twig', [ 'contentId' => $contentId, ]); diff --git a/src/bundle/Controller/ContentDraftController.php b/src/bundle/Controller/ContentDraftController.php index 05055ea3a3..5e2e7d79db 100644 --- a/src/bundle/Controller/ContentDraftController.php +++ b/src/bundle/Controller/ContentDraftController.php @@ -22,39 +22,19 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class ContentDraftController extends Controller +final class ContentDraftController extends Controller { - private const PAGINATION_PARAM_NAME = 'page'; - - private ContentService $contentService; - - private DatasetFactory $datasetFactory; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private ConfigResolverInterface $configResolver; + private const string PAGINATION_PARAM_NAME = 'page'; public function __construct( - ContentService $contentService, - DatasetFactory $datasetFactory, - FormFactory $formFactory, - SubmitHandler $submitHandler, - ConfigResolverInterface $configResolver + private readonly ContentService $contentService, + private readonly DatasetFactory $datasetFactory, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly ConfigResolverInterface $configResolver ) { - $this->contentService = $contentService; - $this->datasetFactory = $datasetFactory; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->configResolver = $configResolver; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function listAction(Request $request): Response { $currentPage = $request->query->getInt(self::PAGINATION_PARAM_NAME, 1); @@ -62,7 +42,11 @@ public function listAction(Request $request): Response $pagination = new Pagerfanta( new ContentDraftAdapter($this->contentService, $this->datasetFactory) ); - $pagination->setMaxPerPage($this->configResolver->getParameter('pagination.content_draft_limit')); + + $pagination->setMaxPerPage( + $this->configResolver->getParameter('pagination.content_draft_limit') + ); + $pagination->setCurrentPage(min($currentPage, $pagination->getNbPages())); $removeContentDraftForm = $this->formFactory->removeContentDraft( @@ -75,11 +59,6 @@ public function listAction(Request $request): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function removeAction(Request $request): Response { $form = $this->formFactory->removeContentDraft(); @@ -109,11 +88,6 @@ public function removeAction(Request $request): Response return $this->redirectToRoute('ibexa.content_draft.list'); } - /** - * @param \Pagerfanta\Pagerfanta $pagerfanta - * - * @return \Ibexa\AdminUi\Form\Data\Content\Draft\ContentRemoveData - */ private function createContentRemoveData(Pagerfanta $pagerfanta): ContentRemoveData { $versions = []; diff --git a/src/bundle/Controller/ContentEditController.php b/src/bundle/Controller/ContentEditController.php index 4c92cf50a6..f680850ed9 100644 --- a/src/bundle/Controller/ContentEditController.php +++ b/src/bundle/Controller/ContentEditController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -17,22 +18,13 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; -class ContentEditController extends Controller +final class ContentEditController extends Controller { - private ContentService $contentService; - - private LocationService $locationService; - - private EventDispatcherInterface $eventDispatcher; - public function __construct( - ContentService $contentService, - LocationService $locationService, - EventDispatcherInterface $eventDispatcher + private readonly ContentService $contentService, + private readonly LocationService $locationService, + private readonly EventDispatcherInterface $eventDispatcher ) { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->eventDispatcher = $eventDispatcher; } public function proxyTranslateAction( @@ -64,21 +56,11 @@ public function proxyTranslateAction( ]); } - /** - * @param \Ibexa\AdminUi\View\ContentTranslateView $view - * - * @return \Ibexa\AdminUi\View\ContentTranslateView - */ public function translateAction(ContentTranslateView $view): ContentTranslateView { return $view; } - /** - * @param \Ibexa\AdminUi\View\ContentTranslateSuccessView $view - * - * @return \Ibexa\AdminUi\View\ContentTranslateSuccessView - */ public function translationSuccessAction(ContentTranslateSuccessView $view): ContentTranslateSuccessView { return $view; diff --git a/src/bundle/Controller/ContentOnTheFlyController.php b/src/bundle/Controller/ContentOnTheFlyController.php index 61989e3257..10fe50a635 100644 --- a/src/bundle/Controller/ContentOnTheFlyController.php +++ b/src/bundle/Controller/ContentOnTheFlyController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -36,62 +37,30 @@ use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Core\Base\Exceptions\UnauthorizedException; use Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface; +use Ibexa\Core\MVC\Symfony\View\BaseView; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; -class ContentOnTheFlyController extends Controller +final class ContentOnTheFlyController extends Controller { - private const AUTOSAVE_ACTION_NAME = 'autosave'; - - private ContentService $contentService; - - private LanguageService $languageService; - - private LocationService $locationService; - - private ContentTypeService $contentTypeService; - - private PermissionResolver $permissionResolver; - - private GroupedContentFormFieldsProviderInterface $groupedContentFormFieldsProvider; - - private UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider; - - private CreateContentOnTheFlyDispatcher $createContentActionDispatcher; - - private ConfigResolverInterface $configResolver; - - private EventDispatcherInterface $eventDispatcher; - - private ActionDispatcherInterface $contentActionDispatcher; + private const string AUTOSAVE_ACTION_NAME = 'autosave'; public function __construct( - ContentService $contentService, - LanguageService $languageService, - LocationService $locationService, - ContentTypeService $contentTypeService, - PermissionResolver $permissionResolver, - GroupedContentFormFieldsProviderInterface $groupedContentFormFieldsProvider, - UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, - CreateContentOnTheFlyDispatcher $createContentActionDispatcher, - ConfigResolverInterface $configResolver, - EventDispatcherInterface $eventDispatcher, - ActionDispatcherInterface $contentActionDispatcher + private readonly ContentService $contentService, + private readonly LanguageService $languageService, + private readonly LocationService $locationService, + private readonly ContentTypeService $contentTypeService, + private readonly PermissionResolver $permissionResolver, + private readonly GroupedContentFormFieldsProviderInterface $groupedContentFormFieldsProvider, + private readonly UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, + private readonly CreateContentOnTheFlyDispatcher $createContentActionDispatcher, + private readonly ConfigResolverInterface $configResolver, + private readonly EventDispatcherInterface $eventDispatcher, + private readonly ActionDispatcherInterface $contentActionDispatcher ) { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->languageService = $languageService; - $this->contentTypeService = $contentTypeService; - $this->permissionResolver = $permissionResolver; - $this->groupedContentFormFieldsProvider = $groupedContentFormFieldsProvider; - $this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider; - $this->createContentActionDispatcher = $createContentActionDispatcher; - $this->configResolver = $configResolver; - $this->eventDispatcher = $eventDispatcher; - $this->contentActionDispatcher = $contentActionDispatcher; } /** @@ -109,24 +78,38 @@ public function hasCreateAccessAction( $contentCreateStruct = $this->createContentCreateStruct($parentLocation, $contentType, $languageCode); $locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocation->id); - if (!$this->permissionResolver->canUser('content', 'create', $contentCreateStruct, [$locationCreateStruct])) { + if ( + !$this->permissionResolver->canUser( + 'content', + 'create', + $contentCreateStruct, + [$locationCreateStruct] + ) + ) { throw new UnauthorizedException( 'content', 'create', [ - 'contentTypeIdentifier' => $contentType->identifier, + 'contentTypeIdentifier' => $contentType->getIdentifier(), 'parentLocationId' => $locationCreateStruct->parentLocationId, 'languageCode' => $languageCode, ] ); } - if (!$this->permissionResolver->canUser('content', 'publish', $contentCreateStruct, [$locationCreateStruct])) { + if ( + !$this->permissionResolver->canUser( + 'content', + 'publish', + $contentCreateStruct, + [$locationCreateStruct] + ) + ) { throw new UnauthorizedException( 'content', 'publish', [ - 'contentTypeIdentifier' => $contentType->identifier, + 'contentTypeIdentifier' => $contentType->getIdentifier(), 'parentLocationId' => $locationCreateStruct->parentLocationId, 'languageCode' => $languageCode, ] @@ -147,8 +130,6 @@ public function hasCreateAccessAction( } /** - * @return \Ibexa\Core\MVC\Symfony\View\BaseView|\Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ @@ -157,8 +138,11 @@ public function createContentAction( string $languageCode, ContentType $contentType, Location $parentLocation - ) { - if ((new ContentTypeIsUser($this->configResolver->getParameter('user_content_type_identifier')))->isSatisfiedBy($contentType)) { + ): BaseView|Response { + if ( + (new ContentTypeIsUser($this->configResolver->getParameter('user_content_type_identifier'))) + ->isSatisfiedBy($contentType) + ) { return $this->forward('Ibexa\Bundle\AdminUi\Controller\UserOnTheFlyController::createUserAction', [ 'languageCode' => $languageCode, 'contentType' => $contentType, @@ -201,7 +185,12 @@ public function createContentAction( $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid() && $form->getClickedButton()) { - $this->createContentActionDispatcher->dispatchFormAction($form, $data, $form->getClickedButton()->getName()); + $this->createContentActionDispatcher->dispatchFormAction( + $form, + $data, + $form->getClickedButton()->getName() + ); + if ($response = $this->createContentActionDispatcher->getResponse()) { return $response; } @@ -245,7 +234,10 @@ public function editContentAction( $this->userLanguagePreferenceProvider->getPreferredLanguages() ); - if ((new ContentTypeIsUser($this->configResolver->getParameter('user_content_type_identifier')))->isSatisfiedBy($contentType)) { + if ( + (new ContentTypeIsUser($this->configResolver->getParameter('user_content_type_identifier'))) + ->isSatisfiedBy($contentType) + ) { return $this->forward('Ibexa\Bundle\AdminUi\Controller\UserOnTheFlyController::editUserAction', [ 'languageCode' => $languageCode, 'contentId' => $contentId, @@ -281,12 +273,12 @@ public function editContentAction( throw new BadStateException('Version', 'The status is not draft'); } - if (null === $location && $content->contentInfo->isPublished()) { + if (null === $location && $content->getContentInfo()->isPublished()) { // assume main location if no location was provided - $location = $content->contentInfo->getMainLocation(); + $location = $content->getContentInfo()->getMainLocation(); } - if (null !== $location && $location->contentId !== $content->id) { + if (null !== $location && $location->getContentId() !== $content->getId()) { throw new InvalidArgumentException('Location', 'The provided Location does not belong to the selected content'); } @@ -305,17 +297,20 @@ public function editContentAction( ); if (!$location instanceof Location) { - $contentInfo = $this->contentService->loadContentInfo($content->id); + $contentInfo = $this->contentService->loadContentInfo($content->getId()); - if (null !== $contentInfo->mainLocationId) { - $location = $this->locationService->loadLocation($contentInfo->mainLocationId); + if (null !== $contentInfo->getMainLocationId()) { + $location = $this->locationService->loadLocation($contentInfo->getMainLocationId()); } } if ($actionDispatcher->getResponse()) { - $view = new EditContentOnTheFlySuccessView('@ibexadesign/ui/on_the_fly/content_edit_response.html.twig'); + $view = new EditContentOnTheFlySuccessView( + '@ibexadesign/ui/on_the_fly/content_edit_response.html.twig' + ); + $view->addParameters([ - 'locationId' => $location instanceof Location ? $location->id : null, + 'locationId' => $location instanceof Location ? $location->getId() : null, ]); return $view; @@ -331,7 +326,7 @@ private function createContentCreateStruct( string $language ): ContentCreateStruct { $contentCreateStruct = $this->contentService->newContentCreateStruct($contentType, $language); - $contentCreateStruct->sectionId = $location->contentInfo->sectionId; + $contentCreateStruct->sectionId = $location->getContentInfo()->getSectionId(); return $contentCreateStruct; } @@ -343,7 +338,9 @@ private function buildEditView( FormInterface $form, ContentType $contentType ): EditContentOnTheFlyView { - $view = new EditContentOnTheFlyView('@ibexadesign/ui/on_the_fly/content_edit_on_the_fly.html.twig'); + $view = new EditContentOnTheFlyView( + '@ibexadesign/ui/on_the_fly/content_edit_on_the_fly.html.twig' + ); $view->setContent($content); $view->setLanguage($language); diff --git a/src/bundle/Controller/ContentTypeController.php b/src/bundle/Controller/ContentTypeController.php index 02df4adc4f..585af7af6a 100644 --- a/src/bundle/Controller/ContentTypeController.php +++ b/src/bundle/Controller/ContentTypeController.php @@ -8,6 +8,7 @@ namespace Ibexa\Bundle\AdminUi\Controller; +use Exception; use Ibexa\AdminUi\Form\Data\ContentType\ContentTypeCopyData; use Ibexa\AdminUi\Form\Data\ContentType\ContentTypeEditData; use Ibexa\AdminUi\Form\Data\ContentType\ContentTypesDeleteData; @@ -47,73 +48,28 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; -class ContentTypeController extends Controller +final class ContentTypeController extends Controller { - private const PRIMARY_UPDATE_ACTION = 'publishContentType'; - - private TranslatableNotificationHandlerInterface $notificationHandler; - - private TranslatorInterface $translator; - - private ContentTypeService $contentTypeService; - - private ActionDispatcherInterface $contentTypeActionDispatcher; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private UserService $userService; - - private LanguageService $languageService; - - private ContentTypeFormFactory $contentTypeFormFactory; - - private ContentTypeDraftMapper $contentTypeDraftMapper; - - private ConfigResolverInterface $configResolver; - - private FieldTypeToolbarFactory $fieldTypeToolbarFactory; - - private MetaFieldDefinitionServiceInterface $metaFieldDefinitionService; + private const string PRIMARY_UPDATE_ACTION = 'publishContentType'; public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - TranslatorInterface $translator, - ContentTypeService $contentTypeService, - ActionDispatcherInterface $contentTypeActionDispatcher, - FormFactory $formFactory, - SubmitHandler $submitHandler, - UserService $userService, - LanguageService $languageService, - ContentTypeFormFactory $contentTypeFormFactory, - ContentTypeDraftMapper $contentTypeDraftMapper, - ConfigResolverInterface $configResolver, - FieldTypeToolbarFactory $fieldTypeToolbarFactory, - MetaFieldDefinitionServiceInterface $metaFieldDefinitionService + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly TranslatorInterface $translator, + private readonly ContentTypeService $contentTypeService, + private readonly ActionDispatcherInterface $contentTypeActionDispatcher, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly UserService $userService, + private readonly LanguageService $languageService, + private readonly ContentTypeFormFactory $contentTypeFormFactory, + private readonly ContentTypeDraftMapper $contentTypeDraftMapper, + private readonly ConfigResolverInterface $configResolver, + private readonly FieldTypeToolbarFactory $fieldTypeToolbarFactory, + private readonly MetaFieldDefinitionServiceInterface $metaFieldDefinitionService ) { - $this->notificationHandler = $notificationHandler; - $this->translator = $translator; - $this->contentTypeService = $contentTypeService; - $this->contentTypeActionDispatcher = $contentTypeActionDispatcher; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->userService = $userService; - $this->languageService = $languageService; - $this->contentTypeFormFactory = $contentTypeFormFactory; - $this->contentTypeDraftMapper = $contentTypeDraftMapper; - $this->configResolver = $configResolver; - $this->fieldTypeToolbarFactory = $fieldTypeToolbarFactory; - $this->metaFieldDefinitionService = $metaFieldDefinitionService; } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param string $routeName - * @param int $page - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \Pagerfanta\Exception\OutOfRangeCurrentPageException * @throws \Pagerfanta\Exception\LessThan1CurrentPageException @@ -123,7 +79,10 @@ public function listAction(ContentTypeGroup $group, string $routeName, int $page { $deletableTypes = []; $contentTypes = iterator_to_array( - $this->contentTypeService->loadContentTypes($group, $this->configResolver->getParameter('languages')) + $this->contentTypeService->loadContentTypes( + $group, + $this->configResolver->getParameter('languages') + ) ); usort($contentTypes, static function (ContentType $contentType1, ContentType $contentType2): int { @@ -134,7 +93,9 @@ public function listAction(ContentTypeGroup $group, string $routeName, int $page new ArrayAdapter($contentTypes) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.content_type_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.content_type_limit') + ); $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); /** @var \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup[] $contentTypeGroupList */ @@ -149,7 +110,7 @@ public function listAction(ContentTypeGroup $group, string $routeName, int $page } $copyData = new ContentTypeCopyData(null, $group); - $contentTypeCopyForm = $this->contentTypeFormFactory->contentTypeCopy($copyData, null)->createView(); + $contentTypeCopyForm = $this->contentTypeFormFactory->contentTypeCopy($copyData)->createView(); return $this->render('@ibexadesign/content_type/list.html.twig', [ 'content_type_group' => $group, @@ -168,14 +129,15 @@ public function listAction(ContentTypeGroup $group, string $routeName, int $page /** * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentTypeFieldDefinitionValidationException */ public function addAction(ContentTypeGroup $group): RedirectResponse|ContentTypeCreateView { $this->denyAccessUnlessGranted(new Attribute('class', 'create')); $mainLanguageCode = $this->languageService->getDefaultLanguageCode(); - $createStruct = $this->contentTypeService->newContentTypeCreateStruct('__new__' . md5((string)microtime(true))); + $createStruct = $this->contentTypeService->newContentTypeCreateStruct( + '__new__' . md5((string)microtime(true)) + ); $createStruct->mainLanguageCode = $mainLanguageCode; $createStruct->names = [$mainLanguageCode => 'New content type']; @@ -209,11 +171,6 @@ public function addAction(ContentTypeGroup $group): RedirectResponse|ContentType return $view; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addTranslationAction(Request $request): Response { $form = $this->contentTypeFormFactory->addContentTypeTranslation( @@ -235,7 +192,7 @@ public function addTranslationAction(Request $request): Response try { $contentTypeDraft = $this->tryToCreateContentTypeDraft($contentType); - } catch (BadStateException $e) { + } catch (BadStateException) { $userId = $contentType->modifierId; $this->notificationHandler->error( /** @Desc("Draft of content type '%name%' already exists and is locked by '%userContentName%'") */ @@ -253,8 +210,8 @@ public function addTranslationAction(Request $request): Response return new RedirectResponse($this->generateUrl('ibexa.content_type.update', [ 'contentTypeId' => $contentTypeDraft->id, 'contentTypeGroupId' => $contentTypeGroup->id, - 'fromLanguageCode' => null !== $baseLanguage ? $baseLanguage->languageCode : null, - 'toLanguageCode' => $language->languageCode, + 'fromLanguageCode' => $baseLanguage?->getLanguageCode(), + 'toLanguageCode' => $language->getLanguageCode(), ])); }); @@ -269,11 +226,6 @@ public function addTranslationAction(Request $request): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function removeTranslationAction(Request $request): Response { $form = $this->contentTypeFormFactory->removeContentTypeTranslation( @@ -293,7 +245,7 @@ public function removeTranslationAction(Request $request): Response $contentTypeGroup = $data->getContentTypeGroup(); try { $contentTypeDraft = $this->tryToCreateContentTypeDraft($contentType); - } catch (BadStateException $e) { + } catch (BadStateException) { $userId = $contentType->modifierId; $this->notificationHandler->error( /** @Desc("Draft of content type '%name%' already exists and is locked by '%userContentName%'") */ @@ -308,7 +260,10 @@ public function removeTranslationAction(Request $request): Response ]); } foreach ($languageCodes as $languageCode => $isChecked) { - $newContentTypeDraft = $this->contentTypeService->removeContentTypeTranslation($contentTypeDraft, $languageCode); + $newContentTypeDraft = $this->contentTypeService->removeContentTypeTranslation( + $contentTypeDraft, + $languageCode + ); } $this->contentTypeService->publishContentTypeDraft($newContentTypeDraft); @@ -331,11 +286,6 @@ public function removeTranslationAction(Request $request): Response } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException */ @@ -344,7 +294,7 @@ public function editAction(Request $request, ContentTypeGroup $group, ContentTyp $this->denyAccessUnlessGranted(new Attribute('class', 'update')); try { $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentType->id, true); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType); } @@ -396,14 +346,6 @@ public function editAction(Request $request, ContentTypeGroup $group, ContentTyp ]); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException - */ public function copyAction(Request $request, ContentTypeGroup $group, ContentType $contentType): Response { $this->denyAccessUnlessGranted(new Attribute('class', 'create')); @@ -417,31 +359,34 @@ public function copyAction(Request $request, ContentTypeGroup $group, ContentTyp $form->handleRequest($request); if ($form->isSubmitted()) { - $result = $this->submitHandler->handle($form, function (ContentTypeCopyData $data) use ($contentTypeService, $notificationHandler): RedirectResponse { - $contentType = $data->getContentType(); - - try { - $contentTypeService->copyContentType($contentType); - - $notificationHandler->success( - /** @Desc("Content type '%name%' copied.") */ - 'content_type.copy.success', - ['%name%' => $contentType->getName()], - 'ibexa_content_type' - ); - } catch (UnauthorizedException $exception) { - $notificationHandler->error( - /** @Desc("Content type '%name%' cannot be copied.") */ - 'content_type.copy.error', - ['%name%' => $contentType->getName()], - 'ibexa_content_type' - ); + $result = $this->submitHandler->handle( + $form, + function (ContentTypeCopyData $data) use ($contentTypeService, $notificationHandler): RedirectResponse { + $contentType = $data->getContentType(); + + try { + $contentTypeService->copyContentType($contentType); + + $notificationHandler->success( + /** @Desc("Content type '%name%' copied.") */ + 'content_type.copy.success', + ['%name%' => $contentType->getName()], + 'ibexa_content_type' + ); + } catch (UnauthorizedException) { + $notificationHandler->error( + /** @Desc("Content type '%name%' cannot be copied.") */ + 'content_type.copy.error', + ['%name%' => $contentType->getName()], + 'ibexa_content_type' + ); + } + + return $this->redirectToRoute('ibexa.content_type_group.view', [ + 'contentTypeGroupId' => $data->getContentTypeGroup()->id, + ]); } - - return $this->redirectToRoute('ibexa.content_type_group.view', [ - 'contentTypeGroupId' => $data->getContentTypeGroup()->id, - ]); - }); + ); if ($result instanceof Response) { return $result; @@ -454,14 +399,6 @@ public function copyAction(Request $request, ContentTypeGroup $group, ContentTyp } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $baseLanguage - * - * @return \Symfony\Component\HttpFoundation\Response|\Ibexa\AdminUi\View\ContentTypeEditView - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ public function updateAction( @@ -485,7 +422,7 @@ public function updateAction( $contentTypeDraft, $language, $baseLanguage - ) { + ): Response { $action = $form->getClickedButton() ? $form->getClickedButton()->getName() : self::PRIMARY_UPDATE_ACTION; $this->contentTypeActionDispatcher->dispatchFormAction( $form, @@ -509,7 +446,7 @@ public function updateAction( return $this->redirectToRoute('ibexa.content_type.view', [ 'contentTypeGroupId' => $group->id, 'contentTypeId' => $contentTypeDraft->id, - 'languageCode' => $language->languageCode, + 'languageCode' => $language->getLanguageCode(), ]); } @@ -517,7 +454,7 @@ public function updateAction( 'contentTypeGroupId' => $group->id, 'contentTypeId' => $contentTypeDraft->id, 'toLanguageCode' => $language->languageCode, - 'fromLanguageCode' => $baseLanguage ? $baseLanguage->languageCode : null, + 'fromLanguageCode' => $baseLanguage ? $baseLanguage->getLanguageCode() : null, ]); }); @@ -572,7 +509,7 @@ public function addFieldDefinitionFormAction( 'form' => $fieldDefinitionsGroupForm[$fieldDefinitionIdentifier], 'content_type_group' => $group, 'content_type' => $contentTypeDraft, - 'language_code' => $baseLanguage ? $baseLanguage->languageCode : $language->languageCode, + 'language_code' => $baseLanguage ? $baseLanguage->getLanguageCode() : $language->getLanguageCode(), 'is_translation' => $contentTypeDraftData->mainLanguageCode !== $contentTypeDraftData->languageCode, ]); } @@ -581,12 +518,6 @@ public function addFieldDefinitionFormAction( } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException */ public function deleteAction(Request $request, ContentTypeGroup $group, ContentType $contentType): Response @@ -618,13 +549,6 @@ public function deleteAction(Request $request, ContentTypeGroup $group, ContentT } /** - * Handles removing content types based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \InvalidArgumentException @@ -658,15 +582,13 @@ public function bulkDeleteAction(Request $request, ContentTypeGroup $group): Res } } - return $this->redirectToRoute('ibexa.content_type_group.view', ['contentTypeGroupId' => $group->id]); + return $this->redirectToRoute( + 'ibexa.content_type_group.view', + ['contentTypeGroupId' => $group->id] + ); } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ public function viewAction( @@ -687,8 +609,8 @@ public function viewAction( } $fieldDefinitionsByGroup = []; - foreach ($contentType->fieldDefinitions as $fieldDefinition) { - $fieldDefinitionsByGroup[$fieldDefinition->fieldGroup ?: 'content'][] = $fieldDefinition; + foreach ($contentType->getFieldDefinitions() as $fieldDefinition) { + $fieldDefinitionsByGroup[$fieldDefinition->getFieldGroup() ?: 'content'][] = $fieldDefinition; } $languages = []; foreach ($contentType->languageCodes as $languageCode) { @@ -720,17 +642,12 @@ public function viewAction( } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $baseLanguage - * - * @return \Symfony\Component\Form\FormInterface + * @return FormInterface */ public function createUpdateForm( ContentTypeGroup $contentTypeGroup, ContentTypeDraft $contentTypeDraft, - Language $language = null, + ?Language $language = null, ?Language $baseLanguage = null ): FormInterface { $this->metaFieldDefinitionService->addMetaFieldDefinitions($contentTypeDraft, $language); @@ -747,19 +664,16 @@ public function createUpdateForm( 'action' => $this->generateUrl('ibexa.content_type.update', [ 'contentTypeGroupId' => $contentTypeGroup->id, 'contentTypeId' => $contentTypeDraft->id, - 'fromLanguageCode' => $baseLanguage ? $baseLanguage->languageCode : null, - 'toLanguageCode' => $language->languageCode, + 'fromLanguageCode' => $baseLanguage ? $baseLanguage->getLanguageCode() : null, + 'toLanguageCode' => $language->getLanguageCode(), ]), - 'languageCode' => $language->languageCode, + 'languageCode' => $language->getLanguageCode(), 'mainLanguageCode' => $contentTypeDraft->mainLanguageCode, ]); } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Symfony\Component\Form\FormInterface + * @return FormInterface */ protected function createDeleteForm(ContentTypeGroup $group, ContentType $contentType): FormInterface { @@ -787,10 +701,6 @@ private function getContentTypesNumbers(array $contentTypes): array } /** - * @param int $userId - * - * @return string|null - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException */ private function getUserNameById(int $userId): ?string @@ -799,7 +709,7 @@ private function getUserNameById(int $userId): ?string $user = $this->userService->loadUser($userId); return $user->getName(); - } catch (\Exception $e) { + } catch (Exception) { return $this->translator->trans( /** @Desc("another user") */ 'content_type.user_name.can_not_be_fetched', @@ -810,10 +720,6 @@ private function getUserNameById(int $userId): ?string } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Language - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ private function getDefaultLanguage(ContentTypeDraft $contentTypeDraft): Language @@ -832,10 +738,6 @@ private function getDefaultLanguage(ContentTypeDraft $contentTypeDraft): Languag } /** - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType $contentType - * - * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeDraft - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ @@ -844,7 +746,8 @@ private function tryToCreateContentTypeDraft(ContentType $contentType): ContentT try { $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentType->id); $this->contentTypeService->deleteContentType($contentTypeDraft); - } catch (NotFoundException $e) { + } catch (NotFoundException) { + //do nothing } finally { return $this->contentTypeService->createContentTypeDraft($contentType); } diff --git a/src/bundle/Controller/ContentTypeGroupController.php b/src/bundle/Controller/ContentTypeGroupController.php index 1919908f6f..e85435f84c 100644 --- a/src/bundle/Controller/ContentTypeGroupController.php +++ b/src/bundle/Controller/ContentTypeGroupController.php @@ -29,37 +29,17 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class ContentTypeGroupController extends Controller +final class ContentTypeGroupController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private ContentTypeService $contentTypeService; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - ContentTypeService $contentTypeService, - FormFactory $formFactory, - SubmitHandler $submitHandler, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly ContentTypeService $contentTypeService, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->contentTypeService = $contentTypeService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->configResolver = $configResolver; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function listAction(Request $request): Response { $deletableContentTypeGroup = []; @@ -71,7 +51,9 @@ public function listAction(Request $request): Response new ArrayAdapter(iterator_to_array($this->contentTypeService->loadContentTypeGroups())) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.content_type_group_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.content_type_group_limit') + ); $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); /** @var \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup[] $contentTypeGroupList */ @@ -193,12 +175,6 @@ public function updateAction(Request $request, ContentTypeGroup $group): Respons ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function deleteAction(Request $request, ContentTypeGroup $group): Response { $this->denyAccessUnlessGranted(new Attribute('class', 'delete')); @@ -229,13 +205,6 @@ public function deleteAction(Request $request, ContentTypeGroup $group): Respons return $this->redirectToRoute('ibexa.content_type_group.list'); } - /** - * Handles removing content type groups based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function bulkDeleteAction(Request $request): Response { $this->denyAccessUnlessGranted(new Attribute('class', 'delete')); @@ -267,13 +236,6 @@ public function bulkDeleteAction(Request $request): Response return $this->redirectToRoute('ibexa.content_type_group.list'); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup $group - * @param int $page - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function viewAction(Request $request, ContentTypeGroup $group, int $page = 1): Response { return $this->render('@ibexadesign/content_type/content_type_group/index.html.twig', [ @@ -287,7 +249,7 @@ public function viewAction(Request $request, ContentTypeGroup $group, int $page /** * @param \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup[] $contentTypeGroups * - * @return array + * @return array */ private function getContentTypeGroupsNumbers(array $contentTypeGroups): array { diff --git a/src/bundle/Controller/ContentViewController.php b/src/bundle/Controller/ContentViewController.php index c7b97e7bcf..5997440c22 100644 --- a/src/bundle/Controller/ContentViewController.php +++ b/src/bundle/Controller/ContentViewController.php @@ -24,12 +24,10 @@ use Ibexa\AdminUi\Permission\LookupLimitationsTransformer; use Ibexa\AdminUi\Specification\ContentIsUser; use Ibexa\AdminUi\Specification\ContentType\ContentTypeIsUserGroup; -use Ibexa\AdminUi\UI\Module\Subitems\ContentViewParameterSupplier; use Ibexa\AdminUi\UI\Module\Subitems\ContentViewParameterSupplier as SubitemsContentViewParameterSupplier; use Ibexa\AdminUi\UI\Service\PathService; use Ibexa\Contracts\AdminUi\Controller\Controller; use Ibexa\Contracts\Core\Repository\BookmarkService; -use Ibexa\Contracts\Core\Repository\ContentService; use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\LanguageService; use Ibexa\Contracts\Core\Repository\LocationService; @@ -49,98 +47,30 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; -class ContentViewController extends Controller +final class ContentViewController extends Controller { - private ContentTypeService $contentTypeService; - - private LanguageService $languageService; - - private PathService $pathService; - - private FormFactory $formFactory; - - private ContentViewParameterSupplier $subitemsContentViewParameterSupplier; - - private UserService $userService; - - private BookmarkService $bookmarkService; - - private ContentService $contentService; - - private LocationService $locationService; - - private UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider; - - private FormFactoryInterface $sfFormFactory; - - private ConfigResolverInterface $configResolver; - - private Repository $repository; - - private PermissionResolver $permissionResolver; - - private LookupLimitationsTransformer $lookupLimitationsTransformer; - - /** - * @param \Ibexa\Contracts\Core\Repository\ContentTypeService $contentTypeService - * @param \Ibexa\Contracts\Core\Repository\LanguageService $languageService - * @param \Ibexa\AdminUi\UI\Service\PathService $pathService - * @param \Ibexa\AdminUi\Form\Factory\FormFactory $formFactory - * @param \Symfony\Component\Form\FormFactoryInterface $sfFormFactory - * @param \Ibexa\AdminUi\UI\Module\Subitems\ContentViewParameterSupplier $subitemsContentViewParameterSupplier - * @param \Ibexa\Contracts\Core\Repository\UserService $userService - * @param \Ibexa\Contracts\Core\Repository\BookmarkService $bookmarkService - * @param \Ibexa\Contracts\Core\Repository\ContentService $contentService - * @param \Ibexa\Contracts\Core\Repository\LocationService $locationService - * @param \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider - * @param \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface $configResolver - * @param \Ibexa\Contracts\Core\Repository\Repository $repository - * @param \Ibexa\Contracts\Core\Repository\PermissionResolver $permissionResolver - * @param \Ibexa\AdminUi\Permission\LookupLimitationsTransformer $lookupLimitationsTransformer - */ public function __construct( - ContentTypeService $contentTypeService, - LanguageService $languageService, - PathService $pathService, - FormFactory $formFactory, - FormFactoryInterface $sfFormFactory, - SubitemsContentViewParameterSupplier $subitemsContentViewParameterSupplier, - UserService $userService, - BookmarkService $bookmarkService, - ContentService $contentService, - LocationService $locationService, - UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, - ConfigResolverInterface $configResolver, - Repository $repository, - PermissionResolver $permissionResolver, - LookupLimitationsTransformer $lookupLimitationsTransformer + private readonly ContentTypeService $contentTypeService, + private readonly LanguageService $languageService, + private readonly PathService $pathService, + private readonly FormFactory $formFactory, + private readonly FormFactoryInterface $sfFormFactory, + private readonly SubitemsContentViewParameterSupplier $subitemsContentViewParameterSupplier, + private readonly UserService $userService, + private readonly BookmarkService $bookmarkService, + private readonly LocationService $locationService, + private readonly UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, + private readonly ConfigResolverInterface $configResolver, + private readonly Repository $repository, + private readonly PermissionResolver $permissionResolver, + private readonly LookupLimitationsTransformer $lookupLimitationsTransformer ) { - $this->contentTypeService = $contentTypeService; - $this->languageService = $languageService; - $this->pathService = $pathService; - $this->formFactory = $formFactory; - $this->sfFormFactory = $sfFormFactory; - $this->subitemsContentViewParameterSupplier = $subitemsContentViewParameterSupplier; - $this->userService = $userService; - $this->bookmarkService = $bookmarkService; - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider; - $this->configResolver = $configResolver; - $this->permissionResolver = $permissionResolver; - $this->lookupLimitationsTransformer = $lookupLimitationsTransformer; - $this->repository = $repository; } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * - * @return \Ibexa\Core\MVC\Symfony\View\ContentView - * - * @throws \Ibexa\AdminUi\Exception\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ public function locationViewAction(Request $request, ContentView $view): ContentView @@ -178,10 +108,6 @@ public function locationViewAction(Request $request, ContentView $view): Content } /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * - * @return \Ibexa\Core\MVC\Symfony\View\ContentView - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ public function embedViewAction(ContentView $view): ContentView @@ -196,37 +122,30 @@ public function embedViewAction(ContentView $view): ContentView return $view; } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - */ private function supplyPathLocations(ContentView $view): void { $location = $view->getLocation(); + if ($location === null) { + return; + } + $pathLocations = $this->pathService->loadPathLocations($location); $view->addParameters(['path_locations' => $pathLocations]); } /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ private function supplyContentType(ContentView $view): void { $contentType = $this->contentTypeService->loadContentType( - $view->getContent()->contentInfo->contentTypeId, + $view->getContent()->getContentInfo()->contentTypeId, $this->userLanguagePreferenceProvider->getPreferredLanguages() ); + $view->addParameters(['content_type' => $contentType]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * - * @throws \Ibexa\AdminUi\Exception\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException - */ private function supplyContentActionForms(ContentView $view): void { $location = $view->getLocation(); @@ -259,7 +178,7 @@ private function supplyContentActionForms(ContentView $view): void new ContentVisibilityUpdateData( $location->getContentInfo(), $location, - $location->getContentInfo()->isHidden + $location->getContentInfo()->isHidden() ) ); @@ -268,7 +187,7 @@ private function supplyContentActionForms(ContentView $view): void ); $contentEditType = $this->createContentEditForm( - $content->contentInfo, + $content->getContentInfo(), $versionInfo, null, $location @@ -287,10 +206,10 @@ private function supplyContentActionForms(ContentView $view): void if ((new ContentIsUser($this->userService))->isSatisfiedBy($content)) { $userDeleteType = $this->formFactory->deleteUser( - new UserDeleteData($content->contentInfo) + new UserDeleteData($content->getContentInfo()), ); $userEditType = $this->formFactory->editUser( - new UserEditData($content->contentInfo, $versionInfo, null, $location) + new UserEditData($content->getContentInfo(), $versionInfo, null, $location) ); $view->addParameters([ @@ -300,21 +219,13 @@ private function supplyContentActionForms(ContentView $view): void } } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo|null $contentInfo - * @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo|null $versionInfo - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language|null $language - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * - * @return \Symfony\Component\Form\FormInterface - */ private function createContentEditForm( ?ContentInfo $contentInfo = null, ?VersionInfo $versionInfo = null, ?Language $language = null, ?Location $location = null ): FormInterface { - $languageCodes = $versionInfo->languageCodes ?? []; + $languageCodes = $versionInfo->getLanguageCodes() ?? []; return $this->formFactory->contentEdit( new ContentEditData($contentInfo, null, $language, $location), @@ -333,10 +244,6 @@ private function createContentEditForm( ); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * @param \Symfony\Component\HttpFoundation\Request $request - */ private function supplyDraftPagination(ContentView $view, Request $request): void { $page = $request->query->all('page'); @@ -367,10 +274,6 @@ private function supplyRelationPagination(ContentView $view, Request $request): ]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * @param \Symfony\Component\HttpFoundation\Request $request - */ private function supplyReverseRelationPagination(ContentView $view, Request $request): void { $page = $request->query->all('page'); @@ -381,15 +284,13 @@ private function supplyReverseRelationPagination(ContentView $view, Request $req 'route_params' => $request->get('_route_params'), 'page' => (int) ($page['reverse_relation'] ?? 1), 'pages_map' => $page, - 'limit' => $this->configResolver->getParameter('pagination.reverse_relation_limit'), + 'limit' => $this->configResolver->getParameter( + 'pagination.reverse_relation_limit' + ), ], ]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * @param \Symfony\Component\HttpFoundation\Request $request - */ private function supplyCustomUrlPagination(ContentView $view, Request $request): void { $page = $request->query->all('page'); @@ -399,15 +300,13 @@ private function supplyCustomUrlPagination(ContentView $view, Request $request): 'route_name' => $request->get('_route'), 'route_params' => $request->get('_route_params'), 'page' => (int) ($page['custom_url'] ?? 1), - 'limit' => $this->configResolver->getParameter('pagination.content_custom_url_limit'), + 'limit' => $this->configResolver->getParameter( + 'pagination.content_custom_url_limit' + ), ], ]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * @param \Symfony\Component\HttpFoundation\Request $request - */ private function supplySystemUrlPagination(ContentView $view, Request $request): void { $page = $request->query->all('page'); @@ -417,15 +316,13 @@ private function supplySystemUrlPagination(ContentView $view, Request $request): 'route_name' => $request->get('_route'), 'route_params' => $request->get('_route_params'), 'page' => (int) ($page['system_url'] ?? 1), - 'limit' => $this->configResolver->getParameter('pagination.content_system_url_limit'), + 'limit' => $this->configResolver->getParameter( + 'pagination.content_system_url_limit' + ), ], ]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * @param \Symfony\Component\HttpFoundation\Request $request - */ private function supplyRolePagination(ContentView $view, Request $request): void { $page = $request->query->all('page'); @@ -435,15 +332,13 @@ private function supplyRolePagination(ContentView $view, Request $request): void 'route_name' => $request->get('_route'), 'route_params' => $request->get('_route_params'), 'page' => (int) ($page['role'] ?? 1), - 'limit' => $this->configResolver->getParameter('pagination.content_role_limit'), + 'limit' => $this->configResolver->getParameter( + 'pagination.content_role_limit' + ), ], ]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - * @param \Symfony\Component\HttpFoundation\Request $request - */ private function supplyPolicyPagination(ContentView $view, Request $request): void { $page = $request->query->all('page'); @@ -453,14 +348,13 @@ private function supplyPolicyPagination(ContentView $view, Request $request): vo 'route_name' => $request->get('_route'), 'route_params' => $request->get('_route_params'), 'page' => (int) ($page['policy'] ?? 1), - 'limit' => $this->configResolver->getParameter('pagination.content_policy_limit'), + 'limit' => $this->configResolver->getParameter( + 'pagination.content_policy_limit' + ), ], ]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - */ private function supplyContentTreeParameters(ContentView $view): void { $view->addParameters([ @@ -469,10 +363,6 @@ private function supplyContentTreeParameters(ContentView $view): void } /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * - * @return int - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ private function resolveTreeRootLocationId(?Location $location): int @@ -481,55 +371,52 @@ private function resolveTreeRootLocationId(?Location $location): int return $this->configResolver->getParameter('content_tree_module.tree_root_location_id'); } - $contextualContentTreeRootLocationIds = $this->configResolver->getParameter('content_tree_module.contextual_tree_root_location_ids'); + $contextualContentTreeRootLocationIds = $this->configResolver->getParameter( + 'content_tree_module.contextual_tree_root_location_ids' + ); + $possibleContentTreeRoots = array_intersect($location->path, $contextualContentTreeRootLocationIds); - if (\is_array($this->permissionResolver->hasAccess('content', 'read'))) { + if (is_array($this->permissionResolver->hasAccess('content', 'read'))) { $accessibleLocations = $this->locationService->loadLocationList($possibleContentTreeRoots); $possibleContentTreeRoots = array_column($accessibleLocations, 'id'); } if (empty($possibleContentTreeRoots)) { // if a user has no access to any tree root than current location id is set - return $location->id; + return $location->getId(); } // use the outermost ancestor return (int)reset($possibleContentTreeRoots); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Location|null $location - * - * @return \Ibexa\AdminUi\Form\Data\Content\Draft\ContentCreateData - */ private function getContentCreateData(?Location $location): ContentCreateData { - $languages = $this->languageService->loadLanguages(); - $language = 1 === \count($languages) + $languages = iterator_to_array($this->languageService->loadLanguages()); + $language = 1 === count($languages) ? array_shift($languages) : null; return new ContentCreateData(null, $location, $language); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - */ private function supplyIsLocationBookmarked(ContentView $view): void { - $locationIsBookmarked = $view->getLocation() ? $this->bookmarkService->isBookmarked($view->getLocation()) : false; + $locationIsBookmarked = $view->getLocation() && $this->bookmarkService->isBookmarked($view->getLocation()); $view->addParameters(['location_is_bookmarked' => $locationIsBookmarked]); } - /** - * @param \Ibexa\Core\MVC\Symfony\View\ContentView $view - */ private function supplyContentReverseRelations(ContentView $view): void { - $contentInfo = $view->getLocation()->getContentInfo(); + $location = $view->getLocation(); + if ($location === null) { + return; + } - $hasReverseRelations = $this->permissionResolver->sudo( + $contentInfo = $location->getContentInfo(); + + $hasReverseRelations = $this->repository->sudo( static function (Repository $repository) use ($contentInfo): bool { return $repository->getContentService()->countReverseRelations($contentInfo) > 0; }, @@ -546,7 +433,11 @@ private function supplyUserInvitation(ContentView $view): void $view->getContent()->getVersionInfo()->getContentInfo()->contentTypeId, $this->userLanguagePreferenceProvider->getPreferredLanguages() ); - $userGroupContentTypeIdentifier = $this->configResolver->getParameter('user_group_content_type_identifier'); + + $userGroupContentTypeIdentifier = $this->configResolver->getParameter( + 'user_group_content_type_identifier' + ); + $contentIsUserGroup = (new ContentTypeIsUserGroup($userGroupContentTypeIdentifier)) ->isSatisfiedBy($contentType); diff --git a/src/bundle/Controller/DashboardController.php b/src/bundle/Controller/DashboardController.php index 9eacfb90eb..664c0cf449 100644 --- a/src/bundle/Controller/DashboardController.php +++ b/src/bundle/Controller/DashboardController.php @@ -14,34 +14,20 @@ use Ibexa\Contracts\Core\Repository\PermissionResolver; use Symfony\Component\HttpFoundation\Response; -class DashboardController extends Controller +final class DashboardController extends Controller { - protected FormFactory $formFactory; - - private PermissionResolver $permissionResolver; - - /** - * @param \Ibexa\AdminUi\Form\Factory\FormFactory $formFactory - * @param \Ibexa\Contracts\Core\Repository\PermissionResolver $permissionResolver - */ public function __construct( - FormFactory $formFactory, - PermissionResolver $permissionResolver + private readonly FormFactory $formFactory, + private readonly PermissionResolver $permissionResolver ) { - $this->formFactory = $formFactory; - $this->permissionResolver = $permissionResolver; } /** - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function dashboardAction(): Response { - $editForm = $this->formFactory->contentEdit( - new ContentEditData() - ); + $editForm = $this->formFactory->contentEdit(new ContentEditData()); return $this->render('@ibexadesign/ui/dashboard/dashboard.html.twig', [ 'form_edit' => $editForm, diff --git a/src/bundle/Controller/DownloadImageController.php b/src/bundle/Controller/DownloadImageController.php index 0557ae943a..18d14df79b 100644 --- a/src/bundle/Controller/DownloadImageController.php +++ b/src/bundle/Controller/DownloadImageController.php @@ -23,32 +23,19 @@ final class DownloadImageController extends Controller { - private const EXTENSION_ZIP = '.zip'; + private const string EXTENSION_ZIP = '.zip'; - private const ARCHIVE_NAME_PATTERN = 'images_%s' . self::EXTENSION_ZIP; - - private int $downloadLimit; - - private FormatterInterface $formatter; - - /** @var array */ - private array $imageMappings; - - private SearchService $searchService; + private const string ARCHIVE_NAME_PATTERN = 'images_%s' . self::EXTENSION_ZIP; /** * @param array $imageMappings */ public function __construct( - int $downloadLimit, - FormatterInterface $formatter, - array $imageMappings, - SearchService $searchService + private readonly int $downloadLimit, + private readonly FormatterInterface $formatter, + private readonly array $imageMappings, + private readonly SearchService $searchService ) { - $this->downloadLimit = $downloadLimit; - $this->formatter = $formatter; - $this->imageMappings = $imageMappings; - $this->searchService = $searchService; } /** @@ -178,7 +165,10 @@ private function downloadArchiveWithImages(array $contentList): Response private function getImageValue(Content $content): Value { - $imageFieldIdentifier = $this->getImageFieldIdentifier($content->getContentType()->identifier); + $imageFieldIdentifier = $this->getImageFieldIdentifier( + $content->getContentType()->getIdentifier() + ); + $value = $content->getFieldValue($imageFieldIdentifier); if (null === $value) { @@ -241,8 +231,8 @@ private function getImageFileName(Value $value): string * * @phpstan-return \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult<\Ibexa\Contracts\Core\Repository\Values\Content\Content> * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException; + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException */ private function loadImages(array $contentIdList): SearchResult { diff --git a/src/bundle/Controller/FieldDefinitionController.php b/src/bundle/Controller/FieldDefinitionController.php index 47c72fc991..25692829dd 100644 --- a/src/bundle/Controller/FieldDefinitionController.php +++ b/src/bundle/Controller/FieldDefinitionController.php @@ -25,14 +25,10 @@ final class FieldDefinitionController extends RestController { - private ContentTypeService $contentTypeService; - - private UrlGeneratorInterface $urlGenerator; - - public function __construct(ContentTypeService $contentTypeService, UrlGeneratorInterface $urlGenerator) - { - $this->contentTypeService = $contentTypeService; - $this->urlGenerator = $urlGenerator; + public function __construct( + private readonly ContentTypeService $contentTypeService, + private readonly UrlGeneratorInterface $urlGenerator + ) { } public function addFieldDefinitionAction( @@ -52,7 +48,7 @@ public function addFieldDefinitionAction( $fieldDefinitionCreateStruct = $this->contentTypeService->newFieldDefinitionCreateStruct( uniqid('field_'), - $input->fieldTypeIdentifier + $input->fieldTypeIdentifier ?? '' ); $fieldDefinitionCreateStruct->fieldGroup = $input->fieldGroupIdentifier; @@ -74,8 +70,8 @@ public function addFieldDefinitionAction( 'fieldDefinitionIdentifier' => $fieldDefinitionCreateStruct->identifier, 'contentTypeGroupId' => $group->id, 'contentTypeId' => $contentTypeDraft->id, - 'toLanguageCode' => $language->languageCode, - 'fromLanguageCode' => $baseLanguage ? $baseLanguage->languageCode : null, + 'toLanguageCode' => $language->getLanguageCode(), + 'fromLanguageCode' => $baseLanguage?->getLanguageCode(), ] ) ); @@ -97,13 +93,13 @@ public function removeFieldDefinitionAction( $this->repository->beginTransaction(); try { foreach ($input->fieldDefinitionIdentifiers as $identifier) { - if (!$contentTypeDraft->fieldDefinitions->has($identifier)) { + if (!$contentTypeDraft->getFieldDefinitions()->has($identifier)) { throw new Exceptions\NotFoundException("No field definition with $identifier found"); } $this->contentTypeService->removeFieldDefinition( $contentTypeDraft, - $contentTypeDraft->fieldDefinitions->get($identifier) + $contentTypeDraft->getFieldDefinitions()->get($identifier) ); } @@ -159,8 +155,8 @@ public function reorderFieldDefinitionsAction( private function getNextFieldPosition(ContentType $contentType): int { - if (!$contentType->fieldDefinitions->isEmpty()) { - return $contentType->fieldDefinitions->last()->position + 1; + if (!$contentType->getFieldDefinitions()->isEmpty()) { + return $contentType->getFieldDefinitions()->last()->getPosition() + 1; } return 0; diff --git a/src/bundle/Controller/LanguageController.php b/src/bundle/Controller/LanguageController.php index 9f26101f65..24b4c06193 100644 --- a/src/bundle/Controller/LanguageController.php +++ b/src/bundle/Controller/LanguageController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -30,43 +31,18 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class LanguageController extends Controller +final class LanguageController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private LanguageService $languageService; - - private LanguageCreateMapper $languageCreateMapper; - - private SubmitHandler $submitHandler; - - private FormFactory $formFactory; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - LanguageService $languageService, - LanguageCreateMapper $languageCreateMapper, - SubmitHandler $submitHandler, - FormFactory $formFactory, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly LanguageService $languageService, + private readonly LanguageCreateMapper $languageCreateMapper, + private readonly SubmitHandler $submitHandler, + private readonly FormFactory $formFactory, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->languageService = $languageService; - $this->languageCreateMapper = $languageCreateMapper; - $this->submitHandler = $submitHandler; - $this->formFactory = $formFactory; - $this->configResolver = $configResolver; } - /** - * Renders the language list. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function listAction(Request $request): Response { $page = $request->query->getInt('page', 1); @@ -75,7 +51,10 @@ public function listAction(Request $request): Response new ArrayAdapter(iterator_to_array($this->languageService->loadLanguages())) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.language_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.language_limit') + ); + $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Language[] $languageList */ @@ -92,13 +71,6 @@ public function listAction(Request $request): Response ]); } - /** - * Renders the view of a language. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language $language - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function viewAction(Language $language): Response { $deleteForm = $this->formFactory->deleteLanguage( @@ -113,14 +85,6 @@ public function viewAction(Language $language): Response ]); } - /** - * Deletes a language. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language $language - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function deleteAction(Request $request, Language $language): Response { $form = $this->formFactory->deleteLanguage( @@ -137,7 +101,7 @@ public function deleteAction(Request $request, Language $language): Response $this->notificationHandler->success( /** @Desc("Language '%name%' removed.") */ 'language.delete.success', - ['%name%' => $language->name], + ['%name%' => $language->getName()], 'ibexa_language' ); }); @@ -150,20 +114,6 @@ public function deleteAction(Request $request, Language $language): Response return $this->redirectToRoute('ibexa.language.list'); } - /** - * Handles removing languages based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - * @throws \InvalidArgumentException - */ public function bulkDeleteAction(Request $request): Response { $form = $this->formFactory->deleteLanguages( @@ -180,7 +130,7 @@ public function bulkDeleteAction(Request $request): Response $this->notificationHandler->success( /** @Desc("Language '%name%' removed.") */ 'language.delete.success', - ['%name%' => $language->name], + ['%name%' => $language->getName()], 'ibexa_language' ); } @@ -216,12 +166,12 @@ public function createAction(Request $request): Response && $form->getClickedButton()->getName() === LanguageCreateType::BTN_SAVE ) { return $this->redirectToRoute('ibexa.language.edit', [ - 'languageId' => $language->id, + 'languageId' => $language->getId(), ]); } return new RedirectResponse($this->generateUrl('ibexa.language.view', [ - 'languageId' => $language->id, + 'languageId' => $language->getId(), ])); }); @@ -246,7 +196,9 @@ public function editAction(Request $request, Language $language): Response if ($form->isSubmitted()) { $result = $this->submitHandler->handle($form, function (LanguageUpdateData $data) use ($language, $form): Response { - $this->languageService->updateLanguageName($language, $data->getName()); + if ($data->getName() !== null) { + $this->languageService->updateLanguageName($language, $data->getName()); + } $data->isEnabled() ? $this->languageService->enableLanguage($language) @@ -263,12 +215,12 @@ public function editAction(Request $request, Language $language): Response && $form->getClickedButton()->getName() === LanguageUpdateType::BTN_SAVE ) { return $this->redirectToRoute('ibexa.language.edit', [ - 'languageId' => $language->id, + 'languageId' => $language->getId(), ]); } return new RedirectResponse($this->generateUrl('ibexa.language.view', [ - 'languageId' => $language->id, + 'languageId' => $language->getId(), ])); }); @@ -287,7 +239,7 @@ public function editAction(Request $request, Language $language): Response /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Language[] $languages * - * @return array + * @return array */ private function getLanguagesNumbers(array $languages): array { diff --git a/src/bundle/Controller/LinkManagerController.php b/src/bundle/Controller/LinkManagerController.php index e17407ea93..1f5d7e94e2 100644 --- a/src/bundle/Controller/LinkManagerController.php +++ b/src/bundle/Controller/LinkManagerController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -45,8 +46,8 @@ public function editAction(Request $request, int $urlId): Response /** @var \Symfony\Component\Form\Form $form */ $form = $this->formFactory->createUrlEditForm(new URLUpdateData([ - 'id' => $url->id, - 'url' => $url->url, + 'id' => $url->getId(), + 'url' => $url->getUrl(), ])); $form->handleRequest($request); @@ -65,7 +66,7 @@ public function editAction(Request $request, int $urlId): Response && $form->getClickedButton()->getName() === URLEditType::BTN_SAVE ) { return $this->redirectToRoute('ibexa.link_manager.edit', [ - 'urlId' => $url->id, + 'urlId' => $url->getId(), ]); } diff --git a/src/bundle/Controller/Location/LoadSubItemsController.php b/src/bundle/Controller/Location/LoadSubItemsController.php index b9a8ef4117..a14657200f 100644 --- a/src/bundle/Controller/Location/LoadSubItemsController.php +++ b/src/bundle/Controller/Location/LoadSubItemsController.php @@ -44,6 +44,9 @@ public function __construct(readonly private SearchService $searchService) { } + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + */ public function loadAction( Request $request, Location $location, @@ -77,13 +80,16 @@ private function getDefaultSortClause(Location $location): array { try { $sortClauses = $location->getSortClauses(); - } catch (NotImplementedException $e) { + } catch (NotImplementedException) { return []; } return $sortClauses; } + /** + * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException + */ private function buildSortClause(string $sortClause, string $sortOrder): SortClause { if (!isset(static::SORT_CLAUSE_MAP[$sortClause])) { @@ -111,7 +117,7 @@ private function buildSubItemsList(int $totalCount, array $childrenList): SubIte $versionInfo = $content->getVersionInfo(); $owner = $location->getContentInfo()->getOwner(); try { - $sectionName = $contentInfo->getSection()->name; + $sectionName = $contentInfo->getSection()->getName(); } catch (UnauthorizedException $e) { $sectionName = null; } diff --git a/src/bundle/Controller/LocationController.php b/src/bundle/Controller/LocationController.php index 936677c321..b43d07207f 100644 --- a/src/bundle/Controller/LocationController.php +++ b/src/bundle/Controller/LocationController.php @@ -8,6 +8,7 @@ namespace Ibexa\Bundle\AdminUi\Controller; +use Exception; use Ibexa\AdminUi\Form\Data\Content\Location\ContentLocationAddData; use Ibexa\AdminUi\Form\Data\Content\Location\ContentLocationRemoveData; use Ibexa\AdminUi\Form\Data\Location\LocationAssignSubtreeData; @@ -26,10 +27,8 @@ use Ibexa\Contracts\AdminUi\Controller\Controller; use Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface; use Ibexa\Contracts\Core\Repository\ContentService; -use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException as APIRepositoryUnauthorizedException; use Ibexa\Contracts\Core\Repository\LocationService; -use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\SectionService; use Ibexa\Contracts\Core\Repository\TrashService; @@ -44,79 +43,22 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; -class LocationController extends Controller +final class LocationController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private TranslatorInterface $translator; - - private ContentService $contentService; - - private LocationService $locationService; - - private ContentTypeService $contentTypeService; - - private TrashService $trashService; - - private SectionService $sectionService; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private PermissionResolver $permissionResolver; - - private Repository $repository; - - private TranslationHelper $translationHelper; - - /** - * @param \Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface $notificationHandler - * @param \Symfony\Contracts\Translation\TranslatorInterface $translator - * @param \Ibexa\Contracts\Core\Repository\LocationService $locationService - * @param \Ibexa\Contracts\Core\Repository\ContentTypeService $contentTypeService - * @param \Ibexa\Contracts\Core\Repository\ContentService $contentService - * @param \Ibexa\Contracts\Core\Repository\TrashService $trashService - * @param \Ibexa\Contracts\Core\Repository\SectionService $sectionService - * @param \Ibexa\AdminUi\Form\Factory\FormFactory $formFactory - * @param \Ibexa\AdminUi\Form\SubmitHandler $submitHandler - * @param \Ibexa\Contracts\Core\Repository\PermissionResolver $permissionResolver - * @param \Ibexa\Contracts\Core\Repository\Repository $repository - * @param \Ibexa\Core\Helper\TranslationHelper $translationHelper - */ public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - TranslatorInterface $translator, - LocationService $locationService, - ContentTypeService $contentTypeService, - ContentService $contentService, - TrashService $trashService, - SectionService $sectionService, - FormFactory $formFactory, - SubmitHandler $submitHandler, - PermissionResolver $permissionResolver, - Repository $repository, - TranslationHelper $translationHelper + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly TranslatorInterface $translator, + private readonly LocationService $locationService, + private readonly ContentService $contentService, + private readonly TrashService $trashService, + private readonly SectionService $sectionService, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly Repository $repository, + private readonly TranslationHelper $translationHelper ) { - $this->notificationHandler = $notificationHandler; - $this->translator = $translator; - $this->locationService = $locationService; - $this->contentService = $contentService; - $this->contentTypeService = $contentTypeService; - $this->trashService = $trashService; - $this->sectionService = $sectionService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->permissionResolver = $permissionResolver; - $this->repository = $repository; - $this->translationHelper = $translationHelper; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function moveAction(Request $request): Response { $form = $this->formFactory->moveLocation( @@ -144,13 +86,16 @@ public function moveAction(Request $request): Response $this->notificationHandler->success( /** @Desc("'%name%' moved to '%location%'") */ 'location.move.success', - ['%name%' => $location->getContentInfo()->name, '%location%' => $newParentLocation->getContentInfo()->name], + [ + '%name%' => $location->getContentInfo()->getName(), + '%location%' => $newParentLocation->getContentInfo()->getName(), + ], 'ibexa_location' ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $location->contentId, - 'locationId' => $location->id, + 'contentId' => $location->getContentId(), + 'locationId' => $location->getId(), ])); }); @@ -160,16 +105,11 @@ public function moveAction(Request $request): Response } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $location->contentId, - 'locationId' => $location->id, + 'contentId' => $location->getContentId(), + 'locationId' => $location->getId(), ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function copyAction(Request $request): Response { $form = $this->formFactory->copyLocation( @@ -183,6 +123,15 @@ public function copyAction(Request $request): Response if ($form->isSubmitted()) { $result = $this->submitHandler->handle($form, function (LocationCopyData $data): RedirectResponse { $location = $data->getLocation(); + if ($location === null) { + $this->notificationHandler->error( + /** @Desc("Location cannot be copied.") */ + 'location.copy.failure', + [], + 'ibexa_location' + ); + } + $newParentLocation = $data->getNewParentLocation(); if (!$newParentLocation->getContent()->getContentType()->isContainer()) { @@ -192,13 +141,18 @@ public function copyAction(Request $request): Response ); } - $locationCreateStruct = $this->locationService->newLocationCreateStruct($newParentLocation->id); + $locationCreateStruct = $this->locationService->newLocationCreateStruct( + $newParentLocation->getId() + ); + $copiedContent = $this->contentService->copyContent( - $location->contentInfo, + $location->getContentInfo(), $locationCreateStruct ); - $newLocation = $this->locationService->loadLocation($copiedContent->contentInfo->mainLocationId); + $newLocation = $this->locationService->loadLocation( + $copiedContent->getContentInfo()->getMainLocationId() + ); $this->notificationHandler->success( /** @Desc("'%name%' copied to '%location%'") */ @@ -208,8 +162,8 @@ public function copyAction(Request $request): Response ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $newLocation->contentId, - 'locationId' => $newLocation->id, + 'contentId' => $newLocation->getContentId(), + 'locationId' => $newLocation->getId(), ])); }); @@ -219,16 +173,11 @@ public function copyAction(Request $request): Response } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $location->contentId, - 'locationId' => $location->id, + 'contentId' => $location->getContentId(), + 'locationId' => $location->getId(), ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function copySubtreeAction(Request $request): Response { $form = $this->formFactory->copyLocationSubtree( @@ -240,28 +189,33 @@ public function copySubtreeAction(Request $request): Response $location = $form->getData()->getLocation(); if ($form->isSubmitted()) { - $result = $this->submitHandler->handle($form, function (LocationCopySubtreeData $data) use ($location): RedirectResponse { - $newParentLocation = $data->getNewParentLocation(); + $result = $this->submitHandler->handle( + $form, + function (LocationCopySubtreeData $data) use ($location): RedirectResponse { + $newParentLocation = $data->getNewParentLocation(); - $copiedContent = $this->locationService->copySubtree( - $location, - $newParentLocation - ); + $copiedContent = $this->locationService->copySubtree( + $location, + $newParentLocation + ); - $newLocation = $this->locationService->loadLocation($copiedContent->contentInfo->mainLocationId); + $newLocation = $this->locationService->loadLocation( + $copiedContent->getContentInfo()->getMainLocationId() + ); - $this->notificationHandler->success( - /** @Desc("Subtree '%name%' copied to Location '%location%'") */ - 'location.copy_subtree.success', - [ - '%name%' => $location->getContentInfo()->name, - '%location%' => $newParentLocation->getContentInfo()->name, - ], - 'ibexa_location' - ); + $this->notificationHandler->success( + /** @Desc("Subtree '%name%' copied to Location '%location%'") */ + 'location.copy_subtree.success', + [ + '%name%' => $location->getContentInfo()->getName(), + '%location%' => $newParentLocation->getContentInfo()->getName(), + ], + 'ibexa_location' + ); - return $this->redirectToLocation($newLocation); - }); + return $this->redirectToLocation($newLocation); + } + ); if ($result instanceof Response) { return $result; @@ -271,11 +225,6 @@ public function copySubtreeAction(Request $request): Response return $this->redirectToLocation($location); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function swapAction(Request $request): Response { $form = $this->formFactory->swapLocation( @@ -303,13 +252,16 @@ public function swapAction(Request $request): Response $this->notificationHandler->success( /** @Desc("Location '%name%' swapped with Location '%location%'") */ 'location.swap.success', - ['%name%' => $currentLocation->getContentInfo()->name, '%location%' => $newLocation->getContentInfo()->name], + [ + '%name%' => $currentLocation->getContentInfo()->getName(), + '%location%' => $newLocation->getContentInfo()->getName(), + ], 'ibexa_location' ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $currentLocation->contentId, - 'locationId' => $newLocation->id, + 'contentId' => $currentLocation->getContentId(), + 'locationId' => $newLocation->getId(), '_fragment' => LocationsTab::URI_FRAGMENT, ])); }); @@ -320,17 +272,12 @@ public function swapAction(Request $request): Response } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $location->contentId, - 'locationId' => $location->id, + 'contentId' => $location->getContentId(), + 'locationId' => $location->getId(), '_fragment' => LocationsTab::URI_FRAGMENT, ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function trashAction(Request $request): Response { $form = $this->formFactory->trashLocation( @@ -364,7 +311,7 @@ private function trashRelatedAsset(ContentInfo $contentInfo): void { $content = $this->contentService->loadContentByContentInfo($contentInfo); $relations = $this->contentService->loadRelationList( - $content->versionInfo, + $content->getVersionInfo(), 0, 1 ); @@ -383,17 +330,15 @@ private function trashRelatedAsset(ContentInfo $contentInfo): void } /** - * @param \Ibexa\AdminUi\Form\Data\Location\LocationTrashData $data - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException */ private function handleTrashLocation(LocationTrashData $data): RedirectResponse { $location = $data->getLocation(); - $parentLocation = $this->locationService->loadLocation($location->parentLocationId); + $parentLocation = $this->locationService->loadLocation( + $location->parentLocationId + ); $trashOptions = $data->getTrashOptions(); $this->repository->beginTransaction(); @@ -405,7 +350,7 @@ private function handleTrashLocation(LocationTrashData $data): RedirectResponse } $this->trashService->trash($location); $this->repository->commit(); - } catch (\Exception $exception) { + } catch (Exception $exception) { $this->repository->rollback(); throw $exception; } @@ -414,7 +359,7 @@ private function handleTrashLocation(LocationTrashData $data): RedirectResponse $this->translator->trans( /** @Desc("Location '%name%' moved to Trash.") */ 'location.trash.success', - ['%name%' => $location->getContentInfo()->name], + ['%name%' => $location->getContentInfo()->getName()], 'ibexa_location' ) ); @@ -422,13 +367,6 @@ private function handleTrashLocation(LocationTrashData $data): RedirectResponse return $this->redirectToLocation($parentLocation); } - /** - * Handles removing locations assigned to content item based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function removeAction(Request $request): Response { $form = $this->formFactory->removeLocation( @@ -450,14 +388,14 @@ public function removeAction(Request $request): Response $this->notificationHandler->success( /** @Desc("Location '%name%' removed.") */ 'location.delete.success', - ['%name%' => $location->getContentInfo()->name], + ['%name%' => $location->getContentInfo()->getName()], 'ibexa_location' ); } return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => LocationsTab::URI_FRAGMENT, ])); }); @@ -468,19 +406,12 @@ public function removeAction(Request $request): Response } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => LocationsTab::URI_FRAGMENT, ]); } - /** - * Handles assigning new location to the content item based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addAction(Request $request): Response { $form = $this->formFactory->addLocation( @@ -499,13 +430,16 @@ function (ContentLocationAddData $data) use ($referer): RedirectResponse { $contentInfo = $data->getContentInfo(); foreach ($data->getNewLocations() as $newLocation) { - $locationCreateStruct = $this->locationService->newLocationCreateStruct($newLocation->id); + $locationCreateStruct = $this->locationService->newLocationCreateStruct( + $newLocation->getId() + ); + $this->locationService->createLocation($contentInfo, $locationCreateStruct); $this->notificationHandler->success( /** @Desc("Location '%name%' created.") */ 'location.create.success', - ['%name%' => $newLocation->getContentInfo()->name], + ['%name%' => $newLocation->getContentInfo()->getName()], 'ibexa_location', ); } @@ -513,8 +447,8 @@ function (ContentLocationAddData $data) use ($referer): RedirectResponse { $redirectUrl = $referer ?: $this->generateUrl( 'ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => LocationsTab::URI_FRAGMENT, ], ); @@ -529,19 +463,12 @@ function (ContentLocationAddData $data) use ($referer): RedirectResponse { } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => LocationsTab::URI_FRAGMENT, ]); } - /** - * Handles toggling visibility location of a content item based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateVisibilityAction(Request $request): Response { $form = $this->formFactory->updateVisibilityLocation(); @@ -555,7 +482,9 @@ public function updateVisibilityAction(Request $request): Response $hidden = $data->getHidden(); try { - $contentName = $this->translationHelper->getTranslatedContentNameByContentInfo($location->getContentInfo()); + $contentName = $this->translationHelper->getTranslatedContentNameByContentInfo( + $location->getContentInfo() + ); if ($hidden) { $this->locationService->hideLocation($location); @@ -579,7 +508,7 @@ public function updateVisibilityAction(Request $request): Response } } else { $errors = []; - foreach ($form->getErrors(true, true) as $formError) { + foreach ($form->getErrors(true) as $formError) { $errors[] = $formError->getMessage(); } @@ -589,13 +518,6 @@ public function updateVisibilityAction(Request $request): Response return new JsonResponse(['message' => $message]); } - /** - * Handles update existing location. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateAction(Request $request): Response { $form = $this->formFactory->updateLocation(); @@ -607,19 +529,23 @@ public function updateAction(Request $request): Response $result = $this->submitHandler->handle($form, function (LocationUpdateData $data): RedirectResponse { $location = $data->getLocation(); - $locationUpdateStruct = new LocationUpdateStruct(['sortField' => $data->getSortField(), 'sortOrder' => $data->getSortOrder()]); + $locationUpdateStruct = new LocationUpdateStruct([ + 'sortField' => $data->getSortField(), + 'sortOrder' => $data->getSortOrder(), + ]); + $this->locationService->updateLocation($location, $locationUpdateStruct); $this->notificationHandler->success( /** @Desc("Location '%name%' updated.") */ 'location.update.success', - ['%name%' => $location->getContentInfo()->name], + ['%name%' => $location->getContentInfo()->getName()], 'ibexa_location' ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $location->contentId, - 'locationId' => $location->getContentInfo()->mainLocationId, + 'contentId' => $location->getContentId(), + 'locationId' => $location->getContentInfo()->getMainLocationId(), '_fragment' => DetailsTab::URI_FRAGMENT, ])); }); @@ -632,19 +558,12 @@ public function updateAction(Request $request): Response $contentInfo = $location->getContentInfo(); return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => DetailsTab::URI_FRAGMENT, ]); } - /** - * Handles assigning section to subtree. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function assignSectionAction(Request $request): Response { $form = $this->createForm(LocationAssignSectionType::class, new LocationAssignSubtreeData()); @@ -661,7 +580,7 @@ public function assignSectionAction(Request $request): Response $this->notificationHandler->success( /** @Desc("Subtree assigned to Section '%name%'") */ 'location.assign_section.success', - ['%name%' => $section->name], + ['%name%' => $section->getName()], 'ibexa_location' ); diff --git a/src/bundle/Controller/NotificationController.php b/src/bundle/Controller/NotificationController.php index d09b561ac9..40eecb44d3 100644 --- a/src/bundle/Controller/NotificationController.php +++ b/src/bundle/Controller/NotificationController.php @@ -8,6 +8,7 @@ namespace Ibexa\Bundle\AdminUi\Controller; +use Exception; use Ibexa\AdminUi\Pagination\Pagerfanta\NotificationAdapter; use Ibexa\Bundle\AdminUi\View\IbexaPagerfantaView; use Ibexa\Bundle\AdminUi\View\Template\IbexaPagerfantaTemplate; @@ -18,28 +19,14 @@ use Pagerfanta\Pagerfanta; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; -use Symfony\Contracts\Translation\TranslatorInterface; -class NotificationController extends Controller +final class NotificationController extends Controller { - protected NotificationService $notificationService; - - protected Registry $registry; - - protected TranslatorInterface $translator; - - private ConfigResolverInterface $configResolver; - public function __construct( - NotificationService $notificationService, - Registry $registry, - TranslatorInterface $translator, - ConfigResolverInterface $configResolver + private readonly NotificationService $notificationService, + private readonly Registry $registry, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationService = $notificationService; - $this->registry = $registry; - $this->translator = $translator; - $this->configResolver = $configResolver; } public function getNotificationsAction(int $offset, int $limit): JsonResponse @@ -53,7 +40,7 @@ public function getNotificationsAction(int $offset, int $limit): JsonResponse 'total' => $notificationList->totalCount, 'notifications' => $notificationList->items, ]); - } catch (\Exception $exception) { + } catch (Exception $exception) { $response->setData([ 'status' => 'failed', 'error' => $exception->getMessage(), @@ -63,11 +50,6 @@ public function getNotificationsAction(int $offset, int $limit): JsonResponse return $response; } - /** - * @param int $page - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function renderNotificationsPageAction(int $page): Response { $pagerfanta = new Pagerfanta( @@ -101,9 +83,6 @@ public function renderNotificationsPageAction(int $page): Response ])->getContent()); } - /** - * @return \Symfony\Component\HttpFoundation\JsonResponse - */ public function countNotificationsAction(): JsonResponse { $response = new JsonResponse(); @@ -148,7 +127,7 @@ public function markNotificationAsReadAction(string $notificationId): JsonRespon } $response->setData($data); - } catch (\Exception $exception) { + } catch (Exception $exception) { $response->setData([ 'status' => 'failed', 'error' => $exception->getMessage(), diff --git a/src/bundle/Controller/ObjectStateController.php b/src/bundle/Controller/ObjectStateController.php index a7f9663772..fb3888150a 100644 --- a/src/bundle/Controller/ObjectStateController.php +++ b/src/bundle/Controller/ObjectStateController.php @@ -34,41 +34,18 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class ObjectStateController extends Controller +final class ObjectStateController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private ObjectStateService $objectStateService; - - private FormFactoryInterface $formFactory; - - private SubmitHandler $submitHandler; - - private PermissionResolver $permissionResolver; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - ObjectStateService $objectStateService, - FormFactoryInterface $formFactory, - SubmitHandler $submitHandler, - PermissionResolver $permissionResolver, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly ObjectStateService $objectStateService, + private readonly FormFactoryInterface $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly PermissionResolver $permissionResolver, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->objectStateService = $objectStateService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->permissionResolver = $permissionResolver; - $this->configResolver = $configResolver; } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function listAction(ObjectStateGroup $objectStateGroup): Response { /** @var \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState[] $objectStates */ @@ -80,7 +57,6 @@ public function listAction(ObjectStateGroup $objectStateGroup): Response ); $unusedObjectStates = []; - foreach ($objectStates as $state) { $unusedObjectStates[$state->id] = empty($this->objectStateService->getContentCount($state)); } @@ -94,11 +70,6 @@ public function listAction(ObjectStateGroup $objectStateGroup): Response ]); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState $objectState - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function viewAction(ObjectState $objectState): Response { $deleteForm = $this->formFactory->create( @@ -114,12 +85,6 @@ public function viewAction(ObjectState $objectState): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addAction(Request $request, ObjectStateGroup $objectStateGroup): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -138,7 +103,7 @@ public function addAction(Request $request, ObjectStateGroup $objectStateGroup): $form, function (ObjectStateCreateData $data) use ($defaultLanguageCode, $objectStateGroup, $form): Response { $createStruct = $this->objectStateService->newObjectStateCreateStruct( - $data->getIdentifier() + $data->getIdentifier() ?? '' ); $createStruct->defaultLanguageCode = $defaultLanguageCode; $createStruct->names = [$defaultLanguageCode => $data->getName()]; @@ -175,12 +140,6 @@ function (ObjectStateCreateData $data) use ($defaultLanguageCode, $objectStateGr ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState $objectState - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function deleteAction(Request $request, ObjectState $objectState): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -213,14 +172,6 @@ public function deleteAction(Request $request, ObjectState $objectState): Respon ]); } - /** - * Handles removing object state groups based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param int $objectStateGroupId - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function bulkDeleteAction(Request $request, int $objectStateGroupId): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -255,12 +206,6 @@ public function bulkDeleteAction(Request $request, int $objectStateGroupId): Res ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState $objectState - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateAction(Request $request, ObjectState $objectState): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -313,12 +258,6 @@ public function updateAction(Request $request, ObjectState $objectState): Respon } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function updateContentStateAction( @@ -361,16 +300,16 @@ public function updateContentStateAction( } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => 'ibexa-tab-location-view-details', ]); } /** - * @param array $states + * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState[] $states * - * @return array + * @return array */ private function getObjectStatesIds(array $states): array { diff --git a/src/bundle/Controller/ObjectStateGroupController.php b/src/bundle/Controller/ObjectStateGroupController.php index 6754ffd0cd..329226cce9 100644 --- a/src/bundle/Controller/ObjectStateGroupController.php +++ b/src/bundle/Controller/ObjectStateGroupController.php @@ -27,35 +27,17 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class ObjectStateGroupController extends Controller +final class ObjectStateGroupController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private ObjectStateService $objectStateService; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - ObjectStateService $objectStateService, - FormFactory $formFactory, - SubmitHandler $submitHandler, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly ObjectStateService $objectStateService, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->objectStateService = $objectStateService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->configResolver = $configResolver; } - /** - * @return \Symfony\Component\HttpFoundation\Response - */ public function listAction(): Response { /** @var \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup[] $objectStateGroups */ @@ -78,11 +60,6 @@ public function listAction(): Response ]); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function viewAction(ObjectStateGroup $objectStateGroup): Response { $deleteForm = $this->formFactory->deleteObjectStateGroup( @@ -96,11 +73,6 @@ public function viewAction(ObjectStateGroup $objectStateGroup): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addAction(Request $request): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -155,12 +127,6 @@ function (ObjectStateGroupCreateData $data) use ($defaultLanguageCode, $form): R ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup $group - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function deleteAction(Request $request, ObjectStateGroup $group): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -190,13 +156,6 @@ public function deleteAction(Request $request, ObjectStateGroup $group): Respons return $this->redirectToRoute('ibexa.object_state.groups.list'); } - /** - * Handles removing object state groups based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function bulkDeleteAction(Request $request): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -228,12 +187,6 @@ public function bulkDeleteAction(Request $request): Response return $this->redirectToRoute('ibexa.object_state.groups.list'); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup $group - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateAction(Request $request, ObjectStateGroup $group): Response { $this->denyAccessUnlessGranted(new Attribute('state', 'administrate')); @@ -287,7 +240,7 @@ public function updateAction(Request $request, ObjectStateGroup $group): Respons /** * @param \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectStateGroup[] $groups * - * @return array + * @return array */ private function getObjectStateGroupsIds(array $groups): array { diff --git a/src/bundle/Controller/Permission/LanguageLimitationController.php b/src/bundle/Controller/Permission/LanguageLimitationController.php index 957bfbcf2e..d434b2051c 100644 --- a/src/bundle/Controller/Permission/LanguageLimitationController.php +++ b/src/bundle/Controller/Permission/LanguageLimitationController.php @@ -20,20 +20,11 @@ final class LanguageLimitationController extends Controller { - private ContentService $contentService; - - private LimitationResolverInterface $limitationResolver; - - private LocationService $locationService; - public function __construct( - ContentService $contentService, - LimitationResolverInterface $limitationResolver, - LocationService $locationService + private readonly ContentService $contentService, + private readonly LimitationResolverInterface $limitationResolver, + private readonly LocationService $locationService ) { - $this->contentService = $contentService; - $this->limitationResolver = $limitationResolver; - $this->locationService = $locationService; } public function loadLanguageLimitationsForContentCreateAction(Location $location): Response @@ -45,7 +36,7 @@ public function loadLanguageLimitationsForContentCreateAction(Location $location $contentInfo->getMainLanguageCode() ); $contentCreateStruct->sectionId = $contentInfo->getSectionId(); - $locationCreateStruct = $this->locationService->newLocationCreateStruct($location->id); + $locationCreateStruct = $this->locationService->newLocationCreateStruct($location->getId()); return new JsonResponse( $this->limitationResolver->getLanguageLimitations( diff --git a/src/bundle/Controller/PolicyController.php b/src/bundle/Controller/PolicyController.php index ba02dd53d9..7649531a05 100644 --- a/src/bundle/Controller/PolicyController.php +++ b/src/bundle/Controller/PolicyController.php @@ -33,47 +33,20 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class PolicyController extends Controller +final class PolicyController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private RoleService $roleService; - - private PolicyCreateMapper $policyCreateMapper; - - private PolicyUpdateMapper $policyUpdateMapper; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - RoleService $roleService, - PolicyCreateMapper $policyCreateMapper, - PolicyUpdateMapper $policyUpdateMapper, - FormFactory $formFactory, - SubmitHandler $submitHandler, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly RoleService $roleService, + private readonly PolicyCreateMapper $policyCreateMapper, + private readonly PolicyUpdateMapper $policyUpdateMapper, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->roleService = $roleService; - $this->policyCreateMapper = $policyCreateMapper; - $this->policyUpdateMapper = $policyUpdateMapper; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->configResolver = $configResolver; } /** - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * @param string $routeName - * @param int $policyPage - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException * @throws \Pagerfanta\Exception\OutOfRangeCurrentPageException @@ -86,7 +59,9 @@ public function listAction(Role $role, string $routeName, int $policyPage = 1): new ArrayAdapter(iterator_to_array($role->getPolicies())) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.policy_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.policy_limit') + ); $pagerfanta->setCurrentPage(min($policyPage, $pagerfanta->getNbPages())); /** @var \Ibexa\Contracts\Core\Repository\Values\User\Policy[] $policies */ @@ -116,11 +91,6 @@ public function listAction(Role $role, string $routeName, int $policyPage = 1): } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \InvalidArgumentException */ @@ -137,7 +107,10 @@ public function createAction(Request $request, Role $role): Response $policyCreateStruct = $this->policyCreateMapper->reverseMap($data); $limitationTypes = $policyCreateStruct->module - ? $this->roleService->getLimitationTypesByModuleFunction($policyCreateStruct->module, $policyCreateStruct->function) + ? $this->roleService->getLimitationTypesByModuleFunction( + $policyCreateStruct->module, + $policyCreateStruct->function + ) : []; $isEditable = !empty($limitationTypes); @@ -159,7 +132,8 @@ public function createAction(Request $request, Role $role): Response try { $this->roleService->deleteRoleDraft($this->roleService->loadRoleDraftByRoleId($role->id)); - } catch (NotFoundException $e) { + } catch (NotFoundException) { + //do nothing } $roleDraft = $this->roleService->createRoleDraft($role); @@ -190,12 +164,6 @@ public function createAction(Request $request, Role $role): Response } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * @param \Ibexa\Contracts\Core\Repository\Values\User\Policy $policy - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException * @throws \InvalidArgumentException @@ -222,7 +190,6 @@ public function updateAction(Request $request, Role $role, Policy $policy): Resp ])); } - /** @var \Symfony\Component\Form\Form $form */ $form = $this->formFactory->updatePolicy( new PolicyUpdateData($policy) ); @@ -275,14 +242,6 @@ public function updateAction(Request $request, Role $role, Policy $policy): Resp ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * @param string $policyModule - * @param string $policyFunction - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function createWithLimitationAction(Request $request, Role $role, string $policyModule, string $policyFunction): Response { $this->denyAccessUnlessGranted(new Attribute('role', 'update')); @@ -325,12 +284,6 @@ public function createWithLimitationAction(Request $request, Role $role, string } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * @param \Ibexa\Contracts\Core\Repository\Values\User\Policy $policy - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \InvalidArgumentException */ @@ -376,13 +329,6 @@ public function deleteAction(Request $request, Role $role, Policy $policy): Resp } /** - * Handles removing policies based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \InvalidArgumentException @@ -434,7 +380,7 @@ public function bulkDeleteAction(Request $request, Role $role): Response /** * @param \Ibexa\Contracts\Core\Repository\Values\User\Policy[] $policies * - * @return array + * @return array */ private function getPoliciesNumbers(array $policies): array { diff --git a/src/bundle/Controller/RoleAssignmentController.php b/src/bundle/Controller/RoleAssignmentController.php index c2657a1dd5..1efca1d6f3 100644 --- a/src/bundle/Controller/RoleAssignmentController.php +++ b/src/bundle/Controller/RoleAssignmentController.php @@ -30,30 +30,15 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class RoleAssignmentController extends Controller +final class RoleAssignmentController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private RoleService $roleService; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - RoleService $roleService, - FormFactory $formFactory, - SubmitHandler $submitHandler, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly RoleService $roleService, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->roleService = $roleService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->configResolver = $configResolver; } public function listAction( @@ -91,12 +76,6 @@ public function listAction( ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function createAction(Request $request, Role $role): Response { $this->denyAccessUnlessGranted(new Attribute('role', 'assign')); @@ -138,13 +117,6 @@ public function createAction(Request $request, Role $role): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * @param \Ibexa\Contracts\Core\Repository\Values\User\RoleAssignment $roleAssignment - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function deleteAction(Request $request, Role $role, RoleAssignment $roleAssignment): Response { $this->denyAccessUnlessGranted(new Attribute('role', 'assign')); @@ -180,14 +152,6 @@ public function deleteAction(Request $request, Role $role, RoleAssignment $roleA ]); } - /** - * Handles removing role assignments based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function bulkDeleteAction(Request $request, Role $role): Response { $this->denyAccessUnlessGranted(new Attribute('role', 'assign')); @@ -229,7 +193,7 @@ public function bulkDeleteAction(Request $request, Role $role): Response /** * @param \Ibexa\Contracts\Core\Repository\Values\User\RoleAssignment[] $roleAssignments * - * @return array + * @return array */ private function getRoleAssignmentsNumbers(array $roleAssignments): array { @@ -239,8 +203,6 @@ private function getRoleAssignmentsNumbers(array $roleAssignments): array } /** - * @param \Ibexa\AdminUi\Form\Data\Role\RoleAssignmentCreateData $data - * * @return \Ibexa\Contracts\Core\Repository\Values\User\Limitation\RoleLimitation[] */ private function createLimitations(RoleAssignmentCreateData $data): array diff --git a/src/bundle/Controller/RoleController.php b/src/bundle/Controller/RoleController.php index edc1f5dd64..c5e8abcf28 100644 --- a/src/bundle/Controller/RoleController.php +++ b/src/bundle/Controller/RoleController.php @@ -35,42 +35,18 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class RoleController extends Controller +final class RoleController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private RoleService $roleService; - - private RoleCreateMapper $roleCreateMapper; - - private RoleCopyMapper $roleCopyMapper; - - private RoleUpdateMapper $roleUpdateMapper; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - RoleService $roleService, - RoleCreateMapper $roleCreateMapper, - RoleCopyMapper $roleCopyMapper, - RoleUpdateMapper $roleUpdateMapper, - FormFactory $formFactory, - SubmitHandler $submitHandler, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly RoleService $roleService, + private readonly RoleCreateMapper $roleCreateMapper, + private readonly RoleCopyMapper $roleCopyMapper, + private readonly RoleUpdateMapper $roleUpdateMapper, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->roleService = $roleService; - $this->roleCreateMapper = $roleCreateMapper; - $this->roleCopyMapper = $roleCopyMapper; - $this->roleUpdateMapper = $roleUpdateMapper; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->configResolver = $configResolver; } public function listAction(Request $request): Response @@ -81,7 +57,10 @@ public function listAction(Request $request): Response new ArrayAdapter(iterator_to_array($this->roleService->loadRoles())) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.role_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.role_limit') + ); + $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); /** @var \Ibexa\Contracts\Core\Repository\Values\User\Role[] $roles */ @@ -120,11 +99,6 @@ public function viewAction(Request $request, Role $role, int $policyPage = 1, in ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function createAction(Request $request): Response { $this->denyAccessUnlessGranted(new Attribute('role', 'create')); @@ -203,12 +177,6 @@ public function copyAction(Request $request, Role $role): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateAction(Request $request, Role $role): Response { $this->denyAccessUnlessGranted(new Attribute('role', 'update')); @@ -260,12 +228,6 @@ public function updateAction(Request $request, Role $role): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\User\Role $role - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function deleteAction(Request $request, Role $role): Response { $this->denyAccessUnlessGranted(new Attribute('role', 'delete')); @@ -300,12 +262,6 @@ public function deleteAction(Request $request, Role $role): Response } /** - * Handles removing roles based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \InvalidArgumentException * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException diff --git a/src/bundle/Controller/SectionController.php b/src/bundle/Controller/SectionController.php index 317adb025a..37b4b093a5 100644 --- a/src/bundle/Controller/SectionController.php +++ b/src/bundle/Controller/SectionController.php @@ -38,6 +38,7 @@ use Ibexa\Core\MVC\Symfony\Security\Authorization\Attribute; use Ibexa\Core\Pagination\Pagerfanta\ContentSearchAdapter; use JMS\TranslationBundle\Annotation\Desc; +use JMS\TranslationBundle\Annotation\Ignore; use Pagerfanta\Adapter\ArrayAdapter; use Pagerfanta\Pagerfanta; use Symfony\Component\Form\Button; @@ -45,71 +46,32 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class SectionController extends Controller +final class SectionController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private SectionService $sectionService; - - private SearchService $searchService; - - private FormFactory $formFactory; - - private SectionCreateMapper $sectionCreateMapper; - - private SectionUpdateMapper $sectionUpdateMapper; - - private SubmitHandler $submitHandler; - - private LocationService $locationService; - - private PathService $pathService; - - private PermissionResolver $permissionResolver; - - private PermissionCheckerInterface $permissionChecker; - - private ConfigResolverInterface $configResolver; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - SectionService $sectionService, - SearchService $searchService, - FormFactory $formFactory, - SectionCreateMapper $sectionCreateMapper, - SectionUpdateMapper $sectionUpdateMapper, - SubmitHandler $submitHandler, - LocationService $locationService, - PathService $pathService, - PermissionResolver $permissionResolver, - PermissionCheckerInterface $permissionChecker, - ConfigResolverInterface $configResolver + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly SectionService $sectionService, + private readonly SearchService $searchService, + private readonly FormFactory $formFactory, + private readonly SectionCreateMapper $sectionCreateMapper, + private readonly SectionUpdateMapper $sectionUpdateMapper, + private readonly SubmitHandler $submitHandler, + private readonly LocationService $locationService, + private readonly PathService $pathService, + private readonly PermissionResolver $permissionResolver, + private readonly PermissionCheckerInterface $permissionChecker, + private readonly ConfigResolverInterface $configResolver ) { - $this->notificationHandler = $notificationHandler; - $this->sectionService = $sectionService; - $this->searchService = $searchService; - $this->formFactory = $formFactory; - $this->sectionCreateMapper = $sectionCreateMapper; - $this->sectionUpdateMapper = $sectionUpdateMapper; - $this->submitHandler = $submitHandler; - $this->locationService = $locationService; - $this->pathService = $pathService; - $this->permissionResolver = $permissionResolver; - $this->permissionChecker = $permissionChecker; - $this->configResolver = $configResolver; } public function performAccessCheck(): void { parent::performAccessCheck(); + $this->denyAccessUnlessGranted(new Attribute('section', 'view')); } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function listAction(Request $request): Response @@ -120,7 +82,9 @@ public function listAction(Request $request): Response new ArrayAdapter(iterator_to_array($this->sectionService->loadSections())) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.section_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.section_limit') + ); $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Section[] $sectionList */ @@ -164,11 +128,6 @@ public function listAction(Request $request): Response ]); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Section $section - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function viewAction(Section $section): Response { $sectionDeleteForm = $this->formFactory->deleteSection( @@ -184,14 +143,6 @@ public function viewAction(Section $section): Response } /** - * Fragment action which renders list of contents assigned to section. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Section $section - * @param int $page Current page - * @param int $limit Number of items per page - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException @@ -245,12 +196,6 @@ public function viewSectionContentAction(Section $section, int $page = 1, int $l ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Section $section - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function deleteAction(Request $request, Section $section): Response { $this->denyAccessUnlessGranted(new Attribute('section', 'edit')); @@ -283,13 +228,6 @@ public function deleteAction(Request $request, Section $section): Response return $this->redirectToRoute('ibexa.section.list'); } - /** - * Handles removing sections based on submitted form. - * - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function bulkDeleteAction(Request $request): Response { $this->denyAccessUnlessGranted(new Attribute('section', 'edit')); @@ -307,7 +245,7 @@ public function bulkDeleteAction(Request $request): Response $this->notificationHandler->success( /** @Desc("Section '%name%' removed.") */ 'section.delete.success', - ['%name%' => $section->name], + ['%name%' => $section->getName()], 'ibexa_section' ); } @@ -322,10 +260,7 @@ public function bulkDeleteAction(Request $request): Response } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Section $section - * - * @return \Symfony\Component\HttpFoundation\Response + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ public function assignContentAction(Request $request, Section $section): Response { @@ -355,12 +290,12 @@ public function assignContentAction(Request $request, Section $section): Respons $this->notificationHandler->success( /** @Desc("%contentItemsCount% Content items assigned to '%name%'") */ 'section.assign_content.success', - ['%name%' => $section->name, '%contentItemsCount%' => \count($contentInfos)], + ['%name%' => $section->getName(), '%contentItemsCount%' => \count($contentInfos)], 'ibexa_section' ); return new RedirectResponse($this->generateUrl('ibexa.section.view', [ - 'sectionId' => $section->id, + 'sectionId' => $section->getId(), ])); }); @@ -370,15 +305,10 @@ public function assignContentAction(Request $request, Section $section): Respons } return $this->redirectToRoute('ibexa.section.view', [ - 'sectionId' => $section->id, + 'sectionId' => $section->getId(), ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function createAction(Request $request): Response { $this->denyAccessUnlessGranted(new Attribute('section', 'edit')); @@ -397,7 +327,7 @@ public function createAction(Request $request): Response $this->notificationHandler->success( /** @Desc("Section '%name%' created.") */ 'section.create.success', - ['%name%' => $section->name], + ['%name%' => $section->getName()], 'ibexa_section' ); @@ -405,12 +335,12 @@ public function createAction(Request $request): Response && $form->getClickedButton()->getName() === SectionCreateType::BTN_CREATE_AND_EDIT ) { return $this->redirectToRoute('ibexa.section.update', [ - 'sectionId' => $section->id, + 'sectionId' => $section->getId(), ]); } return new RedirectResponse($this->generateUrl('ibexa.section.view', [ - 'sectionId' => $section->id, + 'sectionId' => $section->getId(), ])); } catch (Exception $e) { $this->notificationHandler->error(/** @Ignore */ @@ -424,12 +354,6 @@ public function createAction(Request $request): Response ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Section $section - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateAction(Request $request, Section $section): Response { $this->denyAccessUnlessGranted(new Attribute('section', 'edit')); @@ -475,7 +399,7 @@ public function updateAction(Request $request, Section $section): Response /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Section[] $sections * - * @return array + * @return array */ private function getSectionsNumbers(array $sections): array { @@ -485,25 +409,19 @@ private function getSectionsNumbers(array $sections): array } /** - * Specifies if the User has access to assigning a given Section to Content. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Section $section - * - * @return bool - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ private function canUserAssignSectionToSomeContent(Section $section): bool { $hasAccess = $this->permissionResolver->hasAccess('section', 'assign'); - if (\is_bool($hasAccess)) { + if (is_bool($hasAccess)) { return $hasAccess; } $restrictedNewSections = $this->permissionChecker->getRestrictions($hasAccess, NewSectionLimitation::class); if (!empty($restrictedNewSections)) { - return \in_array($section->id, array_map('intval', $restrictedNewSections), true); + return in_array($section->getId(), array_map('intval', $restrictedNewSections), true); } // If a user has other limitation than NewSectionLimitation, then a decision will be taken later, based on selected Content. diff --git a/src/bundle/Controller/TranslationController.php b/src/bundle/Controller/TranslationController.php index cb58f486d3..f518617065 100644 --- a/src/bundle/Controller/TranslationController.php +++ b/src/bundle/Controller/TranslationController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -21,43 +22,17 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class TranslationController extends Controller +final class TranslationController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private ContentService $contentService; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private TranslationHelper $translationHelper; - - /** - * @param \Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface $notificationHandler - * @param \Ibexa\Contracts\Core\Repository\ContentService $contentService - * @param \Ibexa\AdminUi\Form\Factory\FormFactory $formFactory - * @param \Ibexa\AdminUi\Form\SubmitHandler $submitHandler - */ public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - ContentService $contentService, - FormFactory $formFactory, - SubmitHandler $submitHandler, - TranslationHelper $translationHelper + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly ContentService $contentService, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly TranslationHelper $translationHelper ) { - $this->notificationHandler = $notificationHandler; - $this->contentService = $contentService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->translationHelper = $translationHelper; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addAction(Request $request): Response { $formName = $request->query->get('formName'); @@ -76,10 +51,10 @@ public function addAction(Request $request): Response $baseLanguage = $data->getBaseLanguage(); return new RedirectResponse($this->generateUrl('ibexa.content.translate_with_location.proxy', [ - 'contentId' => $contentInfo->id, - 'fromLanguageCode' => null !== $baseLanguage ? $baseLanguage->languageCode : null, - 'toLanguageCode' => $language->languageCode, - 'locationId' => $location->id, + 'contentId' => $contentInfo->getId(), + 'fromLanguageCode' => $baseLanguage?->getLanguageCode(), + 'toLanguageCode' => $language->getLanguageCode(), + 'locationId' => $location->getId(), ])); }); @@ -90,19 +65,14 @@ public function addAction(Request $request): Response $redirectionUrl = null !== $location ? $this->generateUrl('ibexa.content.view', [ - 'contentId' => $location->contentId, - 'locationId' => $location->id, + 'contentId' => $location->getContentId(), + 'locationId' => $location->getId(), ]) : $this->generateUrl('ibexa.dashboard'); return $this->redirect($redirectionUrl); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function removeAction(Request $request): Response { $form = $this->formFactory->deleteTranslation(); @@ -130,8 +100,8 @@ public function removeAction(Request $request): Response } return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => TranslationsTab::URI_FRAGMENT, ])); }); @@ -142,8 +112,8 @@ public function removeAction(Request $request): Response } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => TranslationsTab::URI_FRAGMENT, ]); } diff --git a/src/bundle/Controller/TrashController.php b/src/bundle/Controller/TrashController.php index 0f5ef63a3b..92fffa4ce4 100644 --- a/src/bundle/Controller/TrashController.php +++ b/src/bundle/Controller/TrashController.php @@ -19,7 +19,6 @@ use Ibexa\AdminUi\Pagination\Pagerfanta\TrashItemAdapter; use Ibexa\AdminUi\QueryType\TrashSearchQueryType; use Ibexa\AdminUi\Specification\UserExists; -use Ibexa\AdminUi\UI\Service\PathService; use Ibexa\AdminUi\UI\Service\PathService as UiPathService; use Ibexa\Contracts\AdminUi\Controller\Controller; use Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface; @@ -38,63 +37,30 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class TrashController extends Controller +final class TrashController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private TrashService $trashService; - - private ContentTypeService $contentTypeService; - - private TrashFormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private PathService $uiPathService; - - private UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider; - - private ConfigResolverInterface $configResolver; - - private TrashSearchQueryType $trashSearchQueryType; - - private UserService $userService; - public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - TrashService $trashService, - ContentTypeService $contentTypeService, - UiPathService $uiPathService, - TrashFormFactory $formFactory, - SubmitHandler $submitHandler, - UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, - ConfigResolverInterface $configResolver, - TrashSearchQueryType $trashSearchQueryType, - UserService $userService + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly TrashService $trashService, + private readonly ContentTypeService $contentTypeService, + private readonly UiPathService $uiPathService, + private readonly TrashFormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, + private readonly ConfigResolverInterface $configResolver, + private readonly TrashSearchQueryType $trashSearchQueryType, + private readonly UserService $userService ) { - $this->notificationHandler = $notificationHandler; - $this->trashService = $trashService; - $this->contentTypeService = $contentTypeService; - $this->uiPathService = $uiPathService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider; - $this->configResolver = $configResolver; - $this->trashSearchQueryType = $trashSearchQueryType; - $this->userService = $userService; } public function performAccessCheck(): void { parent::performAccessCheck(); + $this->denyAccessUnlessGranted(new Attribute('content', 'restore')); } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \LogicException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Pagerfanta\Exception\OutOfRangeCurrentPageException @@ -122,7 +88,9 @@ public function listAction(Request $request): Response ) ); - $pagerfanta->setMaxPerPage($this->configResolver->getParameter('pagination.trash_limit')); + $pagerfanta->setMaxPerPage( + $this->configResolver->getParameter('pagination.trash_limit') + ); $pagerfanta->setCurrentPage(min($page, $pagerfanta->getNbPages())); /** @var \Ibexa\Contracts\Core\Repository\Values\Content\TrashItem $item */ @@ -165,10 +133,6 @@ public function listAction(Request $request): Response } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \LogicException * @throws \InvalidArgumentException @@ -207,10 +171,6 @@ public function emptyAction(Request $request): Response } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \LogicException * @throws \InvalidArgumentException @@ -245,7 +205,7 @@ function (TrashItemRestoreData $data) use ($request): RedirectResponse { $this->notificationHandler->success( /** @Desc("Restored content under Location '%location%'.") */ 'trash.restore_new_location.success', - ['%location%' => $newParentLocation->getContentInfo()->name], + ['%location%' => $newParentLocation->getContentInfo()->getName()], 'ibexa_trash' ); } @@ -263,10 +223,6 @@ function (TrashItemRestoreData $data) use ($request): RedirectResponse { } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException * @throws \LogicException @@ -321,12 +277,14 @@ private function redirectToTrashList(Request $request): RedirectResponse */ private function getCreatorFromTrashItem(TrashItem $trashItem): ?User { - $ownerId = $trashItem->getContentInfo()->ownerId; + $ownerId = $trashItem->getContentInfo()->getOwner()->getUserId(); if (false === (new UserExists($this->userService))->isSatisfiedBy($ownerId)) { return null; } - return $this->userService->loadUser($trashItem->getContentInfo()->ownerId); + return $this->userService->loadUser( + $trashItem->getContentInfo()->getOwner()->getUserId() + ); } } diff --git a/src/bundle/Controller/URLWildcardController.php b/src/bundle/Controller/URLWildcardController.php index a5e04c3154..7ed2ac07e9 100644 --- a/src/bundle/Controller/URLWildcardController.php +++ b/src/bundle/Controller/URLWildcardController.php @@ -27,31 +27,14 @@ final class URLWildcardController extends Controller { - private URLWildcardService $urlWildcardService; - - private TranslatableNotificationHandlerInterface $notificationHandler; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - public function __construct( - URLWildcardService $urlWildcardService, - TranslatableNotificationHandlerInterface $notificationHandler, - FormFactory $formFactory, - SubmitHandler $submitHandler + private readonly URLWildcardService $urlWildcardService, + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler ) { - $this->urlWildcardService = $urlWildcardService; - $this->notificationHandler = $notificationHandler; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addAction(Request $request): Response { /** @var \Symfony\Component\Form\Form $form */ @@ -62,8 +45,8 @@ public function addAction(Request $request): Response if ($form->isSubmitted()) { $this->submitHandler->handle($form, function (URLWildcardData $data) use ($form): Response { $urlWildcard = $this->urlWildcardService->create( - $data->getSourceURL(), - $data->getDestinationUrl(), + $data->getSourceURL() ?? '', + $data->getDestinationUrl() ?? '', (bool) $data->getForward() ); @@ -93,12 +76,6 @@ public function addAction(Request $request): Response ]); } - /** - * @param \Ibexa\Contracts\Core\Repository\Values\Content\URLWildcard $urlWildcard - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function updateAction(URLWildcard $urlWildcard, Request $request): Response { /** @var \Symfony\Component\Form\Form $form */ @@ -160,11 +137,6 @@ function (URLWildcardUpdateData $data) use ($urlWildcard, $form): Response { ]); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function bulkDeleteAction(Request $request): Response { $form = $this->formFactory->deleteURLWildcard(); diff --git a/src/bundle/Controller/UrlAliasController.php b/src/bundle/Controller/UrlAliasController.php index 0299c3aaad..045996b7cc 100644 --- a/src/bundle/Controller/UrlAliasController.php +++ b/src/bundle/Controller/UrlAliasController.php @@ -19,34 +19,15 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class UrlAliasController extends Controller +final class UrlAliasController extends Controller { - protected FormFactory $formFactory; - - protected SubmitHandler $submitHandler; - - protected URLAliasService $urlAliasService; - - /** - * @param \Ibexa\AdminUi\Form\Factory\FormFactory $formFactory - * @param \Ibexa\AdminUi\Form\SubmitHandler $submitHandler - * @param \Ibexa\Contracts\Core\Repository\URLAliasService $urlAliasService - */ public function __construct( - FormFactory $formFactory, - SubmitHandler $submitHandler, - URLAliasService $urlAliasService + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly URLAliasService $urlAliasService ) { - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->urlAliasService = $urlAliasService; } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function addAction(Request $request): Response { $form = $this->formFactory->addCustomUrl(); @@ -61,7 +42,7 @@ public function addAction(Request $request): Response $this->urlAliasService->createUrlAlias( $data->getLocation(), $data->getPath(), - $data->getLanguage()->languageCode, + $data->getLanguage()->getLanguageCode(), $data->isRedirect() ); @@ -80,11 +61,6 @@ public function addAction(Request $request): Response return $this->redirectToRoute('ibexa.dashboard'); } - /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ public function removeAction(Request $request): Response { $form = $this->formFactory->removeCustomUrl(); diff --git a/src/bundle/Controller/User/FocusModeController.php b/src/bundle/Controller/User/FocusModeController.php index 72c2f1ec9d..2bc4f48743 100644 --- a/src/bundle/Controller/User/FocusModeController.php +++ b/src/bundle/Controller/User/FocusModeController.php @@ -22,32 +22,23 @@ final class FocusModeController extends Controller { - private const RETURN_PATH_PARAM = 'returnPath'; - - private EventDispatcherInterface $eventDispatcher; - - private UserSettingService $userSettingService; - - private UrlMatcherInterface $urlMatcher; - - /** @var iterable<\Ibexa\Contracts\AdminUi\FocusMode\RedirectStrategyInterface> */ - private iterable $redirectStrategies; + private const string RETURN_PATH_PARAM = 'returnPath'; /** * @param iterable<\Ibexa\Contracts\AdminUi\FocusMode\RedirectStrategyInterface> $redirectStrategies */ public function __construct( - EventDispatcherInterface $eventDispatcher, - UserSettingService $userSettingService, - UrlMatcherInterface $urlMatcher, - iterable $redirectStrategies + private readonly EventDispatcherInterface $eventDispatcher, + private readonly UserSettingService $userSettingService, + private readonly UrlMatcherInterface $urlMatcher, + private readonly iterable $redirectStrategies ) { - $this->eventDispatcher = $eventDispatcher; - $this->userSettingService = $userSettingService; - $this->urlMatcher = $urlMatcher; - $this->redirectStrategies = $redirectStrategies; } + /** + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException + */ public function changeAction(Request $request, ?string $returnPath): Response { $data = new FocusModeChangeData(); @@ -76,7 +67,9 @@ public function changeAction(Request $request, ?string $returnPath): Response $data->isEnabled() ? FocusMode::FOCUS_MODE_ON : FocusMode::FOCUS_MODE_OFF ); - $this->eventDispatcher->dispatch(new FocusModeChangedEvent($data->isEnabled())); + $this->eventDispatcher->dispatch( + new FocusModeChangedEvent($data->isEnabled() ?? false) + ); return $this->createRedirectToReturnPath($request); } diff --git a/src/bundle/Controller/User/InvitationController.php b/src/bundle/Controller/User/InvitationController.php index e73eefc4d2..cc95fd9afd 100644 --- a/src/bundle/Controller/User/InvitationController.php +++ b/src/bundle/Controller/User/InvitationController.php @@ -18,49 +18,24 @@ use Ibexa\Contracts\User\Invitation\InvitationService; use Ibexa\Core\MVC\Symfony\SiteAccess\SiteAccessServiceInterface; use JMS\TranslationBundle\Annotation\Desc; +use RuntimeException; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Twig\Environment; -final class InvitationController +final readonly class InvitationController { - private FormFactoryInterface $formFactory; - - private UserService $userService; - - private InvitationService $invitationService; - - private InvitationSender $sender; - - private Environment $twig; - - private TranslatableNotificationHandlerInterface $notificationHandler; - - private SiteAccessServiceInterface $siteAccessService; - - private UrlGeneratorInterface $urlGenerator; - public function __construct( - FormFactoryInterface $formFactory, - UserService $userService, - InvitationService $invitationService, - InvitationSender $sender, - Environment $twig, - TranslatableNotificationHandlerInterface $notificationHandler, - SiteAccessServiceInterface $siteAccessService, - UrlGeneratorInterface $urlGenerator + private FormFactoryInterface $formFactory, + private UserService $userService, + private InvitationService $invitationService, + private InvitationSender $sender, + private TranslatableNotificationHandlerInterface $notificationHandler, + private SiteAccessServiceInterface $siteAccessService, + private UrlGeneratorInterface $urlGenerator ) { - $this->formFactory = $formFactory; - $this->invitationService = $invitationService; - $this->sender = $sender; - $this->twig = $twig; - $this->userService = $userService; - $this->notificationHandler = $notificationHandler; - $this->siteAccessService = $siteAccessService; - $this->urlGenerator = $urlGenerator; } public function sendInvitationsAction(int $userGroupId, Request $request): Response @@ -72,6 +47,9 @@ public function sendInvitationsAction(int $userGroupId, Request $request): Respo ); $siteAccess = $this->siteAccessService->getCurrent(); + if ($siteAccess === null) { + throw new RuntimeException('No SiteAccess found to send the invitation.'); + } $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -88,7 +66,7 @@ public function sendInvitationsAction(int $userGroupId, Request $request): Respo $invitation = $this->invitationService->createInvitation($struct); $this->sender->sendInvitation($invitation); $atLeastOneWasSent = true; - } catch (InvitationAlreadyExistsException $exception) { + } catch (InvitationAlreadyExistsException) { $this->notificationHandler->info( /** @Desc("Invitation for %email% already exists") */ 'ibexa.user.invitations.invitation_exist', @@ -97,7 +75,7 @@ public function sendInvitationsAction(int $userGroupId, Request $request): Respo ], 'ibexa_user_invitation' ); - } catch (UserAlreadyExistsException $exception) { + } catch (UserAlreadyExistsException) { $this->notificationHandler->info( /** @Desc("User with %email% already exists") */ 'ibexa.user.invitations.user_exist', @@ -120,8 +98,8 @@ public function sendInvitationsAction(int $userGroupId, Request $request): Respo } return new RedirectResponse($this->urlGenerator->generate('ibexa.content.view', [ - 'contentId' => $group->id, - 'locationId' => $group->getVersionInfo()->getContentInfo()->mainLocationId, + 'contentId' => $group->getId(), + 'locationId' => $group->getVersionInfo()->getContentInfo()->getMainLocationId(), ])); } } diff --git a/src/bundle/Controller/User/ProfileViewController.php b/src/bundle/Controller/User/ProfileViewController.php index b99f125f48..adaf6673f3 100644 --- a/src/bundle/Controller/User/ProfileViewController.php +++ b/src/bundle/Controller/User/ProfileViewController.php @@ -21,28 +21,13 @@ final class ProfileViewController extends Controller { - private Repository $repository; - - private UserService $userService; - - private RoleService $roleService; - - private PermissionResolver $permissionResolver; - - private UserProfileConfigurationInterface $configuration; - public function __construct( - Repository $repository, - UserService $userService, - RoleService $roleService, - PermissionResolver $permissionResolver, - UserProfileConfigurationInterface $configuration + private readonly Repository $repository, + private readonly UserService $userService, + private readonly RoleService $roleService, + private readonly PermissionResolver $permissionResolver, + private readonly UserProfileConfigurationInterface $configuration ) { - $this->repository = $repository; - $this->userService = $userService; - $this->roleService = $roleService; - $this->permissionResolver = $permissionResolver; - $this->configuration = $configuration; } public function viewAction(int $userId): Response diff --git a/src/bundle/Controller/User/UserDeleteController.php b/src/bundle/Controller/User/UserDeleteController.php index 3d52bb7f20..89b9721b7b 100644 --- a/src/bundle/Controller/User/UserDeleteController.php +++ b/src/bundle/Controller/User/UserDeleteController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller\User; @@ -19,48 +20,19 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class UserDeleteController extends Controller +final class UserDeleteController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private UserService $userService; - - private LocationService $locationService; - - /** - * @param \Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface $notificationHandler - * @param \Ibexa\AdminUi\Form\Factory\FormFactory $formFactory - * @param \Ibexa\AdminUi\Form\SubmitHandler $submitHandler - * @param \Ibexa\Contracts\Core\Repository\UserService $userService - * @param \Ibexa\Contracts\Core\Repository\LocationService $locationService - */ public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - FormFactory $formFactory, - SubmitHandler $submitHandler, - UserService $userService, - LocationService $locationService + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly UserService $userService, + private readonly LocationService $locationService ) { - $this->notificationHandler = $notificationHandler; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->userService = $userService; - $this->locationService = $locationService; } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * - * @throws \InvalidArgumentException * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ public function userDeleteAction(Request $request): Response { @@ -71,11 +43,33 @@ public function userDeleteAction(Request $request): Response if ($form->isSubmitted()) { $result = $this->submitHandler->handle($form, function (UserDeleteData $data): RedirectResponse { $contentInfo = $data->getContentInfo(); - - $location = $this->locationService->loadLocation($contentInfo->mainLocationId); + if ($contentInfo === null) { + $this->notificationHandler->error( + /** @Desc("Deleting user failed.") */ + 'user.delete.error.failed', + [], + 'ibexa_content' + ); + + return new RedirectResponse($this->generateUrl('ibexa.dashboard')); + } + + $mainLocationId = $contentInfo->getMainLocationId(); + if ($mainLocationId === null) { + $this->notificationHandler->error( + /** @Desc("Deleting user failed. User has no main location.") */ + 'user.delete.error.no_main_location', + [], + 'ibexa_content' + ); + + return new RedirectResponse($this->generateUrl('ibexa.dashboard')); + } + + $location = $this->locationService->loadLocation($mainLocationId); $parentLocation = $this->locationService->loadLocation($location->parentLocationId); - $user = $this->userService->loadUser($contentInfo->id); + $user = $this->userService->loadUser($contentInfo->getId()); $this->userService->deleteUser($user); @@ -87,7 +81,7 @@ public function userDeleteAction(Request $request): Response ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $parentLocation->contentId, + 'contentId' => $parentLocation->getContentId(), 'locationId' => $location->parentLocationId, ])); }); diff --git a/src/bundle/Controller/UserOnTheFlyController.php b/src/bundle/Controller/UserOnTheFlyController.php index 096a1c8be0..b1a159d734 100644 --- a/src/bundle/Controller/UserOnTheFlyController.php +++ b/src/bundle/Controller/UserOnTheFlyController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -17,8 +18,6 @@ use Ibexa\ContentForms\Form\Type\User\UserCreateType; use Ibexa\ContentForms\Form\Type\User\UserUpdateType; use Ibexa\Contracts\AdminUi\Controller\Controller; -use Ibexa\Contracts\Core\Repository\ContentService; -use Ibexa\Contracts\Core\Repository\ContentTypeService; use Ibexa\Contracts\Core\Repository\Exceptions as ApiException; use Ibexa\Contracts\Core\Repository\LanguageService; use Ibexa\Contracts\Core\Repository\LocationService; @@ -31,57 +30,25 @@ use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Core\Base\Exceptions\UnauthorizedException; -use Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface; use Ibexa\Core\MVC\Symfony\View\BaseView; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; -class UserOnTheFlyController extends Controller +final class UserOnTheFlyController extends Controller { - private ContentService $contentService; - - private LanguageService $languageService; - - private LocationService $locationService; - - private UserService $userService; - - private ContentTypeService $contentTypeService; - - private PermissionResolver $permissionResolver; - - private UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider; - - private CreateUserOnTheFlyDispatcher $createUserActionDispatcher; - - private EditUserOnTheFlyDispatcher $editUserActionDispatcher; - public function __construct( - ContentService $contentService, - LanguageService $languageService, - LocationService $locationService, - UserService $userService, - ContentTypeService $contentTypeService, - PermissionResolver $permissionResolver, - UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider, - CreateUserOnTheFlyDispatcher $createUserActionDispatcher, - EditUserOnTheFlyDispatcher $editUserActionDispatcher + private readonly LanguageService $languageService, + private readonly LocationService $locationService, + private readonly UserService $userService, + private readonly PermissionResolver $permissionResolver, + private readonly CreateUserOnTheFlyDispatcher $createUserActionDispatcher, + private readonly EditUserOnTheFlyDispatcher $editUserActionDispatcher ) { - $this->contentService = $contentService; - $this->locationService = $locationService; - $this->languageService = $languageService; - $this->userService = $userService; - $this->contentTypeService = $contentTypeService; - $this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider; - $this->createUserActionDispatcher = $createUserActionDispatcher; - $this->editUserActionDispatcher = $editUserActionDispatcher; - $this->permissionResolver = $permissionResolver; } /** - * @return \Ibexa\Core\MVC\Symfony\View\BaseView|\Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException @@ -91,9 +58,9 @@ public function createUserAction( string $languageCode, ContentType $contentType, Location $parentLocation - ) { + ): BaseView|Response { $language = $this->languageService->loadLanguage($languageCode); - $parentGroup = $this->userService->loadUserGroup($parentLocation->contentId); + $parentGroup = $this->userService->loadUserGroup($parentLocation->getContentId()); $data = (new UserCreateMapper())->mapToFormData($contentType, [$parentGroup], [ 'mainLanguageCode' => $language->languageCode, @@ -130,14 +97,16 @@ public function hasCreateAccessAction( try { $userCreateStruct = $this->createContentCreateStruct($contentType, $languageCode); - $locationCreateStruct = $this->locationService->newLocationCreateStruct($parentLocation->id); + $locationCreateStruct = $this->locationService->newLocationCreateStruct( + $parentLocation->getId() + ); if (!$this->permissionResolver->canUser('content', 'create', $userCreateStruct, [$locationCreateStruct])) { throw new UnauthorizedException( 'content', 'create', [ - 'contentTypeIdentifier' => $contentType->identifier, + 'contentTypeIdentifier' => $contentType->getIdentifier(), 'parentLocationId' => $locationCreateStruct->parentLocationId, 'languageCode' => $languageCode, ] @@ -149,7 +118,7 @@ public function hasCreateAccessAction( 'content', 'publish', [ - 'contentTypeIdentifier' => $contentType->identifier, + 'contentTypeIdentifier' => $contentType->getIdentifier(), 'parentLocationId' => $locationCreateStruct->parentLocationId, 'languageCode' => $languageCode, ] @@ -203,13 +172,16 @@ public function editUserAction( $form->handleRequest($request); - if (null === $location && $user->contentInfo->isPublished()) { + if (null === $location && $user->getContentInfo()->isPublished()) { // assume main location if no location was provided - $location = $user->contentInfo->getMainLocation(); + $location = $user->getContentInfo()->getMainLocation(); } - if (null !== $location && $location->contentId !== $user->id) { - throw new InvalidArgumentException('Location', 'The provided Location does not belong to the selected content'); + if (null !== $location && $location->getContentId() !== $user->getUserId()) { + throw new InvalidArgumentException( + 'Location', + 'The provided Location does not belong to the selected content' + ); } if ($form->isSubmitted() && $form->isValid() && null !== $form->getClickedButton()) { @@ -223,7 +195,7 @@ public function editUserAction( if ($this->editUserActionDispatcher->getResponse()) { $view = new EditContentOnTheFlySuccessView('@ibexadesign/ui/on_the_fly/user_edit_response.html.twig'); $view->addParameters([ - 'locationId' => $location->id, + 'locationId' => $location->getId(), ]); return $view; diff --git a/src/bundle/Controller/Version/VersionConflictController.php b/src/bundle/Controller/Version/VersionConflictController.php index 50af7e0272..be8c8dde93 100644 --- a/src/bundle/Controller/Version/VersionConflictController.php +++ b/src/bundle/Controller/Version/VersionConflictController.php @@ -14,16 +14,11 @@ use Ibexa\Core\Base\Exceptions\BadStateException; use Symfony\Component\HttpFoundation\Response; -class VersionConflictController extends Controller +final class VersionConflictController extends Controller { - private ContentService $contentService; - - /** - * @param \Ibexa\Contracts\Core\Repository\ContentService $contentService - */ - public function __construct(ContentService $contentService) - { - $this->contentService = $contentService; + public function __construct( + private readonly ContentService $contentService + ) { } /** @@ -31,12 +26,6 @@ public function __construct(ContentService $contentService) * * If Version has no conflict, return empty Response. If it has conflict return HTML with content of modal. * - * @param int $contentId - * @param int $versionNo - * @param string $languageCode - * - * @return \Symfony\Component\HttpFoundation\Response - * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Core\Base\Exceptions\BadStateException diff --git a/src/bundle/Controller/VersionController.php b/src/bundle/Controller/VersionController.php index 72440aa835..27a2086347 100644 --- a/src/bundle/Controller/VersionController.php +++ b/src/bundle/Controller/VersionController.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\Controller; @@ -20,45 +21,18 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class VersionController extends Controller +final class VersionController extends Controller { - private TranslatableNotificationHandlerInterface $notificationHandler; - - private ContentService $contentService; - - private FormFactory $formFactory; - - private SubmitHandler $submitHandler; - - private TranslationHelper $translationHelper; - - /** - * @param \Ibexa\Contracts\AdminUi\Notification\TranslatableNotificationHandlerInterface $notificationHandler - * @param \Ibexa\Contracts\Core\Repository\ContentService $contentService - * @param \Ibexa\AdminUi\Form\Factory\FormFactory $formFactory - * @param \Ibexa\AdminUi\Form\SubmitHandler $submitHandler - * @param \Ibexa\Core\Helper\TranslationHelper $translationHelper - */ public function __construct( - TranslatableNotificationHandlerInterface $notificationHandler, - ContentService $contentService, - FormFactory $formFactory, - SubmitHandler $submitHandler, - TranslationHelper $translationHelper + private readonly TranslatableNotificationHandlerInterface $notificationHandler, + private readonly ContentService $contentService, + private readonly FormFactory $formFactory, + private readonly SubmitHandler $submitHandler, + private readonly TranslationHelper $translationHelper ) { - $this->notificationHandler = $notificationHandler; - $this->contentService = $contentService; - $this->formFactory = $formFactory; - $this->submitHandler = $submitHandler; - $this->translationHelper = $translationHelper; } /** - * @param \Symfony\Component\HttpFoundation\Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - * - * @throws \InvalidArgumentException * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException @@ -102,8 +76,8 @@ public function removeAction(Request $request): Response ); return new RedirectResponse($this->generateUrl('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => VersionsTab::URI_FRAGMENT, ])); }); @@ -114,8 +88,8 @@ public function removeAction(Request $request): Response } return $this->redirectToRoute('ibexa.content.view', [ - 'contentId' => $contentInfo->id, - 'locationId' => $contentInfo->mainLocationId, + 'contentId' => $contentInfo->getId(), + 'locationId' => $contentInfo->getMainLocationId(), '_fragment' => VersionsTab::URI_FRAGMENT, ]); } diff --git a/src/bundle/DependencyInjection/Compiler/ComponentPass.php b/src/bundle/DependencyInjection/Compiler/ComponentPass.php index 26522511a4..c72fa9c006 100644 --- a/src/bundle/DependencyInjection/Compiler/ComponentPass.php +++ b/src/bundle/DependencyInjection/Compiler/ComponentPass.php @@ -18,15 +18,13 @@ * @deprecated 4.6.19 The {@see \Ibexa\Bundle\AdminUi\DependencyInjection\Compiler\ComponentPass} class is deprecated, will be removed in 6.0. * Use {@see \Ibexa\Bundle\TwigComponents\DependencyInjection\Compiler\ComponentPass} instead */ -class ComponentPass implements CompilerPassInterface +final readonly class ComponentPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; - public const TAG_NAME = 'ibexa.admin_ui.component'; + public const string TAG_NAME = 'ibexa.admin_ui.component'; /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - * * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException When a service is abstract * @throws \Ibexa\AdminUi\Exception\InvalidArgumentException When a tag is missing 'group' attribute */ diff --git a/src/bundle/DependencyInjection/Compiler/FieldTypeFormMapperDispatcherPass.php b/src/bundle/DependencyInjection/Compiler/FieldTypeFormMapperDispatcherPass.php index 8eff398d47..e5dbc04478 100644 --- a/src/bundle/DependencyInjection/Compiler/FieldTypeFormMapperDispatcherPass.php +++ b/src/bundle/DependencyInjection/Compiler/FieldTypeFormMapperDispatcherPass.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\DependencyInjection\Compiler; @@ -16,10 +17,10 @@ /** * Compiler pass to register FieldType form mappers in the mapper dispatcher. */ -class FieldTypeFormMapperDispatcherPass implements CompilerPassInterface +final readonly class FieldTypeFormMapperDispatcherPass implements CompilerPassInterface { - public const FIELD_TYPE_FORM_MAPPER_DISPATCHER = FieldTypeDefinitionFormMapperDispatcher::class; - public const FIELD_TYPE_FORM_MAPPER_DEFINITION_SERVICE_TAG = 'ibexa.admin_ui.field_type.form.mapper.definition'; + public const string FIELD_TYPE_FORM_MAPPER_DISPATCHER = FieldTypeDefinitionFormMapperDispatcher::class; + public const string FIELD_TYPE_FORM_MAPPER_DEFINITION_SERVICE_TAG = 'ibexa.admin_ui.field_type.form.mapper.definition'; public function process(ContainerBuilder $container): void { @@ -32,6 +33,7 @@ public function process(ContainerBuilder $container): void $serviceTags = $container->findTaggedServiceIds( self::FIELD_TYPE_FORM_MAPPER_DEFINITION_SERVICE_TAG ); + foreach ($serviceTags as $id => $tags) { foreach ($tags as $tag) { if (!isset($tag['fieldType'])) { diff --git a/src/bundle/DependencyInjection/Compiler/LimitationFormMapperPass.php b/src/bundle/DependencyInjection/Compiler/LimitationFormMapperPass.php index d2880f3537..f57d8ec055 100644 --- a/src/bundle/DependencyInjection/Compiler/LimitationFormMapperPass.php +++ b/src/bundle/DependencyInjection/Compiler/LimitationFormMapperPass.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\DependencyInjection\Compiler; @@ -16,9 +17,9 @@ /** * Compiler pass to register Limitation form mappers. */ -class LimitationFormMapperPass implements CompilerPassInterface +final readonly class LimitationFormMapperPass implements CompilerPassInterface { - private const LIMITATION_MAPPER_FORM_TAG = 'ibexa.admin_ui.limitation.mapper.form'; + private const string LIMITATION_MAPPER_FORM_TAG = 'ibexa.admin_ui.limitation.mapper.form'; public function process(ContainerBuilder $container): void { diff --git a/src/bundle/DependencyInjection/Compiler/LimitationValueMapperPass.php b/src/bundle/DependencyInjection/Compiler/LimitationValueMapperPass.php index 0e9da639ab..8784ebaecf 100644 --- a/src/bundle/DependencyInjection/Compiler/LimitationValueMapperPass.php +++ b/src/bundle/DependencyInjection/Compiler/LimitationValueMapperPass.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\DependencyInjection\Compiler; @@ -16,10 +17,10 @@ /** * Compiler pass to register Limitation value mappers. */ -class LimitationValueMapperPass implements CompilerPassInterface +final readonly class LimitationValueMapperPass implements CompilerPassInterface { - public const LIMITATION_VALUE_MAPPER_REGISTRY = LimitationValueMapperRegistry::class; - public const LIMITATION_VALUE_MAPPER_TAG = 'ibexa.admin_ui.limitation.mapper.value'; + public const string LIMITATION_VALUE_MAPPER_REGISTRY = LimitationValueMapperRegistry::class; + public const string LIMITATION_VALUE_MAPPER_TAG = 'ibexa.admin_ui.limitation.mapper.value'; public function process(ContainerBuilder $container): void { diff --git a/src/bundle/DependencyInjection/Compiler/TabPass.php b/src/bundle/DependencyInjection/Compiler/TabPass.php index 81df035295..46f7cd70ac 100644 --- a/src/bundle/DependencyInjection/Compiler/TabPass.php +++ b/src/bundle/DependencyInjection/Compiler/TabPass.php @@ -14,15 +14,13 @@ use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; -class TabPass implements CompilerPassInterface +final readonly class TabPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; - public const TAG_TAB = 'ibexa.admin_ui.tab'; + public const string TAG_TAB = 'ibexa.admin_ui.tab'; /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - * * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException When a service is abstract * @throws \Ibexa\AdminUi\Exception\InvalidArgumentException When a tag is missing 'group' attribute */ diff --git a/src/bundle/DependencyInjection/Compiler/UiConfigProviderPass.php b/src/bundle/DependencyInjection/Compiler/UiConfigProviderPass.php index d74450417a..b11f81acd4 100644 --- a/src/bundle/DependencyInjection/Compiler/UiConfigProviderPass.php +++ b/src/bundle/DependencyInjection/Compiler/UiConfigProviderPass.php @@ -16,13 +16,11 @@ /** * Supplies config Providers to the Aggregator. */ -class UiConfigProviderPass implements CompilerPassInterface +final readonly class UiConfigProviderPass implements CompilerPassInterface { - public const TAG_CONFIG_PROVIDER = 'ibexa.admin_ui.config.provider'; + public const string TAG_CONFIG_PROVIDER = 'ibexa.admin_ui.config.provider'; /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - * * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException */ diff --git a/src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php b/src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php index 626e755192..0ce3996d3d 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/AdminUiForms.php @@ -26,22 +26,17 @@ * - { template: 'template.html.twig', priority: 0 } * ``` */ -class AdminUiForms extends AbstractParser +final class AdminUiForms extends AbstractParser { - public const FORM_TEMPLATES_PARAM = 'admin_ui_forms.content_edit_form_templates'; - public const FIELD_TYPES_PARAM = 'admin_ui_forms.content_edit.fieldtypes'; - public const META_FIELD_GROUPS_LIST_PARAM = 'admin_ui_forms.content_edit.meta_field_groups_list'; - public const CONTENT_TYPE_FIELD_TYPES_PARAM = 'admin_ui_forms.content_type_edit.field_types'; - public const CONTENT_TYPE_DEFAULT_META_FIELD_TYPE_GROUP_PARAM = + public const string FORM_TEMPLATES_PARAM = 'admin_ui_forms.content_edit_form_templates'; + public const string FIELD_TYPES_PARAM = 'admin_ui_forms.content_edit.fieldtypes'; + public const string META_FIELD_GROUPS_LIST_PARAM = 'admin_ui_forms.content_edit.meta_field_groups_list'; + public const string CONTENT_TYPE_FIELD_TYPES_PARAM = 'admin_ui_forms.content_type_edit.field_types'; + public const string CONTENT_TYPE_DEFAULT_META_FIELD_TYPE_GROUP_PARAM = 'admin_ui_forms.content_type_edit.default_meta_field_type_group'; - private const GROUP_NAME_PATTERN = '/^[a-zA-Z0-9_][a-zA-Z0-9_\-:]*$/D'; + private const string GROUP_NAME_PATTERN = '/^[a-zA-Z0-9_][a-zA-Z0-9_\-:]*$/D'; - /** - * Adds semantic configuration definition. - * - * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system. - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -128,11 +123,11 @@ static function (array $config): bool { } /** - * {@inheritdoc} + * @param array $scopeSettings */ public function mapConfig( array &$scopeSettings, - $currentScope, + mixed $currentScope, ContextualizerInterface $contextualizer ): void { if (!empty($scopeSettings['admin_ui_forms']['content_edit']['form_templates'])) { @@ -194,10 +189,12 @@ public function mapConfig( } /** - * {@inheritdoc} + * @param array $config */ - public function postMap(array $config, ContextualizerInterface $contextualizer): void - { + public function postMap( + array $config, + ContextualizerInterface $contextualizer + ): void { $contextualizer->mapConfigArray('admin_ui_forms.content_edit_form_templates', $config); $contextualizer->mapConfigArray('admin_ui_forms.content_edit.fieldtypes', $config); $contextualizer->mapConfigArray('admin_ui_forms.content_edit.meta_field_groups_list', $config); @@ -216,9 +213,9 @@ public function postMap(array $config, ContextualizerInterface $contextualizer): * ], * * - * @param array $formTemplates + * @param string[] $formTemplates * - * @return array ordered list of templates + * @return string[] ordered list of templates */ private function processContentEditFormTemplates(array $formTemplates): array { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/AdminUiParser.php b/src/bundle/DependencyInjection/Configuration/Parser/AdminUiParser.php index 0c454ca3df..11f14f801b 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/AdminUiParser.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/AdminUiParser.php @@ -26,7 +26,7 @@ */ final class AdminUiParser extends AbstractParser { - private const MODES = [ + private const array MODES = [ 'off' => FocusMode::FOCUS_MODE_OFF, 'on' => FocusMode::FOCUS_MODE_ON, ]; @@ -36,7 +36,7 @@ final class AdminUiParser extends AbstractParser */ public function mapConfig( array &$scopeSettings, - $currentScope, + mixed $currentScope, ContextualizerInterface $contextualizer ): void { if (empty($scopeSettings['admin_ui'])) { diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Assets.php b/src/bundle/DependencyInjection/Configuration/Parser/Assets.php index 6ed1a6cc2f..5f5f81565c 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Assets.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Assets.php @@ -10,11 +10,12 @@ use Ibexa\Bundle\Core\DependencyInjection\Configuration\AbstractParser; use Ibexa\Bundle\Core\DependencyInjection\Configuration\SiteAccessAware\ContextualizerInterface; +use SplFileInfo; use Symfony\Component\Config\Definition\Builder\NodeBuilder; -class Assets extends AbstractParser +final class Assets extends AbstractParser { - private const ASSETS_NODE = 'assets'; + private const string ASSETS_NODE = 'assets'; public function addSemanticConfig(NodeBuilder $nodeBuilder): void { @@ -33,8 +34,8 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ]) ->validate() ->ifTrue(static function (array $value): bool { - foreach ($value as $set => $path) { - $file = new \SplFileInfo($path); + foreach ($value as $path) { + $file = new SplFileInfo($path); if ($file->getExtension() !== 'svg') { return true; @@ -61,8 +62,14 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ->end(); } - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + /** + * @param array $scopeSettings + */ + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings[self::ASSETS_NODE])) { return; } @@ -72,7 +79,11 @@ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerIn continue; } - $contextualizer->setContextualParameter(sprintf('%s.%s', self::ASSETS_NODE, $identifier), $currentScope, $config); + $contextualizer->setContextualParameter( + sprintf('%s.%s', self::ASSETS_NODE, $identifier), + $currentScope, + $config + ); } } } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/ContentTranslateView.php b/src/bundle/DependencyInjection/Configuration/Parser/ContentTranslateView.php index cd73c7d345..5ebba74be9 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/ContentTranslateView.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/ContentTranslateView.php @@ -10,8 +10,8 @@ use Ibexa\Bundle\Core\DependencyInjection\Configuration\Parser\View; -class ContentTranslateView extends View +final class ContentTranslateView extends View { - public const NODE_KEY = 'content_translate_view'; - public const INFO = 'Template selection settings when displaying a content translate form'; + public const string NODE_KEY = 'content_translate_view'; + public const string INFO = 'Template selection settings when displaying a content translate form'; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/ContentType.php b/src/bundle/DependencyInjection/Configuration/Parser/ContentType.php index 22a6c69cf6..6cff743571 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/ContentType.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/ContentType.php @@ -28,19 +28,26 @@ * thumbnail: '/assets/images/poll.svg' * ``` */ -class ContentType extends AbstractParser +final class ContentType extends AbstractParser { /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['content_type'])) { return; } foreach ($scopeSettings['content_type'] as $identifier => $config) { - $contextualizer->setContextualParameter("content_type.$identifier", $currentScope, $config); + $contextualizer->setContextualParameter( + "content_type.$identifier", + $currentScope, + $config + ); } } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/ContentTypeGroup.php b/src/bundle/DependencyInjection/Configuration/Parser/ContentTypeGroup.php index 6f9bcd170d..95a31a2f4f 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/ContentTypeGroup.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/ContentTypeGroup.php @@ -48,14 +48,21 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void /** * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['content_type_group'])) { return; } foreach ($scopeSettings['content_type_group'] as $identifier => $config) { - $contextualizer->setContextualParameter("content_type_group.$identifier", $currentScope, $config); + $contextualizer->setContextualParameter( + "content_type_group.$identifier", + $currentScope, + $config + ); } } } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/LimitationValueTemplates.php b/src/bundle/DependencyInjection/Configuration/Parser/LimitationValueTemplates.php index 29a5c420dd..d195ef4c17 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/LimitationValueTemplates.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/LimitationValueTemplates.php @@ -4,14 +4,15 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\DependencyInjection\Configuration\Parser; use Ibexa\Bundle\Core\DependencyInjection\Configuration\Parser\Templates; -class LimitationValueTemplates extends Templates +final class LimitationValueTemplates extends Templates { - public const NODE_KEY = 'limitation_value_templates'; - public const INFO = 'Settings for limitation value templates'; - public const INFO_TEMPLATE_KEY = 'Template file where to find block definition to display limitation values'; + public const string NODE_KEY = 'limitation_value_templates'; + public const string INFO = 'Settings for limitation value templates'; + public const string INFO_TEMPLATE_KEY = 'Template file where to find block definition to display limitation values'; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/LocationIds.php b/src/bundle/DependencyInjection/Configuration/Parser/LocationIds.php index 4ded21f4f9..73c9bd459f 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/LocationIds.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/LocationIds.php @@ -17,7 +17,7 @@ * * Example configuration: * ```yaml - * ezpublish: + * ibexa: * system: * default: # configuration per siteaccess or siteaccess group * location_ids: @@ -26,13 +26,8 @@ * users: 5 * ``` */ -class LocationIds extends AbstractParser +final class LocationIds extends AbstractParser { - /** - * Adds semantic configuration definition. - * - * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system. - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -47,10 +42,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['location_ids'])) { return; } @@ -59,7 +57,7 @@ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerIn $keys = ['content_structure', 'media', 'users']; foreach ($keys as $key) { - if (!isset($settings[$key]) || empty($settings[$key])) { + if (empty($settings[$key])) { continue; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Module/ContentTree.php b/src/bundle/DependencyInjection/Configuration/Parser/Module/ContentTree.php index 09d3cd9626..23160f2eb2 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Module/ContentTree.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Module/ContentTree.php @@ -17,7 +17,7 @@ * * Example configuration: * ```yaml - * ezpublish: + * ibexa: * system: * default: # configuration per siteaccess or siteaccess group * content_tree_module: @@ -29,7 +29,7 @@ * ignored_content_types: [article, post] * ``` */ -class ContentTree extends AbstractParser +final class ContentTree extends AbstractParser { /** * {@inheritdoc} @@ -99,10 +99,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['content_tree_module'])) { return; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Module/Subitems.php b/src/bundle/DependencyInjection/Configuration/Parser/Module/Subitems.php index 45ac0852f1..0df3c21e66 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Module/Subitems.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Module/Subitems.php @@ -17,20 +17,15 @@ * * Example configuration: * ```yaml - * ezpublish: + * ibexa: * system: * default: # configuration per siteaccess or siteaccess group * subitems_module: * limit: 10 * ``` */ -class Subitems extends AbstractParser +final class Subitems extends AbstractParser { - /** - * Adds semantic configuration definition. - * - * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system. - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -43,10 +38,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['subitems_module'])) { return; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Module/UniversalDiscoveryWidget.php b/src/bundle/DependencyInjection/Configuration/Parser/Module/UniversalDiscoveryWidget.php index 917799c81d..b02a0e610f 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Module/UniversalDiscoveryWidget.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Module/UniversalDiscoveryWidget.php @@ -15,13 +15,8 @@ /** * Configuration parser for UDW module. */ -class UniversalDiscoveryWidget extends AbstractParser +final class UniversalDiscoveryWidget extends AbstractParser { - /** - * Adds semantic configuration definition. - * - * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system. - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -38,10 +33,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['universal_discovery_widget_module'])) { return; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Notifications.php b/src/bundle/DependencyInjection/Configuration/Parser/Notifications.php index 294b48f24b..94bb682ce8 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Notifications.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Notifications.php @@ -27,20 +27,23 @@ * interval: 60000 # in milliseconds * ``` */ -class Notifications extends AbstractParser +final class Notifications extends AbstractParser { /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (!empty($scopeSettings['notifications'])) { $settings = $scopeSettings['notifications']; $nodes = ['timeout']; foreach ($settings as $type => $config) { foreach ($nodes as $key) { - if (!isset($config[$key]) || empty($config[$key])) { + if (empty($config[$key])) { continue; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php b/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php index 70f85cfb32..add3fc85ed 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Pagination.php @@ -17,7 +17,7 @@ * * Example configuration: * ```yaml - * ezpublish: + * ibexa: * system: * default: # configuration per siteaccess or siteaccess group * pagination: @@ -26,13 +26,8 @@ * language_limit: 10 * ``` */ -class Pagination extends AbstractParser +final class Pagination extends AbstractParser { - /** - * Adds semantic configuration definition. - * - * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system. - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -61,10 +56,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['pagination'])) { return; } @@ -91,7 +89,7 @@ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerIn ]; foreach ($keys as $key) { - if (!isset($settings[$key]) || empty($settings[$key])) { + if (empty($settings[$key])) { continue; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/Security.php b/src/bundle/DependencyInjection/Configuration/Parser/Security.php index 18c34fa27f..51ec2e5c3d 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/Security.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/Security.php @@ -17,20 +17,15 @@ * * Example configuration: * ```yaml - * ezpublish: + * ibexa: * system: * default: # configuration per siteaccess or siteaccess group * security: * token_interval_spec: 'PT1H' * ``` */ -class Security extends AbstractParser +final class Security extends AbstractParser { - /** - * Adds semantic configuration definition. - * - * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system. - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -46,10 +41,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['security'])) { return; } @@ -58,7 +56,7 @@ public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerIn $keys = ['token_interval_spec']; foreach ($keys as $key) { - if (!isset($settings[$key]) || empty($settings[$key])) { + if (empty($settings[$key])) { continue; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/SubtreeOperations.php b/src/bundle/DependencyInjection/Configuration/Parser/SubtreeOperations.php index 1f3714ed6a..7856d5752a 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/SubtreeOperations.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/SubtreeOperations.php @@ -25,10 +25,16 @@ * limit: 200 * ``` */ -class SubtreeOperations extends AbstractParser +final class SubtreeOperations extends AbstractParser { - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + /** + * @param array $scopeSettings + */ + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (!isset($scopeSettings['subtree_operations']['copy_subtree']['limit'])) { return; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/SubtreePath.php b/src/bundle/DependencyInjection/Configuration/Parser/SubtreePath.php index 825a3849a5..02676fc19d 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/SubtreePath.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/SubtreePath.php @@ -17,7 +17,7 @@ * * Example configuration: * ```yaml - * ezpublish: + * ibexa: * system: * default: # configuration per siteaccess or siteaccess group * subtree_paths: @@ -25,10 +25,10 @@ * media: '/1/43/' * ``` */ -class SubtreePath extends AbstractParser +final class SubtreePath extends AbstractParser { - public const CONTENT_SUBTREE_PATH = 'subtree_paths.content'; - public const MEDIA_SUBTREE_PATH = 'subtree_paths.media'; + public const string CONTENT_SUBTREE_PATH = 'subtree_paths.content'; + public const string MEDIA_SUBTREE_PATH = 'subtree_paths.media'; public function addSemanticConfig(NodeBuilder $nodeBuilder): void { @@ -49,8 +49,14 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void ->end(); } - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + /** + * @param array $scopeSettings + */ + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['subtree_paths'])) { return; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/UserGroupIdentifier.php b/src/bundle/DependencyInjection/Configuration/Parser/UserGroupIdentifier.php index ca7f795950..813be73ed0 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/UserGroupIdentifier.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/UserGroupIdentifier.php @@ -17,19 +17,14 @@ * * Example configuration: * ```yaml - * ezpublish: + * ibexa: * system: * default: # configuration per siteaccess or siteaccess group * user_group_content_type_identifier: ['user_group', 'my_custom_user_group_identifier'] * ``` */ -class UserGroupIdentifier extends AbstractParser +final class UserGroupIdentifier extends AbstractParser { - /** - * Adds semantic configuration definition. - * - * @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system. - */ public function addSemanticConfig(NodeBuilder $nodeBuilder): void { $nodeBuilder @@ -42,10 +37,13 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void } /** - * {@inheritdoc} + * @param array $scopeSettings */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['user_group_content_type_identifier'])) { return; } diff --git a/src/bundle/DependencyInjection/Configuration/Parser/UserProfile.php b/src/bundle/DependencyInjection/Configuration/Parser/UserProfile.php index 60f611cda9..24300504ce 100644 --- a/src/bundle/DependencyInjection/Configuration/Parser/UserProfile.php +++ b/src/bundle/DependencyInjection/Configuration/Parser/UserProfile.php @@ -39,10 +39,12 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder): void /** * @param array $scopeSettings - * @param string $currentScope */ - public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void - { + public function mapConfig( + array &$scopeSettings, + mixed $currentScope, + ContextualizerInterface $contextualizer + ): void { if (empty($scopeSettings['user_profile'])) { return; } diff --git a/src/bundle/DependencyInjection/IbexaAdminUiExtension.php b/src/bundle/DependencyInjection/IbexaAdminUiExtension.php index 6c19e76863..336060a995 100644 --- a/src/bundle/DependencyInjection/IbexaAdminUiExtension.php +++ b/src/bundle/DependencyInjection/IbexaAdminUiExtension.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi\DependencyInjection; @@ -16,9 +17,9 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\Yaml\Yaml; -class IbexaAdminUiExtension extends Extension implements PrependExtensionInterface +final class IbexaAdminUiExtension extends Extension implements PrependExtensionInterface { - private const WEBPACK_CONFIG_NAMES = [ + private const array WEBPACK_CONFIG_NAMES = [ 'ibexa.config.js' => [ 'ibexa.config.js' => [], ], @@ -43,10 +44,7 @@ class IbexaAdminUiExtension extends Extension implements PrependExtensionInterfa ]; /** - * Loads a specific configuration. - * - * @param array $configs An array of configuration values - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance + * @param array $configs * * @throws \InvalidArgumentException When provided tag is not defined in this extension * @throws \Exception @@ -93,7 +91,7 @@ public function prepend(ContainerBuilder $container): void private function prependViews(ContainerBuilder $container): void { $configFile = __DIR__ . '/../Resources/config/views.yaml'; - $config = Yaml::parse(file_get_contents($configFile)); + $config = Yaml::parseFile($configFile); $container->prependExtensionConfig('ibexa', $config); $container->addResource(new FileResource($configFile)); } @@ -101,7 +99,7 @@ private function prependViews(ContainerBuilder $container): void private function prependImageVariations(ContainerBuilder $container): void { $imageConfigFile = __DIR__ . '/../Resources/config/image_variations.yaml'; - $config = Yaml::parse(file_get_contents($imageConfigFile)); + $config = Yaml::parseFile($imageConfigFile); $container->prependExtensionConfig('ibexa', $config); $container->addResource(new FileResource($imageConfigFile)); } @@ -109,7 +107,7 @@ private function prependImageVariations(ContainerBuilder $container): void private function prependUniversalDiscoveryWidget(ContainerBuilder $container): void { $udwConfigFile = __DIR__ . '/../Resources/config/universal_discovery_widget.yaml'; - $config = Yaml::parse(file_get_contents($udwConfigFile)); + $config = Yaml::parseFile($udwConfigFile); $container->prependExtensionConfig('ibexa', $config); $container->addResource(new FileResource($udwConfigFile)); } diff --git a/src/bundle/IbexaAdminUiBundle.php b/src/bundle/IbexaAdminUiBundle.php index 3ba667fc84..f1c1e2969e 100644 --- a/src/bundle/IbexaAdminUiBundle.php +++ b/src/bundle/IbexaAdminUiBundle.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\Bundle\AdminUi; @@ -17,13 +18,11 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; -class IbexaAdminUiBundle extends Bundle +final class IbexaAdminUiBundle extends Bundle { - public const ADMIN_GROUP_NAME = 'admin_group'; + public const string ADMIN_GROUP_NAME = 'admin_group'; /** - * {@inheritdoc} - * * @throws \Symfony\Component\DependencyInjection\Exception\LogicException */ public function build(ContainerBuilder $container): void @@ -39,9 +38,6 @@ public function build(ContainerBuilder $container): void $this->addCompilerPasses($container); } - /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - */ private function addCompilerPasses(ContainerBuilder $container): void { $container->addCompilerPass(new TabPass()); diff --git a/src/bundle/Resources/public/js/scripts/fieldType/ibexa_gmap_location.js b/src/bundle/Resources/public/js/scripts/fieldType/ibexa_gmap_location.js index 0fb43e64fd..5aff060f54 100644 --- a/src/bundle/Resources/public/js/scripts/fieldType/ibexa_gmap_location.js +++ b/src/bundle/Resources/public/js/scripts/fieldType/ibexa_gmap_location.js @@ -303,7 +303,7 @@ if (validationResult.isError) { const errorMessage = Translator.trans( - /* @Desc("Area below needs correction") */ 'ezmaplocation.create.message.error', + /* @Desc("Area below needs correction") */ 'ibexa_maplocation.create.message.error', {}, 'ibexa_fieldtypes_edit', ); diff --git a/src/bundle/Resources/translations/ibexa_content.en.xliff b/src/bundle/Resources/translations/ibexa_content.en.xliff index 488ba28134..3ea6b5a3ae 100644 --- a/src/bundle/Resources/translations/ibexa_content.en.xliff +++ b/src/bundle/Resources/translations/ibexa_content.en.xliff @@ -106,6 +106,16 @@ Sending '%content%' and its %children_count% Content item(s) to Trash will also send the sub-items of this Location to Trash. key: trash_container.modal.message_main + + Deleting user failed. + Deleting user failed. + key: user.delete.error.failed + + + Deleting user failed. User has no main location. + Deleting user failed. User has no main location. + key: user.delete.error.no_main_location + User with login '%login%' deleted. User with login '%login%' deleted. diff --git a/src/bundle/Resources/translations/ibexa_content_forms_content.en.xliff b/src/bundle/Resources/translations/ibexa_content_forms_content.en.xliff index 9fb5918efc..fb121977ef 100644 --- a/src/bundle/Resources/translations/ibexa_content_forms_content.en.xliff +++ b/src/bundle/Resources/translations/ibexa_content_forms_content.en.xliff @@ -6,191 +6,191 @@ The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message. - + Delete Delete key: content.field_type.ibexa_image.delete - + H:%height% px H:%height% px key: content.field_type.ibexa_image.dimensions.height - + Master dimension Master dimension key: content.field_type.ibexa_image.dimensions.label - + W:%width% px W:%width% px key: content.field_type.ibexa_image.dimensions.width - + File name File name key: content.field_type.ibexa_image.file_name.label - + Size Size key: content.field_type.ibexa_image.file_size.label - + Image stored in Field '%label%' Image stored in Field '%label%' key: content.field_type.ibexa_image.img_alt - + Preview Preview key: content.field_type.ibexa_image.preview - + File name File name key: content.field_type.ibexa_image_asset.file_name.label - + Image stored in Field '%label%' Image stored in Field '%label%' key: content.field_type.ibexa_image_asset.img_alt - + Delete Delete key: content.field_type.ibexa_media.delete - + Download Download key: content.field_type.ibexa_media.download - + File name File name key: content.field_type.ibexa_media.file_name.label - + Size Size key: content.field_type.ibexa_media.file_size.label - + Player settings Player settings key: content.field_type.ibexa_media.player_settings - + + Drag and drop file + Drag and drop file + key: fieldtype.binary_base.drag_drop + + + or + or + key: fieldtype.binary_base.drag_drop.or + + + Allowed extensions: %extensions% + Allowed extensions: %extensions% + key: fieldtype.binary_base.image_extensions + + + Max file size: %size% + Max file size: %size% + key: fieldtype.binary_base.max_file_size + + + Upload file + Upload file + key: fieldtype.binary_base.upload_file + + + Delete + Delete + key: fieldtype.ibexa_image_asset.delete + + + Select from library + Select from library + key: fieldtype.ibexa_image_asset.select.label + + + to choose a file]]> + to choose a file]]> + key: fieldtype.imageasset.drag_drop + + Download Download key: ibexa_binaryfile.action.download - + Delete Delete key: ibexa_binaryfile.action.remove - + File name File name key: ibexa_binaryfile.file_name.label - + Size Size key: ibexa_binaryfile.file_size.label - + Search address Search address key: ibexa_gmap_location.input.placeholder - + or enter geographical coordinates or enter geographical coordinates key: ibexa_gmap_location.text.info - + Stores a Relation to a Content item. Stores a Relation to a Content item. key: ibexa_object_relation.helper - + Select Item Select Item key: ibexa_object_relation_list.cta.select - + Delete Delete key: ibexa_object_relation_list.delete_selected_relations - + Stores Relations to other Content items. Stores Relations to other Content items. key: ibexa_object_relation_list.helper - + Content type Content type key: ibexa_object_relation_list.table.row.content_type - + Created Created key: ibexa_object_relation_list.table.row.created - + Name Name key: ibexa_object_relation_list.table.row.name - + Order Order key: ibexa_object_relation_list.table.row.order - - Drag and drop file - Drag and drop file - key: fieldtype.binary_base.drag_drop - - - or - or - key: fieldtype.binary_base.drag_drop.or - - - Allowed extensions: %extensions% - Allowed extensions: %extensions% - key: fieldtype.binary_base.image_extensions - - - Max file size: %size% - Max file size: %size% - key: fieldtype.binary_base.max_file_size - - - Upload file - Upload file - key: fieldtype.binary_base.upload_file - - - Delete - Delete - key: fieldtype.ibexa_image_asset.delete - - - Select from library - Select from library - key: fieldtype.ibexa_image_asset.select.label - - - to choose a file]]> - to choose a file]]> - key: fieldtype.imageasset.drag_drop - diff --git a/src/bundle/Resources/translations/ibexa_content_type.en.xliff b/src/bundle/Resources/translations/ibexa_content_type.en.xliff index c330d9d853..b23c20505c 100644 --- a/src/bundle/Resources/translations/ibexa_content_type.en.xliff +++ b/src/bundle/Resources/translations/ibexa_content_type.en.xliff @@ -506,367 +506,367 @@ Description key: field_definition.description - + Default value Default value key: field_definition.ibexa_author.default_author - + Current User Current User key: field_definition.ibexa_author.default_user_current - + Empty Empty key: field_definition.ibexa_author.default_user_empty - + Maximum file size (MB) Maximum file size (MB) key: field_definition.ibexa_binaryfile.max_file_size - + Default value Default value key: field_definition.ibexa_boolean.default_value - + Default country Default country key: field_definition.ibexa_country.default_value - + Multiple choice Multiple choice key: field_definition.ibexa_country.is_multiple - + Default value Default value key: field_definition.ibexa_date.default_type - + Current date Current date key: field_definition.ibexa_date.default_type_current - + Empty Empty key: field_definition.ibexa_date.default_type_empty - + Current date and time adjusted by Current date and time adjusted by key: field_definition.ibexa_datetime.date_interval - + Default value Default value key: field_definition.ibexa_datetime.default_type - + Adjusted current datetime Adjusted current datetime key: field_definition.ibexa_datetime.default_type_adjusted - + Current datetime Current datetime key: field_definition.ibexa_datetime.default_type_current - + Empty Empty key: field_definition.ibexa_datetime.default_type_empty - + Use seconds Use seconds key: field_definition.ibexa_datetime.use_seconds - + Default value Default value key: field_definition.ibexa_float.default_value - + Maximum value Maximum value key: field_definition.ibexa_float.max_value - + Minimum value Minimum value key: field_definition.ibexa_float.min_value - + Image types Image types key: field_definition.ibexa_image.image_types - + Alternative text is required Alternative text is required key: field_definition.ibexa_image.is_alternative_text_required - + Maximum file size (MB) Maximum file size (MB) key: field_definition.ibexa_image.max_file_size - + Default value Default value key: field_definition.ibexa_integer.default_value - + Maximum value Maximum value key: field_definition.ibexa_integer.max_value - + Minimum value Minimum value key: field_definition.ibexa_integer.min_value - + Default value Default value key: field_definition.ibexa_isbn.default_value - + ISBN-13 format ISBN-13 format key: field_definition.ibexa_isbn.is_isbn13 - + Maximum file size (MB) Maximum file size (MB) key: field_definition.ibexa_media.max_file_size - + Media type Media type key: field_definition.ibexa_media.media_type - + Flash Flash key: field_definition.ibexa_media.type_flash - + HTML5 audio HTML5 audio key: field_definition.ibexa_media.type_html5_audio - + HTML5 video HTML5 video key: field_definition.ibexa_media.type_html5_video - + QuickTime QuickTime key: field_definition.ibexa_media.type_quick_time - + RealPlayer RealPlayer key: field_definition.ibexa_media.type_real_player - + Silverlight Silverlight key: field_definition.ibexa_media.type_silverlight - + Windows Media Player Windows Media Player key: field_definition.ibexa_media.type_windows_media_player - + Change path Change path key: field_definition.ibexa_object_relation.change_root_udw_button - + Root Default Location Root Default Location key: field_definition.ibexa_object_relation.root_default_location - + Allowed content types Allowed content types key: field_definition.ibexa_object_relation.selection_content_types - + Starting Location Starting Location key: field_definition.ibexa_object_relation.selection_root - + Select path Select path key: field_definition.ibexa_object_relation.selection_root_udw_button - + Select where to start browsing for a Relation Select where to start browsing for a Relation key: field_definition.ibexa_object_relation.selection_root_udw_title - + Change path Change path key: field_definition.ibexa_object_relation_list.change_root_udw_button - + Root Default Location Root Default Location key: field_definition.ibexa_object_relation_list.root_default_location - + Allowed content types Allowed content types key: field_definition.ibexa_object_relation_list.selection_content_types - + Default Location Default Location key: field_definition.ibexa_object_relation_list.selection_default_location - + Selection limit Selection limit key: field_definition.ibexa_object_relation_list.selection_limit - + Select path Select path key: field_definition.ibexa_object_relation_list.selection_root_udw_button - + Select where to start browsing for Relations Select where to start browsing for Relations key: field_definition.ibexa_object_relation_list.selection_root_udw_title - + Add an option Add an option key: field_definition.ibexa_selection.add_option - + Multiple choice Multiple choice key: field_definition.ibexa_selection.is_multiple - + Options Options key: field_definition.ibexa_selection.options - + Remove selected options Remove selected options key: field_definition.ibexa_selection.remove_selected_options - + Default value Default value key: field_definition.ibexa_string.default_value - + Maximum length Maximum length key: field_definition.ibexa_string.max_length - + Minimum length Minimum length key: field_definition.ibexa_string.min_length - + Number of text rows Number of text rows key: field_definition.ibexa_text.text_rows - + Default value Default value key: field_definition.ibexa_time.default_type - + Current time Current time key: field_definition.ibexa_time.default_type_current - + Empty Empty key: field_definition.ibexa_time.default_type_empty - + Use seconds Use seconds key: field_definition.ibexa_time.use_seconds - + Minimum password length Minimum password length key: field_definition.ibexa_user.min_length - + Days before password expires Days before password expires key: field_definition.ibexa_user.password_ttl - + Days before a user is notified about expiration Days before a user is notified about expiration key: field_definition.ibexa_user.password_ttl_warning - + Password must contain at least one lowercase letter Password must contain at least one lowercase letter key: field_definition.ibexa_user.require_at_least_one_lower_case_character - + Password must contain at least one non-alphanumeric character Password must contain at least one non-alphanumeric character key: field_definition.ibexa_user.require_at_least_one_non_alphanumeric_character - + Password must contain at least one number Password must contain at least one number key: field_definition.ibexa_user.require_at_least_one_numeric_character - + Password must contain at least one uppercase letter Password must contain at least one uppercase letter key: field_definition.ibexa_user.require_at_least_one_upper_case_character - + Prevent reusing old password Prevent reusing old password key: field_definition.ibexa_user.require_new_password - + Password must not be contained in a public breach. Password must not be contained in a public breach. key: field_definition.ibexa_user.require_not_compromised_password - + This uses the API at %link% to securely check breach data. The password is not transmitted to the API. This uses the API at %link% to securely check breach data. The password is not transmitted to the API. key: field_definition.ibexa_user.require_not_compromised_password_help - + Email must be unique Email must be unique key: field_definition.ibexa_user.require_unique_email - + Username pattern Username pattern key: field_definition.ibexa_user.username_pattern diff --git a/src/bundle/Resources/translations/ibexa_fieldtypes_edit.en.xliff b/src/bundle/Resources/translations/ibexa_fieldtypes_edit.en.xliff index 0db76e58d0..510d8f50cc 100644 --- a/src/bundle/Resources/translations/ibexa_fieldtypes_edit.en.xliff +++ b/src/bundle/Resources/translations/ibexa_fieldtypes_edit.en.xliff @@ -6,35 +6,35 @@ The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message. - + H:%height% px H:%height% px key: ibexa_image.dimensions.height - + W:%width% px W:%width% px key: ibexa_image.dimensions.width - + Error while creating Image Asset: %error% Error while creating Image Asset: %error% key: ibexa_image_asset.create.message.error - + The image has been published and can now be reused The image has been published and can now be reused key: ibexa_image_asset.create.message.success - + The chosen asset has no image data available. The chosen asset has no image data available. key: ibexa_image_asset.empty_data.message.error - + Area below needs correction Area below needs correction - key: ezmaplocation.create.message.error + key: ibexa_maplocation.create.message.error diff --git a/src/bundle/Resources/translations/ibexa_fieldtypes_preview.en.xliff b/src/bundle/Resources/translations/ibexa_fieldtypes_preview.en.xliff index 137f374ab0..2def1311e1 100644 --- a/src/bundle/Resources/translations/ibexa_fieldtypes_preview.en.xliff +++ b/src/bundle/Resources/translations/ibexa_fieldtypes_preview.en.xliff @@ -6,242 +6,242 @@ The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message. - + No No key: ibexa_boolean.no - + Yes Yes key: ibexa_boolean.yes - + `The date format is based on your user preferences and does not include seconds even if the Field allows it` `The date format is based on your user preferences and does not include seconds even if the Field allows it` key: ibexa_datetime.useseconds.enabled - + Address Address key: ibexa_gmap_location.address - + Latitude Latitude key: ibexa_gmap_location.latitude - + Location properties Location properties key: ibexa_gmap_location.location_properties - + Longitude Longitude key: ibexa_gmap_location.longitude - + Alternative text Alternative text key: ibexa_image.alternative_text - + File name File name key: ibexa_image.file_name - + Image file properties Image file properties key: ibexa_image.image_file_properties - + Master dimensions Master dimensions key: ibexa_image.master_dimensions - + Ratio Ratio key: ibexa_image.ratio - + Size Size key: ibexa_image.size - + Width: %width%px height: %height%px Width: %width%px height: %height%px key: ibexa_image.width_and_height - + Alternative text Alternative text key: ibexa_image_asset.alternative_text - + File name File name key: ibexa_image_asset.file_name - + Image file properties Image file properties key: ibexa_image_asset.image_file_properties - + Master dimensions Master dimensions key: ibexa_image_asset.master_dimensions - + Image asset is not available (related content has been deleted or you have insufficient permissions) Image asset is not available (related content has been deleted or you have insufficient permissions) key: ibexa_image_asset.not_available - + Ratio Ratio key: ibexa_image_asset.ratio - + Size Size key: ibexa_image_asset.size - + Width: %width%px height: %height%px Width: %width%px height: %height%px key: ibexa_image_asset.width_and_height - + Autoplay Autoplay key: ibexa_media.auto_play - + Your browser does not support HTML5 video Your browser does not support HTML5 video key: ibexa_media.browser_does_not_support_html5_video - + Display controls Display controls key: ibexa_media.display_controls - + File name File name key: ibexa_media.file_name - + Loop Loop key: ibexa_media.loop - + No No key: ibexa_media.no - + Size Size key: ibexa_media.size - + Type Type key: ibexa_media.type - + Video file properties Video file properties key: ibexa_media.video_file_properties - + Yes Yes key: ibexa_media.yes - + Content type Content type key: ibexa_object_relation.content_type - + Name Name key: ibexa_object_relation.name - + Single relation Single relation key: ibexa_object_relation.single_relation - + Version created Version created key: ibexa_object_relation.version_created - + Content type Content type key: ibexa_object_relation_list.content_type - + Created Created key: ibexa_object_relation_list.created - + Multiple relations Multiple relations key: ibexa_object_relation_list.multiple_relations - + Name Name key: ibexa_object_relation_list.name - + Email Email key: ibexa_user.email - + Enabled Enabled key: ibexa_user.enabled - + No No key: ibexa_user.no - + Password has expired Password has expired key: ibexa_user.password_already_expired - + expires in %count% days]]> expires in %count% days]]> key: ibexa_user.password_expires_in - + expires today]]> expires today]]> key: ibexa_user.password_expires_today - + Username Username key: ibexa_user.username - + Yes Yes key: ibexa_user.yes diff --git a/src/bundle/Resources/translations/ibexa_location.en.xliff b/src/bundle/Resources/translations/ibexa_location.en.xliff index 0385cd1135..1c60ed92ab 100644 --- a/src/bundle/Resources/translations/ibexa_location.en.xliff +++ b/src/bundle/Resources/translations/ibexa_location.en.xliff @@ -11,6 +11,11 @@ Subtree assigned to Section '%name%' key: location.assign_section.success + + Location cannot be copied. + Location cannot be copied. + key: location.copy.failure + '%name%' copied to '%location%' '%name%' copied to '%location%' diff --git a/src/bundle/Resources/translations/ibexa_universal_discovery_widget.en.xliff b/src/bundle/Resources/translations/ibexa_universal_discovery_widget.en.xliff index 4dd3c5c4c6..44fdd5c001 100644 --- a/src/bundle/Resources/translations/ibexa_universal_discovery_widget.en.xliff +++ b/src/bundle/Resources/translations/ibexa_universal_discovery_widget.en.xliff @@ -131,21 +131,6 @@ Search... key: dropdown.placeholder - - Select Image Asset - Select Image Asset - key: ibexa_image_asset.title - - - Select Content item(s) - Select Content item(s) - key: ibexa_object_relation_list.title.multi - - - Select a Content item - Select a Content item - key: ibexa_object_relation_list.title.single - Apply Apply @@ -186,6 +171,21 @@ Filters key: filters.title + + Select Image Asset + Select Image Asset + key: ibexa_image_asset.title + + + Select Content item(s) + Select Content item(s) + key: ibexa_object_relation_list.title.multi + + + Select a Content item + Select a Content item + key: ibexa_object_relation_list.title.single + Items already added to the list are marked as selected and unable to deselect. Items already added to the list are marked as selected and unable to deselect. diff --git a/src/bundle/Resources/translations/messages.en.xliff b/src/bundle/Resources/translations/messages.en.xliff index de15fc429d..66c3d4c922 100644 --- a/src/bundle/Resources/translations/messages.en.xliff +++ b/src/bundle/Resources/translations/messages.en.xliff @@ -286,51 +286,6 @@ Something went wrong. Try to refresh the page or contact your administrator. key: error.request.default_msg - - Email - Email - key: ibexa_author.Email - - - Add - Add - key: ibexa_author.action.add - - - Delete - Delete - key: ibexa_author.action.delete - - - Name - Name - key: ibexa_author.name - - - Set up a Relation with one or several Items - Set up a Relation with one or several Items - key: ibexa_object_relation_list.cta.limit.multi - - - Set up a relation with one Content item - Set up a relation with one Content item - key: ibexa_object_relation_list.cta.limit.single - - - Relations max. %limit% - Relations max. %limit% - key: ibexa_object_relation_list.cta.limit.sub_text - - - Select Item - Select Item - key: ibexa_object_relation_list.cta.select - - - Delete - Delete - key: ibexa_object_relation_list.delete_selected_relations - Your password has expired, change it. Your password has expired, change it. @@ -423,6 +378,51 @@ We’ve sent to your email account a link to reset your password. key: ibexa.forgot_user_password.success.alert + + Email + Email + key: ibexa_author.Email + + + Add + Add + key: ibexa_author.action.add + + + Delete + Delete + key: ibexa_author.action.delete + + + Name + Name + key: ibexa_author.name + + + Set up a Relation with one or several Items + Set up a Relation with one or several Items + key: ibexa_object_relation_list.cta.limit.multi + + + Set up a relation with one Content item + Set up a relation with one Content item + key: ibexa_object_relation_list.cta.limit.single + + + Relations max. %limit% + Relations max. %limit% + key: ibexa_object_relation_list.cta.limit.sub_text + + + Select Item + Select Item + key: ibexa_object_relation_list.cta.select + + + Delete + Delete + key: ibexa_object_relation_list.delete_selected_relations + Delete Delete diff --git a/src/bundle/Templating/Twig/ComponentExtension.php b/src/bundle/Templating/Twig/ComponentExtension.php index 27833ca4b3..e43e99af24 100644 --- a/src/bundle/Templating/Twig/ComponentExtension.php +++ b/src/bundle/Templating/Twig/ComponentExtension.php @@ -14,18 +14,12 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -class ComponentExtension extends AbstractExtension +final class ComponentExtension extends AbstractExtension { - protected ComponentRegistry $registry; - - protected RendererInterface $renderer; - public function __construct( - ComponentRegistry $registry, - RendererInterface $renderer + private readonly ComponentRegistry $registry, + private readonly RendererInterface $renderer ) { - $this->registry = $registry; - $this->renderer = $renderer; } public function getFunctions(): array @@ -50,11 +44,17 @@ public function getFunctions(): array ]; } + /** + * @param array $parameters + */ public function renderComponentGroup(string $group, array $parameters = []): string { return implode('', $this->renderer->renderGroup($group, $parameters)); } + /** + * @param array $parameters + */ public function renderComponent(string $group, string $id, array $parameters = []): string { return $this->renderer->renderSingle($group, $id, $parameters); diff --git a/src/bundle/Templating/Twig/ContentTypeGroupIconExtension.php b/src/bundle/Templating/Twig/ContentTypeGroupIconExtension.php index 912a0aaf17..30ad7e4835 100644 --- a/src/bundle/Templating/Twig/ContentTypeGroupIconExtension.php +++ b/src/bundle/Templating/Twig/ContentTypeGroupIconExtension.php @@ -17,11 +17,9 @@ */ final class ContentTypeGroupIconExtension extends AbstractExtension { - private ContentTypeGroupIconResolver $contentTypeGroupIconResolver; - - public function __construct(ContentTypeGroupIconResolver $contentTypeGroupIconResolver) - { - $this->contentTypeGroupIconResolver = $contentTypeGroupIconResolver; + public function __construct( + private readonly ContentTypeGroupIconResolver $contentTypeGroupIconResolver + ) { } public function getFunctions(): array diff --git a/src/bundle/Templating/Twig/ContentTypeIconExtension.php b/src/bundle/Templating/Twig/ContentTypeIconExtension.php index 1a3c0cf4a4..11bfa2aa7d 100644 --- a/src/bundle/Templating/Twig/ContentTypeIconExtension.php +++ b/src/bundle/Templating/Twig/ContentTypeIconExtension.php @@ -12,13 +12,11 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -class ContentTypeIconExtension extends AbstractExtension +final class ContentTypeIconExtension extends AbstractExtension { - private ContentTypeIconResolver $contentTypeIconResolver; - - public function __construct(ContentTypeIconResolver $contentTypeIconResolver) - { - $this->contentTypeIconResolver = $contentTypeIconResolver; + public function __construct( + private readonly ContentTypeIconResolver $contentTypeIconResolver + ) { } public function getFunctions(): array diff --git a/src/bundle/Templating/Twig/EmbeddedItemEditFormExtension.php b/src/bundle/Templating/Twig/EmbeddedItemEditFormExtension.php index 61447587e7..7c9929c8e4 100644 --- a/src/bundle/Templating/Twig/EmbeddedItemEditFormExtension.php +++ b/src/bundle/Templating/Twig/EmbeddedItemEditFormExtension.php @@ -17,16 +17,10 @@ final class EmbeddedItemEditFormExtension extends AbstractExtension { - private FormFactory $formFactory; - - private RouterInterface $router; - public function __construct( - FormFactory $formFactory, - RouterInterface $router + private readonly FormFactory $formFactory, + private readonly RouterInterface $router ) { - $this->formFactory = $formFactory; - $this->router = $router; } public function getFunctions(): array diff --git a/src/bundle/Templating/Twig/FieldEditRenderingExtension.php b/src/bundle/Templating/Twig/FieldEditRenderingExtension.php index 71726fd860..43b3153569 100644 --- a/src/bundle/Templating/Twig/FieldEditRenderingExtension.php +++ b/src/bundle/Templating/Twig/FieldEditRenderingExtension.php @@ -15,13 +15,11 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -class FieldEditRenderingExtension extends AbstractExtension +final class FieldEditRenderingExtension extends AbstractExtension { - private FieldBlockRendererInterface $fieldBlockRenderer; - - public function __construct(FieldBlockRendererInterface $fieldBlockRenderer) - { - $this->fieldBlockRenderer = $fieldBlockRenderer; + public function __construct( + private readonly FieldBlockRendererInterface $fieldBlockRenderer + ) { } /** @@ -29,7 +27,11 @@ public function __construct(FieldBlockRendererInterface $fieldBlockRenderer) */ public function getFunctions(): array { - $fieldDefinitionEditCallable = function (Environment $twig, FieldDefinitionData $fieldDefinitionData, array $params = []): string { + $fieldDefinitionEditCallable = function ( + Environment $twig, + FieldDefinitionData $fieldDefinitionData, + array $params = [] + ): string { $this->fieldBlockRenderer->setTwig($twig); return $this->renderFieldDefinitionEdit($fieldDefinitionData, $params); @@ -47,12 +49,18 @@ public function getFunctions(): array ]; } + /** + * @param array $params + */ public function renderFieldDefinitionEdit(FieldDefinitionData $fieldDefinitionData, array $params = []): string { $params += ['data' => $fieldDefinitionData]; try { - return $this->fieldBlockRenderer->renderFieldDefinitionEdit($fieldDefinitionData->fieldDefinition, $params); - } catch (MissingFieldBlockException $e) { + return $this->fieldBlockRenderer->renderFieldDefinitionEdit( + $fieldDefinitionData->fieldDefinition, + $params + ); + } catch (MissingFieldBlockException) { // Silently fail on purpose. // If there is no template block for current field definition, there might not be anything specific to add. return ''; diff --git a/src/bundle/Templating/Twig/FieldGroupRenderingExtension.php b/src/bundle/Templating/Twig/FieldGroupRenderingExtension.php index 648f040ab6..a5225a0a9f 100644 --- a/src/bundle/Templating/Twig/FieldGroupRenderingExtension.php +++ b/src/bundle/Templating/Twig/FieldGroupRenderingExtension.php @@ -14,14 +14,9 @@ final class FieldGroupRenderingExtension extends AbstractExtension { - private FieldsGroupsList $fieldsGroupsList; - - /** - * @param \Ibexa\Core\Helper\FieldsGroups\FieldsGroupsList $fieldsGroupsListHelper - */ - public function __construct(FieldsGroupsList $fieldsGroupsListHelper) - { - $this->fieldsGroupsList = $fieldsGroupsListHelper; + public function __construct( + private readonly FieldsGroupsList $fieldsGroupsList + ) { } /** diff --git a/src/bundle/Templating/Twig/FocusModeExtension.php b/src/bundle/Templating/Twig/FocusModeExtension.php index d938f8bc1e..bba3e03a3a 100644 --- a/src/bundle/Templating/Twig/FocusModeExtension.php +++ b/src/bundle/Templating/Twig/FocusModeExtension.php @@ -15,11 +15,9 @@ final class FocusModeExtension extends AbstractExtension { - private UserSettingService $userService; - - public function __construct(UserSettingService $userService) - { - $this->userService = $userService; + public function __construct( + private readonly UserSettingService $userService + ) { } public function getFunctions(): array diff --git a/src/bundle/Templating/Twig/FormatIntervalExtension.php b/src/bundle/Templating/Twig/FormatIntervalExtension.php index 8cbbbc503e..e16e86a19b 100644 --- a/src/bundle/Templating/Twig/FormatIntervalExtension.php +++ b/src/bundle/Templating/Twig/FormatIntervalExtension.php @@ -15,7 +15,7 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFilter; -class FormatIntervalExtension extends AbstractExtension implements TranslationContainerInterface +final class FormatIntervalExtension extends AbstractExtension implements TranslationContainerInterface { private const array INTERVAL_PARTS = [ 'y' => 'years', @@ -26,11 +26,9 @@ class FormatIntervalExtension extends AbstractExtension implements TranslationCo 's' => 'seconds', ]; - private TranslatorInterface $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; + public function __construct( + private readonly TranslatorInterface $translator + ) { } public function getFilters(): array diff --git a/src/bundle/Templating/Twig/IconPathExtension.php b/src/bundle/Templating/Twig/IconPathExtension.php index abb1db6165..86244342f3 100644 --- a/src/bundle/Templating/Twig/IconPathExtension.php +++ b/src/bundle/Templating/Twig/IconPathExtension.php @@ -15,11 +15,9 @@ final class IconPathExtension extends AbstractExtension { - private IconPathResolverInterface $iconPathResolver; - - public function __construct(IconPathResolverInterface $iconPathResolver) - { - $this->iconPathResolver = $iconPathResolver; + public function __construct( + private readonly IconPathResolverInterface $iconPathResolver + ) { } public function getFunctions(): array diff --git a/src/bundle/Templating/Twig/LimitationValueRenderingExtension.php b/src/bundle/Templating/Twig/LimitationValueRenderingExtension.php index 6d7babc8e1..2f86881ffc 100644 --- a/src/bundle/Templating/Twig/LimitationValueRenderingExtension.php +++ b/src/bundle/Templating/Twig/LimitationValueRenderingExtension.php @@ -14,13 +14,11 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -class LimitationValueRenderingExtension extends AbstractExtension +final class LimitationValueRenderingExtension extends AbstractExtension { - private LimitationBlockRendererInterface $limitationRenderer; - - public function __construct(LimitationBlockRendererInterface $limitationRenderer) - { - $this->limitationRenderer = $limitationRenderer; + public function __construct( + private readonly LimitationBlockRendererInterface $limitationRenderer + ) { } /** @@ -28,7 +26,7 @@ public function __construct(LimitationBlockRendererInterface $limitationRenderer */ public function getFunctions(): array { - $limitationValueCallable = function (Environment $twig, Limitation $limitation, array $params = []) { + $limitationValueCallable = function (Environment $twig, Limitation $limitation, array $params = []): string { return $this->limitationRenderer->renderLimitationValue($limitation, $params); }; diff --git a/src/bundle/Templating/Twig/LocationExtension.php b/src/bundle/Templating/Twig/LocationExtension.php index d4473f6731..4c02ebb875 100644 --- a/src/bundle/Templating/Twig/LocationExtension.php +++ b/src/bundle/Templating/Twig/LocationExtension.php @@ -14,7 +14,7 @@ final class LocationExtension extends AbstractExtension { - private const SORT_FIELD_TO_SORT_CLAUSE_MAP = [ + private const array SORT_FIELD_TO_SORT_CLAUSE_MAP = [ Location::SORT_FIELD_PATH => 'LocationPath', Location::SORT_FIELD_PUBLISHED => 'DatePublished', Location::SORT_FIELD_MODIFIED => 'DateModified', diff --git a/src/bundle/Templating/Twig/PathStringExtension.php b/src/bundle/Templating/Twig/PathStringExtension.php index 126d0d957f..2ee15304a7 100644 --- a/src/bundle/Templating/Twig/PathStringExtension.php +++ b/src/bundle/Templating/Twig/PathStringExtension.php @@ -12,18 +12,15 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -class PathStringExtension extends AbstractExtension +final class PathStringExtension extends AbstractExtension { - private LocationService $locationService; - public function __construct( - LocationService $locationService + private readonly LocationService $locationService ) { - $this->locationService = $locationService; } /** - * @return array + * @return \Twig\TwigFunction[] */ public function getFunctions(): array { diff --git a/src/bundle/Templating/Twig/TimeDiffExtension.php b/src/bundle/Templating/Twig/TimeDiffExtension.php index bc32eb7204..409cb0545b 100644 --- a/src/bundle/Templating/Twig/TimeDiffExtension.php +++ b/src/bundle/Templating/Twig/TimeDiffExtension.php @@ -14,13 +14,11 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFilter; -class TimeDiffExtension extends AbstractExtension +final class TimeDiffExtension extends AbstractExtension { - private DateTimeFormatter $dateTimeFormatter; - - public function __construct(DateTimeFormatter $dateTimeFormatter) - { - $this->dateTimeFormatter = $dateTimeFormatter; + public function __construct( + private readonly DateTimeFormatter $dateTimeFormatter + ) { } public function getFilters(): array diff --git a/src/bundle/Templating/Twig/UiConfigExtension.php b/src/bundle/Templating/Twig/UiConfigExtension.php index 2a8fe113fe..16355beaa1 100644 --- a/src/bundle/Templating/Twig/UiConfigExtension.php +++ b/src/bundle/Templating/Twig/UiConfigExtension.php @@ -12,31 +12,21 @@ use Ibexa\AdminUi\UI\Config\ConfigWrapper; use ProxyManager\Factory\LazyLoadingValueHolderFactory; use ProxyManager\Proxy\LazyLoadingInterface; -use Twig\Environment; use Twig\Extension\AbstractExtension; use Twig\Extension\GlobalsInterface; /** * Exports `ibexa_admin_ui_config` providing UI Config as a global Twig variable. */ -class UiConfigExtension extends AbstractExtension implements GlobalsInterface +final class UiConfigExtension extends AbstractExtension implements GlobalsInterface { - protected Environment $twig; - - protected Aggregator $aggregator; - - /** - * @param \Twig\Environment $twig - * @param \Ibexa\AdminUi\UI\Config\Aggregator $aggregator - */ - public function __construct(Environment $twig, Aggregator $aggregator) - { - $this->twig = $twig; - $this->aggregator = $aggregator; + public function __construct( + private readonly Aggregator $aggregator + ) { } /** - * @return array + * @return array */ public function getGlobals(): array { @@ -49,8 +39,6 @@ public function getGlobals(): array /** * Create lazy loaded configuration. - * - * @return \Ibexa\AdminUi\UI\Config\ConfigWrapper */ private function createConfigWrapper(): ConfigWrapper { diff --git a/src/bundle/Templating/Twig/UniversalDiscoveryExtension.php b/src/bundle/Templating/Twig/UniversalDiscoveryExtension.php index 71b04ba993..077c919d90 100644 --- a/src/bundle/Templating/Twig/UniversalDiscoveryExtension.php +++ b/src/bundle/Templating/Twig/UniversalDiscoveryExtension.php @@ -12,23 +12,17 @@ use Twig\Extension\AbstractExtension; use Twig\TwigFunction; -class UniversalDiscoveryExtension extends AbstractExtension +final class UniversalDiscoveryExtension extends AbstractExtension { - protected ConfigResolver $udwConfigResolver; - - /** - * @param \Ibexa\AdminUi\UniversalDiscovery\ConfigResolver $udwConfigResolver - */ public function __construct( - ConfigResolver $udwConfigResolver + private readonly ConfigResolver $udwConfigResolver ) { - $this->udwConfigResolver = $udwConfigResolver; } /** - * @return array + * @return \Twig\TwigFunction[] */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction( @@ -40,10 +34,7 @@ public function getFunctions() } /** - * @param string $configName - * @param array $context - * - * @return string + * @param array $context */ public function renderUniversalDiscoveryWidgetConfig(string $configName, array $context = []): string { @@ -51,9 +42,14 @@ public function renderUniversalDiscoveryWidgetConfig(string $configName, array $ $normalized = $this->recursiveConfigurationArrayNormalize($config); - return json_encode($normalized); + return json_encode($normalized) ?: ''; } + /** + * @param array $config + * + * @return array + */ private function recursiveConfigurationArrayNormalize(array $config): array { $normalized = []; @@ -68,9 +64,9 @@ private function recursiveConfigurationArrayNormalize(array $config): array return $normalized; } - private function toCamelCase(string $input, string $delimiter = '_'): string + private function toCamelCase(string $input): string { - $words = explode($delimiter, ucwords($input, $delimiter)); + $words = explode('_', ucwords($input, '_')); return lcfirst(implode('', $words)); } diff --git a/src/bundle/Templating/Twig/UserPreferencesGlobalExtension.php b/src/bundle/Templating/Twig/UserPreferencesGlobalExtension.php index 6e7529118c..07b12a32d1 100644 --- a/src/bundle/Templating/Twig/UserPreferencesGlobalExtension.php +++ b/src/bundle/Templating/Twig/UserPreferencesGlobalExtension.php @@ -19,19 +19,13 @@ */ class UserPreferencesGlobalExtension extends AbstractExtension implements GlobalsInterface { - protected UserSettingArrayAccessor $userSettingArrayAccessor; - - /** - * @param \Ibexa\User\UserSetting\UserSettingArrayAccessor $userSettingArrayAccessor - */ public function __construct( - UserSettingArrayAccessor $userSettingArrayAccessor + private readonly UserSettingArrayAccessor $userSettingArrayAccessor ) { - $this->userSettingArrayAccessor = $userSettingArrayAccessor; } /** - * @return array + * @return array> */ public function getGlobals(): array { diff --git a/src/bundle/Templating/Twig/UserProfileExtension.php b/src/bundle/Templating/Twig/UserProfileExtension.php index 0a592ab521..7030b1d206 100644 --- a/src/bundle/Templating/Twig/UserProfileExtension.php +++ b/src/bundle/Templating/Twig/UserProfileExtension.php @@ -16,11 +16,9 @@ final class UserProfileExtension extends AbstractExtension { - private UserProfileConfigurationInterface $configuration; - - public function __construct(UserProfileConfigurationInterface $configuration) - { - $this->configuration = $configuration; + public function __construct( + private readonly UserProfileConfigurationInterface $configuration + ) { } public function getFunctions(): array diff --git a/src/bundle/ValueResolver/ContentTreeChildrenQueryValueResolver.php b/src/bundle/ValueResolver/ContentTreeChildrenQueryValueResolver.php index 85879662e7..d9c2d387b0 100644 --- a/src/bundle/ValueResolver/ContentTreeChildrenQueryValueResolver.php +++ b/src/bundle/ValueResolver/ContentTreeChildrenQueryValueResolver.php @@ -18,18 +18,14 @@ /** * @phpstan-import-type TCriterionProcessor from \Ibexa\AdminUi\REST\Input\Parser\CriterionProcessor */ -final class ContentTreeChildrenQueryValueResolver implements ValueResolverInterface +final readonly class ContentTreeChildrenQueryValueResolver implements ValueResolverInterface { - /** @phpstan-var TCriterionProcessor */ - private CriterionProcessorInterface $criterionProcessor; - /** * @phpstan-param TCriterionProcessor $criterionProcessor */ public function __construct( - CriterionProcessorInterface $criterionProcessor + private CriterionProcessorInterface $criterionProcessor ) { - $this->criterionProcessor = $criterionProcessor; } /** diff --git a/src/bundle/ValueResolver/UniversalDiscoveryRequestQueryValueResolver.php b/src/bundle/ValueResolver/UniversalDiscoveryRequestQueryValueResolver.php index 9dc228d989..9f2c6cdb00 100644 --- a/src/bundle/ValueResolver/UniversalDiscoveryRequestQueryValueResolver.php +++ b/src/bundle/ValueResolver/UniversalDiscoveryRequestQueryValueResolver.php @@ -21,16 +21,10 @@ final class UniversalDiscoveryRequestQueryValueResolver implements ValueResolverInterface { - private Provider $provider; - - private ValidatorInterface $validator; - public function __construct( - Provider $provider, - ValidatorInterface $validator + private readonly Provider $provider, + private readonly ValidatorInterface $validator ) { - $this->provider = $provider; - $this->validator = $validator; } private function supports(ArgumentMetadata $argument): bool diff --git a/src/bundle/View/IbexaPagerfantaView.php b/src/bundle/View/IbexaPagerfantaView.php index 318a2bbc0e..d717c464cf 100644 --- a/src/bundle/View/IbexaPagerfantaView.php +++ b/src/bundle/View/IbexaPagerfantaView.php @@ -15,7 +15,7 @@ /** * View to render Pagerfanta pagination. */ -class IbexaPagerfantaView extends DefaultView +final class IbexaPagerfantaView extends DefaultView { protected function createDefaultTemplate(): TemplateInterface { diff --git a/src/bundle/View/Template/IbexaPagerfantaTemplate.php b/src/bundle/View/Template/IbexaPagerfantaTemplate.php index e06d698b9b..e4db099583 100644 --- a/src/bundle/View/Template/IbexaPagerfantaTemplate.php +++ b/src/bundle/View/Template/IbexaPagerfantaTemplate.php @@ -13,7 +13,7 @@ /** * Template to customize Pagerfanta pagination. */ -class IbexaPagerfantaTemplate extends TwitterBootstrap4Template +final class IbexaPagerfantaTemplate extends TwitterBootstrap4Template { /** * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException diff --git a/src/lib/Limitation/Templating/LimitationBlockRendererInterface.php b/src/lib/Limitation/Templating/LimitationBlockRendererInterface.php index 73f2a2d3f9..c7ff001df5 100644 --- a/src/lib/Limitation/Templating/LimitationBlockRendererInterface.php +++ b/src/lib/Limitation/Templating/LimitationBlockRendererInterface.php @@ -4,6 +4,7 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); namespace Ibexa\AdminUi\Limitation\Templating; @@ -12,12 +13,7 @@ interface LimitationBlockRendererInterface { /** - * Returns limitation value in human readable format. - * - * @param \Ibexa\Contracts\Core\Repository\Values\User\Limitation $limitation - * @param array $parameters - * - * @return string + * @param array $parameters */ - public function renderLimitationValue(Limitation $limitation, array $parameters = []); + public function renderLimitationValue(Limitation $limitation, array $parameters = []): string; }