From 2ec18dd777a707d6c9cbf8552ab06d470c862098 Mon Sep 17 00:00:00 2001 From: Maximilian Graf Schimmelmann Date: Sun, 3 Sep 2023 19:50:16 +0200 Subject: [PATCH] Apply ECS. --- src/ArgumentResolver/AdminContextResolver.php | 1 - .../BatchActionDtoResolver.php | 28 +- src/Cache/CacheWarmer.php | 1 + src/Collection/ActionCollection.php | 31 +- src/Collection/EntityCollection.php | 1 - src/Collection/FieldCollection.php | 1 - src/Collection/FilterCollection.php | 1 - src/Command/MakeAdminDashboardCommand.php | 51 +- src/Command/MakeCrudControllerCommand.php | 44 +- src/Config/Action.php | 20 +- src/Config/ActionInterface.php | 3 +- src/Config/Actions.php | 101 +- src/Config/ActionsInterface.php | 1 - src/Config/Asset.php | 31 +- src/Config/AssetInterface.php | 1 - src/Config/Assets.php | 7 +- src/Config/AssetsInterface.php | 1 - src/Config/Crud.php | 126 +- src/Config/Dashboard.php | 21 +- src/Config/DashboardInterface.php | 1 - src/Config/Filters.php | 9 +- src/Config/FiltersInterface.php | 1 - src/Config/Locale.php | 7 +- src/Config/LocaleInterface.php | 1 - src/Config/Menu/CrudMenuItem.php | 52 +- src/Config/Menu/MenuItemTrait.php | 5 +- src/Config/Menu/RouteMenuItem.php | 8 +- src/Config/MenuItem.php | 27 +- src/Config/UserMenu.php | 1 - src/Config/UserMenuInterface.php | 1 - src/Context/AdminContext.php | 17 +- src/Context/AdminContextInterface.php | 9 - src/Context/ExceptionContext.php | 2 +- .../Controller/CrudControllerInterface.php | 72 +- .../DashboardControllerInterface.php | 4 - .../Field/FieldConfiguratorInterface.php | 2 - src/Contracts/Field/FieldInterface.php | 6 +- .../Filter/FilterConfiguratorInterface.php | 17 +- src/Contracts/Filter/FilterInterface.php | 11 +- src/Contracts/Menu/MenuItemInterface.php | 1 - .../Orm/EntityPaginatorInterface.php | 1 - .../Orm/EntityRepositoryInterface.php | 9 +- src/Contracts/Orm/EntityUpdaterInterface.php | 1 - src/Controller/AbstractCrudController.php | 359 +++-- .../AbstractDashboardController.php | 16 +- .../CreateControllerRegistriesPass.php | 20 +- src/Dto/ActionConfigDto.php | 1 - src/Dto/ActionDto.php | 7 +- src/Dto/AssetDto.php | 17 +- src/Dto/AssetDtoInterface.php | 6 +- src/Dto/AssetsDto.php | 27 +- src/Dto/BatchActionDto.php | 9 +- src/Dto/CrudDto.php | 112 +- src/Dto/CrudDtoInterface.php | 24 +- src/Dto/DashboardDto.php | 1 - src/Dto/EntityDto.php | 47 +- src/Dto/EntityDtoInterface.php | 4 +- src/Dto/FieldDto.php | 53 +- src/Dto/FieldDtoInterface.php | 10 +- src/Dto/FilterConfigDto.php | 2 +- src/Dto/FilterDataDto.php | 17 +- src/Dto/FilterDto.php | 8 +- src/Dto/I18nDto.php | 8 +- src/Dto/PaginatorDto.php | 9 +- src/Dto/SearchDto.php | 14 +- src/Dto/UserMenuDto.php | 2 - src/Event/AbstractLifecycleEvent.php | 2 +- src/Event/AfterCrudActionEvent.php | 19 +- src/Event/AfterEntityBuiltEvent.php | 3 +- src/Event/AfterEntitySearchEvent.php | 15 +- src/Event/BeforeCrudActionEvent.php | 8 +- src/EventListener/AdminRouterSubscriber.php | 60 +- src/EventListener/CrudResponseListener.php | 8 +- src/EventListener/ExceptionListener.php | 29 +- src/Exception/BaseException.php | 8 +- src/Exception/EntityNotFoundException.php | 7 +- src/Exception/EntityRemoveException.php | 6 +- src/Exception/FlattenException.php | 12 +- src/Exception/ForbiddenActionException.php | 11 +- .../InsufficientEntityPermissionException.php | 15 +- src/Factory/ActionFactory.php | 115 +- src/Factory/AdminContextFactory.php | 147 +- src/Factory/ControllerFactory.php | 38 +- src/Factory/EntityFactory.php | 46 +- src/Factory/FieldFactory.php | 41 +- src/Factory/FieldLayoutFactory.php | 1 - src/Factory/FilterFactory.php | 12 +- src/Factory/FormFactory.php | 48 +- src/Factory/FormFactoryInterface.php | 5 +- src/Factory/MenuFactory.php | 47 +- src/Factory/PaginatorFactory.php | 12 +- src/Field/AssociationField.php | 7 +- src/Field/AvatarField.php | 17 +- src/Field/ChoiceField.php | 25 +- src/Field/CodeEditorField.php | 32 +- src/Field/CollectionField.php | 7 +- src/Field/Configurator/ArrayConfigurator.php | 6 +- .../Configurator/AssociationConfigurator.php | 119 +- src/Field/Configurator/AvatarConfigurator.php | 11 +- .../Configurator/BooleanConfigurator.php | 12 +- src/Field/Configurator/ChoiceConfigurator.php | 55 +- .../Configurator/CodeEditorConfigurator.php | 2 - .../Configurator/CollectionConfigurator.php | 112 +- .../Configurator/CommonPostConfigurator.php | 16 +- .../Configurator/CommonPreConfigurator.php | 47 +- .../Configurator/CountryConfigurator.php | 41 +- .../Configurator/CurrencyConfigurator.php | 18 +- .../Configurator/DateTimeConfigurator.php | 37 +- src/Field/Configurator/EmailConfigurator.php | 2 - src/Field/Configurator/FormConfigurator.php | 2 - src/Field/Configurator/IdConfigurator.php | 4 +- src/Field/Configurator/ImageConfigurator.php | 30 +- .../Configurator/IntegerConfigurator.php | 2 - .../Configurator/LanguageConfigurator.php | 35 +- src/Field/Configurator/LocaleConfigurator.php | 25 +- src/Field/Configurator/MoneyConfigurator.php | 46 +- src/Field/Configurator/NumberConfigurator.php | 5 +- .../Configurator/PercentConfigurator.php | 2 - src/Field/Configurator/SlugConfigurator.php | 24 +- .../Configurator/TelephoneConfigurator.php | 2 - src/Field/Configurator/TextConfigurator.php | 18 +- .../Configurator/TextEditorConfigurator.php | 2 - .../Configurator/TimezoneConfigurator.php | 2 - src/Field/Configurator/UrlConfigurator.php | 8 +- src/Field/CountryField.php | 5 +- src/Field/DateField.php | 18 +- src/Field/DateTimeField.php | 48 +- src/Field/FieldTrait.php | 24 +- src/Field/FormField.php | 33 +- src/Field/IdField.php | 8 +- src/Field/ImageField.php | 5 +- src/Field/LanguageField.php | 5 +- src/Field/MoneyField.php | 12 +- src/Field/NumberField.php | 13 +- src/Field/PercentField.php | 16 +- src/Field/SlugField.php | 3 +- src/Field/TextEditorField.php | 4 +- src/Field/TextField.php | 4 +- src/Field/TextareaField.php | 8 +- src/Field/TimeField.php | 18 +- src/Filter/ArrayFilter.php | 11 +- src/Filter/BooleanFilter.php | 21 +- src/Filter/ChoiceFilter.php | 11 +- src/Filter/ComparisonFilter.php | 11 +- .../Configurator/ChoiceConfigurator.php | 26 +- .../Configurator/CommonConfigurator.php | 19 +- .../Configurator/ComparisonConfigurator.php | 19 +- .../Configurator/DateTimeConfigurator.php | 19 +- .../Configurator/EntityConfigurator.php | 36 +- src/Filter/Configurator/NullConfigurator.php | 26 +- .../Configurator/NumericConfigurator.php | 19 +- src/Filter/Configurator/TextConfigurator.php | 19 +- src/Filter/DateTimeFilter.php | 15 +- src/Filter/EntityFilter.php | 20 +- src/Filter/FilterTrait.php | 12 +- src/Filter/NullFilter.php | 15 +- src/Filter/NumericFilter.php | 15 +- src/Filter/TextFilter.php | 11 +- .../Extension/EaCrudFormTypeExtension.php | 3 +- src/Form/Filter/Type/ArrayFilterType.php | 24 +- src/Form/Filter/Type/ChoiceFilterType.php | 48 +- src/Form/Filter/Type/ComparisonFilterType.php | 18 +- src/Form/Filter/Type/DateTimeFilterType.php | 68 +- src/Form/Filter/Type/NumericFilterType.php | 42 +- src/Form/Filter/Type/TextFilterType.php | 40 +- src/Form/Type/CrudFormType.php | 7 +- src/Form/Type/FileUploadType.php | 39 +- src/Form/Type/FiltersFormType.php | 1 - src/Form/Type/SlugType.php | 3 +- src/Inspector/DataCollector.php | 3 +- src/Intl/IntlFormatter.php | 124 +- src/Maker/ClassMaker.php | 16 +- src/Menu/MenuItemMatcher.php | 30 +- src/Menu/MenuItemMatcherInterface.php | 1 - src/Orm/EntityPaginator.php | 24 +- src/Orm/EntityRepository.php | 127 +- src/Orm/EntityUpdater.php | 7 +- src/Provider/FieldProvider.php | 20 +- src/Registry/CrudControllerRegistry.php | 8 +- src/Registry/DashboardControllerRegistry.php | 12 +- src/Registry/TemplateRegistry.php | 16 +- .../bin/fix-assets-manifest-file.php | 28 +- src/Resources/config/services.php | 324 ++--- src/Resources/public/images/flags/AC.svg | 33 +- src/Resources/public/images/flags/AD.svg | 17 +- src/Resources/public/images/flags/AE.svg | 7 +- src/Resources/public/images/flags/AF.svg | 9 +- src/Resources/public/images/flags/AG.svg | 13 +- src/Resources/public/images/flags/AI.svg | 18 +- src/Resources/public/images/flags/AL.svg | 13 +- src/Resources/public/images/flags/AM.svg | 6 +- src/Resources/public/images/flags/AO.svg | 12 +- src/Resources/public/images/flags/AQ.svg | 6 +- src/Resources/public/images/flags/AR.svg | 6 +- src/Resources/public/images/flags/AS.svg | 10 +- src/Resources/public/images/flags/AT.svg | 5 +- src/Resources/public/images/flags/AU.svg | 19 +- src/Resources/public/images/flags/AW.svg | 9 +- src/Resources/public/images/flags/AX.svg | 6 +- src/Resources/public/images/flags/AZ.svg | 10 +- src/Resources/public/images/flags/BA.svg | 16 +- src/Resources/public/images/flags/BB.svg | 8 +- src/Resources/public/images/flags/BD.svg | 5 +- src/Resources/public/images/flags/BE.svg | 6 +- src/Resources/public/images/flags/BF.svg | 6 +- src/Resources/public/images/flags/BG.svg | 6 +- src/Resources/public/images/flags/BH.svg | 6 +- src/Resources/public/images/flags/BI.svg | 15 +- src/Resources/public/images/flags/BJ.svg | 6 +- src/Resources/public/images/flags/BL.svg | 22 +- src/Resources/public/images/flags/BM.svg | 18 +- src/Resources/public/images/flags/BN.svg | 10 +- src/Resources/public/images/flags/BO.svg | 6 +- src/Resources/public/images/flags/BQ.svg | 9 +- src/Resources/public/images/flags/BR.svg | 8 +- src/Resources/public/images/flags/BS.svg | 8 +- src/Resources/public/images/flags/BT.svg | 7 +- src/Resources/public/images/flags/BV.svg | 8 +- src/Resources/public/images/flags/BW.svg | 8 +- src/Resources/public/images/flags/BY.svg | 12 +- src/Resources/public/images/flags/BZ.svg | 14 +- src/Resources/public/images/flags/CA.svg | 7 +- src/Resources/public/images/flags/CC.svg | 10 +- src/Resources/public/images/flags/CD.svg | 7 +- src/Resources/public/images/flags/CF.svg | 14 +- src/Resources/public/images/flags/CG.svg | 6 +- src/Resources/public/images/flags/CH.svg | 6 +- src/Resources/public/images/flags/CI.svg | 6 +- src/Resources/public/images/flags/CK.svg | 11 +- src/Resources/public/images/flags/CL.svg | 7 +- src/Resources/public/images/flags/CM.svg | 8 +- src/Resources/public/images/flags/CN.svg | 7 +- src/Resources/public/images/flags/CO.svg | 6 +- src/Resources/public/images/flags/CR.svg | 6 +- src/Resources/public/images/flags/CU.svg | 11 +- src/Resources/public/images/flags/CV.svg | 9 +- src/Resources/public/images/flags/CW.svg | 8 +- src/Resources/public/images/flags/CX.svg | 13 +- src/Resources/public/images/flags/CY.svg | 11 +- src/Resources/public/images/flags/CZ.svg | 6 +- src/Resources/public/images/flags/DE.svg | 6 +- src/Resources/public/images/flags/DJ.svg | 7 +- src/Resources/public/images/flags/DK.svg | 5 +- src/Resources/public/images/flags/DM.svg | 16 +- src/Resources/public/images/flags/DO.svg | 14 +- src/Resources/public/images/flags/DZ.svg | 9 +- src/Resources/public/images/flags/EC.svg | 11 +- src/Resources/public/images/flags/EE.svg | 6 +- src/Resources/public/images/flags/EG.svg | 8 +- src/Resources/public/images/flags/EH.svg | 10 +- src/Resources/public/images/flags/ER.svg | 16 +- src/Resources/public/images/flags/ES.svg | 11 +- src/Resources/public/images/flags/ET.svg | 15 +- src/Resources/public/images/flags/EU.svg | 6 +- src/Resources/public/images/flags/FI.svg | 5 +- src/Resources/public/images/flags/FJ.svg | 14 +- src/Resources/public/images/flags/FK.svg | 25 +- src/Resources/public/images/flags/FM.svg | 7 +- src/Resources/public/images/flags/FO.svg | 6 +- src/Resources/public/images/flags/FR.svg | 6 +- src/Resources/public/images/flags/GA.svg | 6 +- src/Resources/public/images/flags/GB.svg | 14 +- src/Resources/public/images/flags/GD.svg | 16 +- src/Resources/public/images/flags/GE-AB.svg | 16 +- src/Resources/public/images/flags/GE-OS.svg | 6 +- src/Resources/public/images/flags/GE.svg | 7 +- src/Resources/public/images/flags/GF.svg | 6 +- src/Resources/public/images/flags/GG.svg | 7 +- src/Resources/public/images/flags/GH.svg | 7 +- src/Resources/public/images/flags/GI.svg | 11 +- src/Resources/public/images/flags/GL.svg | 7 +- src/Resources/public/images/flags/GM.svg | 7 +- src/Resources/public/images/flags/GN.svg | 6 +- src/Resources/public/images/flags/GP.svg | 6 +- src/Resources/public/images/flags/GQ.svg | 15 +- src/Resources/public/images/flags/GR.svg | 12 +- src/Resources/public/images/flags/GS.svg | 26 +- src/Resources/public/images/flags/GT.svg | 10 +- src/Resources/public/images/flags/GU.svg | 16 +- src/Resources/public/images/flags/GW.svg | 7 +- src/Resources/public/images/flags/GY.svg | 8 +- src/Resources/public/images/flags/HK.svg | 9 +- src/Resources/public/images/flags/HM.svg | 19 +- src/Resources/public/images/flags/HN.svg | 7 +- src/Resources/public/images/flags/HR.svg | 17 +- src/Resources/public/images/flags/HT.svg | 11 +- src/Resources/public/images/flags/HU.svg | 6 +- src/Resources/public/images/flags/IC.svg | 6 +- src/Resources/public/images/flags/ID.svg | 5 +- src/Resources/public/images/flags/IE.svg | 6 +- src/Resources/public/images/flags/IL.svg | 7 +- src/Resources/public/images/flags/IM.svg | 8 +- src/Resources/public/images/flags/IN.svg | 11 +- src/Resources/public/images/flags/IO.svg | 21 +- src/Resources/public/images/flags/IQ.svg | 9 +- src/Resources/public/images/flags/IR.svg | 11 +- src/Resources/public/images/flags/IS.svg | 6 +- src/Resources/public/images/flags/IT.svg | 6 +- src/Resources/public/images/flags/JE.svg | 9 +- src/Resources/public/images/flags/JM.svg | 9 +- src/Resources/public/images/flags/JO.svg | 9 +- src/Resources/public/images/flags/JP.svg | 5 +- src/Resources/public/images/flags/KE.svg | 15 +- src/Resources/public/images/flags/KG.svg | 13 +- src/Resources/public/images/flags/KH.svg | 9 +- src/Resources/public/images/flags/KI.svg | 13 +- src/Resources/public/images/flags/KM.svg | 12 +- src/Resources/public/images/flags/KN.svg | 10 +- src/Resources/public/images/flags/KP.svg | 12 +- src/Resources/public/images/flags/KR.svg | 18 +- src/Resources/public/images/flags/KW.svg | 7 +- src/Resources/public/images/flags/KY.svg | 21 +- src/Resources/public/images/flags/KZ.svg | 7 +- src/Resources/public/images/flags/LA.svg | 8 +- src/Resources/public/images/flags/LB.svg | 10 +- src/Resources/public/images/flags/LC.svg | 7 +- src/Resources/public/images/flags/LI.svg | 7 +- src/Resources/public/images/flags/LK.svg | 13 +- src/Resources/public/images/flags/LR.svg | 9 +- src/Resources/public/images/flags/LS.svg | 8 +- src/Resources/public/images/flags/LT.svg | 6 +- src/Resources/public/images/flags/LU.svg | 6 +- src/Resources/public/images/flags/LV.svg | 7 +- src/Resources/public/images/flags/LY.svg | 10 +- src/Resources/public/images/flags/MA.svg | 6 +- src/Resources/public/images/flags/MC.svg | 5 +- src/Resources/public/images/flags/MD.svg | 8 +- src/Resources/public/images/flags/ME.svg | 9 +- src/Resources/public/images/flags/MF.svg | 8 +- src/Resources/public/images/flags/MG.svg | 6 +- src/Resources/public/images/flags/MH.svg | 8 +- src/Resources/public/images/flags/MK.svg | 9 +- src/Resources/public/images/flags/ML.svg | 6 +- src/Resources/public/images/flags/MM.svg | 8 +- src/Resources/public/images/flags/MN.svg | 14 +- src/Resources/public/images/flags/MO.svg | 12 +- src/Resources/public/images/flags/MP.svg | 14 +- src/Resources/public/images/flags/MQ.svg | 8 +- src/Resources/public/images/flags/MR.svg | 9 +- src/Resources/public/images/flags/MS.svg | 17 +- src/Resources/public/images/flags/MT.svg | 7 +- src/Resources/public/images/flags/MU.svg | 7 +- src/Resources/public/images/flags/MV.svg | 7 +- src/Resources/public/images/flags/MW.svg | 7 +- src/Resources/public/images/flags/MX.svg | 9 +- src/Resources/public/images/flags/MY.svg | 10 +- src/Resources/public/images/flags/MZ.svg | 10 +- src/Resources/public/images/flags/NA.svg | 9 +- src/Resources/public/images/flags/NC.svg | 13 +- src/Resources/public/images/flags/NE.svg | 7 +- src/Resources/public/images/flags/NF.svg | 7 +- src/Resources/public/images/flags/NG.svg | 7 +- src/Resources/public/images/flags/NI.svg | 12 +- src/Resources/public/images/flags/NL.svg | 6 +- src/Resources/public/images/flags/NO.svg | 8 +- src/Resources/public/images/flags/NP.svg | 10 +- src/Resources/public/images/flags/NR.svg | 7 +- src/Resources/public/images/flags/NU.svg | 36 +- src/Resources/public/images/flags/NZ.svg | 20 +- src/Resources/public/images/flags/OM.svg | 10 +- src/Resources/public/images/flags/PA.svg | 10 +- src/Resources/public/images/flags/PE.svg | 7 +- src/Resources/public/images/flags/PF.svg | 13 +- src/Resources/public/images/flags/PG.svg | 10 +- src/Resources/public/images/flags/PH.svg | 9 +- src/Resources/public/images/flags/PK.svg | 11 +- src/Resources/public/images/flags/PL.svg | 8 +- src/Resources/public/images/flags/PM.svg | 8 +- src/Resources/public/images/flags/PN.svg | 25 +- src/Resources/public/images/flags/PR.svg | 10 +- src/Resources/public/images/flags/PS.svg | 7 +- src/Resources/public/images/flags/PT.svg | 8 +- src/Resources/public/images/flags/PW.svg | 5 +- src/Resources/public/images/flags/PY.svg | 10 +- src/Resources/public/images/flags/QA.svg | 6 +- src/Resources/public/images/flags/RE.svg | 8 +- src/Resources/public/images/flags/RO.svg | 6 +- src/Resources/public/images/flags/RS.svg | 13 +- src/Resources/public/images/flags/RU.svg | 7 +- src/Resources/public/images/flags/RW.svg | 8 +- src/Resources/public/images/flags/SA.svg | 9 +- src/Resources/public/images/flags/SB.svg | 9 +- src/Resources/public/images/flags/SC.svg | 8 +- src/Resources/public/images/flags/SD.svg | 7 +- src/Resources/public/images/flags/SE.svg | 5 +- src/Resources/public/images/flags/SG.svg | 9 +- src/Resources/public/images/flags/SH.svg | 24 +- src/Resources/public/images/flags/SI.svg | 12 +- src/Resources/public/images/flags/SJ.svg | 8 +- src/Resources/public/images/flags/SK.svg | 14 +- src/Resources/public/images/flags/SL.svg | 6 +- src/Resources/public/images/flags/SM.svg | 15 +- src/Resources/public/images/flags/SN.svg | 8 +- src/Resources/public/images/flags/SO.svg | 6 +- src/Resources/public/images/flags/SR.svg | 10 +- src/Resources/public/images/flags/SS.svg | 10 +- src/Resources/public/images/flags/ST.svg | 9 +- src/Resources/public/images/flags/SV.svg | 11 +- src/Resources/public/images/flags/SX.svg | 16 +- src/Resources/public/images/flags/SY.svg | 9 +- src/Resources/public/images/flags/SZ.svg | 10 +- src/Resources/public/images/flags/TA.svg | 29 +- src/Resources/public/images/flags/TC.svg | 27 +- src/Resources/public/images/flags/TD.svg | 6 +- src/Resources/public/images/flags/TF.svg | 10 +- src/Resources/public/images/flags/TG.svg | 10 +- src/Resources/public/images/flags/TH.svg | 8 +- src/Resources/public/images/flags/TJ.svg | 9 +- src/Resources/public/images/flags/TK.svg | 10 +- src/Resources/public/images/flags/TL.svg | 8 +- src/Resources/public/images/flags/TM.svg | 27 +- src/Resources/public/images/flags/TN.svg | 9 +- src/Resources/public/images/flags/TO.svg | 7 +- src/Resources/public/images/flags/TR.svg | 6 +- src/Resources/public/images/flags/TT.svg | 6 +- src/Resources/public/images/flags/TV.svg | 15 +- src/Resources/public/images/flags/TW.svg | 10 +- src/Resources/public/images/flags/TZ.svg | 7 +- src/Resources/public/images/flags/UA.svg | 5 +- src/Resources/public/images/flags/UG.svg | 10 +- src/Resources/public/images/flags/UM.svg | 11 +- src/Resources/public/images/flags/UNKNOWN.svg | 4 +- src/Resources/public/images/flags/US.svg | 11 +- src/Resources/public/images/flags/UY.svg | 10 +- src/Resources/public/images/flags/UZ.svg | 11 +- src/Resources/public/images/flags/VA.svg | 9 +- src/Resources/public/images/flags/VC.svg | 8 +- src/Resources/public/images/flags/VE.svg | 8 +- src/Resources/public/images/flags/VG.svg | 27 +- src/Resources/public/images/flags/VI.svg | 23 +- src/Resources/public/images/flags/VN.svg | 6 +- src/Resources/public/images/flags/VU.svg | 11 +- src/Resources/public/images/flags/WF.svg | 9 +- src/Resources/public/images/flags/WS.svg | 8 +- src/Resources/public/images/flags/XK.svg | 9 +- src/Resources/public/images/flags/YE.svg | 6 +- src/Resources/public/images/flags/YT.svg | 13 +- src/Resources/public/images/flags/ZA.svg | 10 +- src/Resources/public/images/flags/ZM.svg | 9 +- src/Resources/public/images/flags/ZW.svg | 18 +- src/Resources/skeleton/crud_controller.tpl | 28 +- src/Resources/skeleton/dashboard.tpl | 66 +- .../translations/EasyAdminBundle.el.php | 48 +- src/Resources/views/crud/action.html.twig | 20 +- src/Resources/views/crud/detail.html.twig | 292 ++-- src/Resources/views/crud/edit.html.twig | 62 +- .../views/crud/field/array.html.twig | 12 +- .../views/crud/field/association.html.twig | 12 +- .../views/crud/field/avatar.html.twig | 3 +- .../views/crud/field/boolean.html.twig | 30 +- .../views/crud/field/code_editor.html.twig | 43 +- .../views/crud/field/collection.html.twig | 4 +- .../views/crud/field/color.html.twig | 6 +- .../views/crud/field/country.html.twig | 36 +- .../views/crud/field/currency.html.twig | 6 +- .../views/crud/field/image.html.twig | 16 +- .../views/crud/field/language.html.twig | 4 +- .../views/crud/field/locale.html.twig | 4 +- src/Resources/views/crud/field/text.html.twig | 4 +- .../views/crud/field/text_editor.html.twig | 39 +- .../views/crud/field/textarea.html.twig | 4 +- src/Resources/views/crud/field/url.html.twig | 4 +- src/Resources/views/crud/filters.html.twig | 8 +- src/Resources/views/crud/form_theme.html.twig | 1280 +++++++++-------- .../includes/_batch_action_modal.html.twig | 34 +- .../crud/includes/_delete_form.html.twig | 35 +- .../crud/includes/_filters_modal.html.twig | 40 +- src/Resources/views/crud/index.html.twig | 432 +++--- src/Resources/views/crud/new.html.twig | 56 +- src/Resources/views/crud/paginator.html.twig | 72 +- src/Resources/views/exception.html.twig | 8 +- src/Resources/views/flash_messages.html.twig | 26 +- .../views/includes/_css_assets.html.twig | 15 +- .../includes/_encore_link_tags.html.twig | 2 +- .../includes/_encore_script_tags.html.twig | 2 +- .../views/includes/_js_assets.html.twig | 15 +- .../views/inspector/data_collector.html.twig | 30 +- .../views/inspector/icon-v3.svg.twig | 11 +- src/Resources/views/inspector/icon.svg.twig | 6 +- src/Resources/views/label/null.html.twig | 2 +- src/Resources/views/layout.html.twig | 769 +++++----- src/Resources/views/menu.html.twig | 80 +- src/Resources/views/page/login.html.twig | 154 +- .../views/page/login_minimal.html.twig | 42 +- .../bootstrap_5_layout.html.twig | 604 ++++---- .../bootstrap_base_layout.html.twig | 324 +++-- .../form_div_layout.html.twig | 658 ++++----- src/Resources/views/welcome.html.twig | 659 +++++++-- src/Router/AdminUrlGenerator.php | 55 +- src/Security/SecurityVoter.php | 34 +- src/Test/PhpUnitExtension.php | 6 +- src/Test/Trait/CrudTestIndexAsserts.php | 97 +- src/Test/Trait/CrudTestSelectors.php | 2 +- src/Test/Trait/CrudTestUrlGeneration.php | 56 +- src/Translation/TranslatableChoiceMessage.php | 2 +- .../TranslatableChoiceMessageCollection.php | 2 +- .../TranslatableMessageBuilder.php | 3 +- src/Twig/EasyAdminTwigExtension.php | 25 +- .../src/Controller/ActionsCrudController.php | 3 +- .../src/Controller/CategoryCrudController.php | 15 +- .../Search/CustomCrudSearchController.php | 3 +- .../Controller/Sort/BillCrudController.php | 3 +- .../Sort/CustomerCrudController.php | 3 +- .../Controller/Sort/PageCrudController.php | 3 +- .../Controller/Sort/WebsiteCrudController.php | 3 +- 505 files changed, 8968 insertions(+), 4639 deletions(-) diff --git a/src/ArgumentResolver/AdminContextResolver.php b/src/ArgumentResolver/AdminContextResolver.php index f042a773da..59dbc74d93 100644 --- a/src/ArgumentResolver/AdminContextResolver.php +++ b/src/ArgumentResolver/AdminContextResolver.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\ArgumentResolver; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; diff --git a/src/ArgumentResolver/BatchActionDtoResolver.php b/src/ArgumentResolver/BatchActionDtoResolver.php index 969c329a36..c84638c31d 100644 --- a/src/ArgumentResolver/BatchActionDtoResolver.php +++ b/src/ArgumentResolver/BatchActionDtoResolver.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDto; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; -use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface; @@ -23,8 +21,10 @@ final class BatchActionDtoResolver implements ValueResolverInterface private AdminUrlGeneratorInterface $adminUrlGenerator; - public function __construct(AdminContextProviderInterface $adminContextProvider, AdminUrlGeneratorInterface $adminUrlGenerator) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + AdminUrlGeneratorInterface $adminUrlGenerator + ) { $this->adminContextProvider = $adminContextProvider; $this->adminUrlGenerator = $adminUrlGenerator; } @@ -36,7 +36,12 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable } if (null === $context = $this->adminContextProvider->getContext()) { - throw new \RuntimeException(sprintf('Some of your controller actions have type-hinted an argument with the "%s" class but that\'s only available for actions run to serve EasyAdmin requests. Remove the type-hint or make sure the action is part of an EasyAdmin request.', BatchActionDto::class)); + throw new \RuntimeException( + sprintf( + 'Some of your controller actions have type-hinted an argument with the "%s" class but that\'s only available for actions run to serve EasyAdmin requests. Remove the type-hint or make sure the action is part of an EasyAdmin request.', + BatchActionDto::class + ) + ); } $batchActionUrl = $context->getRequest()->request->get(EA::BATCH_ACTION_URL); @@ -59,8 +64,10 @@ final class BatchActionDtoResolver implements ArgumentValueResolverInterface private AdminContextProviderInterface $adminContextProvider; private AdminUrlGeneratorInterface $adminUrlGenerator; - public function __construct(AdminContextProviderInterface $adminContextProvider, AdminUrlGeneratorInterface $adminUrlGenerator) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + AdminUrlGeneratorInterface $adminUrlGenerator + ) { $this->adminContextProvider = $adminContextProvider; $this->adminUrlGenerator = $adminUrlGenerator; } @@ -73,7 +80,12 @@ public function supports(Request $request, ArgumentMetadata $argument): bool public function resolve(Request $request, ArgumentMetadata $argument): iterable { if (null === $context = $this->adminContextProvider->getContext()) { - throw new \RuntimeException(sprintf('Some of your controller actions have type-hinted an argument with the "%s" class but that\'s only available for actions run to serve EasyAdmin requests. Remove the type-hint or make sure the action is part of an EasyAdmin request.', BatchActionDto::class)); + throw new \RuntimeException( + sprintf( + 'Some of your controller actions have type-hinted an argument with the "%s" class but that\'s only available for actions run to serve EasyAdmin requests. Remove the type-hint or make sure the action is part of an EasyAdmin request.', + BatchActionDto::class + ) + ); } $batchActionUrl = $context->getRequest()->request->get(EA::BATCH_ACTION_URL); diff --git a/src/Cache/CacheWarmer.php b/src/Cache/CacheWarmer.php index 467dc5da93..4e6dbcd796 100644 --- a/src/Cache/CacheWarmer.php +++ b/src/Cache/CacheWarmer.php @@ -7,6 +7,7 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouterInterface; + use function Symfony\Component\String\u; /** diff --git a/src/Collection/ActionCollection.php b/src/Collection/ActionCollection.php index f6d38d603b..9972e07107 100644 --- a/src/Collection/ActionCollection.php +++ b/src/Collection/ActionCollection.php @@ -4,7 +4,6 @@ use ArrayIterator; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Collection\CollectionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDtoInterface; use function array_key_exists; @@ -85,25 +84,31 @@ public function getIterator(): ArrayIterator public function getEntityActions(): self { - return self::new(array_filter( - $this->actions, - static fn (ActionDtoInterface $action): bool => $action->isEntityAction() - )); + return self::new( + array_filter( + $this->actions, + static fn(ActionDtoInterface $action): bool => $action->isEntityAction() + ) + ); } public function getGlobalActions(): self { - return self::new(array_filter( - $this->actions, - static fn (ActionDtoInterface $action): bool => $action->isGlobalAction() - )); + return self::new( + array_filter( + $this->actions, + static fn(ActionDtoInterface $action): bool => $action->isGlobalAction() + ) + ); } public function getBatchActions(): self { - return self::new(array_filter( - $this->actions, - static fn (ActionDtoInterface $action): bool => $action->isBatchAction() - )); + return self::new( + array_filter( + $this->actions, + static fn(ActionDtoInterface $action): bool => $action->isBatchAction() + ) + ); } } diff --git a/src/Collection/EntityCollection.php b/src/Collection/EntityCollection.php index 1c6eea70bb..5fe30a8061 100644 --- a/src/Collection/EntityCollection.php +++ b/src/Collection/EntityCollection.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Collection; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Collection\CollectionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; /** diff --git a/src/Collection/FieldCollection.php b/src/Collection/FieldCollection.php index 612ee8898c..d31d785312 100644 --- a/src/Collection/FieldCollection.php +++ b/src/Collection/FieldCollection.php @@ -4,7 +4,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Contracts\Collection\CollectionInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\Field; diff --git a/src/Collection/FilterCollection.php b/src/Collection/FilterCollection.php index 4f0961864d..a32bb1fc73 100644 --- a/src/Collection/FilterCollection.php +++ b/src/Collection/FilterCollection.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Collection; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Collection\CollectionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; /** diff --git a/src/Command/MakeAdminDashboardCommand.php b/src/Command/MakeAdminDashboardCommand.php index b27980340e..afa1239d3f 100644 --- a/src/Command/MakeAdminDashboardCommand.php +++ b/src/Command/MakeAdminDashboardCommand.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Command; -use EasyCorp\Bundle\EasyAdminBundle\Maker\ClassMaker; use EasyCorp\Bundle\EasyAdminBundle\Maker\ClassMakerInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -11,6 +10,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\String\Slugger\AsciiSlugger; + use function Symfony\Component\String\u; /** @@ -37,8 +37,7 @@ public function __construct(ClassMakerInterface $classMaker, string $projectDir, protected function configure(): void { $this - ->setHelp($this->getCommandHelp()) - ; + ->setHelp($this->getCommandHelp()); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -49,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $controllerClassName = $io->ask( 'Which class name do you prefer for your Dashboard controller?', 'DashboardController', - fn (string $className): string => u($className)->ensureEnd('Controller')->toString() + fn(string $className): string => u($className)->ensureEnd('Controller')->toString() ); $projectDir = $this->projectDir; @@ -59,32 +58,56 @@ protected function execute(InputInterface $input, OutputInterface $output): int static function (string $selectedDir) use ($fs, $projectDir) { $absoluteDir = u($selectedDir)->ensureStart($projectDir.\DIRECTORY_SEPARATOR); if (null !== $absoluteDir->indexOf('..')) { - throw new \RuntimeException(sprintf('The given directory path can\'t contain ".." and must be relative to the project directory (which is "%s")', $projectDir)); + throw new \RuntimeException( + sprintf( + 'The given directory path can\'t contain ".." and must be relative to the project directory (which is "%s")', + $projectDir + ) + ); } $fs->mkdir($absoluteDir); if (!$fs->exists($absoluteDir)) { - throw new \RuntimeException('The given directory does not exist and couldn\'t be created. Type in the path of an existing directory relative to your project root (e.g. src/Controller/Admin/)'); + throw new \RuntimeException( + 'The given directory does not exist and couldn\'t be created. Type in the path of an existing directory relative to your project root (e.g. src/Controller/Admin/)' + ); } return $absoluteDir->after($projectDir.\DIRECTORY_SEPARATOR)->trimEnd(\DIRECTORY_SEPARATOR)->toString(); } ); - $controllerFilePath = sprintf('%s/%s.php', u($controllerDir)->ensureStart($projectDir.\DIRECTORY_SEPARATOR), $controllerClassName); + $controllerFilePath = sprintf( + '%s/%s.php', + u($controllerDir)->ensureStart($projectDir.\DIRECTORY_SEPARATOR), + $controllerClassName + ); if ($fs->exists($controllerFilePath)) { - throw new \RuntimeException(sprintf('The "%s.php" file already exists in the given "%s" directory. Use a different controller name or generate it in a different directory.', $controllerClassName, $controllerDir)); + throw new \RuntimeException( + sprintf( + 'The "%s.php" file already exists in the given "%s" directory. Use a different controller name or generate it in a different directory.', + $controllerClassName, + $controllerDir + ) + ); } $guessedNamespace = u($controllerDir)->equalsTo('src') ? 'App' - : u($controllerDir)->replace('/', ' ')->replace('\\', ' ')->replace('src ', 'app ')->title(true)->replace(' ', '\\')->trimEnd('\\'); - - $generatedFilePath = $this->classMaker->make(sprintf('%s/%s.php', $controllerDir, $controllerClassName), 'dashboard.tpl', [ - 'namespace' => $guessedNamespace, - 'site_title' => $this->getSiteTitle($this->projectDir), - ]); + : u($controllerDir)->replace('/', ' ')->replace('\\', ' ')->replace('src ', 'app ')->title(true)->replace( + ' ', + '\\' + )->trimEnd('\\'); + + $generatedFilePath = $this->classMaker->make( + sprintf('%s/%s.php', $controllerDir, $controllerClassName), + 'dashboard.tpl', + [ + 'namespace' => $guessedNamespace, + 'site_title' => $this->getSiteTitle($this->projectDir), + ] + ); $io = new SymfonyStyle($input, $output); $io->success('Your dashboard class has been successfully generated.'); diff --git a/src/Command/MakeCrudControllerCommand.php b/src/Command/MakeCrudControllerCommand.php index fe99286fe3..9b02c59c67 100644 --- a/src/Command/MakeCrudControllerCommand.php +++ b/src/Command/MakeCrudControllerCommand.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Command; use Doctrine\Persistence\ManagerRegistry; -use EasyCorp\Bundle\EasyAdminBundle\Maker\ClassMaker; use EasyCorp\Bundle\EasyAdminBundle\Maker\ClassMakerInterface; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -11,6 +10,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Filesystem; + use function Symfony\Component\String\u; /** @@ -28,8 +28,12 @@ final class MakeCrudControllerCommand extends Command private ClassMakerInterface $classMaker; private ManagerRegistry $doctrine; - public function __construct(string $projectDir, ClassMakerInterface $classMaker, ManagerRegistry $doctrine, ?string $name = null) - { + public function __construct( + string $projectDir, + ClassMakerInterface $classMaker, + ManagerRegistry $doctrine, + ?string $name = null + ) { parent::__construct($name); $this->projectDir = $projectDir; $this->classMaker = $classMaker; @@ -39,8 +43,7 @@ public function __construct(string $projectDir, ClassMakerInterface $classMaker, protected function configure(): void { $this - ->setHelp($this->getCommandHelp()) - ; + ->setHelp($this->getCommandHelp()); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -50,7 +53,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $doctrineEntitiesFqcn = $this->getAllDoctrineEntitiesFqcn(); if (0 === \count($doctrineEntitiesFqcn)) { - $io->error('This command generates the CRUD controller of an existing Doctrine entity, but no entities were found in your application. Create some Doctrine entities first and then run this command again.'); + $io->error( + 'This command generates the CRUD controller of an existing Doctrine entity, but no entities were found in your application. Create some Doctrine entities first and then run this command again.' + ); return Command::FAILURE; } @@ -62,22 +67,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int $controllerFileNamePattern = sprintf('%s{number}CrudController.php', $entityClassName); $projectDir = $this->projectDir; - $controllerDir = $io->ask('Which directory do you want to generate the CRUD controller in?', 'src/Controller/Admin/', static function (string $selectedDir) use ($fs, $projectDir) { - $absoluteDir = u($selectedDir)->ensureStart($projectDir.\DIRECTORY_SEPARATOR); - if (!$fs->exists($absoluteDir)) { - throw new \RuntimeException('The given directory does not exist. Type in the path of an existing directory relative to your project root (e.g. src/Controller/Admin/)'); + $controllerDir = $io->ask( + 'Which directory do you want to generate the CRUD controller in?', + 'src/Controller/Admin/', + static function (string $selectedDir) use ($fs, $projectDir) { + $absoluteDir = u($selectedDir)->ensureStart($projectDir.\DIRECTORY_SEPARATOR); + if (!$fs->exists($absoluteDir)) { + throw new \RuntimeException( + 'The given directory does not exist. Type in the path of an existing directory relative to your project root (e.g. src/Controller/Admin/)' + ); + } + + return $absoluteDir->after($projectDir.\DIRECTORY_SEPARATOR)->trimEnd(\DIRECTORY_SEPARATOR)->toString(); } - - return $absoluteDir->after($projectDir.\DIRECTORY_SEPARATOR)->trimEnd(\DIRECTORY_SEPARATOR)->toString(); - }); + ); $guessedNamespace = u($controllerDir)->equalsTo('src') ? 'App' - : u($controllerDir)->replace('/', ' ')->replace('\\', ' ')->replace('src ', 'app ')->title(true)->replace('App App ', 'App ')->replace(' ', '\\')->trimEnd(\DIRECTORY_SEPARATOR); + : u($controllerDir)->replace('/', ' ')->replace('\\', ' ')->replace('src ', 'app ')->title(true)->replace( + 'App App ', + 'App ' + )->replace(' ', '\\')->trimEnd(\DIRECTORY_SEPARATOR); $namespace = $io->ask( 'Namespace of the generated CRUD controller', $guessedNamespace, - static fn (string $namespace): string => u($namespace)->replace('/', '\\')->toString() + static fn(string $namespace): string => u($namespace)->replace('/', '\\')->toString() ); $generatedFilePath = $this->classMaker->make( diff --git a/src/Config/Action.php b/src/Config/Action.php index 6ff9064fcb..76aa373b52 100644 --- a/src/Config/Action.php +++ b/src/Config/Action.php @@ -4,9 +4,10 @@ use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDtoInterface; -use function Symfony\Component\String\u; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\String\u; + final class Action implements ActionInterface { private ActionDtoInterface $dto; @@ -186,11 +187,22 @@ public function displayIf(callable $callable): self public function getAsDto(): ActionDtoInterface { if (null === $this->dto->getLabel() && null === $this->dto->getIcon()) { - throw new \InvalidArgumentException(sprintf('The label and icon of an action cannot be null at the same time. Either set the label, the icon or both for the "%s" action.', $this->dto->getName())); + throw new \InvalidArgumentException( + sprintf( + 'The label and icon of an action cannot be null at the same time. Either set the label, the icon or both for the "%s" action.', + $this->dto->getName() + ) + ); } - if (null === $this->dto->getCrudActionName() && null === $this->dto->getRouteName() && null === $this->dto->getUrl()) { - throw new \InvalidArgumentException(sprintf('Actions must link to either a route, a CRUD action, or a URL. Set the "linkToCrudAction()", "linkToRoute()", or "linkToUrl()" method for the "%s" action.', $this->dto->getName())); + if (null === $this->dto->getCrudActionName() && null === $this->dto->getRouteName( + ) && null === $this->dto->getUrl()) { + throw new \InvalidArgumentException( + sprintf( + 'Actions must link to either a route, a CRUD action, or a URL. Set the "linkToCrudAction()", "linkToRoute()", or "linkToUrl()" method for the "%s" action.', + $this->dto->getName() + ) + ); } return $this->dto; diff --git a/src/Config/ActionInterface.php b/src/Config/ActionInterface.php index d1e6a9a33b..c0d7db21a9 100644 --- a/src/Config/ActionInterface.php +++ b/src/Config/ActionInterface.php @@ -5,7 +5,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config; -use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDtoInterface; use Symfony\Contracts\Translation\TranslatableInterface; @@ -45,7 +44,7 @@ interface ActionInterface /** * @param TranslatableInterface|string|false|null $label Use FALSE to hide the label; use NULL to autogenerate it - * @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free) + * @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free) */ public static function new(string $name, $label = null, ?string $icon = null): self; diff --git a/src/Config/Actions.php b/src/Config/Actions.php index af3b907c15..17634dca2c 100644 --- a/src/Config/Actions.php +++ b/src/Config/Actions.php @@ -35,7 +35,10 @@ public function addBatchAction(Action|string $actionNameOrObject): self public function set(string $pageName, Action|string $actionNameOrObject): self { - $action = \is_string($actionNameOrObject) ? $this->createBuiltInAction($pageName, $actionNameOrObject) : $actionNameOrObject; + $action = \is_string($actionNameOrObject) ? $this->createBuiltInAction( + $pageName, + $actionNameOrObject + ) : $actionNameOrObject; $this->dto->appendAction($pageName, $action->getAsDto()); @@ -45,7 +48,13 @@ public function set(string $pageName, Action|string $actionNameOrObject): self public function update(string $pageName, string $actionName, callable $callable): self { if (null === $actionDto = $this->dto->getAction($pageName, $actionName)) { - throw new \InvalidArgumentException(sprintf('The "%s" action does not exist in the "%s" page, so you cannot update it. Instead, add the action with the "add()" method.', $actionName, $pageName)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" action does not exist in the "%s" page, so you cannot update it. Instead, add the action with the "add()" method.', + $actionName, + $pageName + ) + ); } $action = $actionDto->getAsConfigObject(); @@ -59,7 +68,13 @@ public function update(string $pageName, string $actionName, callable $callable) public function remove(string $pageName, string $actionName): self { if (null === $this->dto->getAction($pageName, $actionName)) { - throw new \InvalidArgumentException(sprintf('The "%s" action does not exist in the "%s" page, so you cannot remove it.', $actionName, $pageName)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" action does not exist in the "%s" page, so you cannot remove it.', + $actionName, + $pageName + ) + ); } $this->dto->removeAction($pageName, $actionName); @@ -79,7 +94,13 @@ public function reorder(string $pageName, array $orderedActionNames): self $currentActions = $this->dto->getActions(); foreach ($orderedActionNames as $actionName) { if (!\array_key_exists($actionName, $currentActions[$pageName])) { - throw new \InvalidArgumentException(sprintf('The "%s" action does not exist in the "%s" page, so you cannot set its order.', $actionName, $pageName)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" action does not exist in the "%s" page, so you cannot set its order.', + $actionName, + $pageName + ) + ); } $newActionOrder[] = $actionName; @@ -173,38 +194,69 @@ private function createBuiltInAction(string $pageName, string $actionName): Acti return Action::new(ActionInterface::INDEX, t('action.index', domain: 'EasyAdminBundle')) ->linkToCrudAction(ActionInterface::INDEX) ->setCssClass('action-'.ActionInterface::INDEX) - ->addCssClass(\in_array($pageName, [CrudInterface::PAGE_DETAIL, CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], true) ? 'btn btn-secondary' : ''); + ->addCssClass( + \in_array( + $pageName, + [CrudInterface::PAGE_DETAIL, CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], + true + ) ? 'btn btn-secondary' : '' + ); } if (ActionInterface::DELETE === $actionName) { - $cssClass = \in_array($pageName, [CrudInterface::PAGE_DETAIL, CrudInterface::PAGE_EDIT], true) ? 'btn btn-secondary pr-0 text-danger' : 'text-danger'; - - return Action::new(ActionInterface::DELETE, t('action.delete', domain: 'EasyAdminBundle'), CrudInterface::PAGE_INDEX === $pageName ? null : 'fa fa-fw fa-trash-o') + $cssClass = \in_array( + $pageName, + [CrudInterface::PAGE_DETAIL, CrudInterface::PAGE_EDIT], + true + ) ? 'btn btn-secondary pr-0 text-danger' : 'text-danger'; + + return Action::new( + ActionInterface::DELETE, + t('action.delete', domain: 'EasyAdminBundle'), + CrudInterface::PAGE_INDEX === $pageName ? null : 'fa fa-fw fa-trash-o' + ) ->linkToCrudAction(ActionInterface::DELETE) ->setCssClass('action-'.ActionInterface::DELETE) ->addCssClass($cssClass); } if (ActionInterface::SAVE_AND_RETURN === $actionName) { - return Action::new(ActionInterface::SAVE_AND_RETURN, t(CrudInterface::PAGE_EDIT === $pageName ? 'action.save' : 'action.create', domain: 'EasyAdminBundle')) + return Action::new( + ActionInterface::SAVE_AND_RETURN, + t(CrudInterface::PAGE_EDIT === $pageName ? 'action.save' : 'action.create', domain: 'EasyAdminBundle') + ) ->setCssClass('action-'.ActionInterface::SAVE_AND_RETURN) ->addCssClass('btn btn-primary action-save') ->displayAsButton() ->setHtmlAttributes(['type' => 'submit', 'name' => 'ea[newForm][btn]', 'value' => $actionName]) - ->linkToCrudAction(CrudInterface::PAGE_EDIT === $pageName ? ActionInterface::EDIT : ActionInterface::NEW); + ->linkToCrudAction( + CrudInterface::PAGE_EDIT === $pageName ? ActionInterface::EDIT : ActionInterface::NEW + ); } if (ActionInterface::SAVE_AND_CONTINUE === $actionName) { - return Action::new(ActionInterface::SAVE_AND_CONTINUE, t(CrudInterface::PAGE_EDIT === $pageName ? 'action.save_and_continue' : 'action.create_and_continue', domain: 'EasyAdminBundle'), 'far fa-edit') + return Action::new( + ActionInterface::SAVE_AND_CONTINUE, + t( + CrudInterface::PAGE_EDIT === $pageName ? 'action.save_and_continue' : 'action.create_and_continue', + domain: 'EasyAdminBundle' + ), + 'far fa-edit' + ) ->setCssClass('action-'.ActionInterface::SAVE_AND_CONTINUE) ->addCssClass('btn btn-secondary action-save') ->displayAsButton() ->setHtmlAttributes(['type' => 'submit', 'name' => 'ea[newForm][btn]', 'value' => $actionName]) - ->linkToCrudAction(CrudInterface::PAGE_EDIT === $pageName ? ActionInterface::EDIT : ActionInterface::NEW); + ->linkToCrudAction( + CrudInterface::PAGE_EDIT === $pageName ? ActionInterface::EDIT : ActionInterface::NEW + ); } if (ActionInterface::SAVE_AND_ADD_ANOTHER === $actionName) { - return Action::new(ActionInterface::SAVE_AND_ADD_ANOTHER, t('action.create_and_add_another', domain: 'EasyAdminBundle')) + return Action::new( + ActionInterface::SAVE_AND_ADD_ANOTHER, + t('action.create_and_add_another', domain: 'EasyAdminBundle') + ) ->setCssClass('action-'.ActionInterface::SAVE_AND_ADD_ANOTHER) ->addCssClass('btn btn-secondary action-save') ->displayAsButton() @@ -212,16 +264,31 @@ private function createBuiltInAction(string $pageName, string $actionName): Acti ->linkToCrudAction(ActionInterface::NEW); } - throw new \InvalidArgumentException(sprintf('The "%s" action is not a built-in action, so you can\'t add or configure it via its name. Either refer to one of the built-in actions or create a custom action called "%s".', $actionName, $actionName)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" action is not a built-in action, so you can\'t add or configure it via its name. Either refer to one of the built-in actions or create a custom action called "%s".', + $actionName, + $actionName + ) + ); } private function doAddAction(string $pageName, Action|string $actionNameOrObject, bool $isBatchAction = false): self { - $actionName = \is_string($actionNameOrObject) ? $actionNameOrObject : (string) $actionNameOrObject; - $action = \is_string($actionNameOrObject) ? $this->createBuiltInAction($pageName, $actionNameOrObject) : $actionNameOrObject; + $actionName = \is_string($actionNameOrObject) ? $actionNameOrObject : (string)$actionNameOrObject; + $action = \is_string($actionNameOrObject) ? $this->createBuiltInAction( + $pageName, + $actionNameOrObject + ) : $actionNameOrObject; if (null !== $this->dto->getAction($pageName, $actionName)) { - throw new \InvalidArgumentException(sprintf('The "%s" action already exists in the "%s" page, so you can\'t add it again. Instead, you can use the "updateAction()" method to update any options of an existing action.', $actionName, $pageName)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" action already exists in the "%s" page, so you can\'t add it again. Instead, you can use the "updateAction()" method to update any options of an existing action.', + $actionName, + $pageName + ) + ); } $actionDto = $action->getAsDto(); diff --git a/src/Config/ActionsInterface.php b/src/Config/ActionsInterface.php index df0a47c24b..2d1afecf94 100644 --- a/src/Config/ActionsInterface.php +++ b/src/Config/ActionsInterface.php @@ -5,7 +5,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config; -use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDtoInterface; /** diff --git a/src/Config/Asset.php b/src/Config/Asset.php index 2a62f5eb3e..ec0d8ba382 100644 --- a/src/Config/Asset.php +++ b/src/Config/Asset.php @@ -29,7 +29,12 @@ public static function new(string $value): AssetInterface { $isWebpackEncoreEntry = !u($value)->endsWith('.css') && !u($value)->endsWith('.js'); if ($isWebpackEncoreEntry && !class_exists('Symfony\\WebpackEncoreBundle\\WebpackEncoreBundle')) { - throw new \RuntimeException(sprintf('You are trying to add a Webpack Encore entry called "%s" but WebpackEncoreBundle is not installed in your project. Try running "composer require symfony/webpack-encore-bundle"', $value)); + throw new \RuntimeException( + sprintf( + 'You are trying to add a Webpack Encore entry called "%s" but WebpackEncoreBundle is not installed in your project. Try running "composer require symfony/webpack-encore-bundle"', + $value + ) + ); } $dto = new AssetDto($value); @@ -67,7 +72,12 @@ public function defer(bool $defer = true): AssetInterface public function preload(bool $preload = true): AssetInterface { if (!class_exists('Symfony\\Component\\WebLink\\Link')) { - throw new \RuntimeException(sprintf('You are trying to preload an asset called "%s" but WebLink component is not installed in your project. Try running "composer require symfony/web-link"', $this->dto->getValue())); + throw new \RuntimeException( + sprintf( + 'You are trying to preload an asset called "%s" but WebLink component is not installed in your project. Try running "composer require symfony/web-link"', + $this->dto->getValue() + ) + ); } $this->dto->setPreload($preload); @@ -78,7 +88,12 @@ public function preload(bool $preload = true): AssetInterface public function nopush(bool $nopush = true): AssetInterface { if (!class_exists('Symfony\\Component\\WebLink\\Link')) { - throw new \RuntimeException(sprintf('You are trying to configure the "nopush" preload attribute of an asset called "%s" but WebLink component is not installed in your project. Try running "composer require symfony/web-link"', $this->dto->getValue())); + throw new \RuntimeException( + sprintf( + 'You are trying to configure the "nopush" preload attribute of an asset called "%s" but WebLink component is not installed in your project. Try running "composer require symfony/web-link"', + $this->dto->getValue() + ) + ); } $this->dto->setNopush($nopush); @@ -183,10 +198,12 @@ public function onlyOnDetail(): AssetInterface public function onlyOnForms(): AssetInterface { - $this->dto->setLoadedOn(KeyValueStore::new([ - CrudInterface::PAGE_NEW => CrudInterface::PAGE_NEW, - CrudInterface::PAGE_EDIT => CrudInterface::PAGE_EDIT, - ])); + $this->dto->setLoadedOn( + KeyValueStore::new([ + CrudInterface::PAGE_NEW => CrudInterface::PAGE_NEW, + CrudInterface::PAGE_EDIT => CrudInterface::PAGE_EDIT, + ]) + ); return $this; } diff --git a/src/Config/AssetInterface.php b/src/Config/AssetInterface.php index d3547e908f..61a41b491f 100644 --- a/src/Config/AssetInterface.php +++ b/src/Config/AssetInterface.php @@ -5,7 +5,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config; -use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetDtoInterface; /** diff --git a/src/Config/Assets.php b/src/Config/Assets.php index 7c0aa9f680..e4c06fa6c7 100644 --- a/src/Config/Assets.php +++ b/src/Config/Assets.php @@ -25,7 +25,12 @@ public static function new(): AssetsInterface public function addWebpackEncoreEntry(AssetInterface|string $entryNameOrAsset): AssetsInterface { if (!class_exists('Symfony\\WebpackEncoreBundle\\WebpackEncoreBundle')) { - throw new \RuntimeException(sprintf('You are trying to add a Webpack Encore entry called "%s" but WebpackEncoreBundle is not installed in your project. Try running "composer require symfony/webpack-encore-bundle"', $entryNameOrAsset)); + throw new \RuntimeException( + sprintf( + 'You are trying to add a Webpack Encore entry called "%s" but WebpackEncoreBundle is not installed in your project. Try running "composer require symfony/webpack-encore-bundle"', + $entryNameOrAsset + ) + ); } if (\is_string($entryNameOrAsset)) { diff --git a/src/Config/AssetsInterface.php b/src/Config/AssetsInterface.php index 8bae4806c4..e05e96dab4 100644 --- a/src/Config/AssetsInterface.php +++ b/src/Config/AssetsInterface.php @@ -5,7 +5,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config; -use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDtoInterface; /** diff --git a/src/Config/Crud.php b/src/Config/Crud.php index 7bb47ede47..b6a149e7f4 100644 --- a/src/Config/Crud.php +++ b/src/Config/Crud.php @@ -5,7 +5,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\SortOrder; use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\PaginatorDto; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; @@ -88,7 +87,14 @@ public function setPageTitle(string $pageName, $title): self } if (!\in_array($pageName, $this->getValidPageNames(), true)) { - throw new \InvalidArgumentException(sprintf('The first argument of the "%s()" method must be one of these valid page names: %s ("%s" given).', __METHOD__, implode(', ', $this->getValidPageNames()), $pageName)); + throw new \InvalidArgumentException( + sprintf( + 'The first argument of the "%s()" method must be one of these valid page names: %s ("%s" given).', + __METHOD__, + implode(', ', $this->getValidPageNames()), + $pageName + ) + ); } $this->dto->setCustomPageTitle($pageName, $title); @@ -99,7 +105,14 @@ public function setPageTitle(string $pageName, $title): self public function setHelp(string $pageName, TranslatableInterface|string $helpMessage): self { if (!\in_array($pageName, $this->getValidPageNames(), true)) { - throw new \InvalidArgumentException(sprintf('The first argument of the "%s()" method must be one of these valid page names: %s ("%s" given).', __METHOD__, implode(', ', $this->getValidPageNames()), $pageName)); + throw new \InvalidArgumentException( + sprintf( + 'The first argument of the "%s()" method must be one of these valid page names: %s ("%s" given).', + __METHOD__, + implode(', ', $this->getValidPageNames()), + $pageName + ) + ); } $this->dto->setHelpMessage($pageName, $helpMessage); @@ -112,10 +125,17 @@ public function setDateFormat(string $formatOrPattern): self if (DateTimeField::FORMAT_NONE === $formatOrPattern || '' === trim($formatOrPattern)) { $validDateFormatsWithoutNone = array_filter( DateTimeField::VALID_DATE_FORMATS, - static fn (string $format): bool => DateTimeField::FORMAT_NONE !== $format + static fn(string $format): bool => DateTimeField::FORMAT_NONE !== $format ); - throw new \InvalidArgumentException(sprintf('The first argument of the "%s()" method cannot be "%s" or an empty string. Use either the special date formats (%s) or a datetime Intl pattern.', __METHOD__, DateTimeField::FORMAT_NONE, implode(', ', $validDateFormatsWithoutNone))); + throw new \InvalidArgumentException( + sprintf( + 'The first argument of the "%s()" method cannot be "%s" or an empty string. Use either the special date formats (%s) or a datetime Intl pattern.', + __METHOD__, + DateTimeField::FORMAT_NONE, + implode(', ', $validDateFormatsWithoutNone) + ) + ); } $datePattern = DateTimeField::INTL_DATE_PATTERNS[$formatOrPattern] ?? $formatOrPattern; @@ -129,10 +149,17 @@ public function setTimeFormat(string $formatOrPattern): self if (DateTimeField::FORMAT_NONE === $formatOrPattern || '' === trim($formatOrPattern)) { $validTimeFormatsWithoutNone = array_filter( DateTimeField::VALID_DATE_FORMATS, - static fn (string $format): bool => DateTimeField::FORMAT_NONE !== $format + static fn(string $format): bool => DateTimeField::FORMAT_NONE !== $format ); - throw new \InvalidArgumentException(sprintf('The first argument of the "%s()" method cannot be "%s" or an empty string. Use either the special time formats (%s) or a datetime Intl pattern.', __METHOD__, DateTimeField::FORMAT_NONE, implode(', ', $validTimeFormatsWithoutNone))); + throw new \InvalidArgumentException( + sprintf( + 'The first argument of the "%s()" method cannot be "%s" or an empty string. Use either the special time formats (%s) or a datetime Intl pattern.', + __METHOD__, + DateTimeField::FORMAT_NONE, + implode(', ', $validTimeFormatsWithoutNone) + ) + ); } $timePattern = DateTimeField::INTL_TIME_PATTERNS[$formatOrPattern] ?? $formatOrPattern; @@ -141,21 +168,39 @@ public function setTimeFormat(string $formatOrPattern): self return $this; } - public function setDateTimeFormat(string $dateFormatOrPattern, string $timeFormat = DateTimeField::FORMAT_NONE): self - { + public function setDateTimeFormat( + string $dateFormatOrPattern, + string $timeFormat = DateTimeField::FORMAT_NONE + ): self { if ('' === trim($dateFormatOrPattern)) { - throw new \InvalidArgumentException(sprintf('The first argument of the "%s()" method cannot be an empty string. Use either a date format (%s) or a datetime Intl pattern.', __METHOD__, implode(', ', DateTimeField::VALID_DATE_FORMATS))); + throw new \InvalidArgumentException( + sprintf( + 'The first argument of the "%s()" method cannot be an empty string. Use either a date format (%s) or a datetime Intl pattern.', + __METHOD__, + implode(', ', DateTimeField::VALID_DATE_FORMATS) + ) + ); } $datePatternIsEmpty = DateTimeField::FORMAT_NONE === $dateFormatOrPattern; $timePatternIsEmpty = DateTimeField::FORMAT_NONE === $timeFormat || '' === trim($timeFormat); if ($datePatternIsEmpty && $timePatternIsEmpty) { - throw new \InvalidArgumentException(sprintf('The values of the arguments of "%s()" cannot be "%s" or an empty string at the same time. Change any of them (or both).', __METHOD__, DateTimeField::FORMAT_NONE)); + throw new \InvalidArgumentException( + sprintf( + 'The values of the arguments of "%s()" cannot be "%s" or an empty string at the same time. Change any of them (or both).', + __METHOD__, + DateTimeField::FORMAT_NONE + ) + ); } // when date format/pattern is none and time format is a pattern, // silently turn them into a datetime pattern - if (DateTimeField::FORMAT_NONE === $dateFormatOrPattern && !\in_array($timeFormat, DateTimeField::VALID_DATE_FORMATS, true)) { + if (DateTimeField::FORMAT_NONE === $dateFormatOrPattern && !\in_array( + $timeFormat, + DateTimeField::VALID_DATE_FORMATS, + true + )) { $dateFormatOrPattern = $timeFormat; $timeFormat = DateTimeField::FORMAT_NONE; } @@ -163,11 +208,22 @@ public function setDateTimeFormat(string $dateFormatOrPattern, string $timeForma $isDatePattern = !\in_array($dateFormatOrPattern, DateTimeField::VALID_DATE_FORMATS, true); if ($isDatePattern && DateTimeField::FORMAT_NONE !== $timeFormat) { - throw new \InvalidArgumentException(sprintf('When the first argument of "%s()" is a datetime pattern, you cannot set the time format in the second argument (define the time format inside the datetime pattern).', __METHOD__)); + throw new \InvalidArgumentException( + sprintf( + 'When the first argument of "%s()" is a datetime pattern, you cannot set the time format in the second argument (define the time format inside the datetime pattern).', + __METHOD__ + ) + ); } if (!$isDatePattern && !\in_array($timeFormat, DateTimeField::VALID_DATE_FORMATS, true)) { - throw new \InvalidArgumentException(sprintf('The value of the time format can only be one of the following: %s (but "%s" was given).', implode(', ', DateTimeField::VALID_DATE_FORMATS), $timeFormat)); + throw new \InvalidArgumentException( + sprintf( + 'The value of the time format can only be one of the following: %s (but "%s" was given).', + implode(', ', DateTimeField::VALID_DATE_FORMATS), + $timeFormat + ) + ); } $this->dto->setDateTimePattern($dateFormatOrPattern, $timeFormat); @@ -185,7 +241,12 @@ public function setDateIntervalFormat(string $format): self public function setTimezone(string $timezoneId): self { if (!\in_array($timezoneId, timezone_identifiers_list(), true)) { - throw new \InvalidArgumentException(sprintf('The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', $timezoneId)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', + $timezoneId + ) + ); } $this->dto->setTimezone($timezoneId); @@ -205,11 +266,24 @@ public function setDefaultSort(array $sortFieldsAndOrder): self $sortFieldsAndOrder = array_map('strtoupper', $sortFieldsAndOrder); foreach ($sortFieldsAndOrder as $sortField => $sortOrder) { if (!\in_array($sortOrder, [SortOrder::ASC, SortOrder::DESC], true)) { - throw new \InvalidArgumentException(sprintf('The sort order can be only "%s" or "%s", "%s" given.', SortOrder::ASC, SortOrder::DESC, $sortOrder)); + throw new \InvalidArgumentException( + sprintf( + 'The sort order can be only "%s" or "%s", "%s" given.', + SortOrder::ASC, + SortOrder::DESC, + $sortOrder + ) + ); } if (!\is_string($sortField)) { - throw new \InvalidArgumentException(sprintf('The keys of the array that defines the default sort must be strings with the field names, but the given "%s" value is a "%s".', $sortField, \gettype($sortField))); + throw new \InvalidArgumentException( + sprintf( + 'The keys of the array that defines the default sort must be strings with the field names, but the given "%s" value is a "%s".', + $sortField, + \gettype($sortField) + ) + ); } } @@ -309,7 +383,13 @@ public function setFormThemes(array $themePaths): self { foreach ($themePaths as $path) { if (!\is_string($path)) { - throw new \InvalidArgumentException(sprintf('All form theme paths passed to the "%s" method must be strings, but at least one of those values is of type "%s".', __METHOD__, \gettype($path))); + throw new \InvalidArgumentException( + sprintf( + 'All form theme paths passed to the "%s" method must be strings, but at least one of those values is of type "%s".', + __METHOD__, + \gettype($path) + ) + ); } } @@ -356,7 +436,15 @@ public function hideNullValues(bool $hide = true): self public function getAsDto(): CrudDtoInterface { - $this->dto->setPaginator(new PaginatorDto($this->paginatorPageSize, $this->paginatorRangeSize, 1, $this->paginatorFetchJoinCollection, $this->paginatorUseOutputWalkers)); + $this->dto->setPaginator( + new PaginatorDto( + $this->paginatorPageSize, + $this->paginatorRangeSize, + 1, + $this->paginatorFetchJoinCollection, + $this->paginatorUseOutputWalkers + ) + ); return $this->dto; } diff --git a/src/Config/Dashboard.php b/src/Config/Dashboard.php index f0241fbf8a..a89d92c2c2 100644 --- a/src/Config/Dashboard.php +++ b/src/Config/Dashboard.php @@ -46,7 +46,14 @@ public function setTranslationDomain(string $translationDomain): DashboardInterf public function setTextDirection(string $direction): DashboardInterface { if (!\in_array($direction, [TextDirection::LTR, TextDirection::RTL], true)) { - throw new \InvalidArgumentException(sprintf('The "%s" value given to the textDirection option is not valid. It can only be "%s" or "%s"', $direction, TextDirection::LTR, TextDirection::RTL)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" value given to the textDirection option is not valid. It can only be "%s" or "%s"', + $direction, + TextDirection::LTR, + TextDirection::RTL + ) + ); } $this->dto->setTextDirection($direction); @@ -56,14 +63,18 @@ public function setTextDirection(string $direction): DashboardInterface public function renderContentMaximized(bool $maximized = true): DashboardInterface { - $this->dto->setContentWidth($maximized ? CrudInterface::LAYOUT_CONTENT_FULL : CrudInterface::LAYOUT_CONTENT_DEFAULT); + $this->dto->setContentWidth( + $maximized ? CrudInterface::LAYOUT_CONTENT_FULL : CrudInterface::LAYOUT_CONTENT_DEFAULT + ); return $this; } public function renderSidebarMinimized(bool $minimized = true): DashboardInterface { - $this->dto->setSidebarWidth($minimized ? CrudInterface::LAYOUT_SIDEBAR_COMPACT : CrudInterface::LAYOUT_SIDEBAR_DEFAULT); + $this->dto->setSidebarWidth( + $minimized ? CrudInterface::LAYOUT_SIDEBAR_COMPACT : CrudInterface::LAYOUT_SIDEBAR_DEFAULT + ); return $this; } @@ -102,8 +113,8 @@ public function setLocales(array $locales): DashboardInterface foreach ($locales as $key => $value) { $locale = match (true) { $value instanceof Locale => $value, - \is_string($key) => Locale::new($key, (string) $value), - default => Locale::new((string) $value), + \is_string($key) => Locale::new($key, (string)$value), + default => Locale::new((string)$value), }; $localeDtos[] = $locale->getAsDto(); diff --git a/src/Config/DashboardInterface.php b/src/Config/DashboardInterface.php index 09cd21e224..77f0a0e67c 100644 --- a/src/Config/DashboardInterface.php +++ b/src/Config/DashboardInterface.php @@ -5,7 +5,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config; -use EasyCorp\Bundle\EasyAdminBundle\Dto\DashboardDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\DashboardDtoInterface; /** diff --git a/src/Config/Filters.php b/src/Config/Filters.php index 23889639c0..a5b314401b 100644 --- a/src/Config/Filters.php +++ b/src/Config/Filters.php @@ -24,9 +24,14 @@ public static function new(): FiltersInterface public function add(FilterInterface|string $propertyNameOrFilter): FiltersInterface { - $filterPropertyName = \is_string($propertyNameOrFilter) ? $propertyNameOrFilter : (string) $propertyNameOrFilter; + $filterPropertyName = \is_string($propertyNameOrFilter) ? $propertyNameOrFilter : (string)$propertyNameOrFilter; if (null !== $this->dto->getFilter($filterPropertyName)) { - throw new \InvalidArgumentException(sprintf('There are two or more different filters defined for the "%s" property, but you can only define a single filter per property.', $filterPropertyName)); + throw new \InvalidArgumentException( + sprintf( + 'There are two or more different filters defined for the "%s" property, but you can only define a single filter per property.', + $filterPropertyName + ) + ); } $this->dto->addFilter($propertyNameOrFilter); diff --git a/src/Config/FiltersInterface.php b/src/Config/FiltersInterface.php index 42986ca30d..86262a13ce 100644 --- a/src/Config/FiltersInterface.php +++ b/src/Config/FiltersInterface.php @@ -6,7 +6,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDtoInterface; /** diff --git a/src/Config/Locale.php b/src/Config/Locale.php index e1a7cd47da..bb06710d5d 100644 --- a/src/Config/Locale.php +++ b/src/Config/Locale.php @@ -23,7 +23,12 @@ public function __toString() public static function new(string $locale, string|null $label = null, ?string $icon = null): self { if (!Locales::exists($locale)) { - throw new \InvalidArgumentException(sprintf('The given value "%s" is not a valid locale code or it is not supported by the Symfony Intl component.', $locale)); + throw new \InvalidArgumentException( + sprintf( + 'The given value "%s" is not a valid locale code or it is not supported by the Symfony Intl component.', + $locale + ) + ); } $label ??= Locales::getName($locale, $locale); diff --git a/src/Config/LocaleInterface.php b/src/Config/LocaleInterface.php index 9d63608a35..326480f160 100644 --- a/src/Config/LocaleInterface.php +++ b/src/Config/LocaleInterface.php @@ -5,7 +5,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config; -use EasyCorp\Bundle\EasyAdminBundle\Dto\LocaleDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\LocaleDtoInterface; /** diff --git a/src/Config/Menu/CrudMenuItem.php b/src/Config/Menu/CrudMenuItem.php index 559c70b975..a2a5b7acd4 100644 --- a/src/Config/Menu/CrudMenuItem.php +++ b/src/Config/Menu/CrudMenuItem.php @@ -35,20 +35,24 @@ public function __construct(TranslatableInterface|string $label, ?string $icon, public function setController(string $controllerFqcn): self { - $this->dto->setRouteParameters(array_merge( - $this->dto->getRouteParameters(), - [EA::CRUD_CONTROLLER_FQCN => $controllerFqcn] - )); + $this->dto->setRouteParameters( + array_merge( + $this->dto->getRouteParameters(), + [EA::CRUD_CONTROLLER_FQCN => $controllerFqcn] + ) + ); return $this; } public function setAction(string $actionName): self { - $this->dto->setRouteParameters(array_merge( - $this->dto->getRouteParameters(), - [EA::CRUD_ACTION => $actionName] - )); + $this->dto->setRouteParameters( + array_merge( + $this->dto->getRouteParameters(), + [EA::CRUD_ACTION => $actionName] + ) + ); return $this; } @@ -67,10 +71,12 @@ public function setEntityId(/* AbstractUid|int|string */ $entityId): self ); } - $this->dto->setRouteParameters(array_merge( - $this->dto->getRouteParameters(), - [EA::ENTITY_ID => $entityId] - )); + $this->dto->setRouteParameters( + array_merge( + $this->dto->getRouteParameters(), + [EA::ENTITY_ID => $entityId] + ) + ); return $this; } @@ -83,18 +89,28 @@ public function setDefaultSort(array $sortFieldsAndOrder): self $sortFieldsAndOrder = array_map('strtoupper', $sortFieldsAndOrder); foreach ($sortFieldsAndOrder as $sortField => $sortOrder) { if (!\in_array($sortOrder, [SortOrder::ASC, SortOrder::DESC], true)) { - throw new \InvalidArgumentException(sprintf('The sort order can be only "ASC" or "DESC", "%s" given.', $sortOrder)); + throw new \InvalidArgumentException( + sprintf('The sort order can be only "ASC" or "DESC", "%s" given.', $sortOrder) + ); } if (!\is_string($sortField)) { - throw new \InvalidArgumentException(sprintf('The keys of the array that defines the default sort must be strings with the field names, but the given "%s" value is a "%s".', $sortField, \gettype($sortField))); + throw new \InvalidArgumentException( + sprintf( + 'The keys of the array that defines the default sort must be strings with the field names, but the given "%s" value is a "%s".', + $sortField, + \gettype($sortField) + ) + ); } } - $this->dto->setRouteParameters(array_merge( - $this->dto->getRouteParameters(), - [EA::SORT => $sortFieldsAndOrder] - )); + $this->dto->setRouteParameters( + array_merge( + $this->dto->getRouteParameters(), + [EA::SORT => $sortFieldsAndOrder] + ) + ); return $this; } diff --git a/src/Config/Menu/MenuItemTrait.php b/src/Config/Menu/MenuItemTrait.php index 78a6431ab9..c6d5158437 100644 --- a/src/Config/Menu/MenuItemTrait.php +++ b/src/Config/Menu/MenuItemTrait.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config\Menu; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDtoInterface; /** @@ -55,9 +54,9 @@ public function setLinkTarget(string $target): self } /** - * @param mixed $content This is rendered as the value of the badge; it can be anything that can be cast to + * @param mixed $content This is rendered as the value of the badge; it can be anything that can be cast to * a string (numbers, stringable objects, etc.) - * @param string $style Pass one of these values for predefined styles: 'primary', 'secondary', 'success', + * @param string $style Pass one of these values for predefined styles: 'primary', 'secondary', 'success', * 'danger', 'warning', 'info', 'light', 'dark' * Otherwise, the passed value is applied "as is" to the `style` attribute of the HTML * element of the badge diff --git a/src/Config/Menu/RouteMenuItem.php b/src/Config/Menu/RouteMenuItem.php index 27f4707289..ea40bbf2a1 100644 --- a/src/Config/Menu/RouteMenuItem.php +++ b/src/Config/Menu/RouteMenuItem.php @@ -16,8 +16,12 @@ final class RouteMenuItem implements MenuItemInterface { use MenuItemTrait; - public function __construct(TranslatableInterface|string $label, ?string $icon, string $routeName, array $routeParameters) - { + public function __construct( + TranslatableInterface|string $label, + ?string $icon, + string $routeName, + array $routeParameters + ) { $this->dto = new MenuItemDto(); $this->dto->setType(MenuItemDtoInterface::TYPE_ROUTE); diff --git a/src/Config/MenuItem.php b/src/Config/MenuItem.php index ad1e3e2629..6b7d3b8abb 100644 --- a/src/Config/MenuItem.php +++ b/src/Config/MenuItem.php @@ -18,8 +18,11 @@ private function __construct() { } - public static function linkToCrud(TranslatableInterface|string $label, ?string $icon, string $entityFqcn): CrudMenuItem - { + public static function linkToCrud( + TranslatableInterface|string $label, + ?string $icon, + string $entityFqcn + ): CrudMenuItem { return new CrudMenuItem($label, $icon, $entityFqcn); } @@ -28,8 +31,10 @@ public static function linkToDashboard(TranslatableInterface|string $label, ?str return new DashboardMenuItem($label, $icon); } - public static function linkToExitImpersonation(TranslatableInterface|string $label, ?string $icon = null): ExitImpersonationMenuItem - { + public static function linkToExitImpersonation( + TranslatableInterface|string $label, + ?string $icon = null + ): ExitImpersonationMenuItem { return new ExitImpersonationMenuItem($label, $icon); } @@ -38,8 +43,12 @@ public static function linkToLogout(TranslatableInterface|string $label, ?string return new LogoutMenuItem($label, $icon); } - public static function linkToRoute(TranslatableInterface|string $label, ?string $icon, string $routeName, array $routeParameters = []): RouteMenuItem - { + public static function linkToRoute( + TranslatableInterface|string $label, + ?string $icon, + string $routeName, + array $routeParameters = [] + ): RouteMenuItem { return new RouteMenuItem($label, $icon, $routeName, $routeParameters); } @@ -48,8 +57,10 @@ public static function linkToUrl(TranslatableInterface|string $label, ?string $i return new UrlMenuItem($label, $icon, $url); } - public static function section(TranslatableInterface|string|null $label = null, ?string $icon = null): SectionMenuItem - { + public static function section( + TranslatableInterface|string|null $label = null, + ?string $icon = null + ): SectionMenuItem { return new SectionMenuItem($label, $icon); } diff --git a/src/Config/UserMenu.php b/src/Config/UserMenu.php index 3cdf9be822..bc658b4df9 100644 --- a/src/Config/UserMenu.php +++ b/src/Config/UserMenu.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Config; -use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDtoInterface; diff --git a/src/Config/UserMenuInterface.php b/src/Config/UserMenuInterface.php index 112ed9784a..fd5b476c20 100644 --- a/src/Config/UserMenuInterface.php +++ b/src/Config/UserMenuInterface.php @@ -6,7 +6,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDtoInterface; /** diff --git a/src/Context/AdminContext.php b/src/Context/AdminContext.php index bb60b72824..9852de9ca9 100644 --- a/src/Context/AdminContext.php +++ b/src/Context/AdminContext.php @@ -5,28 +5,16 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\DashboardDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\DashboardDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\I18nDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\I18nDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\LocaleDto; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\MenuFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\MenuFactoryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Registry\CrudControllerRegistry; use EasyCorp\Bundle\EasyAdminBundle\Registry\CrudControllerRegistryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Registry\TemplateRegistry; use EasyCorp\Bundle\EasyAdminBundle\Registry\TemplateRegistryInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\User\UserInterface; @@ -168,7 +156,10 @@ public function getMainMenu(): MainMenuDtoInterface } $configuredMenuItems = $this->dashboardControllerInstance->configureMenuItems(); - $mainMenuItems = \is_array($configuredMenuItems) ? $configuredMenuItems : iterator_to_array($configuredMenuItems, false); + $mainMenuItems = \is_array($configuredMenuItems) ? $configuredMenuItems : iterator_to_array( + $configuredMenuItems, + false + ); return $this->mainMenuDto = $this->menuFactory->createMainMenu($mainMenuItems); } diff --git a/src/Context/AdminContextInterface.php b/src/Context/AdminContextInterface.php index ea87e3968b..cb572c6e42 100644 --- a/src/Context/AdminContextInterface.php +++ b/src/Context/AdminContextInterface.php @@ -5,23 +5,14 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Context; -use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\I18nDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\I18nDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\LocaleDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\LocaleDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Registry\CrudControllerRegistry; use EasyCorp\Bundle\EasyAdminBundle\Registry\CrudControllerRegistryInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\User\UserInterface; diff --git a/src/Context/ExceptionContext.php b/src/Context/ExceptionContext.php index 982f5d1d92..9c73517e50 100644 --- a/src/Context/ExceptionContext.php +++ b/src/Context/ExceptionContext.php @@ -41,7 +41,7 @@ public function getParameters(): array public function getTranslationParameters(): array { return array_map( - static fn ($parameter): string => u($parameter)->ensureStart('%')->ensureEnd('%')->toString(), + static fn($parameter): string => u($parameter)->ensureStart('%')->ensureEnd('%')->toString(), $this->parameters ); } diff --git a/src/Contracts/Controller/CrudControllerInterface.php b/src/Contracts/Controller/CrudControllerInterface.php index 92c49fa701..1ce5aa483f 100644 --- a/src/Contracts/Controller/CrudControllerInterface.php +++ b/src/Contracts/Controller/CrudControllerInterface.php @@ -6,18 +6,14 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; +use EasyCorp\Bundle\EasyAdminBundle\Config\ActionsInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\AssetsInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; +use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\FiltersInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; -use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; +use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContextInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; @@ -31,11 +27,11 @@ interface CrudControllerInterface { public static function getEntityFqcn(): string; - public function configureCrud(Crud $crud): Crud; + public function configureCrud(CrudInterface $crud): CrudInterface; public function configureAssets(AssetsInterface $assets): AssetsInterface; - public function configureActions(Actions $actions): Actions; + public function configureActions(ActionsInterface $actions): ActionsInterface; public function configureFilters(FiltersInterface $filters): FiltersInterface; @@ -46,26 +42,26 @@ public function configureFilters(FiltersInterface $filters): FiltersInterface; */ public function configureFields(string $pageName): iterable; - /** @return KeyValueStore|Response */ - public function index(AdminContext $context); + public function index(AdminContextInterface $context): Response|KeyValueStoreInterface; - /** @return KeyValueStore|Response */ - public function detail(AdminContext $context); + public function detail(AdminContextInterface $context): Response|KeyValueStoreInterface; - /** @return KeyValueStore|Response */ - public function edit(AdminContext $context); + public function edit(AdminContextInterface $context): Response|KeyValueStoreInterface; - /** @return KeyValueStore|Response */ - public function new(AdminContext $context); + public function new(AdminContextInterface $context): Response|KeyValueStoreInterface; - /** @return KeyValueStore|Response */ - public function delete(AdminContext $context); + public function delete(AdminContextInterface $context): Response|KeyValueStoreInterface; - public function autocomplete(AdminContext $context): JsonResponse; + public function autocomplete(AdminContextInterface $context): JsonResponse; - public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore; + public function configureResponseParameters(KeyValueStoreInterface $responseParameters): KeyValueStoreInterface; - public function createIndexQueryBuilder(SearchDtoInterface $searchDto, EntityDtoInterface $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder; + public function createIndexQueryBuilder( + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto, + FieldCollection $fields, + FilterCollection $filters + ): QueryBuilder; public function createEntity(string $entityFqcn); @@ -75,11 +71,27 @@ public function persistEntity(EntityManagerInterface $entityManager, $entityInst public function deleteEntity(EntityManagerInterface $entityManager, $entityInstance): void; - public function createEditFormBuilder(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormBuilderInterface; - - public function createEditForm(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormInterface; - - public function createNewFormBuilder(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormBuilderInterface; - - public function createNewForm(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormInterface; + public function createEditFormBuilder( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormBuilderInterface; + + public function createEditForm( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormInterface; + + public function createNewFormBuilder( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormBuilderInterface; + + public function createNewForm( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormInterface; } diff --git a/src/Contracts/Controller/DashboardControllerInterface.php b/src/Contracts/Controller/DashboardControllerInterface.php index 0123e1007c..4f89151d16 100644 --- a/src/Contracts/Controller/DashboardControllerInterface.php +++ b/src/Contracts/Controller/DashboardControllerInterface.php @@ -3,14 +3,10 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; use EasyCorp\Bundle\EasyAdminBundle\Config\AssetsInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; use EasyCorp\Bundle\EasyAdminBundle\Config\DashboardInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Config\FiltersInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu; use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenuInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface; use Symfony\Component\HttpFoundation\Response; diff --git a/src/Contracts/Field/FieldConfiguratorInterface.php b/src/Contracts/Field/FieldConfiguratorInterface.php index ea995556b8..ff6fbad405 100644 --- a/src/Contracts/Field/FieldConfiguratorInterface.php +++ b/src/Contracts/Field/FieldConfiguratorInterface.php @@ -3,9 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Field; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; /** diff --git a/src/Contracts/Field/FieldInterface.php b/src/Contracts/Field/FieldInterface.php index fe9bac8997..e38ba9bc33 100644 --- a/src/Contracts/Field/FieldInterface.php +++ b/src/Contracts/Field/FieldInterface.php @@ -3,14 +3,16 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Field; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use Symfony\Contracts\Translation\TranslatableInterface; /** * @author Javier Eguiluz */ interface FieldInterface { - public static function new(string $propertyName, ?string /* TranslatableInterface|string|false|null */ $label = null); + public static function new( + string $propertyName, + ?string /* TranslatableInterface|string|false|null */ $label = null + ); public function getAsDto(): FieldDtoInterface; } diff --git a/src/Contracts/Filter/FilterConfiguratorInterface.php b/src/Contracts/Filter/FilterConfiguratorInterface.php index d58b284912..06d4913038 100644 --- a/src/Contracts/Filter/FilterConfiguratorInterface.php +++ b/src/Contracts/Filter/FilterConfiguratorInterface.php @@ -3,11 +3,8 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; /** @@ -15,7 +12,17 @@ */ interface FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool; + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool; - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void; + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void; } diff --git a/src/Contracts/Filter/FilterInterface.php b/src/Contracts/Filter/FilterInterface.php index 1dec8d61c6..1bfa5f16f6 100644 --- a/src/Contracts/Filter/FilterInterface.php +++ b/src/Contracts/Filter/FilterInterface.php @@ -3,13 +3,9 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter; use Doctrine\ORM\QueryBuilder; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; /** @@ -17,7 +13,12 @@ */ interface FilterInterface extends \Stringable { - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void; + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void; public function getAsDto(): FilterDtoInterface; } diff --git a/src/Contracts/Menu/MenuItemInterface.php b/src/Contracts/Menu/MenuItemInterface.php index febb6a5e9f..bf18d7d4e0 100644 --- a/src/Contracts/Menu/MenuItemInterface.php +++ b/src/Contracts/Menu/MenuItemInterface.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDtoInterface; /** diff --git a/src/Contracts/Orm/EntityPaginatorInterface.php b/src/Contracts/Orm/EntityPaginatorInterface.php index f11d4ded96..cb000d169c 100644 --- a/src/Contracts/Orm/EntityPaginatorInterface.php +++ b/src/Contracts/Orm/EntityPaginatorInterface.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm; use Doctrine\ORM\QueryBuilder; -use EasyCorp\Bundle\EasyAdminBundle\Dto\PaginatorDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\PaginatorDtoInterface; /** diff --git a/src/Contracts/Orm/EntityRepositoryInterface.php b/src/Contracts/Orm/EntityRepositoryInterface.php index c3355530ab..39d4d11704 100644 --- a/src/Contracts/Orm/EntityRepositoryInterface.php +++ b/src/Contracts/Orm/EntityRepositoryInterface.php @@ -5,9 +5,7 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; /** @@ -15,5 +13,10 @@ */ interface EntityRepositoryInterface { - public function createQueryBuilder(SearchDtoInterface $searchDto, EntityDtoInterface $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder; + public function createQueryBuilder( + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto, + FieldCollection $fields, + FilterCollection $filters + ): QueryBuilder; } diff --git a/src/Contracts/Orm/EntityUpdaterInterface.php b/src/Contracts/Orm/EntityUpdaterInterface.php index 737e9fcbb3..0c21710c63 100644 --- a/src/Contracts/Orm/EntityUpdaterInterface.php +++ b/src/Contracts/Orm/EntityUpdaterInterface.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; /** diff --git a/src/Controller/AbstractCrudController.php b/src/Controller/AbstractCrudController.php index c6d625fbde..a242e39304 100644 --- a/src/Controller/AbstractCrudController.php +++ b/src/Controller/AbstractCrudController.php @@ -2,34 +2,28 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Controller; +use Closure; use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ManagerRegistry; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; +use EasyCorp\Bundle\EasyAdminBundle\Config\ActionsInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\AssetsInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Config\FiltersInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; -use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; +use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContextInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\BatchActionDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Event\AfterCrudActionEvent; use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityDeletedEvent; @@ -58,8 +52,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\FieldProvider; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; -use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Security\PermissionInterface; +use Exception; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -70,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException; + use function Symfony\Component\String\u; /** @@ -79,7 +74,7 @@ abstract class AbstractCrudController extends AbstractController implements Crud { abstract public static function getEntityFqcn(): string; - public function configureCrud(Crud $crud): Crud + public function configureCrud(CrudInterface $crud): CrudInterface { return $crud; } @@ -89,7 +84,7 @@ public function configureAssets(AssetsInterface $assets): AssetsInterface return $assets; } - public function configureActions(Actions $actions): Actions + public function configureActions(ActionsInterface $actions): ActionsInterface { return $actions; } @@ -123,7 +118,7 @@ public static function getSubscribedServices(): array ]); } - public function index(AdminContext $context) + public function index(AdminContextInterface $context): Response|KeyValueStoreInterface { $event = new BeforeCrudActionEvent($context); $this->container->get('event_dispatcher')->dispatch($event); @@ -133,38 +128,52 @@ public function index(AdminContext $context) if (!$this->isGranted(PermissionInterface::EA_EXECUTE_ACTION, [ 'action' => ActionInterface::INDEX, - 'entity' => null + 'entity' => null, ])) { throw new ForbiddenActionException($context); } $fields = FieldCollection::new($this->configureFields(CrudInterface::PAGE_INDEX)); $context->getCrud()->setFieldAssets($this->getFieldAssets($fields)); - $filters = $this->container->get(FilterFactory::class)->create($context->getCrud()->getFiltersConfig(), $fields, $context->getEntity()); + $filters = $this->container->get(FilterFactory::class)->create( + $context->getCrud()->getFiltersConfig(), + $fields, + $context->getEntity() + ); $queryBuilder = $this->createIndexQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); $paginator = $this->container->get(PaginatorFactory::class)->create($queryBuilder); // this can happen after deleting some items and trying to return // to a 'index' page that no longer exists. Redirect to the last page instead if ($paginator->isOutOfRange()) { - return $this->redirect($this->container->get(AdminUrlGenerator::class) - ->set(EA::PAGE, $paginator->getLastPage()) - ->generateUrl()); + return $this->redirect( + $this->container->get(AdminUrlGenerator::class) + ->set(EA::PAGE, $paginator->getLastPage()) + ->generateUrl() + ); } - $entities = $this->container->get(EntityFactory::class)->createCollection($context->getEntity(), $paginator->getResults()); + $entities = $this->container->get(EntityFactory::class)->createCollection( + $context->getEntity(), + $paginator->getResults() + ); $this->container->get(EntityFactory::class)->processFieldsForAll($entities, $fields); - $actions = $this->container->get(EntityFactory::class)->processActionsForAll($entities, $context->getCrud()->getActionsConfig()); - - $responseParameters = $this->configureResponseParameters(KeyValueStore::new([ - 'pageName' => CrudInterface::PAGE_INDEX, - 'templateName' => 'crud/index', - 'entities' => $entities, - 'paginator' => $paginator, - 'global_actions' => $actions->getGlobalActions(), - 'batch_actions' => $actions->getBatchActions(), - 'filters' => $filters, - ])); + $actions = $this->container->get(EntityFactory::class)->processActionsForAll( + $entities, + $context->getCrud()->getActionsConfig() + ); + + $responseParameters = $this->configureResponseParameters( + KeyValueStore::new([ + 'pageName' => CrudInterface::PAGE_INDEX, + 'templateName' => 'crud/index', + 'entities' => $entities, + 'paginator' => $paginator, + 'global_actions' => $actions->getGlobalActions(), + 'batch_actions' => $actions->getBatchActions(), + 'filters' => $filters, + ]) + ); $event = new AfterCrudActionEvent($context, $responseParameters); $this->container->get('event_dispatcher')->dispatch($event); @@ -175,7 +184,7 @@ public function index(AdminContext $context) return $responseParameters; } - public function detail(AdminContext $context) + public function detail(AdminContextInterface $context): Response|KeyValueStoreInterface { $event = new BeforeCrudActionEvent($context); $this->container->get('event_dispatcher')->dispatch($event); @@ -183,7 +192,10 @@ public function detail(AdminContext $context) return $event->getResponse(); } - if (!$this->isGranted(PermissionInterface::EA_EXECUTE_ACTION, ['action' => ActionInterface::DETAIL, 'entity' => $context->getEntity()])) { + if (!$this->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => ActionInterface::DETAIL, 'entity' => $context->getEntity()] + )) { throw new ForbiddenActionException($context); } @@ -191,16 +203,27 @@ public function detail(AdminContext $context) throw new InsufficientEntityPermissionException($context); } - $this->container->get(EntityFactory::class)->processFields($context->getEntity(), FieldCollection::new($this->configureFields( - CrudInterface::PAGE_DETAIL))); + $this->container->get(EntityFactory::class)->processFields( + $context->getEntity(), + FieldCollection::new( + $this->configureFields( + CrudInterface::PAGE_DETAIL + ) + ) + ); $context->getCrud()->setFieldAssets($this->getFieldAssets($context->getEntity()->getFields())); - $this->container->get(EntityFactory::class)->processActions($context->getEntity(), $context->getCrud()->getActionsConfig()); - - $responseParameters = $this->configureResponseParameters(KeyValueStore::new([ - 'pageName' => CrudInterface::PAGE_DETAIL, - 'templateName' => 'crud/detail', - 'entity' => $context->getEntity(), - ])); + $this->container->get(EntityFactory::class)->processActions( + $context->getEntity(), + $context->getCrud()->getActionsConfig() + ); + + $responseParameters = $this->configureResponseParameters( + KeyValueStore::new([ + 'pageName' => CrudInterface::PAGE_DETAIL, + 'templateName' => 'crud/detail', + 'entity' => $context->getEntity(), + ]) + ); $event = new AfterCrudActionEvent($context, $responseParameters); $this->container->get('event_dispatcher')->dispatch($event); @@ -211,7 +234,7 @@ public function detail(AdminContext $context) return $responseParameters; } - public function edit(AdminContext $context) + public function edit(AdminContextInterface $context): Response|KeyValueStoreInterface { $event = new BeforeCrudActionEvent($context); $this->container->get('event_dispatcher')->dispatch($event); @@ -219,7 +242,10 @@ public function edit(AdminContext $context) return $event->getResponse(); } - if (!$this->isGranted(PermissionInterface::EA_EXECUTE_ACTION, ['action' => ActionInterface::EDIT, 'entity' => $context->getEntity()])) { + if (!$this->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => ActionInterface::EDIT, 'entity' => $context->getEntity()] + )) { throw new ForbiddenActionException($context); } @@ -227,10 +253,19 @@ public function edit(AdminContext $context) throw new InsufficientEntityPermissionException($context); } - $this->container->get(EntityFactory::class)->processFields($context->getEntity(), FieldCollection::new($this->configureFields( - CrudInterface::PAGE_EDIT))); + $this->container->get(EntityFactory::class)->processFields( + $context->getEntity(), + FieldCollection::new( + $this->configureFields( + CrudInterface::PAGE_EDIT + ) + ) + ); $context->getCrud()->setFieldAssets($this->getFieldAssets($context->getEntity()->getFields())); - $this->container->get(EntityFactory::class)->processActions($context->getEntity(), $context->getCrud()->getActionsConfig()); + $this->container->get(EntityFactory::class)->processActions( + $context->getEntity(), + $context->getCrud()->getActionsConfig() + ); $entityInstance = $context->getEntity()->getInstance(); if ($context->getRequest()->isXmlHttpRequest()) { @@ -238,7 +273,10 @@ public function edit(AdminContext $context) throw new MethodNotAllowedHttpException(['PATCH']); } - if (!$this->isCsrfTokenValid(BooleanField::CSRF_TOKEN_NAME, $context->getRequest()->query->get('csrfToken'))) { + if (!$this->isCsrfTokenValid( + BooleanField::CSRF_TOKEN_NAME, + $context->getRequest()->query->get('csrfToken') + )) { if (class_exists(InvalidCsrfTokenException::class)) { throw new InvalidCsrfTokenException(); } else { @@ -251,7 +289,7 @@ public function edit(AdminContext $context) try { $event = $this->ajaxEdit($context->getEntity(), $fieldName, $newValue); - } catch (\Exception) { + } catch (Exception) { throw new BadRequestHttpException(); } @@ -262,7 +300,11 @@ public function edit(AdminContext $context) return new Response($newValue ? '1' : '0'); } - $editForm = $this->createEditForm($context->getEntity(), $context->getCrud()->getEditFormOptions(), $context); + $editForm = $this->createEditForm( + $context->getEntity(), + $context->getCrud()->getEditFormOptions(), + $context + ); $editForm->handleRequest($context->getRequest()); if ($editForm->isSubmitted() && $editForm->isValid()) { $this->processUploadedFiles($editForm); @@ -271,19 +313,27 @@ public function edit(AdminContext $context) $this->container->get('event_dispatcher')->dispatch($event); $entityInstance = $event->getEntityInstance(); - $this->updateEntity($this->container->get('doctrine')->getManagerForClass($context->getEntity()->getFqcn()), $entityInstance); + $this->updateEntity( + $this->container->get('doctrine')->getManagerForClass($context->getEntity()->getFqcn()), + $entityInstance + ); $this->container->get('event_dispatcher')->dispatch(new AfterEntityUpdatedEvent($entityInstance)); - return $this->getRedirectResponseAfterSave($context, ActionInterface::EDIT); + return $this->getRedirectResponseAfterSave( + $context, + ActionInterface::EDIT + ); } - $responseParameters = $this->configureResponseParameters(KeyValueStore::new([ - 'pageName' => CrudInterface::PAGE_EDIT, - 'templateName' => 'crud/edit', - 'edit_form' => $editForm, - 'entity' => $context->getEntity(), - ])); + $responseParameters = $this->configureResponseParameters( + KeyValueStore::new([ + 'pageName' => CrudInterface::PAGE_EDIT, + 'templateName' => 'crud/edit', + 'edit_form' => $editForm, + 'entity' => $context->getEntity(), + ]) + ); $event = new AfterCrudActionEvent($context, $responseParameters); $this->container->get('event_dispatcher')->dispatch($event); @@ -294,7 +344,7 @@ public function edit(AdminContext $context) return $responseParameters; } - public function new(AdminContext $context) + public function new(AdminContextInterface $context): Response|KeyValueStoreInterface { $event = new BeforeCrudActionEvent($context); $this->container->get('event_dispatcher')->dispatch($event); @@ -302,7 +352,10 @@ public function new(AdminContext $context) return $event->getResponse(); } - if (!$this->isGranted(PermissionInterface::EA_EXECUTE_ACTION, ['action' => ActionInterface::NEW, 'entity' => null])) { + if (!$this->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => ActionInterface::NEW, 'entity' => null] + )) { throw new ForbiddenActionException($context); } @@ -311,10 +364,19 @@ public function new(AdminContext $context) } $context->getEntity()->setInstance($this->createEntity($context->getEntity()->getFqcn())); - $this->container->get(EntityFactory::class)->processFields($context->getEntity(), FieldCollection::new($this->configureFields( - CrudInterface::PAGE_NEW))); + $this->container->get(EntityFactory::class)->processFields( + $context->getEntity(), + FieldCollection::new( + $this->configureFields( + CrudInterface::PAGE_NEW + ) + ) + ); $context->getCrud()->setFieldAssets($this->getFieldAssets($context->getEntity()->getFields())); - $this->container->get(EntityFactory::class)->processActions($context->getEntity(), $context->getCrud()->getActionsConfig()); + $this->container->get(EntityFactory::class)->processActions( + $context->getEntity(), + $context->getCrud()->getActionsConfig() + ); $newForm = $this->createNewForm($context->getEntity(), $context->getCrud()->getNewFormOptions(), $context); $newForm->handleRequest($context->getRequest()); @@ -329,7 +391,10 @@ public function new(AdminContext $context) $this->container->get('event_dispatcher')->dispatch($event); $entityInstance = $event->getEntityInstance(); - $this->persistEntity($this->container->get('doctrine')->getManagerForClass($context->getEntity()->getFqcn()), $entityInstance); + $this->persistEntity( + $this->container->get('doctrine')->getManagerForClass($context->getEntity()->getFqcn()), + $entityInstance + ); $this->container->get('event_dispatcher')->dispatch(new AfterEntityPersistedEvent($entityInstance)); $context->getEntity()->setInstance($entityInstance); @@ -337,12 +402,14 @@ public function new(AdminContext $context) return $this->getRedirectResponseAfterSave($context, ActionInterface::NEW); } - $responseParameters = $this->configureResponseParameters(KeyValueStore::new([ - 'pageName' => CrudInterface::PAGE_NEW, - 'templateName' => 'crud/new', - 'entity' => $context->getEntity(), - 'new_form' => $newForm, - ])); + $responseParameters = $this->configureResponseParameters( + KeyValueStore::new([ + 'pageName' => CrudInterface::PAGE_NEW, + 'templateName' => 'crud/new', + 'entity' => $context->getEntity(), + 'new_form' => $newForm, + ]) + ); $event = new AfterCrudActionEvent($context, $responseParameters); $this->container->get('event_dispatcher')->dispatch($event); @@ -353,7 +420,7 @@ public function new(AdminContext $context) return $responseParameters; } - public function delete(AdminContext $context) + public function delete(AdminContextInterface $context): Response|KeyValueStoreInterface { $event = new BeforeCrudActionEvent($context); $this->container->get('event_dispatcher')->dispatch($event); @@ -361,7 +428,10 @@ public function delete(AdminContext $context) return $event->getResponse(); } - if (!$this->isGranted(PermissionInterface::EA_EXECUTE_ACTION, ['action' => ActionInterface::DELETE, 'entity' => $context->getEntity()])) { + if (!$this->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => ActionInterface::DELETE, 'entity' => $context->getEntity()] + )) { throw new ForbiddenActionException($context); } @@ -384,16 +454,23 @@ public function delete(AdminContext $context) $entityInstance = $event->getEntityInstance(); try { - $this->deleteEntity($this->container->get('doctrine')->getManagerForClass($context->getEntity()->getFqcn()), $entityInstance); + $this->deleteEntity( + $this->container->get('doctrine')->getManagerForClass($context->getEntity()->getFqcn()), + $entityInstance + ); } catch (ForeignKeyConstraintViolationException $e) { - throw new EntityRemoveException(['entity_name' => $context->getEntity()->getName(), 'message' => $e->getMessage()]); + throw new EntityRemoveException( + ['entity_name' => $context->getEntity()->getName(), 'message' => $e->getMessage()] + ); } $this->container->get('event_dispatcher')->dispatch(new AfterEntityDeletedEvent($entityInstance)); - $responseParameters = $this->configureResponseParameters(KeyValueStore::new([ - 'entity' => $context->getEntity(), - ])); + $responseParameters = $this->configureResponseParameters( + KeyValueStore::new([ + 'entity' => $context->getEntity(), + ]) + ); $event = new AfterCrudActionEvent($context, $responseParameters); $this->container->get('event_dispatcher')->dispatch($event); @@ -405,10 +482,14 @@ public function delete(AdminContext $context) return $this->redirect($referrer); } - return $this->redirect($this->container->get(AdminUrlGenerator::class)->setAction(ActionInterface::INDEX)->unset(EA::ENTITY_ID)->generateUrl()); + return $this->redirect( + $this->container->get(AdminUrlGenerator::class)->setAction(ActionInterface::INDEX)->unset( + EA::ENTITY_ID + )->generateUrl() + ); } - public function batchDelete(AdminContext $context, BatchActionDtoInterface $batchActionDto): Response + public function batchDelete(AdminContextInterface $context, BatchActionDtoInterface $batchActionDto): Response { $event = new BeforeCrudActionEvent($context); $this->container->get('event_dispatcher')->dispatch($event); @@ -416,7 +497,10 @@ public function batchDelete(AdminContext $context, BatchActionDtoInterface $batc return $event->getResponse(); } - if (!$this->isCsrfTokenValid('ea-batch-action-'.ActionInterface::BATCH_DELETE, $batchActionDto->getCsrfToken())) { + if (!$this->isCsrfTokenValid( + 'ea-batch-action-'.ActionInterface::BATCH_DELETE, + $batchActionDto->getCsrfToken() + )) { return $this->redirectToRoute($context->getDashboardRouteName()); } @@ -429,7 +513,10 @@ public function batchDelete(AdminContext $context, BatchActionDtoInterface $batc } $entityDto = $context->getEntity()->newWithInstance($entityInstance); - if (!$this->isGranted(PermissionInterface::EA_EXECUTE_ACTION, ['action' => ActionInterface::DELETE, 'entity' => $entityDto])) { + if (!$this->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => ActionInterface::DELETE, 'entity' => $entityDto] + )) { throw new ForbiddenActionException($context); } @@ -444,16 +531,19 @@ public function batchDelete(AdminContext $context, BatchActionDtoInterface $batc try { $this->deleteEntity($entityManager, $entityInstance); } catch (ForeignKeyConstraintViolationException $e) { - throw new EntityRemoveException(['entity_name' => $entityDto->toString(), 'message' => $e->getMessage()]); + throw new EntityRemoveException(['entity_name' => $entityDto->toString(), 'message' => $e->getMessage()] + ); } $this->container->get('event_dispatcher')->dispatch(new AfterEntityDeletedEvent($entityInstance)); } - $responseParameters = $this->configureResponseParameters(KeyValueStore::new([ - 'entity' => $context->getEntity(), - 'batchActionDto' => $batchActionDto, - ])); + $responseParameters = $this->configureResponseParameters( + KeyValueStore::new([ + 'entity' => $context->getEntity(), + 'batchActionDto' => $batchActionDto, + ]) + ); $event = new AfterCrudActionEvent($context, $responseParameters); $this->container->get('event_dispatcher')->dispatch($event); @@ -464,17 +554,28 @@ public function batchDelete(AdminContext $context, BatchActionDtoInterface $batc return $this->redirect($batchActionDto->getReferrerUrl()); } - public function autocomplete(AdminContext $context): JsonResponse + public function autocomplete(AdminContextInterface $context): JsonResponse { - $queryBuilder = $this->createIndexQueryBuilder($context->getSearch(), $context->getEntity(), FieldCollection::new([]), FilterCollection::new()); + $queryBuilder = $this->createIndexQueryBuilder( + $context->getSearch(), + $context->getEntity(), + FieldCollection::new([]), + FilterCollection::new() + ); $autocompleteContext = $context->getRequest()->get(AssociationField::PARAM_AUTOCOMPLETE_CONTEXT); /** @var CrudControllerInterface $controller */ - $controller = $this->container->get(ControllerFactory::class)->getCrudControllerInstance($autocompleteContext[EA::CRUD_CONTROLLER_FQCN], ActionInterface::INDEX, $context->getRequest()); + $controller = $this->container->get(ControllerFactory::class)->getCrudControllerInstance( + $autocompleteContext[EA::CRUD_CONTROLLER_FQCN], + ActionInterface::INDEX, + $context->getRequest() + ); /** @var FieldDtoInterface|null $field */ - $field = FieldCollection::new($controller->configureFields($autocompleteContext['originatingPage']))->getByProperty($autocompleteContext['propertyName']); - /** @var \Closure|null $queryBuilderCallable */ + $field = FieldCollection::new( + $controller->configureFields($autocompleteContext['originatingPage']) + )->getByProperty($autocompleteContext['propertyName']); + /** @var Closure|null $queryBuilderCallable */ $queryBuilderCallable = $field?->getCustomOption(AssociationField::OPTION_QUERY_BUILDER_CALLABLE); if (null !== $queryBuilderCallable) { @@ -486,18 +587,31 @@ public function autocomplete(AdminContext $context): JsonResponse return JsonResponse::fromJsonString($paginator->getResultsAsJson()); } - public function createIndexQueryBuilder(SearchDtoInterface $searchDto, EntityDtoInterface $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder - { - return $this->container->get(EntityRepository::class)->createQueryBuilder($searchDto, $entityDto, $fields, $filters); + public function createIndexQueryBuilder( + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto, + FieldCollection $fields, + FilterCollection $filters + ): QueryBuilder { + return $this->container->get(EntityRepository::class)->createQueryBuilder( + $searchDto, + $entityDto, + $fields, + $filters + ); } - public function renderFilters(AdminContext $context): KeyValueStore + public function renderFilters(AdminContextInterface $context): KeyValueStoreInterface { $fields = FieldCollection::new($this->configureFields(CrudInterface::PAGE_INDEX)); $this->container->get(EntityFactory::class)->processFields($context->getEntity(), $fields); - $filters = $this->container->get(FilterFactory::class)->create($context->getCrud()->getFiltersConfig(), $context->getEntity()->getFields(), $context->getEntity()); + $filters = $this->container->get(FilterFactory::class)->create( + $context->getCrud()->getFiltersConfig(), + $context->getEntity()->getFields(), + $context->getEntity() + ); - /** @var FormInterface&FiltersFormType $filtersForm */ + /** @var FormInterface|FiltersFormType $filtersForm */ $filtersForm = $this->container->get(FormFactory::class)->createFiltersForm($filters, $context->getRequest()); $formActionParts = parse_url($filtersForm->getConfig()->getAction()); $queryString = $formActionParts[EA::QUERY] ?? ''; @@ -536,48 +650,66 @@ public function deleteEntity(EntityManagerInterface $entityManager, $entityInsta $entityManager->flush(); } - public function createEditForm(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormInterface - { + public function createEditForm( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormInterface { return $this->createEditFormBuilder($entityDto, $formOptions, $context)->getForm(); } - public function createEditFormBuilder(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormBuilderInterface - { + public function createEditFormBuilder( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormBuilderInterface { return $this->container->get(FormFactory::class)->createEditFormBuilder($entityDto, $formOptions, $context); } - public function createNewForm(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormInterface - { + public function createNewForm( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormInterface { return $this->createNewFormBuilder($entityDto, $formOptions, $context)->getForm(); } - public function createNewFormBuilder(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormBuilderInterface - { + public function createNewFormBuilder( + EntityDtoInterface $entityDto, + KeyValueStoreInterface $formOptions, + AdminContextInterface $context + ): FormBuilderInterface { return $this->container->get(FormFactory::class)->createNewFormBuilder($entityDto, $formOptions, $context); } /** * Used to add/modify/remove parameters before passing them to the Twig template. */ - public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore + public function configureResponseParameters(KeyValueStoreInterface $responseParameters): KeyValueStoreInterface { return $responseParameters; } - protected function getContext(): ?AdminContext + protected function getContext(): ?AdminContextInterface { return $this->container->get(AdminContextProvider::class)->getContext(); } - protected function ajaxEdit(EntityDtoInterface $entityDto, ?string $propertyName, bool $newValue): AfterCrudActionEvent - { + protected function ajaxEdit( + EntityDtoInterface $entityDto, + ?string $propertyName, + bool $newValue + ): AfterCrudActionEvent { $this->container->get(EntityUpdater::class)->updateProperty($entityDto, $propertyName, $newValue); $event = new BeforeEntityUpdatedEvent($entityDto->getInstance()); $this->container->get('event_dispatcher')->dispatch($event); $entityInstance = $event->getEntityInstance(); - $this->updateEntity($this->container->get('doctrine')->getManagerForClass($entityDto->getFqcn()), $entityInstance); + $this->updateEntity( + $this->container->get('doctrine')->getManagerForClass($entityDto->getFqcn()), + $entityInstance + ); $this->container->get('event_dispatcher')->dispatch(new AfterEntityUpdatedEvent($entityInstance)); @@ -617,14 +749,15 @@ protected function processUploadedFiles(FormInterface $form): void $uploadDelete = $config->getOption('upload_delete'); - if ($state->hasCurrentFiles() && ($state->isDelete() || (!$state->isAddAllowed() && $state->hasUploadedFiles()))) { + if ($state->hasCurrentFiles() && ($state->isDelete() || (!$state->isAddAllowed( + ) && $state->hasUploadedFiles()))) { foreach ($state->getCurrentFiles() as $file) { $uploadDelete($file); } $state->setCurrentFiles([]); } - $filePaths = (array) $child->getData(); + $filePaths = (array)$child->getData(); $uploadDir = $config->getOption('upload_dir'); $uploadNew = $config->getOption('upload_new'); @@ -635,7 +768,7 @@ protected function processUploadedFiles(FormInterface $form): void } } - protected function getRedirectResponseAfterSave(AdminContext $context, string $action): RedirectResponse + protected function getRedirectResponseAfterSave(AdminContextInterface $context, string $action): RedirectResponse { $submitButtonName = $context->getRequest()->request->all()['ea']['newForm']['btn']; diff --git a/src/Controller/AbstractDashboardController.php b/src/Controller/AbstractDashboardController.php index c9f81e8c26..d387fdf8f1 100644 --- a/src/Controller/AbstractDashboardController.php +++ b/src/Controller/AbstractDashboardController.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Controller; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; @@ -18,13 +17,13 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenuInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; -use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Security\PermissionInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; + use function Symfony\Component\Translation\t; /** @@ -74,10 +73,13 @@ public function configureUserMenu(UserInterface $user): UserMenuInterface $userMenuItems[] = MenuItem::linkToLogout(t('user.sign_out', domain: 'EasyAdminBundle'), 'fa-sign-out'); } if ($this->isGranted(PermissionInterface::EA_EXIT_IMPERSONATION)) { - $userMenuItems[] = MenuItem::linkToExitImpersonation(t('user.exit_impersonation', domain: 'EasyAdminBundle'), 'fa-user-lock'); + $userMenuItems[] = MenuItem::linkToExitImpersonation( + t('user.exit_impersonation', domain: 'EasyAdminBundle'), + 'fa-user-lock' + ); } - $userName = method_exists($user, '__toString') ? (string) $user : $user->getUserIdentifier(); + $userName = method_exists($user, '__toString') ? (string)$user : $user->getUserIdentifier(); return UserMenu::new() ->displayUserName() @@ -99,17 +101,13 @@ public function configureActions(): Actions ->add(CrudInterface::PAGE_INDEX, ActionInterface::NEW) ->add(CrudInterface::PAGE_INDEX, ActionInterface::EDIT) ->add(CrudInterface::PAGE_INDEX, ActionInterface::DELETE) - ->add(CrudInterface::PAGE_DETAIL, ActionInterface::EDIT) ->add(CrudInterface::PAGE_DETAIL, ActionInterface::INDEX) ->add(CrudInterface::PAGE_DETAIL, ActionInterface::DELETE) - ->add(CrudInterface::PAGE_EDIT, ActionInterface::SAVE_AND_RETURN) ->add(CrudInterface::PAGE_EDIT, ActionInterface::SAVE_AND_CONTINUE) - ->add(CrudInterface::PAGE_NEW, ActionInterface::SAVE_AND_RETURN) - ->add(CrudInterface::PAGE_NEW, ActionInterface::SAVE_AND_ADD_ANOTHER) - ; + ->add(CrudInterface::PAGE_NEW, ActionInterface::SAVE_AND_ADD_ANOTHER); } public function configureFilters(): FiltersInterface diff --git a/src/DependencyInjection/CreateControllerRegistriesPass.php b/src/DependencyInjection/CreateControllerRegistriesPass.php index c02d3cfd64..c4f4e204bb 100644 --- a/src/DependencyInjection/CreateControllerRegistriesPass.php +++ b/src/DependencyInjection/CreateControllerRegistriesPass.php @@ -24,11 +24,17 @@ public function process(ContainerBuilder $container): void private function createDashboardControllerRegistryService(ContainerBuilder $container): void { - $dashboardControllersFqcn = array_keys($container->findTaggedServiceIds(EasyAdminExtension::TAG_DASHBOARD_CONTROLLER, true)); + $dashboardControllersFqcn = array_keys( + $container->findTaggedServiceIds(EasyAdminExtension::TAG_DASHBOARD_CONTROLLER, true) + ); $controllerFqcnToContextIdMap = []; foreach ($dashboardControllersFqcn as $controllerFqcn) { - $controllerFqcnToContextIdMap[$controllerFqcn] = substr(sha1($container->getParameter('kernel.secret').$controllerFqcn), 0, 7); + $controllerFqcnToContextIdMap[$controllerFqcn] = substr( + sha1($container->getParameter('kernel.secret').$controllerFqcn), + 0, + 7 + ); } $container @@ -43,13 +49,19 @@ private function createDashboardControllerRegistryService(ContainerBuilder $cont private function createCrudControllerRegistryService(ContainerBuilder $container): void { - $crudControllersFqcn = array_keys($container->findTaggedServiceIds(EasyAdminExtension::TAG_CRUD_CONTROLLER, true)); + $crudControllersFqcn = array_keys( + $container->findTaggedServiceIds(EasyAdminExtension::TAG_CRUD_CONTROLLER, true) + ); $crudFqcnToEntityFqcnMap = $crudFqcnToCrudIdMap = []; foreach ($crudControllersFqcn as $controllerFqcn) { $crudFqcnToEntityFqcnMap[$controllerFqcn] = $controllerFqcn::getEntityFqcn(); - $crudFqcnToCrudIdMap[$controllerFqcn] = substr(sha1($container->getParameter('kernel.secret').$controllerFqcn), 0, 7); + $crudFqcnToCrudIdMap[$controllerFqcn] = substr( + sha1($container->getParameter('kernel.secret').$controllerFqcn), + 0, + 7 + ); } $container diff --git a/src/Dto/ActionConfigDto.php b/src/Dto/ActionConfigDto.php index a142afc14f..c42dbfa630 100644 --- a/src/Dto/ActionConfigDto.php +++ b/src/Dto/ActionConfigDto.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; use EasyCorp\Bundle\EasyAdminBundle\Collection\ActionCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; final class ActionConfigDto implements ActionConfigDtoInterface diff --git a/src/Dto/ActionDto.php b/src/Dto/ActionDto.php index 2e16f2d7ef..5255e09879 100644 --- a/src/Dto/ActionDto.php +++ b/src/Dto/ActionDto.php @@ -20,7 +20,7 @@ final class ActionDto implements ActionDtoInterface private ?string $templatePath = null; private ?string $crudActionName = null; private ?string $routeName = null; - private $routeParameters = []; + private array $routeParameters = []; /* @var callable|string|null */ private $url; private array $translationParameters = []; @@ -227,7 +227,10 @@ public function setTranslationParameters(array $translationParameters): void public function shouldBeDisplayedFor(EntityDtoInterface $entityDto): bool { - return null === $this->displayCallable || (bool) \call_user_func($this->displayCallable, $entityDto->getInstance()); + return null === $this->displayCallable || (bool)\call_user_func( + $this->displayCallable, + $entityDto->getInstance() + ); } public function setDisplayCallable(callable $displayCallable): void diff --git a/src/Dto/AssetDto.php b/src/Dto/AssetDto.php index 3c6b051330..14557f2e92 100644 --- a/src/Dto/AssetDto.php +++ b/src/Dto/AssetDto.php @@ -2,23 +2,32 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; final class AssetDto implements AssetDtoInterface { private string $value; + // the Symfony Asset package name which this asset belongs to private ?string $packageName = null; + private bool $async = false; + private bool $defer = false; + private bool $preload = false; + private bool $nopush = false; + private ?string $webpackPackageName = null; + private string $webpackEntrypointName = '_default'; + private array $htmlAttributes = []; - private KeyValueStore $loadedOn; + + private KeyValueStoreInterface $loadedOn; public function __construct(string $value) { @@ -121,12 +130,12 @@ public function getHtmlAttributes(): array return $this->htmlAttributes; } - public function getLoadedOn(): KeyValueStore + public function getLoadedOn(): KeyValueStoreInterface { return $this->loadedOn; } - public function setLoadedOn(KeyValueStore $loadedOn): void + public function setLoadedOn(KeyValueStoreInterface $loadedOn): void { $this->loadedOn = $loadedOn; } diff --git a/src/Dto/AssetDtoInterface.php b/src/Dto/AssetDtoInterface.php index 72ac73fd1a..f6ed4669b2 100644 --- a/src/Dto/AssetDtoInterface.php +++ b/src/Dto/AssetDtoInterface.php @@ -5,7 +5,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; /** * @author Javier Eguiluz @@ -46,7 +46,7 @@ public function setHtmlAttribute(string $attrName, string $attrValue): void; public function getHtmlAttributes(): array; - public function getLoadedOn(): KeyValueStore; + public function getLoadedOn(): KeyValueStoreInterface; - public function setLoadedOn(KeyValueStore $loadedOn): void; + public function setLoadedOn(KeyValueStoreInterface $loadedOn): void; } diff --git a/src/Dto/AssetsDto.php b/src/Dto/AssetsDto.php index c803e45eec..2208ad1445 100644 --- a/src/Dto/AssetsDto.php +++ b/src/Dto/AssetsDto.php @@ -8,13 +8,15 @@ final class AssetsDto implements AssetsDtoInterface { /** @var AssetDtoInterface[] */ private array $webpackEncoreAssets = []; + /** @var AssetDtoInterface[] */ private array $cssAssets = []; + /** @var AssetDtoInterface[] */ private array $jsAssets = []; - /** @var AssetDtoInterface[] */ + private array $headContents = []; - /** @var AssetDtoInterface[] */ + private array $bodyContents = []; public function __construct() @@ -24,7 +26,12 @@ public function __construct() public function addWebpackEncoreAsset(AssetDtoInterface $assetDto): void { if (\array_key_exists($entryName = $assetDto->getValue(), $this->webpackEncoreAssets)) { - throw new \InvalidArgumentException(sprintf('The "%s" Webpack Encore entry has been added more than once via the addWebpackEncoreEntry() method, but each entry can only be added once (to not overwrite its configuration).', $entryName)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" Webpack Encore entry has been added more than once via the addWebpackEncoreEntry() method, but each entry can only be added once (to not overwrite its configuration).', + $entryName + ) + ); } $this->webpackEncoreAssets[$entryName] = $assetDto; @@ -33,7 +40,12 @@ public function addWebpackEncoreAsset(AssetDtoInterface $assetDto): void public function addCssAsset(AssetDtoInterface $assetDto): void { if (\array_key_exists($cssPath = $assetDto->getValue(), $this->cssAssets)) { - throw new \InvalidArgumentException(sprintf('The "%s" CSS file has been added more than once via the addCssFile() method, but each asset can only be added once (to not overwrite its configuration).', $cssPath)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" CSS file has been added more than once via the addCssFile() method, but each asset can only be added once (to not overwrite its configuration).', + $cssPath + ) + ); } $this->cssAssets[$cssPath] = $assetDto; @@ -42,7 +54,12 @@ public function addCssAsset(AssetDtoInterface $assetDto): void public function addJsAsset(AssetDtoInterface $assetDto): void { if (\array_key_exists($jsPath = $assetDto->getValue(), $this->jsAssets)) { - throw new \InvalidArgumentException(sprintf('The "%s" JS file has been added more than once via the addJsFile() method, but each asset can only be added once (to not overwrite its configuration).', $jsPath)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" JS file has been added more than once via the addJsFile() method, but each asset can only be added once (to not overwrite its configuration).', + $jsPath + ) + ); } $this->jsAssets[$jsPath] = $assetDto; diff --git a/src/Dto/BatchActionDto.php b/src/Dto/BatchActionDto.php index ffee872a16..0906255af0 100644 --- a/src/Dto/BatchActionDto.php +++ b/src/Dto/BatchActionDto.php @@ -10,8 +10,13 @@ final class BatchActionDto implements BatchActionDtoInterface private string $referrerUrl; private string $csrfToken; - public function __construct(string $name, array $entityIds, string $entityFqcn, string $referrerUrl, string $csrfToken) - { + public function __construct( + string $name, + array $entityIds, + string $entityFqcn, + string $referrerUrl, + string $csrfToken + ) { $this->name = $name; $this->entityIds = $entityIds; $this->entityFqcn = $entityFqcn; diff --git a/src/Dto/CrudDto.php b/src/Dto/CrudDto.php index eac7a1b9e8..87c186b1fa 100644 --- a/src/Dto/CrudDto.php +++ b/src/Dto/CrudDto.php @@ -2,61 +2,92 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableMessageBuilder; -use function Symfony\Component\Translation\t; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\Translation\t; + final class CrudDto implements CrudDtoInterface { private ?string $controllerFqcn = null; - private AssetsDto $fieldAssetsDto; + + private AssetsDtoInterface $fieldAssetsDto; + private ?string $pageName = null; + private ?string $actionName = null; - private ?ActionConfigDto $actionConfigDto = null; - private ?FilterConfigDto $filters = null; + + private ?ActionConfigDtoInterface $actionConfigDto = null; + + private ?FilterConfigDtoInterface $filters = null; + private ?string $entityFqcn = null; - private $entityLabelInSingular; - private $entityLabelInPlural; + + private string|null|TranslatableInterface $entityLabelInSingular; + + private string|null|TranslatableInterface $entityLabelInPlural; + private array $defaultPageTitles = [ CrudInterface::PAGE_DETAIL => 'page_title.detail', CrudInterface::PAGE_EDIT => 'page_title.edit', CrudInterface::PAGE_INDEX => 'page_title.index', CrudInterface::PAGE_NEW => 'page_title.new', ]; + private array $customPageTitles = [ CrudInterface::PAGE_DETAIL => null, CrudInterface::PAGE_EDIT => null, CrudInterface::PAGE_INDEX => null, CrudInterface::PAGE_NEW => null, ]; + private array $helpMessages = [ CrudInterface::PAGE_DETAIL => null, CrudInterface::PAGE_EDIT => null, CrudInterface::PAGE_INDEX => null, CrudInterface::PAGE_NEW => null, ]; + private ?string $datePattern = 'medium'; + private ?string $timePattern = 'medium'; + private array $dateTimePattern = ['medium', 'medium']; + private string $dateIntervalFormat = '%%y Year(s) %%m Month(s) %%d Day(s)'; + private ?string $timezone = null; + private ?string $numberFormat = null; + private array $defaultSort = []; + private ?array $searchFields = []; + private bool $autofocusSearch = false; + private bool $showEntityActionsAsDropdown = true; - private ?PaginatorDto $paginatorDto = null; - private $overriddenTemplates; + + private ?PaginatorDtoInterface $paginatorDto = null; + + private array $overriddenTemplates; + private array $formThemes = ['@EasyAdmin/crud/form_theme.html.twig']; - private KeyValueStore $newFormOptions; - private KeyValueStore $editFormOptions; + + private KeyValueStoreInterface $newFormOptions; + + private KeyValueStoreInterface $editFormOptions; + private ?string $entityPermission = null; + private ?string $contentWidth = null; + private ?string $sidebarWidth = null; + private bool $hideNullValues = false; public function __construct() @@ -107,50 +138,41 @@ public function setEntityFqcn(string $entityFqcn): void $this->entityFqcn = $entityFqcn; } - public function getEntityLabelInSingular($entityInstance = null, $pageName = null): TranslatableInterface|string|null - { + public function getEntityLabelInSingular( + $entityInstance = null, + $pageName = null + ): null|string|TranslatableInterface { if (null === $this->entityLabelInSingular) { return null; } - if ( - \is_string($this->entityLabelInSingular) - || $this->entityLabelInSingular instanceof TranslatableInterface - ) { - return $this->entityLabelInSingular; - } - - return ($this->entityLabelInSingular)($entityInstance, $pageName); + return $this->entityLabelInSingular; } - public function setEntityLabelInSingular($label): void + public function setEntityLabelInSingular(null|string|TranslatableInterface $label): void { $this->entityLabelInSingular = $label; } - public function getEntityLabelInPlural($entityInstance = null, $pageName = null): TranslatableInterface|string|null + public function getEntityLabelInPlural($entityInstance = null, $pageName = null): null|string|TranslatableInterface { if (null === $this->entityLabelInPlural) { return null; } - if ( - \is_string($this->entityLabelInPlural) - || $this->entityLabelInPlural instanceof TranslatableInterface - ) { - return $this->entityLabelInPlural; - } - - return ($this->entityLabelInPlural)($entityInstance, $pageName); + return $this->entityLabelInPlural; } - public function setEntityLabelInPlural($label): void + public function setEntityLabelInPlural(null|string|TranslatableInterface $label): void { $this->entityLabelInPlural = $label; } - public function getCustomPageTitle(?string $pageName = null, $entityInstance = null, array $translationParameters = []): ?TranslatableInterface - { + public function getCustomPageTitle( + ?string $pageName = null, + $entityInstance = null, + array $translationParameters = [] + ): ?TranslatableInterface { $title = $this->customPageTitles[$pageName ?? $this->pageName]; if (\is_callable($title)) { $title = null !== $entityInstance ? $title($entityInstance) : $title(); @@ -184,8 +206,10 @@ public function setCustomPageTitle(string $pageName, $pageTitle): void $this->customPageTitles[$pageName] = $pageTitle; } - public function getDefaultPageTitle(?string $pageName = null, /* ?object */ $entityInstance = null, array $translationParameters = []): ?TranslatableInterface - { + public function getDefaultPageTitle( + ?string $pageName = null, /* ?object */ $entityInstance = null, + array $translationParameters = [] + ): ?TranslatableInterface { if (!\is_object($entityInstance) && null !== $entityInstance) { trigger_deprecation( @@ -201,7 +225,7 @@ public function getDefaultPageTitle(?string $pageName = null, /* ?object */ $ent if (null !== $entityInstance) { if (method_exists($entityInstance, '__toString')) { - $entityAsString = (string) $entityInstance; + $entityAsString = (string)$entityInstance; if ('' !== $entityAsString) { return t($entityAsString, $translationParameters, 'EasyAdminBundle'); @@ -256,8 +280,10 @@ public function getDateTimePattern(): array return $this->dateTimePattern; } - public function setDateTimePattern(string $dateFormatOrPattern, string $timeFormat = DateTimeField::FORMAT_NONE): void - { + public function setDateTimePattern( + string $dateFormatOrPattern, + string $timeFormat = DateTimeField::FORMAT_NONE + ): void { $this->dateTimePattern = [$dateFormatOrPattern, $timeFormat]; } @@ -372,22 +398,22 @@ public function setFormThemes(array $formThemes): void $this->formThemes = $formThemes; } - public function getNewFormOptions(): KeyValueStore + public function getNewFormOptions(): KeyValueStoreInterface { return $this->newFormOptions; } - public function getEditFormOptions(): KeyValueStore + public function getEditFormOptions(): KeyValueStoreInterface { return $this->editFormOptions; } - public function setNewFormOptions(KeyValueStore $formOptions): void + public function setNewFormOptions(KeyValueStoreInterface $formOptions): void { $this->newFormOptions = $formOptions; } - public function setEditFormOptions(KeyValueStore $formOptions): void + public function setEditFormOptions(KeyValueStoreInterface $formOptions): void { $this->editFormOptions = $formOptions; } diff --git a/src/Dto/CrudDtoInterface.php b/src/Dto/CrudDtoInterface.php index f5804d16a3..b3db1581ed 100644 --- a/src/Dto/CrudDtoInterface.php +++ b/src/Dto/CrudDtoInterface.php @@ -5,7 +5,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use Symfony\Contracts\Translation\TranslatableInterface; @@ -33,19 +33,13 @@ public function setEntityFqcn(string $entityFqcn): void; public function getEntityLabelInSingular( $entityInstance = null, $pageName = null - ): TranslatableInterface|string|null; + ): null|string|TranslatableInterface; - /** - * @param TranslatableInterface|string|callable $label - */ - public function setEntityLabelInSingular($label): void; + public function setEntityLabelInSingular(null|string|TranslatableInterface $label): void; - public function getEntityLabelInPlural($entityInstance = null, $pageName = null): TranslatableInterface|string|null; + public function getEntityLabelInPlural($entityInstance = null, $pageName = null): null|string|TranslatableInterface; - /** - * @param TranslatableInterface|string|callable $label - */ - public function setEntityLabelInPlural($label): void; + public function setEntityLabelInPlural(null|string|TranslatableInterface $label): void; public function getCustomPageTitle( ?string $pageName = null, @@ -129,13 +123,13 @@ public function addFormTheme(string $formThemePath): void; public function setFormThemes(array $formThemes): void; - public function getNewFormOptions(): KeyValueStore; + public function getNewFormOptions(): KeyValueStoreInterface; - public function getEditFormOptions(): KeyValueStore; + public function getEditFormOptions(): KeyValueStoreInterface; - public function setNewFormOptions(KeyValueStore $formOptions): void; + public function setNewFormOptions(KeyValueStoreInterface $formOptions): void; - public function setEditFormOptions(KeyValueStore $formOptions): void; + public function setEditFormOptions(KeyValueStoreInterface $formOptions): void; public function getEntityPermission(): ?string; diff --git a/src/Dto/DashboardDto.php b/src/Dto/DashboardDto.php index 0c4b664f14..66d16ba61e 100644 --- a/src/Dto/DashboardDto.php +++ b/src/Dto/DashboardDto.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; final class DashboardDto implements DashboardDtoInterface diff --git a/src/Dto/EntityDto.php b/src/Dto/EntityDto.php index e462393748..b87538caad 100644 --- a/src/Dto/EntityDto.php +++ b/src/Dto/EntityDto.php @@ -7,26 +7,39 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\ActionCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; use Symfony\Component\PropertyAccess\PropertyAccess; final class EntityDto implements EntityDtoInterface { private bool $isAccessible = true; + private string $fqcn; + /** @var ClassMetadataInfo */ private ClassMetadata $metadata; - private $instance; - private $primaryKeyName; + + private mixed $instance; + + private string $primaryKeyName; + private mixed $primaryKeyValue = null; + private ?string $permission; + private ?FieldCollection $fields = null; + private ?ActionCollection $actions = null; /** * @param ClassMetadata&ClassMetadataInfo $entityMetadata */ - public function __construct(string $entityFqcn, ClassMetadata $entityMetadata, ?string $entityPermission = null, /* ?object */ $entityInstance = null) - { + public function __construct( + string $entityFqcn, + ClassMetadata $entityMetadata, + ?string $entityPermission = null, + /* ?object */ $entityInstance = null + ) { if (!\is_object($entityInstance) && null !== $entityInstance) { trigger_deprecation( @@ -69,7 +82,7 @@ public function toString(): string } if (method_exists($this->instance, '__toString')) { - return (string) $this->instance; + return (string)$this->instance; } return sprintf('%s #%s', $this->getName(), substr($this->getPrimaryKeyValueAsString(), 0, 16)); @@ -106,7 +119,7 @@ public function getPrimaryKeyValue(): mixed public function getPrimaryKeyValueAsString(): string { - return (string) $this->getPrimaryKeyValue(); + return (string)$this->getPrimaryKeyValue(); } public function getPermission(): ?string @@ -151,7 +164,7 @@ public function getAllPropertyNames(): array return $this->metadata->getFieldNames(); } - public function getPropertyMetadata(string $propertyName): KeyValueStore + public function getPropertyMetadata(string $propertyName): KeyValueStoreInterface { if (\array_key_exists($propertyName, $this->metadata->fieldMappings)) { return KeyValueStore::new($this->metadata->fieldMappings[$propertyName]); @@ -161,7 +174,9 @@ public function getPropertyMetadata(string $propertyName): KeyValueStore return KeyValueStore::new($this->metadata->associationMappings[$propertyName]); } - throw new \InvalidArgumentException(sprintf('The "%s" field does not exist in the "%s" entity.', $propertyName, $this->getFqcn())); + throw new \InvalidArgumentException( + sprintf('The "%s" field does not exist in the "%s" entity.', $propertyName, $this->getFqcn()) + ); } public function getPropertyDataType(string $propertyName) @@ -205,7 +220,13 @@ public function isEmbeddedClassProperty(string $propertyName): bool public function setInstance(?object $newEntityInstance): void { if (null !== $this->instance && null !== $newEntityInstance && !$newEntityInstance instanceof $this->fqcn) { - throw new \InvalidArgumentException(sprintf('The new entity instance must be of the same type as the previous instance (original instance: "%s", new instance: "%s").', $this->fqcn, $newEntityInstance::class)); + throw new \InvalidArgumentException( + sprintf( + 'The new entity instance must be of the same type as the previous instance (original instance: "%s", new instance: "%s").', + $this->fqcn, + $newEntityInstance::class + ) + ); } $this->instance = $newEntityInstance; @@ -227,7 +248,13 @@ public function newWithInstance(/* object */ $newEntityInstance): EntityDtoInter } if (null !== $this->instance && !$newEntityInstance instanceof $this->fqcn) { - throw new \InvalidArgumentException(sprintf('The new entity instance must be of the same type as the previous instance (original instance: "%s", new instance: "%s").', $this->fqcn, $newEntityInstance::class)); + throw new \InvalidArgumentException( + sprintf( + 'The new entity instance must be of the same type as the previous instance (original instance: "%s", new instance: "%s").', + $this->fqcn, + $newEntityInstance::class + ) + ); } return new self($this->fqcn, $this->metadata, $this->permission, $newEntityInstance); diff --git a/src/Dto/EntityDtoInterface.php b/src/Dto/EntityDtoInterface.php index e98565ae70..5bedebcd3c 100644 --- a/src/Dto/EntityDtoInterface.php +++ b/src/Dto/EntityDtoInterface.php @@ -7,7 +7,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\ActionCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; /** * @author Javier Eguiluz @@ -48,7 +48,7 @@ public function getActions(): ActionCollection; */ public function getAllPropertyNames(): array; - public function getPropertyMetadata(string $propertyName): KeyValueStore; + public function getPropertyMetadata(string $propertyName): KeyValueStoreInterface; public function getPropertyDataType(string $propertyName); diff --git a/src/Dto/FieldDto.php b/src/Dto/FieldDto.php index e3380eb388..57384b0b60 100644 --- a/src/Dto/FieldDto.php +++ b/src/Dto/FieldDto.php @@ -2,44 +2,69 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; -use function Symfony\Component\String\u; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; use Symfony\Component\Uid\Ulid; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\String\u; + final class FieldDto implements FieldDtoInterface { private ?string $fieldFqcn = null; + private ?string $propertyName = null; + private mixed $value = null; + private mixed $formattedValue = null; + private $formatValueCallable; - private $label; + + private null|string|TranslatableInterface|false $label; + private ?string $formType = null; - private KeyValueStore $formTypeOptions; + + private KeyValueStoreInterface $formTypeOptions; + private ?bool $sortable = null; + private ?bool $virtual = null; + private ?string $permission = null; + private ?string $textAlign = null; - private $help; + + private null|string|TranslatableInterface $help = null; + private string $cssClass = ''; + // how many columns the field takes when rendering // (defined as Bootstrap 5 grid classes; e.g. 'col-md-6 col-xxl-3') private ?string $columns = null; + // same as $columns but used when the user doesn't define columns explicitly private string $defaultColumns = ''; + private array $translationParameters = []; + private ?string $templateName = 'crud/field/text'; + private ?string $templatePath = null; + private array $formThemePaths = []; - private AssetsDto $assets; - private KeyValueStore $customOptions; - private KeyValueStore $doctrineMetadata; + + private AssetsDtoInterface $assets; + + private KeyValueStoreInterface $customOptions; + + private KeyValueStoreInterface $doctrineMetadata; + /** @internal */ - private $uniqueId; - private KeyValueStore $displayedOn; + private null|string|Ulid $uniqueId; + + private KeyValueStoreInterface $displayedOn; public function __construct() { @@ -350,7 +375,7 @@ public function addHtmlContentToBody(string $htmlContent): void $this->assets->addHtmlContentToBody($htmlContent); } - public function getCustomOptions(): KeyValueStore + public function getCustomOptions(): KeyValueStoreInterface { return $this->customOptions; } @@ -370,7 +395,7 @@ public function setCustomOption(string $optionName, mixed $optionValue): void $this->customOptions->set($optionName, $optionValue); } - public function getDoctrineMetadata(): KeyValueStore + public function getDoctrineMetadata(): KeyValueStoreInterface { return $this->doctrineMetadata; } @@ -380,12 +405,12 @@ public function setDoctrineMetadata(array $metadata): void $this->doctrineMetadata = KeyValueStore::new($metadata); } - public function getDisplayedOn(): KeyValueStore + public function getDisplayedOn(): KeyValueStoreInterface { return $this->displayedOn; } - public function setDisplayedOn(KeyValueStore $displayedOn): void + public function setDisplayedOn(KeyValueStoreInterface $displayedOn): void { $this->displayedOn = $displayedOn; } diff --git a/src/Dto/FieldDtoInterface.php b/src/Dto/FieldDtoInterface.php index 9019f1f174..1871182b1e 100644 --- a/src/Dto/FieldDtoInterface.php +++ b/src/Dto/FieldDtoInterface.php @@ -5,7 +5,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; use Symfony\Contracts\Translation\TranslatableInterface; /** @@ -144,7 +144,7 @@ public function addHtmlContentToHead(string $htmlContent): void; public function addHtmlContentToBody(string $htmlContent): void; - public function getCustomOptions(): KeyValueStore; + public function getCustomOptions(): KeyValueStoreInterface; public function getCustomOption(string $optionName): mixed; @@ -152,13 +152,13 @@ public function setCustomOptions(array $customOptions): void; public function setCustomOption(string $optionName, mixed $optionValue): void; - public function getDoctrineMetadata(): KeyValueStore; + public function getDoctrineMetadata(): KeyValueStoreInterface; public function setDoctrineMetadata(array $metadata): void; - public function getDisplayedOn(): KeyValueStore; + public function getDisplayedOn(): KeyValueStoreInterface; - public function setDisplayedOn(KeyValueStore $displayedOn): void; + public function setDisplayedOn(KeyValueStoreInterface $displayedOn): void; public function isDisplayedOn(string $pageName): bool; } diff --git a/src/Dto/FilterConfigDto.php b/src/Dto/FilterConfigDto.php index bab018e806..8d0f28365c 100644 --- a/src/Dto/FilterConfigDto.php +++ b/src/Dto/FilterConfigDto.php @@ -28,7 +28,7 @@ public function addFilter($filterNameOrConfig): void ); } - $this->filters->set((string) $filterNameOrConfig, $filterNameOrConfig); + $this->filters->set((string)$filterNameOrConfig, $filterNameOrConfig); } public function getFilter(string $propertyName)/* : FilterInterface|string|null */ diff --git a/src/Dto/FilterDataDto.php b/src/Dto/FilterDataDto.php index e2b9b43163..ef39c9ff16 100644 --- a/src/Dto/FilterDataDto.php +++ b/src/Dto/FilterDataDto.php @@ -5,18 +5,27 @@ final class FilterDataDto implements FilterDataDtoInterface { private int $index; + private string $entityAlias; - private FilterDto $filterDto; - private $comparison; + + private FilterDtoInterface $filterDto; + + private ?string $comparison = null; + private mixed $value; + private mixed $value2; private function __construct() { } - public static function new(int $index, FilterDtoInterface $filterDto, string $entityAlias, array $formData): FilterDataDtoInterface - { + public static function new( + int $index, + FilterDtoInterface $filterDto, + string $entityAlias, + array $formData + ): FilterDataDtoInterface { $filterData = new self(); $filterData->index = $index; $filterData->filterDto = $filterDto; diff --git a/src/Dto/FilterDto.php b/src/Dto/FilterDto.php index 2a9fff74fd..8e830a854a 100644 --- a/src/Dto/FilterDto.php +++ b/src/Dto/FilterDto.php @@ -104,8 +104,12 @@ public function setApplyCallable(callable $callable): void $this->applyCallable = $callable; } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { \call_user_func($this->applyCallable, $queryBuilder, $filterDataDto, $fieldDto, $entityDto); } } diff --git a/src/Dto/I18nDto.php b/src/Dto/I18nDto.php index a680b67613..95bca83f23 100644 --- a/src/Dto/I18nDto.php +++ b/src/Dto/I18nDto.php @@ -10,8 +10,12 @@ final class I18nDto implements I18nDtoInterface private string $translationDomain; private array $translationParameters; - public function __construct(string $locale, string $textDirection, string $translationDomain, array $translationParameters) - { + public function __construct( + string $locale, + string $textDirection, + string $translationDomain, + array $translationParameters + ) { $this->locale = $locale; $this->language = strtok($locale, '-_'); $this->textDirection = $textDirection; diff --git a/src/Dto/PaginatorDto.php b/src/Dto/PaginatorDto.php index 00f472296a..03c9b23610 100644 --- a/src/Dto/PaginatorDto.php +++ b/src/Dto/PaginatorDto.php @@ -11,8 +11,13 @@ final class PaginatorDto implements PaginatorDtoInterface private bool $fetchJoinCollection; private ?bool $useOutputWalkers; - public function __construct(int $pageSize, int $rangeSize, int $rangeEdgeSize, bool $fetchJoinCollection, ?bool $useOutputWalkers) - { + public function __construct( + int $pageSize, + int $rangeSize, + int $rangeEdgeSize, + bool $fetchJoinCollection, + ?bool $useOutputWalkers + ) { $this->pageSize = $pageSize; $this->rangeSize = $rangeSize; $this->rangeEdgeSize = $rangeEdgeSize; diff --git a/src/Dto/SearchDto.php b/src/Dto/SearchDto.php index 2a493279d2..8d5aefc536 100644 --- a/src/Dto/SearchDto.php +++ b/src/Dto/SearchDto.php @@ -17,11 +17,17 @@ final class SearchDto implements SearchDtoInterface /** @var string[]|null */ private ?array $appliedFilters; - public function __construct(Request $request, ?array $searchableProperties, ?string $query, array $defaultSort, array $customSort, ?array $appliedFilters) - { + public function __construct( + Request $request, + ?array $searchableProperties, + ?string $query, + array $defaultSort, + array $customSort, + ?array $appliedFilters + ) { $this->request = $request; $this->searchableProperties = $searchableProperties; - $this->query = trim((string) $query); + $this->query = trim((string)$query); $this->defaultSort = $defaultSort; $this->customSort = $customSort; $this->appliedFilters = $appliedFilters; @@ -75,7 +81,7 @@ public function getQuery(): string public function getQueryTerms(): array { preg_match_all('/"(?:\\\\.|[^\\\\"])*"|\S+/', $this->query, $matches); - $terms = array_map(static fn ($match) => trim($match, '" '), $matches[0] ?? []); + $terms = array_map(static fn($match) => trim($match, '" '), $matches[0] ?? []); return $terms; } diff --git a/src/Dto/UserMenuDto.php b/src/Dto/UserMenuDto.php index 28a7ea6f95..3a938c24ef 100644 --- a/src/Dto/UserMenuDto.php +++ b/src/Dto/UserMenuDto.php @@ -2,8 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Dto; -use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface; - final class UserMenuDto implements UserMenuDtoInterface { private bool $displayName = true; diff --git a/src/Event/AbstractLifecycleEvent.php b/src/Event/AbstractLifecycleEvent.php index f6430b7ebf..8a15c83fe6 100644 --- a/src/Event/AbstractLifecycleEvent.php +++ b/src/Event/AbstractLifecycleEvent.php @@ -9,7 +9,7 @@ */ abstract class AbstractLifecycleEvent implements EntityLifecycleEventInterface { - protected $entityInstance; + protected mixed $entityInstance; public function __construct(/* ?object */ $entityInstance) { diff --git a/src/Event/AfterCrudActionEvent.php b/src/Event/AfterCrudActionEvent.php index 591386b2e6..42bef0874a 100644 --- a/src/Event/AfterCrudActionEvent.php +++ b/src/Event/AfterCrudActionEvent.php @@ -2,8 +2,8 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Event; -use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; -use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; +use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStoreInterface; +use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContextInterface; /** * @author Javier Eguiluz @@ -12,16 +12,19 @@ final class AfterCrudActionEvent { use StoppableEventTrait; - private ?AdminContext $adminContext; - private KeyValueStore $responseParameters; + private ?AdminContextInterface $adminContext; - public function __construct(?AdminContext $adminContext, KeyValueStore $responseParameters) - { + private KeyValueStoreInterface $responseParameters; + + public function __construct( + ?AdminContextInterface $adminContext, + KeyValueStoreInterface $responseParameters + ) { $this->adminContext = $adminContext; $this->responseParameters = $responseParameters; } - public function getAdminContext(): ?AdminContext + public function getAdminContext(): ?AdminContextInterface { return $this->adminContext; } @@ -35,7 +38,7 @@ public function addResponseParameters(array $parameters): void $this->responseParameters->setAll($parameters); } - public function getResponseParameters(): KeyValueStore + public function getResponseParameters(): KeyValueStoreInterface { return $this->responseParameters; } diff --git a/src/Event/AfterEntityBuiltEvent.php b/src/Event/AfterEntityBuiltEvent.php index 420de31f87..513c428034 100644 --- a/src/Event/AfterEntityBuiltEvent.php +++ b/src/Event/AfterEntityBuiltEvent.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Event; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; /** @@ -10,7 +9,7 @@ */ final class AfterEntityBuiltEvent { - private EntityDto $entityDto; + private EntityDtoInterface $entityDto; public function __construct(EntityDtoInterface $entityDto) { diff --git a/src/Event/AfterEntitySearchEvent.php b/src/Event/AfterEntitySearchEvent.php index b620e8e4b7..46d75513f8 100644 --- a/src/Event/AfterEntitySearchEvent.php +++ b/src/Event/AfterEntitySearchEvent.php @@ -3,19 +3,22 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Event; use Doctrine\ORM\QueryBuilder; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; final class AfterEntitySearchEvent { private QueryBuilder $queryBuilder; - private SearchDto $searchDto; - private EntityDto $entityDto; - public function __construct(QueryBuilder $queryBuilder, SearchDtoInterface $searchDto, EntityDtoInterface $entityDto) - { + private SearchDtoInterface $searchDto; + + private EntityDtoInterface $entityDto; + + public function __construct( + QueryBuilder $queryBuilder, + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto + ) { $this->queryBuilder = $queryBuilder; $this->searchDto = $searchDto; $this->entityDto = $entityDto; diff --git a/src/Event/BeforeCrudActionEvent.php b/src/Event/BeforeCrudActionEvent.php index 1381130757..6f88b84382 100644 --- a/src/Event/BeforeCrudActionEvent.php +++ b/src/Event/BeforeCrudActionEvent.php @@ -2,7 +2,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Event; -use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; +use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContextInterface; /** * @author Javier Eguiluz @@ -11,14 +11,14 @@ final class BeforeCrudActionEvent { use StoppableEventTrait; - private ?AdminContext $adminContext; + private ?AdminContextInterface $adminContext; - public function __construct(?AdminContext $adminContext) + public function __construct(?AdminContextInterface $adminContext) { $this->adminContext = $adminContext; } - public function getAdminContext(): ?AdminContext + public function getAdminContext(): ?AdminContextInterface { return $this->adminContext; } diff --git a/src/EventListener/AdminRouterSubscriber.php b/src/EventListener/AdminRouterSubscriber.php index ea25b51253..7dfe637944 100644 --- a/src/EventListener/AdminRouterSubscriber.php +++ b/src/EventListener/AdminRouterSubscriber.php @@ -5,9 +5,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\AdminContextFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\AdminContextFactoryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\ControllerFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\ControllerFactoryInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Request; @@ -32,14 +30,23 @@ */ final class AdminRouterSubscriber implements EventSubscriberInterface { - private AdminContextFactory $adminContextFactory; - private ControllerFactory $controllerFactory; + private AdminContextFactoryInterface $adminContextFactory; + + private ControllerFactoryInterface $controllerFactory; + private ControllerResolverInterface $controllerResolver; + private UrlGeneratorInterface $urlGenerator; + private RequestMatcherInterface $requestMatcher; - public function __construct(AdminContextFactoryInterface $adminContextFactory, ControllerFactoryInterface $controllerFactory, ControllerResolverInterface $controllerResolver, UrlGeneratorInterface $urlGenerator, RequestMatcherInterface $requestMatcher) - { + public function __construct( + AdminContextFactoryInterface $adminContextFactory, + ControllerFactoryInterface $controllerFactory, + ControllerResolverInterface $controllerResolver, + UrlGeneratorInterface $urlGenerator, + RequestMatcherInterface $requestMatcher + ) { $this->adminContextFactory = $adminContextFactory; $this->controllerFactory = $controllerFactory; $this->controllerResolver = $controllerResolver; @@ -69,7 +76,10 @@ public function onKernelRequest(RequestEvent $event): void return; } - if (null === $dashboardControllerInstance = $this->getDashboardControllerInstance($dashboardControllerFqcn, $request)) { + if (null === $dashboardControllerInstance = $this->getDashboardControllerInstance( + $dashboardControllerFqcn, + $request + )) { return; } @@ -77,7 +87,11 @@ public function onKernelRequest(RequestEvent $event): void // if the current request already has an AdminContext object, do nothing if (null === $adminContext = $request->attributes->get(EA::CONTEXT_REQUEST_ATTRIBUTE)) { $crudControllerInstance = $this->getCrudControllerInstance($request); - $adminContext = $this->adminContextFactory->create($request, $dashboardControllerInstance, $crudControllerInstance); + $adminContext = $this->adminContextFactory->create( + $request, + $dashboardControllerInstance, + $crudControllerInstance + ); } $request->attributes->set(EA::CONTEXT_REQUEST_ATTRIBUTE, $adminContext); @@ -114,7 +128,10 @@ public function onKernelController(ControllerEvent $event): void // if the request is related to a custom action, change the controller to be executed if (null !== $request->query->get(EA::ROUTE_NAME)) { $symfonyControllerAsString = $this->getSymfonyControllerFqcn($request); - $symfonyControllerCallable = $this->getSymfonyControllerInstance($symfonyControllerAsString, $request->query->all()[EA::ROUTE_PARAMS] ?? []); + $symfonyControllerCallable = $this->getSymfonyControllerInstance( + $symfonyControllerAsString, + $request->query->all()[EA::ROUTE_PARAMS] ?? [] + ); if (false !== $symfonyControllerCallable) { // this makes Symfony believe that another controller is being executed // (e.g. this is needed for the autowiring of controller action arguments) @@ -122,10 +139,12 @@ public function onKernelController(ControllerEvent $event): void // Otherwise, the param converter of the controller method doesn't work $event->getRequest()->attributes->set('_controller', $symfonyControllerAsString); // route params must be added as route attribute; otherwise, param converters don't work - $event->getRequest()->attributes->replace(array_merge( - $request->query->all()[EA::ROUTE_PARAMS] ?? [], - $event->getRequest()->attributes->all() - )); + $event->getRequest()->attributes->replace( + array_merge( + $request->query->all()[EA::ROUTE_PARAMS] ?? [], + $event->getRequest()->attributes->all() + ) + ); // this actually makes Symfony to execute the other controller $event->setController($symfonyControllerCallable); @@ -146,7 +165,7 @@ private function getDashboardControllerFqcn(Request $request): ?string $controllerFqcn = null; if (\is_string($controller)) { - [$controllerFqcn, ] = explode('::', $controller); + [$controllerFqcn,] = explode('::', $controller); } if (\is_array($controller)) { @@ -160,8 +179,10 @@ private function getDashboardControllerFqcn(Request $request): ?string return is_subclass_of($controllerFqcn, DashboardControllerInterface::class) ? $controllerFqcn : null; } - private function getDashboardControllerInstance(string $dashboardControllerFqcn, Request $request): ?DashboardControllerInterface - { + private function getDashboardControllerInstance( + string $dashboardControllerFqcn, + Request $request + ): ?DashboardControllerInterface { return $this->controllerFactory->getDashboardControllerInstance($dashboardControllerFqcn, $request); } @@ -193,7 +214,12 @@ private function getSymfonyControllerFqcn(Request $request): ?string private function getSymfonyControllerInstance(string $controllerFqcn, array $routeParams): callable|false { - $newRequest = new Request([], [], ['_controller' => $controllerFqcn, '_route_params' => $routeParams], [], [], []); + $newRequest = new Request([], + [], + ['_controller' => $controllerFqcn, '_route_params' => $routeParams], + [], + [], + []); return $this->controllerResolver->getController($newRequest); } diff --git a/src/EventListener/CrudResponseListener.php b/src/EventListener/CrudResponseListener.php index 519837760e..985060a741 100644 --- a/src/EventListener/CrudResponseListener.php +++ b/src/EventListener/CrudResponseListener.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\EventListener; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Response; @@ -15,7 +14,8 @@ */ final class CrudResponseListener { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; + private Environment $twig; public function __construct(AdminContextProviderInterface $adminContextProvider, Environment $twig) @@ -32,7 +32,9 @@ public function onKernelView(ViewEvent $event): void } if (!$responseParameters->has('templateName') && !$responseParameters->has('templatePath')) { - throw new \RuntimeException('The KeyValueStore object returned by CrudController actions must include either a "templateName" or a "templatePath" parameter to define the template used to render the action result.'); + throw new \RuntimeException( + 'The KeyValueStore object returned by CrudController actions must include either a "templateName" or a "templatePath" parameter to define the template used to render the action result.' + ); } $templateParameters = $responseParameters->all(); diff --git a/src/EventListener/ExceptionListener.php b/src/EventListener/ExceptionListener.php index af7b91c259..56e87920ed 100644 --- a/src/EventListener/ExceptionListener.php +++ b/src/EventListener/ExceptionListener.php @@ -4,7 +4,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\BaseException; use EasyCorp\Bundle\EasyAdminBundle\Exception\FlattenException; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\ExceptionEvent; @@ -23,11 +22,16 @@ final class ExceptionListener { private bool $kernelDebug; - private AdminContextProvider $adminContextProvider; + + private AdminContextProviderInterface $adminContextProvider; + private Environment $twig; - public function __construct(bool $kernelDebug, AdminContextProviderInterface $adminContextProvider, Environment $twig) - { + public function __construct( + bool $kernelDebug, + AdminContextProviderInterface $adminContextProvider, + Environment $twig + ) { $this->kernelDebug = $kernelDebug; $this->adminContextProvider = $adminContextProvider; $this->twig = $twig; @@ -37,7 +41,8 @@ public function onKernelException(ExceptionEvent $event) { $exception = $event->getThrowable(); - if ($this->kernelDebug && $exception instanceof RuntimeError && 'Variable "ea" does not exist.' === $exception->getRawMessage()) { + if ($this->kernelDebug && $exception instanceof RuntimeError && 'Variable "ea" does not exist.' === $exception->getRawMessage( + )) { $exception->appendMessage($this->getEaVariableExceptionMessage()); return; @@ -58,13 +63,17 @@ public function onKernelException(ExceptionEvent $event) public function createExceptionResponse(FlattenException $exception): Response { $context = $this->adminContextProvider->getContext(); - $exceptionTemplatePath = null === $context ? '@EasyAdmin/exception.html.twig' : $context->getTemplatePath('exception'); + $exceptionTemplatePath = null === $context ? '@EasyAdmin/exception.html.twig' : $context->getTemplatePath( + 'exception' + ); $layoutTemplatePath = null === $context ? '@EasyAdmin/layout.html.twig' : $context->getTemplatePath('layout'); - return new Response($this->twig->render($exceptionTemplatePath, [ - 'exception' => $exception, - 'layout_template_path' => $layoutTemplatePath, - ]), $exception->getStatusCode()); + return new Response( + $this->twig->render($exceptionTemplatePath, [ + 'exception' => $exception, + 'layout_template_path' => $layoutTemplatePath, + ]), $exception->getStatusCode() + ); } private function getEaVariableExceptionMessage(): string diff --git a/src/Exception/BaseException.php b/src/Exception/BaseException.php index 482698ad50..55d3321b70 100644 --- a/src/Exception/BaseException.php +++ b/src/Exception/BaseException.php @@ -2,18 +2,20 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Exception; -use EasyCorp\Bundle\EasyAdminBundle\Context\ExceptionContext; use EasyCorp\Bundle\EasyAdminBundle\Context\ExceptionContextInterface; use Symfony\Component\HttpKernel\Exception\HttpException; abstract class BaseException extends HttpException implements BaseExceptionInterface { - private ExceptionContext $context; + private ExceptionContextInterface $context; public function __construct(ExceptionContextInterface $context) { $this->context = $context; - parent::__construct($this->context->getStatusCode(), $this->context->getDebugMessage()); + parent::__construct( + $this->context->getStatusCode(), + $this->context->getDebugMessage() + ); } public function getContext(): ExceptionContextInterface diff --git a/src/Exception/EntityNotFoundException.php b/src/Exception/EntityNotFoundException.php index 5b08d63f82..35fdb1e11a 100644 --- a/src/Exception/EntityNotFoundException.php +++ b/src/Exception/EntityNotFoundException.php @@ -13,7 +13,12 @@ public function __construct(array $parameters = []) { $exceptionContext = new ExceptionContext( 'exception.entity_not_found', - sprintf('The "%s" entity with "%s = %s" does not exist in the database. The entity may have been deleted by mistake or by a "cascade={"remove"}" operation executed by Doctrine.', $parameters['entity_name'], $parameters['entity_id_name'], $parameters['entity_id_value']), + sprintf( + 'The "%s" entity with "%s = %s" does not exist in the database. The entity may have been deleted by mistake or by a "cascade={"remove"}" operation executed by Doctrine.', + $parameters['entity_name'], + $parameters['entity_id_name'], + $parameters['entity_id_value'] + ), $parameters, 404 ); diff --git a/src/Exception/EntityRemoveException.php b/src/Exception/EntityRemoveException.php index 58a39d75d9..0ac2cef46f 100644 --- a/src/Exception/EntityRemoveException.php +++ b/src/Exception/EntityRemoveException.php @@ -13,7 +13,11 @@ public function __construct(array $parameters = []) { $exceptionContext = new ExceptionContext( 'exception.entity_remove', - sprintf('There is a ForeignKeyConstraintViolationException for the Doctrine entity associated with "%s". Solution: disable the "delete" action for this CRUD controller or configure the "cascade={"remove"}" attribute for the related field in the Doctrine entity. Full exception: %s', $parameters['entity_name'], $parameters['message']), + sprintf( + 'There is a ForeignKeyConstraintViolationException for the Doctrine entity associated with "%s". Solution: disable the "delete" action for this CRUD controller or configure the "cascade={"remove"}" attribute for the related field in the Doctrine entity. Full exception: %s', + $parameters['entity_name'], + $parameters['message'] + ), $parameters, 409 ); diff --git a/src/Exception/FlattenException.php b/src/Exception/FlattenException.php index 298a4ac04f..cc44656fc8 100644 --- a/src/Exception/FlattenException.php +++ b/src/Exception/FlattenException.php @@ -2,7 +2,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Exception; -use EasyCorp\Bundle\EasyAdminBundle\Context\ExceptionContext; +use EasyCorp\Bundle\EasyAdminBundle\Context\ExceptionContextInterface; use Symfony\Component\ErrorHandler\Exception\FlattenException as BaseFlattenException; /** @@ -10,12 +10,18 @@ */ final class FlattenException extends BaseFlattenException { - private ?ExceptionContext $context = null; + private ?ExceptionContextInterface $context = null; public static function create(\Exception $exception, ?int $statusCode = null, array $headers = []): static { if (!$exception instanceof BaseException) { - throw new \RuntimeException(sprintf('You should only try to create an instance of "%s" with a "EasyCorp\Bundle\EasyAdminBundle\Exception\BaseException" instance, or subclass. "%s" given.', __CLASS__, $exception::class)); + throw new \RuntimeException( + sprintf( + 'You should only try to create an instance of "%s" with a "EasyCorp\Bundle\EasyAdminBundle\Exception\BaseException" instance, or subclass. "%s" given.', + __CLASS__, + $exception::class + ) + ); } $e = parent::create($exception, $statusCode, $headers); diff --git a/src/Exception/ForbiddenActionException.php b/src/Exception/ForbiddenActionException.php index be5aba02c1..b69a1602f5 100644 --- a/src/Exception/ForbiddenActionException.php +++ b/src/Exception/ForbiddenActionException.php @@ -2,7 +2,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Exception; -use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; +use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContextInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\ExceptionContext; /** @@ -10,7 +10,7 @@ */ final class ForbiddenActionException extends BaseException { - public function __construct(AdminContext $context) + public function __construct(AdminContextInterface $context) { $parameters = [ 'crud_controller' => null === $context->getCrud() ? null : $context->getCrud()->getControllerFqcn(), @@ -19,7 +19,12 @@ public function __construct(AdminContext $context) $exceptionContext = new ExceptionContext( 'exception.forbidden_action', - sprintf('You don\'t have enough permissions to run the "%s" action on the "%s" or the "%s" action has been disabled.', $parameters['action'], $parameters['crud_controller'], $parameters['action']), + sprintf( + 'You don\'t have enough permissions to run the "%s" action on the "%s" or the "%s" action has been disabled.', + $parameters['action'], + $parameters['crud_controller'], + $parameters['action'] + ), $parameters, 403 ); diff --git a/src/Exception/InsufficientEntityPermissionException.php b/src/Exception/InsufficientEntityPermissionException.php index 6654c703cd..75721e2db4 100644 --- a/src/Exception/InsufficientEntityPermissionException.php +++ b/src/Exception/InsufficientEntityPermissionException.php @@ -2,7 +2,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Exception; -use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; +use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContextInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\ExceptionContext; /** @@ -10,7 +10,7 @@ */ final class InsufficientEntityPermissionException extends BaseException { - public function __construct(AdminContext $adminContext) + public function __construct(AdminContextInterface $adminContext) { $parameters = [ 'entity_fqcn' => $adminContext->getEntity()->getFqcn(), @@ -18,9 +18,16 @@ public function __construct(AdminContext $adminContext) ]; if (null !== $entityId) { - $debugMessage = sprintf('You don\'t have enough permissions to access this instance of the "%s" entity.', $parameters['entity_fqcn']); + $debugMessage = sprintf( + 'You don\'t have enough permissions to access this instance of the "%s" entity.', + $parameters['entity_fqcn'] + ); } else { - $debugMessage = sprintf('You don\'t have enough permissions to access the instance of the "%s" entity with id = %s.', $parameters['entity_fqcn'], $entityId); + $debugMessage = sprintf( + 'You don\'t have enough permissions to access the instance of the "%s" entity with id = %s.', + $parameters['entity_fqcn'], + $entityId + ); } $exceptionContext = new ExceptionContext( diff --git a/src/Factory/ActionFactory.php b/src/Factory/ActionFactory.php index 9cbdb854dc..0edb58f35a 100644 --- a/src/Factory/ActionFactory.php +++ b/src/Factory/ActionFactory.php @@ -3,39 +3,39 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Factory; use EasyCorp\Bundle\EasyAdminBundle\Collection\ActionCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; -use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; -use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Security\PermissionInterface; use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableMessageBuilder; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use function Symfony\Component\Translation\t; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\Translation\t; + final class ActionFactory implements ActionFactoryInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; + private AuthorizationCheckerInterface $authChecker; - private AdminUrlGenerator $adminUrlGenerator; + + private AdminUrlGeneratorInterface $adminUrlGenerator; + private ?CsrfTokenManagerInterface $csrfTokenManager; - public function __construct(AdminContextProviderInterface $adminContextProvider, AuthorizationCheckerInterface $authChecker, AdminUrlGeneratorInterface $adminUrlGenerator, ?CsrfTokenManagerInterface $csrfTokenManager = null) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + AuthorizationCheckerInterface $authChecker, + AdminUrlGeneratorInterface $adminUrlGenerator, + ?CsrfTokenManagerInterface $csrfTokenManager = null + ) { $this->adminContextProvider = $adminContextProvider; $this->authChecker = $authChecker; $this->adminUrlGenerator = $adminUrlGenerator; @@ -51,7 +51,10 @@ public function processEntityActions(EntityDtoInterface $entityDto, ActionConfig continue; } - if (false === $this->authChecker->isGranted(PermissionInterface::EA_EXECUTE_ACTION, ['action' => $actionDto, 'entity' => $entityDto])) { + if (false === $this->authChecker->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => $actionDto, 'entity' => $entityDto] + )) { continue; } @@ -94,12 +97,21 @@ public function processGlobalActions(?ActionConfigDtoInterface $actionsDto = nul continue; } - if (false === $this->authChecker->isGranted(PermissionInterface::EA_EXECUTE_ACTION, ['action' => $actionDto, 'entity' => null])) { + if (false === $this->authChecker->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => $actionDto, 'entity' => null] + )) { continue; } if (CrudInterface::PAGE_INDEX !== $currentPage && $actionDto->isBatchAction()) { - throw new \RuntimeException(sprintf('Batch actions can be added only to the "index" page, but the "%s" batch action is defined in the "%s" page.', $actionDto->getName(), $currentPage)); + throw new \RuntimeException( + sprintf( + 'Batch actions can be added only to the "index" page, but the "%s" batch action is defined in the "%s" page.', + $actionDto->getName(), + $currentPage + ) + ); } if ('' === $actionDto->getCssClass()) { @@ -112,8 +124,11 @@ public function processGlobalActions(?ActionConfigDtoInterface $actionsDto = nul return ActionCollection::new($globalActions); } - private function processAction(string $pageName, ActionDtoInterface $actionDto, ?EntityDtoInterface $entityDto = null): ActionDtoInterface - { + private function processAction( + string $pageName, + ActionDtoInterface $actionDto, + ?EntityDtoInterface $entityDto = null + ): ActionDtoInterface { $adminContext = $this->adminContextProvider->getContext(); $translationDomain = $adminContext->getI18n()->getTranslationDomain(); $defaultTranslationParameters = $adminContext->getI18n()->getTranslationParameters(); @@ -129,24 +144,38 @@ private function processAction(string $pageName, ActionDtoInterface $actionDto, $actionDto->getTranslationParameters() ); $label = $actionDto->getLabel(); - $translatableActionLabel = (null === $label || '' === $label) ? $label : t($label, $translationParameters, $translationDomain); + $translatableActionLabel = (null === $label || '' === $label) ? $label : t( + $label, + $translationParameters, + $translationDomain + ); $actionDto->setLabel($translatableActionLabel); } else { - $actionDto->setLabel(TranslatableMessageBuilder::withParameters($actionDto->getLabel(), $defaultTranslationParameters)); + $actionDto->setLabel( + TranslatableMessageBuilder::withParameters($actionDto->getLabel(), $defaultTranslationParameters) + ); } $defaultTemplatePath = $adminContext->getTemplatePath('crud/action'); $actionDto->setTemplatePath($actionDto->getTemplatePath() ?? $defaultTemplatePath); - $actionDto->setLinkUrl($this->generateActionUrl($currentPage, $adminContext->getRequest(), $actionDto, $entityDto)); + $actionDto->setLinkUrl( + $this->generateActionUrl($currentPage, $adminContext->getRequest(), $actionDto, $entityDto) + ); - if (!$actionDto->isGlobalAction() && \in_array($pageName, [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], true)) { + if (!$actionDto->isGlobalAction() && \in_array( + $pageName, + [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], + true + )) { $actionDto->setHtmlAttribute('form', sprintf('%s-%s-form', $pageName, $entityDto->getName())); } if (ActionInterface::DELETE === $actionDto->getName()) { $actionDto->addHtmlAttributes([ - 'formaction' => $this->adminUrlGenerator->setAction(ActionInterface::DELETE)->setEntityId($entityDto->getPrimaryKeyValue())->removeReferrer()->generateUrl(), + 'formaction' => $this->adminUrlGenerator->setAction(ActionInterface::DELETE)->setEntityId( + $entityDto->getPrimaryKeyValue() + )->removeReferrer()->generateUrl(), 'data-bs-toggle' => 'modal', 'data-bs-target' => '#modal-delete', ]); @@ -156,7 +185,9 @@ private function processAction(string $pageName, ActionDtoInterface $actionDto, $actionDto->addHtmlAttributes([ 'data-bs-toggle' => 'modal', 'data-bs-target' => '#modal-batch-action', - 'data-action-csrf-token' => $this->csrfTokenManager?->getToken('ea-batch-action-'.$actionDto->getName()), + 'data-action-csrf-token' => $this->csrfTokenManager?->getToken( + 'ea-batch-action-'.$actionDto->getName() + ), 'data-action-batch' => 'true', 'data-entity-fqcn' => $adminContext->getCrud()->getEntityFqcn(), 'data-action-url' => $actionDto->getLinkUrl(), @@ -166,8 +197,12 @@ private function processAction(string $pageName, ActionDtoInterface $actionDto, return $actionDto; } - private function generateActionUrl(string $currentAction, Request $request, ActionDtoInterface $actionDto, ?EntityDtoInterface $entityDto = null): string - { + private function generateActionUrl( + string $currentAction, + Request $request, + ActionDtoInterface $actionDto, + ?EntityDtoInterface $entityDto = null + ): string { $entityInstance = $entityDto?->getInstance(); if (null !== $url = $actionDto->getUrl()) { @@ -184,7 +219,10 @@ private function generateActionUrl(string $currentAction, Request $request, Acti $routeParameters = $routeParameters($entityInstance); } - return $this->adminUrlGenerator->unsetAll()->includeReferrer()->setRoute($routeName, $routeParameters)->generateUrl(); + return $this->adminUrlGenerator->unsetAll()->includeReferrer()->setRoute( + $routeName, + $routeParameters + )->generateUrl(); } $requestParameters = [ @@ -193,17 +231,30 @@ private function generateActionUrl(string $currentAction, Request $request, Acti EA::REFERRER => $this->generateReferrerUrl($request, $actionDto, $currentAction), ]; - if (\in_array($actionDto->getName(), [ActionInterface::INDEX, ActionInterface::NEW, ActionInterface::SAVE_AND_ADD_ANOTHER, ActionInterface::SAVE_AND_RETURN], true)) { + if (\in_array( + $actionDto->getName(), + [ + ActionInterface::INDEX, + ActionInterface::NEW, + ActionInterface::SAVE_AND_ADD_ANOTHER, + ActionInterface::SAVE_AND_RETURN, + ], + true + )) { $requestParameters[EA::ENTITY_ID] = null; } elseif (null !== $entityDto) { $requestParameters[EA::ENTITY_ID] = $entityDto->getPrimaryKeyValueAsString(); } - return $this->adminUrlGenerator->unsetAllExcept(EA::FILTERS, EA::PAGE)->setAll($requestParameters)->generateUrl(); + return $this->adminUrlGenerator->unsetAllExcept(EA::FILTERS, EA::PAGE)->setAll($requestParameters)->generateUrl( + ); } - private function generateReferrerUrl(Request $request, ActionDtoInterface $actionDto, string $currentAction): ?string - { + private function generateReferrerUrl( + Request $request, + ActionDtoInterface $actionDto, + string $currentAction + ): ?string { $nextAction = $actionDto->getName(); if (ActionInterface::DETAIL === $currentAction) { @@ -221,7 +272,7 @@ private function generateReferrerUrl(Request $request, ActionDtoInterface $actio } $referrer = $request->query->get(EA::REFERRER); - $referrerParts = parse_url((string) $referrer); + $referrerParts = parse_url((string)$referrer); parse_str($referrerParts[EA::QUERY] ?? '', $referrerQueryStringVariables); $referrerCrudAction = $referrerQueryStringVariables[EA::CRUD_ACTION] ?? null; diff --git a/src/Factory/AdminContextFactory.php b/src/Factory/AdminContextFactory.php index 49c5c1f2a3..1980f3c324 100644 --- a/src/Factory/AdminContextFactory.php +++ b/src/Factory/AdminContextFactory.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Factory; use EasyCorp\Bundle\EasyAdminBundle\Cache\CacheWarmer; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\TextDirection; @@ -12,13 +11,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\AssetsDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\DashboardDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\DashboardDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDtoInterface; @@ -26,27 +21,36 @@ use EasyCorp\Bundle\EasyAdminBundle\Dto\I18nDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Registry\CrudControllerRegistry; use EasyCorp\Bundle\EasyAdminBundle\Registry\CrudControllerRegistryInterface; use EasyCorp\Bundle\EasyAdminBundle\Registry\TemplateRegistry; use EasyCorp\Bundle\EasyAdminBundle\Registry\TemplateRegistryInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\User\UserInterface; +use Symfony\Contracts\Translation\TranslatableInterface; + use function Symfony\Component\String\u; use function Symfony\Component\Translation\t; -use Symfony\Contracts\Translation\TranslatableInterface; final class AdminContextFactory implements AdminContextFactoryInterface { private string $cacheDir; + private ?TokenStorageInterface $tokenStorage; - private MenuFactory $menuFactory; - private CrudControllerRegistry $crudControllers; - private EntityFactory $entityFactory; - public function __construct(string $cacheDir, ?TokenStorageInterface $tokenStorage, MenuFactoryInterface $menuFactory, CrudControllerRegistryInterface $crudControllers, EntityFactoryInterface $entityFactory) - { + private MenuFactoryInterface $menuFactory; + + private CrudControllerRegistryInterface $crudControllers; + + private EntityFactoryInterface $entityFactory; + + public function __construct( + string $cacheDir, + ?TokenStorageInterface $tokenStorage, + MenuFactoryInterface $menuFactory, + CrudControllerRegistryInterface $crudControllers, + EntityFactoryInterface $entityFactory + ) { $this->cacheDir = $cacheDir; $this->tokenStorage = $tokenStorage; $this->menuFactory = $menuFactory; @@ -54,10 +58,18 @@ public function __construct(string $cacheDir, ?TokenStorageInterface $tokenStora $this->entityFactory = $entityFactory; } - public function create(Request $request, DashboardControllerInterface $dashboardController, ?CrudControllerInterface $crudController): AdminContext - { + public function create( + Request $request, + DashboardControllerInterface $dashboardController, + ?CrudControllerInterface $crudController + ): AdminContext { $crudAction = $request->query->get(EA::CRUD_ACTION); - $validPageNames = [CrudInterface::PAGE_INDEX, CrudInterface::PAGE_DETAIL, CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW]; + $validPageNames = [ + CrudInterface::PAGE_INDEX, + CrudInterface::PAGE_DETAIL, + CrudInterface::PAGE_EDIT, + CrudInterface::PAGE_NEW, + ]; $pageName = \in_array($crudAction, $validPageNames, true) ? $crudAction : null; $dashboardDto = $this->getDashboardDto($request, $dashboardController); @@ -65,18 +77,41 @@ public function create(Request $request, DashboardControllerInterface $dashboard $actionConfigDto = $this->getActionConfig($dashboardController, $crudController, $pageName); $filters = $this->getFilters($dashboardController, $crudController); - $crudDto = $this->getCrudDto($this->crudControllers, $dashboardController, $crudController, $actionConfigDto, $filters, $crudAction, $pageName); + $crudDto = $this->getCrudDto( + $this->crudControllers, + $dashboardController, + $crudController, + $actionConfigDto, + $filters, + $crudAction, + $pageName + ); $entityDto = $this->getEntityDto($request, $crudDto); $searchDto = $this->getSearchDto($request, $crudDto); $i18nDto = $this->getI18nDto($request, $dashboardDto, $crudDto, $entityDto); $templateRegistry = $this->getTemplateRegistry($dashboardController, $crudDto); $user = $this->getUser($this->tokenStorage); - return new AdminContext($request, $user, $i18nDto, $this->crudControllers, $dashboardDto, $dashboardController, $assetDto, $crudDto, $entityDto, $searchDto, $this->menuFactory, $templateRegistry); + return new AdminContext( + $request, + $user, + $i18nDto, + $this->crudControllers, + $dashboardDto, + $dashboardController, + $assetDto, + $crudDto, + $entityDto, + $searchDto, + $this->menuFactory, + $templateRegistry + ); } - private function getDashboardDto(Request $request, DashboardControllerInterface $dashboardControllerInstance): DashboardDtoInterface - { + private function getDashboardDto( + Request $request, + DashboardControllerInterface $dashboardControllerInstance + ): DashboardDtoInterface { $dashboardRoutesCachePath = $this->cacheDir.'/'.CacheWarmer::DASHBOARD_ROUTES_CACHE; $dashboardControllerRoutes = !file_exists($dashboardRoutesCachePath) ? [] : require $dashboardRoutesCachePath; $dashboardController = $dashboardControllerInstance::class.'::index'; @@ -93,7 +128,12 @@ private function getDashboardDto(Request $request, DashboardControllerInterface } if (null === $dashboardRouteName) { - throw new \RuntimeException(sprintf('The name of the route associated to "%s" cannot be determined. Clear the application cache to run the EasyAdmin cache warmer, which generates the needed data to find this route.', $dashboardController)); + throw new \RuntimeException( + sprintf( + 'The name of the route associated to "%s" cannot be determined. Clear the application cache to run the EasyAdmin cache warmer, which generates the needed data to find this route.', + $dashboardController + ) + ); } $dashboardDto = $dashboardControllerInstance->configureDashboard()->getAsDto(); @@ -102,8 +142,11 @@ private function getDashboardDto(Request $request, DashboardControllerInterface return $dashboardDto; } - private function getAssetDto(DashboardControllerInterface $dashboardController, ?CrudControllerInterface $crudController, ?string $pageName): AssetsDtoInterface - { + private function getAssetDto( + DashboardControllerInterface $dashboardController, + ?CrudControllerInterface $crudController, + ?string $pageName + ): AssetsDtoInterface { $defaultAssets = $dashboardController->configureAssets(); if (null === $crudController) { @@ -113,8 +156,15 @@ private function getAssetDto(DashboardControllerInterface $dashboardController, return $crudController->configureAssets($defaultAssets)->getAsDto()->loadedOn($pageName); } - private function getCrudDto(CrudControllerRegistryInterface $crudControllers, DashboardControllerInterface $dashboardController, ?CrudControllerInterface $crudController, ActionConfigDtoInterface $actionConfigDto, FilterConfigDtoInterface $filters, ?string $crudAction, ?string $pageName): ?CrudDtoInterface - { + private function getCrudDto( + CrudControllerRegistryInterface $crudControllers, + DashboardControllerInterface $dashboardController, + ?CrudControllerInterface $crudController, + ActionConfigDtoInterface $actionConfigDto, + FilterConfigDtoInterface $filters, + ?string $crudAction, + ?string $pageName + ): ?CrudDtoInterface { if (null === $crudController) { return null; } @@ -134,8 +184,11 @@ private function getCrudDto(CrudControllerRegistryInterface $crudControllers, Da return $crudDto; } - private function getActionConfig(DashboardControllerInterface $dashboardController, ?CrudControllerInterface $crudController, ?string $pageName): ActionConfigDtoInterface - { + private function getActionConfig( + DashboardControllerInterface $dashboardController, + ?CrudControllerInterface $crudController, + ?string $pageName + ): ActionConfigDtoInterface { if (null === $crudController) { return new ActionConfigDto(); } @@ -145,8 +198,10 @@ private function getActionConfig(DashboardControllerInterface $dashboardControll return $crudController->configureActions($defaultActionConfig)->getAsDto($pageName); } - private function getFilters(DashboardControllerInterface $dashboardController, ?CrudControllerInterface $crudController): FilterConfigDtoInterface - { + private function getFilters( + DashboardControllerInterface $dashboardController, + ?CrudControllerInterface $crudController + ): FilterConfigDtoInterface { if (null === $crudController) { return new FilterConfigDto(); } @@ -156,8 +211,10 @@ private function getFilters(DashboardControllerInterface $dashboardController, ? return $crudController->configureFilters($defaultFilterConfig)->getAsDto(); } - private function getTemplateRegistry(DashboardControllerInterface $dashboardController, ?CrudDtoInterface $crudDto): TemplateRegistryInterface - { + private function getTemplateRegistry( + DashboardControllerInterface $dashboardController, + ?CrudDtoInterface $crudDto + ): TemplateRegistryInterface { $templateRegistry = TemplateRegistry::new(); $defaultCrudDto = $dashboardController->configureCrud()->getAsDto(); @@ -170,25 +227,37 @@ private function getTemplateRegistry(DashboardControllerInterface $dashboardCont return $templateRegistry; } - private function getI18nDto(Request $request, DashboardDtoInterface $dashboardDto, ?CrudDtoInterface $crudDto, ?EntityDtoInterface $entityDto): I18nDtoInterface - { + private function getI18nDto( + Request $request, + DashboardDtoInterface $dashboardDto, + ?CrudDtoInterface $crudDto, + ?EntityDtoInterface $entityDto + ): I18nDtoInterface { $locale = $request->getLocale(); $configuredTextDirection = $dashboardDto->getTextDirection(); $localePrefix = strtolower(substr($locale, 0, 2)); - $defaultTextDirection = \in_array($localePrefix, ['ar', 'fa', 'he'], true) ? TextDirection::RTL : TextDirection::LTR; + $defaultTextDirection = \in_array( + $localePrefix, + ['ar', 'fa', 'he'], + true + ) ? TextDirection::RTL : TextDirection::LTR; $textDirection = $configuredTextDirection ?? $defaultTextDirection; $translationDomain = $dashboardDto->getTranslationDomain(); $translationParameters = []; if (null !== $crudDto) { - $translationParameters['%entity_name%'] = $entityName = basename(str_replace('\\', '/', $crudDto->getEntityFqcn())); + $translationParameters['%entity_name%'] = $entityName = basename( + str_replace('\\', '/', $crudDto->getEntityFqcn()) + ); $translationParameters['%entity_as_string%'] = null === $entityDto ? '' : $entityDto->toString(); $translationParameters['%entity_id%'] = $entityId = $request->query->get(EA::ENTITY_ID); - $translationParameters['%entity_short_id%'] = null === $entityId ? null : u($entityId)->truncate(7)->toString(); + $translationParameters['%entity_short_id%'] = null === $entityId ? null : u($entityId)->truncate( + 7 + )->toString(); - $entityInstance = null === $entityDto ? null : $entityDto->getInstance(); + $entityInstance = $entityDto?->getInstance(); $pageName = $crudDto->getCurrentPage(); $singularLabel = $crudDto->getEntityLabelInSingular($entityInstance, $pageName); @@ -246,6 +315,10 @@ private function getEntityDto(Request $request, ?CrudDtoInterface $crudDto): ?En return null; } - return $this->entityFactory->create($crudDto->getEntityFqcn(), $request->query->get(EA::ENTITY_ID), $crudDto->getEntityPermission()); + return $this->entityFactory->create( + $crudDto->getEntityFqcn(), + $request->query->get(EA::ENTITY_ID), + $crudDto->getEntityPermission() + ); } } diff --git a/src/Factory/ControllerFactory.php b/src/Factory/ControllerFactory.php index 5c2d4ead45..58a6eac4cd 100644 --- a/src/Factory/ControllerFactory.php +++ b/src/Factory/ControllerFactory.php @@ -17,13 +17,18 @@ public function __construct(ControllerResolverInterface $controllerResolver) $this->controllerResolver = $controllerResolver; } - public function getDashboardControllerInstance(string $controllerFqcn, Request $request): ?DashboardControllerInterface - { + public function getDashboardControllerInstance( + string $controllerFqcn, + Request $request + ): ?DashboardControllerInterface { return $this->getDashboardController($controllerFqcn, $request); } - public function getCrudControllerInstance(?string $crudControllerFqcn, ?string $crudAction, Request $request): ?CrudControllerInterface - { + public function getCrudControllerInstance( + ?string $crudControllerFqcn, + ?string $crudAction, + Request $request + ): ?CrudControllerInterface { if (null === $crudControllerFqcn) { return null; } @@ -31,18 +36,27 @@ public function getCrudControllerInstance(?string $crudControllerFqcn, ?string $ return $this->getCrudController($crudControllerFqcn, $crudAction, $request); } - private function getDashboardController(?string $dashboardControllerFqcn, Request $request): ?DashboardControllerInterface - { + private function getDashboardController( + ?string $dashboardControllerFqcn, + Request $request + ): ?DashboardControllerInterface { return $this->getController(DashboardControllerInterface::class, $dashboardControllerFqcn, 'index', $request); } - private function getCrudController(?string $crudControllerFqcn, ?string $crudAction, Request $request): ?CrudControllerInterface - { + private function getCrudController( + ?string $crudControllerFqcn, + ?string $crudAction, + Request $request + ): ?CrudControllerInterface { return $this->getController(CrudControllerInterface::class, $crudControllerFqcn, $crudAction, $request); } - private function getController(string $controllerInterface, ?string $controllerFqcn, ?string $controllerAction, Request $request) - { + private function getController( + string $controllerInterface, + ?string $controllerFqcn, + ?string $controllerAction, + Request $request + ) { if (null === $controllerFqcn || null === $controllerAction) { return null; } @@ -51,7 +65,9 @@ private function getController(string $controllerInterface, ?string $controllerF $controllerCallable = $this->controllerResolver->getController($newRequest); if (false === $controllerCallable) { - throw new NotFoundHttpException(sprintf('Unable to find the controller "%s::%s".', $controllerFqcn, $controllerAction)); + throw new NotFoundHttpException( + sprintf('Unable to find the controller "%s::%s".', $controllerFqcn, $controllerAction) + ); } if (!\is_array($controllerCallable)) { diff --git a/src/Factory/EntityFactory.php b/src/Factory/EntityFactory.php index 1e57a6fbbf..6870dfca7a 100644 --- a/src/Factory/EntityFactory.php +++ b/src/Factory/EntityFactory.php @@ -11,27 +11,34 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\ActionCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; -use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionConfigDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityBuiltEvent; use EasyCorp\Bundle\EasyAdminBundle\Exception\EntityNotFoundException; -use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Security\PermissionInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; final class EntityFactory implements EntityFactoryInterface { - private FieldFactory $fieldFactory; - private ActionFactory $actionFactory; + private FieldFactoryInterface $fieldFactory; + + private ActionFactoryInterface $actionFactory; + private AuthorizationCheckerInterface $authorizationChecker; + private ManagerRegistry $doctrine; + private EventDispatcherInterface $eventDispatcher; - public function __construct(FieldFactoryInterface $fieldFactory, ActionFactoryInterface $actionFactory, AuthorizationCheckerInterface $authorizationChecker, ManagerRegistry $doctrine, EventDispatcherInterface $eventDispatcher) - { + public function __construct( + FieldFactoryInterface $fieldFactory, + ActionFactoryInterface $actionFactory, + AuthorizationCheckerInterface $authorizationChecker, + ManagerRegistry $doctrine, + EventDispatcherInterface $eventDispatcher + ) { $this->fieldFactory = $fieldFactory; $this->actionFactory = $actionFactory; $this->authorizationChecker = $authorizationChecker; @@ -57,8 +64,10 @@ public function processActions(EntityDtoInterface $entityDto, ActionConfigDtoInt $this->actionFactory->processEntityActions($entityDto, $actionConfigDto); } - public function processActionsForAll(EntityCollection $entities, ActionConfigDtoInterface $actionConfigDto): ActionCollection - { + public function processActionsForAll( + EntityCollection $entities, + ActionConfigDtoInterface $actionConfigDto + ): ActionCollection { foreach ($entities as $entity) { $this->processActions($entity, clone $actionConfigDto); } @@ -100,14 +109,23 @@ public function getEntityMetadata(string $entityFqcn): ClassMetadata $entityMetadata = $entityManager->getClassMetadata($entityFqcn); if (1 !== \count($entityMetadata->getIdentifierFieldNames())) { - throw new \RuntimeException(sprintf('EasyAdmin does not support Doctrine entities with composite primary keys (such as the ones used in the "%s" entity).', $entityFqcn)); + throw new \RuntimeException( + sprintf( + 'EasyAdmin does not support Doctrine entities with composite primary keys (such as the ones used in the "%s" entity).', + $entityFqcn + ) + ); } return $entityMetadata; } - private function doCreate(?string $entityFqcn = null, $entityId = null, ?string $entityPermission = null, $entityInstance = null): EntityDtoInterface - { + private function doCreate( + ?string $entityFqcn = null, + $entityId = null, + ?string $entityPermission = null, + $entityInstance = null + ): EntityDtoInterface { if (null === $entityInstance && null !== $entityFqcn) { $entityInstance = null === $entityId ? null : $this->getEntityInstance($entityFqcn, $entityId); } @@ -135,7 +153,9 @@ private function doCreate(?string $entityFqcn = null, $entityId = null, ?string private function getEntityManager(string $entityFqcn): ObjectManager { if (null === $entityManager = $this->doctrine->getManagerForClass($entityFqcn)) { - throw new \RuntimeException(sprintf('There is no Doctrine Entity Manager defined for the "%s" class', $entityFqcn)); + throw new \RuntimeException( + sprintf('There is no Doctrine Entity Manager defined for the "%s" class', $entityFqcn) + ); } return $entityManager; @@ -150,7 +170,7 @@ private function getEntityInstance(string $entityFqcn, $entityIdValue): object throw new EntityNotFoundException([ 'entity_name' => $entityFqcn, 'entity_id_name' => $entityIdName, - 'entity_id_value' => $entityIdValue + 'entity_id_value' => $entityIdValue, ]); } diff --git a/src/Factory/FieldFactory.php b/src/Factory/FieldFactory.php index 07734ad426..407beaa53b 100644 --- a/src/Factory/FieldFactory.php +++ b/src/Factory/FieldFactory.php @@ -4,12 +4,9 @@ use Doctrine\DBAL\Types\Types; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; @@ -25,9 +22,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\EaFormRowType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\EasyAdminTabType; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; -use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Security\PermissionInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; @@ -60,12 +55,15 @@ final class FieldFactory implements FieldFactoryInterface Types::TIME_IMMUTABLE => TimeField::class, ]; - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; private AuthorizationCheckerInterface $authorizationChecker; private iterable $fieldConfigurators; - public function __construct(AdminContextProviderInterface $adminContextProvider, AuthorizationCheckerInterface $authorizationChecker, iterable $fieldConfigurators) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + AuthorizationCheckerInterface $authorizationChecker, + iterable $fieldConfigurators + ) { $this->adminContextProvider = $adminContextProvider; $this->authorizationChecker = $authorizationChecker; $this->fieldConfigurators = $fieldConfigurators; @@ -117,7 +115,11 @@ public function processFields(EntityDtoInterface $entityDto, FieldCollection $fi $fields->set($fieldDto); } - $isPageWhereTabsAreVisible = \in_array($currentPage, [CrudInterface::PAGE_DETAIL, CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], true); + $isPageWhereTabsAreVisible = \in_array( + $currentPage, + [CrudInterface::PAGE_DETAIL, CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], + true + ); if ($isPageWhereTabsAreVisible) { $this->checkOrphanTabFields($fields, $context); } @@ -159,7 +161,13 @@ private function preProcessFields(FieldCollection $fields, EntityDtoInterface $e $guessedFieldFqcn = self::$doctrineTypeToFieldFqcn[$doctrinePropertyType] ?? null; if (null === $guessedFieldFqcn) { - throw new \RuntimeException(sprintf('The Doctrine type of the "%s" field is "%s", which is not supported by EasyAdmin. For Doctrine\'s Custom Mapping Types have a look at EasyAdmin\'s field docs.', $fieldDto->getProperty(), $doctrinePropertyType)); + throw new \RuntimeException( + sprintf( + 'The Doctrine type of the "%s" field is "%s", which is not supported by EasyAdmin. For Doctrine\'s Custom Mapping Types have a look at EasyAdmin\'s field docs.', + $fieldDto->getProperty(), + $doctrinePropertyType + ) + ); } } @@ -236,8 +244,8 @@ private function transformField(FieldDtoInterface $fieldDto, string $newFieldFqc private function checkOrphanTabFields(FieldCollection $fields, AdminContext $context): void { $hasTabs = false; - $isTabField = static fn (FieldDtoInterface $fieldDto) => EasyAdminTabType::class === $fieldDto->getFormType(); - $isFormField = static fn (FieldDtoInterface $fieldDto) => FormField::class === $fieldDto->getFieldFqcn(); + $isTabField = static fn(FieldDtoInterface $fieldDto) => EasyAdminTabType::class === $fieldDto->getFormType(); + $isFormField = static fn(FieldDtoInterface $fieldDto) => FormField::class === $fieldDto->getFieldFqcn(); foreach ($fields as $fieldDto) { if ($isTabField($fieldDto)) { @@ -263,6 +271,13 @@ private function checkOrphanTabFields(FieldCollection $fields, AdminContext $con $orphanFieldNames[] = $field->getProperty(); } - throw new \RuntimeException(sprintf('The "%s" page of "%s" uses tabs to display its fields, but the following fields don\'t belong to any tab: %s. Use "FormField::addTab(\'...\')" to add a tab before those fields.', $context->getCrud()->getCurrentPage(), $context->getCrud()->getControllerFqcn(), implode(', ', $orphanFieldNames))); + throw new \RuntimeException( + sprintf( + 'The "%s" page of "%s" uses tabs to display its fields, but the following fields don\'t belong to any tab: %s. Use "FormField::addTab(\'...\')" to add a tab before those fields.', + $context->getCrud()->getCurrentPage(), + $context->getCrud()->getControllerFqcn(), + implode(', ', $orphanFieldNames) + ) + ); } } diff --git a/src/Factory/FieldLayoutFactory.php b/src/Factory/FieldLayoutFactory.php index e7f6a3e950..0523651cc0 100644 --- a/src/Factory/FieldLayoutFactory.php +++ b/src/Factory/FieldLayoutFactory.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Factory; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldLayoutDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldLayoutDtoInterface; diff --git a/src/Factory/FilterFactory.php b/src/Factory/FilterFactory.php index c8d92c3c79..edb76faf91 100644 --- a/src/Factory/FilterFactory.php +++ b/src/Factory/FilterFactory.php @@ -6,9 +6,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterConfigDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\ArrayFilter; use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; @@ -17,12 +15,11 @@ use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter; use EasyCorp\Bundle\EasyAdminBundle\Filter\NumericFilter; use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; final class FilterFactory implements FilterFactoryInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; private iterable $filterConfigurators; private static array $doctrineTypeToFilterClass = [ 'json_array' => ArrayFilter::class, @@ -57,8 +54,11 @@ public function __construct(AdminContextProviderInterface $adminContextProvider, $this->filterConfigurators = $filterConfigurators; } - public function create(FilterConfigDtoInterface $filterConfig, FieldCollection $fields, EntityDtoInterface $entityDto): FilterCollection - { + public function create( + FilterConfigDtoInterface $filterConfig, + FieldCollection $fields, + EntityDtoInterface $entityDto + ): FilterCollection { $builtFilters = []; /** @var FilterInterface|string $filter */ foreach ($filterConfig->all() as $property => $filter) { diff --git a/src/Factory/FormFactory.php b/src/Factory/FormFactory.php index 9b82f14475..c3eff0db71 100644 --- a/src/Factory/FormFactory.php +++ b/src/Factory/FormFactory.php @@ -10,48 +10,70 @@ use EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\FiltersFormType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormFactoryInterface; +use Symfony\Component\Form\FormFactoryInterface as BaseFormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; final class FormFactory implements FormFactoryInterface { - private FormFactoryInterface $symfonyFormFactory; + private BaseFormFactoryInterface $symfonyFormFactory; - public function __construct(FormFactoryInterface $symfonyFormFactory) + public function __construct(BaseFormFactoryInterface $symfonyFormFactory) { $this->symfonyFormFactory = $symfonyFormFactory; } - public function createEditFormBuilder(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormBuilderInterface - { + public function createEditFormBuilder( + EntityDtoInterface $entityDto, + KeyValueStore $formOptions, + AdminContext $context + ): FormBuilderInterface { $cssClass = sprintf('ea-%s-form', $context->getCrud()->getCurrentAction()); $formOptions->set('attr.class', trim(($formOptions->get('attr.class') ?? '').' '.$cssClass)); $formOptions->set('attr.id', sprintf('edit-%s-form', $entityDto->getName())); $formOptions->set('entityDto', $entityDto); $formOptions->setIfNotSet('translation_domain', $context->getI18n()->getTranslationDomain()); - return $this->symfonyFormFactory->createNamedBuilder($entityDto->getName(), CrudFormType::class, $entityDto->getInstance(), $formOptions->all()); + return $this->symfonyFormFactory->createNamedBuilder( + $entityDto->getName(), + CrudFormType::class, + $entityDto->getInstance(), + $formOptions->all() + ); } - public function createEditForm(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormInterface - { + public function createEditForm( + EntityDtoInterface $entityDto, + KeyValueStore $formOptions, + AdminContext $context + ): FormInterface { return $this->createEditFormBuilder($entityDto, $formOptions, $context)->getForm(); } - public function createNewFormBuilder(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormBuilderInterface - { + public function createNewFormBuilder( + EntityDtoInterface $entityDto, + KeyValueStore $formOptions, + AdminContext $context + ): FormBuilderInterface { $cssClass = sprintf('ea-%s-form', $context->getCrud()->getCurrentAction()); $formOptions->set('attr.class', trim(($formOptions->get('attr.class') ?? '').' '.$cssClass)); $formOptions->set('attr.id', sprintf('new-%s-form', $entityDto->getName())); $formOptions->set('entityDto', $entityDto); $formOptions->setIfNotSet('translation_domain', $context->getI18n()->getTranslationDomain()); - return $this->symfonyFormFactory->createNamedBuilder($entityDto->getName(), CrudFormType::class, $entityDto->getInstance(), $formOptions->all()); + return $this->symfonyFormFactory->createNamedBuilder( + $entityDto->getName(), + CrudFormType::class, + $entityDto->getInstance(), + $formOptions->all() + ); } - public function createNewForm(EntityDtoInterface $entityDto, KeyValueStore $formOptions, AdminContext $context): FormInterface - { + public function createNewForm( + EntityDtoInterface $entityDto, + KeyValueStore $formOptions, + AdminContext $context + ): FormInterface { return $this->createNewFormBuilder($entityDto, $formOptions, $context)->getForm(); } diff --git a/src/Factory/FormFactoryInterface.php b/src/Factory/FormFactoryInterface.php index d12cf4cd43..bbb1a9a170 100644 --- a/src/Factory/FormFactoryInterface.php +++ b/src/Factory/FormFactoryInterface.php @@ -42,5 +42,8 @@ public function createNewForm( AdminContext $context ): FormInterface; - public function createFiltersForm(FilterCollection $filters, Request $request): FormInterface; + public function createFiltersForm( + FilterCollection $filters, + Request $request + ): FormInterface; } diff --git a/src/Factory/MenuFactory.php b/src/Factory/MenuFactory.php index 54a5c40cc0..b0c1440cdf 100644 --- a/src/Factory/MenuFactory.php +++ b/src/Factory/MenuFactory.php @@ -3,38 +3,42 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Factory; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; -use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu; use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenuInterface; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MainMenuDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\UserMenuDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Menu\MenuItemMatcherInterface; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; -use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; use EasyCorp\Bundle\EasyAdminBundle\Security\PermissionInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; -use function Symfony\Component\Translation\t; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\Translation\t; + final class MenuFactory implements MenuFactoryInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; + private AuthorizationCheckerInterface $authChecker; + private LogoutUrlGenerator $logoutUrlGenerator; - private AdminUrlGenerator $adminUrlGenerator; + + private AdminUrlGeneratorInterface $adminUrlGenerator; + private MenuItemMatcherInterface $menuItemMatcher; - public function __construct(AdminContextProviderInterface $adminContextProvider, AuthorizationCheckerInterface $authChecker, LogoutUrlGenerator $logoutUrlGenerator, AdminUrlGeneratorInterface $adminUrlGenerator, MenuItemMatcherInterface $menuItemMatcher) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + AuthorizationCheckerInterface $authChecker, + LogoutUrlGenerator $logoutUrlGenerator, + AdminUrlGeneratorInterface $adminUrlGenerator, + MenuItemMatcherInterface $menuItemMatcher + ) { $this->adminContextProvider = $adminContextProvider; $this->authChecker = $authChecker; $this->logoutUrlGenerator = $logoutUrlGenerator; @@ -89,8 +93,10 @@ private function buildMenuItems(array $menuItems): array } private function buildMenuItem( - MenuItemDtoInterface $menuItemDto, array $subItems, string $translationDomain): MenuItemDtoInterface - { + MenuItemDtoInterface $menuItemDto, + array $subItems, + string $translationDomain + ): MenuItemDtoInterface { if (!$menuItemDto->getLabel() instanceof TranslatableInterface) { $label = $menuItemDto->getLabel(); $menuItemDto->setLabel( @@ -132,7 +138,12 @@ private function generateMenuItemUrl(MenuItemDtoInterface $menuItemDto): string $entityFqcn = $routeParameters[EA::ENTITY_FQCN] ?? null; $crudControllerFqcn = $routeParameters[EA::CRUD_CONTROLLER_FQCN] ?? null; if (null === $entityFqcn && null === $crudControllerFqcn) { - throw new \RuntimeException(sprintf('The CRUD menu item with label "%s" must define either the entity FQCN (using the third constructor argument) or the CRUD Controller FQCN (using the "setController()" method).', $menuItemDto->getLabel())); + throw new \RuntimeException( + sprintf( + 'The CRUD menu item with label "%s" must define either the entity FQCN (using the third constructor argument) or the CRUD Controller FQCN (using the "setController()" method).', + $menuItemDto->getLabel() + ) + ); } // 1. if CRUD controller is defined, use it... @@ -142,7 +153,13 @@ private function generateMenuItemUrl(MenuItemDtoInterface $menuItemDto): string } else { $crudControllers = $this->adminContextProvider->getContext()?->getCrudControllers(); if (null === $controllerFqcn = $crudControllers->findCrudFqcnByEntityFqcn($entityFqcn)) { - throw new \RuntimeException(sprintf('Unable to find the controller related to the "%s" Entity; did you forget to extend "%s"?', $entityFqcn, AbstractCrudController::class)); + throw new \RuntimeException( + sprintf( + 'Unable to find the controller related to the "%s" Entity; did you forget to extend "%s"?', + $entityFqcn, + AbstractCrudController::class + ) + ); } $this->adminUrlGenerator->setController($controllerFqcn); diff --git a/src/Factory/PaginatorFactory.php b/src/Factory/PaginatorFactory.php index 1b29f55236..671f730d08 100644 --- a/src/Factory/PaginatorFactory.php +++ b/src/Factory/PaginatorFactory.php @@ -4,16 +4,18 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; final class PaginatorFactory implements PaginatorFactoryInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; + private EntityPaginatorInterface $entityPaginator; - public function __construct(AdminContextProviderInterface $adminContextProvider, EntityPaginatorInterface $entityPaginator) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + EntityPaginatorInterface $entityPaginator + ) { $this->adminContextProvider = $adminContextProvider; $this->entityPaginator = $entityPaginator; } @@ -22,7 +24,7 @@ public function create(QueryBuilder $queryBuilder): EntityPaginatorInterface { $adminContext = $this->adminContextProvider->getContext(); $paginatorDto = $adminContext->getCrud()->getPaginator(); - $paginatorDto->setPageNumber((int) $adminContext->getRequest()->query->get('page', '1')); + $paginatorDto->setPageNumber((int)$adminContext->getRequest()->query->get('page', '1')); return $this->entityPaginator->paginate($paginatorDto, $queryBuilder); } diff --git a/src/Field/AssociationField.php b/src/Field/AssociationField.php index ecb796a26a..4d97b127b5 100644 --- a/src/Field/AssociationField.php +++ b/src/Field/AssociationField.php @@ -95,8 +95,11 @@ public function setQueryBuilder(\Closure $queryBuilderCallable): self return $this; } - public function renderAsEmbeddedForm(?string $crudControllerFqcn = null, ?string $crudNewPageName = null, ?string $crudEditPageName = null): self - { + public function renderAsEmbeddedForm( + ?string $crudControllerFqcn = null, + ?string $crudNewPageName = null, + ?string $crudEditPageName = null + ): self { $this->setCustomOption(self::OPTION_RENDER_AS_EMBEDDED_FORM, true); $this->setCustomOption(self::OPTION_EMBEDDED_CRUD_FORM_CONTROLLER, $crudControllerFqcn); $this->setCustomOption(self::OPTION_EMBEDDED_CRUD_FORM_NEW_PAGE_NAME, $crudNewPageName); diff --git a/src/Field/AvatarField.php b/src/Field/AvatarField.php index da1995b07f..20c4fca89b 100644 --- a/src/Field/AvatarField.php +++ b/src/Field/AvatarField.php @@ -39,7 +39,14 @@ public function setHeight($heightInPixels): self $semanticHeights = [Size::SM => 18, Size::MD => 24, Size::LG => 48, Size::XL => 96]; if (!\is_int($heightInPixels) && !\array_key_exists($heightInPixels, $semanticHeights)) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be either an integer (the height in pixels) or one of these string values: %s (%d given).', __METHOD__, implode(', ', $semanticHeights), $heightInPixels)); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s()" method must be either an integer (the height in pixels) or one of these string values: %s (%d given).', + __METHOD__, + implode(', ', $semanticHeights), + $heightInPixels + ) + ); } if (\is_string($heightInPixels)) { @@ -47,7 +54,13 @@ public function setHeight($heightInPixels): self } if ($heightInPixels < 1) { - throw new \InvalidArgumentException(sprintf('When passing an integer for the argument of the "%s()" method, the value must be 1 or higher (%d given).', __METHOD__, $heightInPixels)); + throw new \InvalidArgumentException( + sprintf( + 'When passing an integer for the argument of the "%s()" method, the value must be 1 or higher (%d given).', + __METHOD__, + $heightInPixels + ) + ); } $this->setCustomOption(self::OPTION_HEIGHT, $heightInPixels); diff --git a/src/Field/ChoiceField.php b/src/Field/ChoiceField.php index 5f7d602141..e39e6e6b4a 100644 --- a/src/Field/ChoiceField.php +++ b/src/Field/ChoiceField.php @@ -79,7 +79,13 @@ public function autocomplete(): self public function setChoices($choiceGenerator): self { if (!\is_array($choiceGenerator) && !\is_callable($choiceGenerator)) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s" method must be an array or a closure ("%s" given).', __METHOD__, \gettype($choiceGenerator))); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s" method must be an array or a closure ("%s" given).', + __METHOD__, + \gettype($choiceGenerator) + ) + ); } $this->setCustomOption(self::OPTION_CHOICES, $choiceGenerator); @@ -115,13 +121,26 @@ public function setTranslatableChoices($choiceGenerator): self public function renderAsBadges($badgeSelector = true): self { if (!\is_bool($badgeSelector) && !\is_array($badgeSelector) && !\is_callable($badgeSelector)) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s" method must be a boolean, an array or a closure ("%s" given).', __METHOD__, \gettype($badgeSelector))); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s" method must be a boolean, an array or a closure ("%s" given).', + __METHOD__, + \gettype($badgeSelector) + ) + ); } if (\is_array($badgeSelector)) { foreach ($badgeSelector as $badgeType) { if (!\in_array($badgeType, self::VALID_BADGE_TYPES, true)) { - throw new \InvalidArgumentException(sprintf('The values of the array passed to the "%s" method must be one of the following valid badge types: "%s" ("%s" given).', __METHOD__, implode(', ', self::VALID_BADGE_TYPES), $badgeType)); + throw new \InvalidArgumentException( + sprintf( + 'The values of the array passed to the "%s" method must be one of the following valid badge types: "%s" ("%s" given).', + __METHOD__, + implode(', ', self::VALID_BADGE_TYPES), + $badgeType + ) + ); } } } diff --git a/src/Field/CodeEditorField.php b/src/Field/CodeEditorField.php index d9f5d9f266..9cd5081b04 100644 --- a/src/Field/CodeEditorField.php +++ b/src/Field/CodeEditorField.php @@ -20,7 +20,21 @@ final class CodeEditorField implements FieldInterface public const OPTION_TAB_SIZE = 'tabSize'; public const OPTION_SHOW_LINE_NUMBERS = 'showLineNumbers'; - private const ALLOWED_LANGUAGES = ['css', 'dockerfile', 'js', 'javascript', 'markdown', 'nginx', 'php', 'shell', 'sql', 'twig', 'xml', 'yaml-frontmatter', 'yaml']; + private const ALLOWED_LANGUAGES = [ + 'css', + 'dockerfile', + 'js', + 'javascript', + 'markdown', + 'nginx', + 'php', + 'shell', + 'sql', + 'twig', + 'xml', + 'yaml-frontmatter', + 'yaml', + ]; /** * @param TranslatableInterface|string|false|null $label @@ -53,7 +67,13 @@ public function setIndentWithTabs(bool $useTabs): self public function setLanguage(string $language): self { if (!\in_array($language, self::ALLOWED_LANGUAGES, true)) { - throw new \InvalidArgumentException(sprintf('The "%s" language is not available for code highlighting (allowed languages: %s).', __METHOD__, implode(', ', self::ALLOWED_LANGUAGES))); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" language is not available for code highlighting (allowed languages: %s).', + __METHOD__, + implode(', ', self::ALLOWED_LANGUAGES) + ) + ); } $this->setCustomOption(self::OPTION_LANGUAGE, $language); @@ -64,7 +84,9 @@ public function setLanguage(string $language): self public function setNumOfRows(int $rows): self { if ($rows < 1) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $rows)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $rows) + ); } $this->setCustomOption(self::OPTION_NUM_OF_ROWS, $rows); @@ -75,7 +97,9 @@ public function setNumOfRows(int $rows): self public function setTabSize(int $tabSize): self { if ($tabSize < 1) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $tabSize)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $tabSize) + ); } $this->setCustomOption(self::OPTION_TAB_SIZE, $tabSize); diff --git a/src/Field/CollectionField.php b/src/Field/CollectionField.php index b875d922f5..670278b112 100644 --- a/src/Field/CollectionField.php +++ b/src/Field/CollectionField.php @@ -96,8 +96,11 @@ public function renderExpanded(bool $renderExpanded = true): self return $this; } - public function useEntryCrudForm(?string $crudControllerFqcn = null, ?string $crudNewPageName = null, ?string $crudEditPageName = null): self - { + public function useEntryCrudForm( + ?string $crudControllerFqcn = null, + ?string $crudNewPageName = null, + ?string $crudEditPageName = null + ): self { $this->setCustomOption(self::OPTION_ENTRY_USES_CRUD_FORM, true); $this->setCustomOption(self::OPTION_ENTRY_CRUD_CONTROLLER_FQCN, $crudControllerFqcn); $this->setCustomOption(self::OPTION_ENTRY_CRUD_NEW_PAGE_NAME, $crudNewPageName); diff --git a/src/Field/Configurator/ArrayConfigurator.php b/src/Field/Configurator/ArrayConfigurator.php index c5beecb6a8..8d03452989 100644 --- a/src/Field/Configurator/ArrayConfigurator.php +++ b/src/Field/Configurator/ArrayConfigurator.php @@ -3,16 +3,14 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; use Doctrine\ORM\PersistentCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; use Symfony\Component\Form\Extension\Core\Type\TextType; + use function Symfony\Component\String\u; /** @@ -43,7 +41,7 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt if (CrudInterface::PAGE_INDEX === $context->getCrud()->getCurrentPage()) { $values = $field->getValue(); if ($values instanceof PersistentCollection) { - $values = array_map(static fn ($item): string => (string) $item, $values->getValues()); + $values = array_map(static fn($item): string => (string)$item, $values->getValues()); } $field->setFormattedValue(u(', ')->join($values)->toString()); diff --git a/src/Field/Configurator/AssociationConfigurator.php b/src/Field/Configurator/AssociationConfigurator.php index 2b749c5a13..5f1c233290 100644 --- a/src/Field/Configurator/AssociationConfigurator.php +++ b/src/Field/Configurator/AssociationConfigurator.php @@ -5,30 +5,24 @@ use Doctrine\ORM\EntityRepository; use Doctrine\ORM\PersistentCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\TextAlign; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\ControllerFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\ControllerFactoryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactoryInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudAutocompleteType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType; -use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException; use Symfony\Component\PropertyAccess\PropertyAccessor; + use function Symfony\Component\Translation\t; /** @@ -36,13 +30,20 @@ */ final class AssociationConfigurator implements FieldConfiguratorInterface { - private EntityFactory $entityFactory; - private AdminUrlGenerator $adminUrlGenerator; + private EntityFactoryInterface $entityFactory; + + private AdminUrlGeneratorInterface $adminUrlGenerator; + private RequestStack $requestStack; - private ControllerFactory $controllerFactory; - public function __construct(EntityFactoryInterface $entityFactory, AdminUrlGeneratorInterface $adminUrlGenerator, RequestStack $requestStack, ControllerFactoryInterface $controllerFactory) - { + private ControllerFactoryInterface $controllerFactory; + + public function __construct( + EntityFactoryInterface $entityFactory, + AdminUrlGeneratorInterface $adminUrlGenerator, + RequestStack $requestStack, + ControllerFactoryInterface $controllerFactory + ) { $this->entityFactory = $entityFactory; $this->adminUrlGenerator = $adminUrlGenerator; $this->requestStack = $requestStack; @@ -58,7 +59,12 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt { $propertyName = $field->getProperty(); if (!$entityDto->isAssociation($propertyName)) { - throw new \RuntimeException(sprintf('The "%s" field is not a Doctrine association, so it cannot be used as an association field.', $propertyName)); + throw new \RuntimeException( + sprintf( + 'The "%s" field is not a Doctrine association, so it cannot be used as an association field.', + $propertyName + ) + ); } $targetEntityFqcn = $field->getDoctrineMetadata()->get('targetEntity'); @@ -109,7 +115,13 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt foreach ($propertyNameParts as $association) { if (!$metadata->hasAssociation($association)) { - throw new \RuntimeException(sprintf('There is no association for the class "%s" with name "%s"', $targetEntityFqcn, $association)); + throw new \RuntimeException( + sprintf( + 'There is no association for the class "%s" with name "%s"', + $targetEntityFqcn, + $association + ) + ); } // overwrite next class from association @@ -125,10 +137,16 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $field->setFormTypeOptionIfNotSet('class', $targetEntityFqcn); try { - $relatedEntityId = $accessor->getValue($entityDto->getInstance(), $propertyName.'.'.$metadata->getIdentifierFieldNames()[0]); + $relatedEntityId = $accessor->getValue( + $entityDto->getInstance(), + $propertyName.'.'.$metadata->getIdentifierFieldNames()[0] + ); $relatedEntityDto = $this->entityFactory->create($targetEntityFqcn, $relatedEntityId); - $field->setCustomOption(AssociationField::OPTION_RELATED_URL, $this->generateLinkToAssociatedEntity($targetCrudControllerFqcn, $relatedEntityDto)); + $field->setCustomOption( + AssociationField::OPTION_RELATED_URL, + $this->generateLinkToAssociatedEntity($targetCrudControllerFqcn, $relatedEntityDto) + ); $field->setFormattedValue($this->formatAsString($relatedEntityDto->getInstance(), $relatedEntityDto)); } catch (UnexpectedTypeException) { // this may crash if something in the tree is null, so just do nothing then @@ -146,7 +164,12 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt if (true === $field->getCustomOption(AssociationField::OPTION_AUTOCOMPLETE)) { $targetCrudControllerFqcn = $field->getCustomOption(AssociationField::OPTION_EMBEDDED_CRUD_FORM_CONTROLLER); if (null === $targetCrudControllerFqcn) { - throw new \RuntimeException(sprintf('The "%s" field cannot be autocompleted because it doesn\'t define the related CRUD controller FQCN with the "setCrudController()" method.', $field->getProperty())); + throw new \RuntimeException( + sprintf( + 'The "%s" field cannot be autocompleted because it doesn\'t define the related CRUD controller FQCN with the "setCrudController()" method.', + $field->getProperty() + ) + ); } $field->setFormType(CrudAutocompleteType::class); @@ -164,16 +187,21 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $field->setFormTypeOption('attr.data-ea-autocomplete-endpoint-url', $autocompleteEndpointUrl); } else { - $field->setFormTypeOptionIfNotSet('query_builder', static function (EntityRepository $repository) use ($field) { - // TODO: should this use `createIndexQueryBuilder` instead, so we get the default ordering etc.? - // it would then be identical to the one used in autocomplete action, but it is a bit complex getting it in here - $queryBuilder = $repository->createQueryBuilder('entity'); - if (null !== $queryBuilderCallable = $field->getCustomOption(AssociationField::OPTION_QUERY_BUILDER_CALLABLE)) { - $queryBuilderCallable($queryBuilder); + $field->setFormTypeOptionIfNotSet( + 'query_builder', + static function (EntityRepository $repository) use ($field) { + // TODO: should this use `createIndexQueryBuilder` instead, so we get the default ordering etc.? + // it would then be identical to the one used in autocomplete action, but it is a bit complex getting it in here + $queryBuilder = $repository->createQueryBuilder('entity'); + if (null !== $queryBuilderCallable = $field->getCustomOption( + AssociationField::OPTION_QUERY_BUILDER_CALLABLE + )) { + $queryBuilderCallable($queryBuilder); + } + + return $queryBuilder; } - - return $queryBuilder; - }); + ); } } @@ -193,7 +221,10 @@ private function configureToOneAssociation(FieldDtoInterface $field): void : $this->entityFactory->createForEntityInstance($field->getValue()); $field->setFormTypeOptionIfNotSet('class', $targetEntityDto->getFqcn()); - $field->setCustomOption(AssociationField::OPTION_RELATED_URL, $this->generateLinkToAssociatedEntity($targetCrudControllerFqcn, $targetEntityDto)); + $field->setCustomOption( + AssociationField::OPTION_RELATED_URL, + $this->generateLinkToAssociatedEntity($targetCrudControllerFqcn, $targetEntityDto) + ); $field->setFormattedValue($this->formatAsString($field->getValue(), $targetEntityDto)); } @@ -221,7 +252,7 @@ private function formatAsString($entityInstance, EntityDtoInterface $entityDto): } if (method_exists($entityInstance, '__toString')) { - return (string) $entityInstance; + return (string)$entityInstance; } if (null !== $primaryKeyValue = $entityDto->getPrimaryKeyValue()) { @@ -265,8 +296,13 @@ private function countNumElements($collection): int return 0; } - private function configureCrudForm(FieldDtoInterface $field, EntityDtoInterface $entityDto, string $propertyName, string $targetEntityFqcn, string $targetCrudControllerFqcn): void - { + private function configureCrudForm( + FieldDtoInterface $field, + EntityDtoInterface $entityDto, + string $propertyName, + string $targetEntityFqcn, + string $targetCrudControllerFqcn + ): void { $field->setFormType(CrudFormType::class); $propertyAccessor = new PropertyAccessor(); @@ -280,20 +316,33 @@ private function configureCrudForm(FieldDtoInterface $field, EntityDtoInterface if (null === $associatedEntity) { $targetCrudControllerAction = ActionInterface::NEW; - $targetCrudControllerPageName = $field->getCustomOption(AssociationField::OPTION_EMBEDDED_CRUD_FORM_NEW_PAGE_NAME) ?? CrudInterface::PAGE_NEW; + $targetCrudControllerPageName = $field->getCustomOption( + AssociationField::OPTION_EMBEDDED_CRUD_FORM_NEW_PAGE_NAME + ) ?? CrudInterface::PAGE_NEW; } else { $targetCrudControllerAction = ActionInterface::EDIT; - $targetCrudControllerPageName = $field->getCustomOption(AssociationField::OPTION_EMBEDDED_CRUD_FORM_EDIT_PAGE_NAME) ?? CrudInterface::PAGE_EDIT; + $targetCrudControllerPageName = $field->getCustomOption( + AssociationField::OPTION_EMBEDDED_CRUD_FORM_EDIT_PAGE_NAME + ) ?? CrudInterface::PAGE_EDIT; } $field->setFormTypeOption( 'entityDto', - $this->createEntityDto($targetEntityFqcn, $targetCrudControllerFqcn, $targetCrudControllerAction, $targetCrudControllerPageName), + $this->createEntityDto( + $targetEntityFqcn, + $targetCrudControllerFqcn, + $targetCrudControllerAction, + $targetCrudControllerPageName + ), ); } - private function createEntityDto(string $entityFqcn, string $crudControllerFqcn, string $crudControllerAction, string $crudControllerPageName): EntityDtoInterface - { + private function createEntityDto( + string $entityFqcn, + string $crudControllerFqcn, + string $crudControllerAction, + string $crudControllerPageName + ): EntityDtoInterface { $entityDto = $this->entityFactory->create($entityFqcn); $crudController = $this->controllerFactory->getCrudControllerInstance( diff --git a/src/Field/Configurator/AvatarConfigurator.php b/src/Field/Configurator/AvatarConfigurator.php index a22896cac3..97c926d532 100644 --- a/src/Field/Configurator/AvatarConfigurator.php +++ b/src/Field/Configurator/AvatarConfigurator.php @@ -2,13 +2,10 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\AvatarField; @@ -30,7 +27,13 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt } if (false !== $field->getCustomOption(AvatarField::OPTION_IS_GRAVATAR_EMAIL)) { - $field->setFormattedValue(sprintf('https://www.gravatar.com/avatar/%s?s=%d&d=mp', md5($field->getValue()), $field->getCustomOption(AvatarField::OPTION_HEIGHT))); + $field->setFormattedValue( + sprintf( + 'https://www.gravatar.com/avatar/%s?s=%d&d=mp', + md5($field->getValue()), + $field->getCustomOption(AvatarField::OPTION_HEIGHT) + ) + ); } } } diff --git a/src/Field/Configurator/BooleanConfigurator.php b/src/Field/Configurator/BooleanConfigurator.php index 3a08298cf7..5fd603d3d4 100644 --- a/src/Field/Configurator/BooleanConfigurator.php +++ b/src/Field/Configurator/BooleanConfigurator.php @@ -2,16 +2,12 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; -use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; @@ -20,11 +16,13 @@ */ final class BooleanConfigurator implements FieldConfiguratorInterface { - private AdminUrlGenerator $adminUrlGenerator; + private AdminUrlGeneratorInterface $adminUrlGenerator; private ?CsrfTokenManagerInterface $csrfTokenManager; - public function __construct(AdminUrlGeneratorInterface $adminUrlGenerator, ?CsrfTokenManagerInterface $csrfTokenManager = null) - { + public function __construct( + AdminUrlGeneratorInterface $adminUrlGenerator, + ?CsrfTokenManagerInterface $csrfTokenManager = null + ) { $this->adminUrlGenerator = $adminUrlGenerator; $this->csrfTokenManager = $csrfTokenManager; } diff --git a/src/Field/Configurator/ChoiceConfigurator.php b/src/Field/Configurator/ChoiceConfigurator.php index cc389d3bd4..a9cd9a63ad 100644 --- a/src/Field/Configurator/ChoiceConfigurator.php +++ b/src/Field/Configurator/ChoiceConfigurator.php @@ -2,22 +2,20 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableChoiceMessage; use EasyCorp\Bundle\EasyAdminBundle\Translation\TranslatableChoiceMessageCollection; -use function Symfony\Component\String\u; -use function Symfony\Component\Translation\t; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\String\u; +use function Symfony\Component\Translation\t; + /** * @author Javier Eguiluz */ @@ -45,9 +43,11 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt // support for enums if ($enumsAreSupported) { - $elementIsEnum = array_unique(array_map(static function ($element): bool { - return \is_object($element) && enum_exists($element::class); - }, $choices)); + $elementIsEnum = array_unique( + array_map(static function ($element): bool { + return \is_object($element) && enum_exists($element::class); + }, $choices) + ); $allChoicesAreEnums = false === \in_array(false, $elementIsEnum, true); // if no choices are passed to the field, check if it's related to an Enum; @@ -71,7 +71,7 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt if ($areChoicesTranslatable) { $field->setFormTypeOptionIfNotSet('choices', array_keys($choices)); - $field->setFormTypeOptionIfNotSet('choice_label', fn ($value) => $choices[$value]); + $field->setFormTypeOptionIfNotSet('choice_label', fn($value) => $choices[$value]); } else { $field->setFormTypeOptionIfNotSet('choices', $choices); } @@ -79,11 +79,19 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $field->setFormTypeOptionIfNotSet('expanded', $isExpanded); if ($isExpanded && ChoiceField::WIDGET_AUTOCOMPLETE === $field->getCustomOption(ChoiceField::OPTION_WIDGET)) { - throw new \InvalidArgumentException(sprintf('The "%s" choice field wants to be displayed as an autocomplete widget and as an expanded list of choices at the same time, which is not possible. Use the renderExpanded() and renderAsNativeWidget() methods to change one of those options.', $field->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" choice field wants to be displayed as an autocomplete widget and as an expanded list of choices at the same time, which is not possible. Use the renderExpanded() and renderAsNativeWidget() methods to change one of those options.', + $field->getProperty() + ) + ); } if (null === $field->getCustomOption(ChoiceField::OPTION_WIDGET)) { - $field->setCustomOption(ChoiceField::OPTION_WIDGET, $isExpanded ? ChoiceField::WIDGET_NATIVE : ChoiceField::WIDGET_AUTOCOMPLETE); + $field->setCustomOption( + ChoiceField::OPTION_WIDGET, + $isExpanded ? ChoiceField::WIDGET_NATIVE : ChoiceField::WIDGET_AUTOCOMPLETE + ); } if (ChoiceField::WIDGET_AUTOCOMPLETE === $field->getCustomOption(ChoiceField::OPTION_WIDGET)) { @@ -94,10 +102,17 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $field->setFormTypeOptionIfNotSet('placeholder', ''); // the value of this form option must be a string to properly propagate it as an HTML attribute value - $field->setFormTypeOption('attr.data-ea-autocomplete-render-items-as-html', true === $field->getCustomOption(ChoiceField::OPTION_ESCAPE_HTML_CONTENTS) ? 'false' : 'true'); + $field->setFormTypeOption( + 'attr.data-ea-autocomplete-render-items-as-html', + true === $field->getCustomOption(ChoiceField::OPTION_ESCAPE_HTML_CONTENTS) ? 'false' : 'true' + ); $fieldValue = $field->getValue(); - $isIndexOrDetail = \in_array($context->getCrud()->getCurrentPage(), [CrudInterface::PAGE_INDEX, CrudInterface::PAGE_DETAIL], true); + $isIndexOrDetail = \in_array( + $context->getCrud()->getCurrentPage(), + [CrudInterface::PAGE_INDEX, CrudInterface::PAGE_DETAIL], + true + ); if (null === $fieldValue || !$isIndexOrDetail) { return; } @@ -110,7 +125,7 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $choiceMessages = []; // Translatable choice don't need to get flipped $flippedChoices = $areChoicesTranslatable ? $choices : array_flip($this->flatten($choices)); - foreach ((array) $fieldValue as $selectedValue) { + foreach ((array)$fieldValue as $selectedValue) { if (null !== $selectedLabel = $flippedChoices[$selectedValue] ?? null) { if ($selectedLabel instanceof TranslatableInterface) { $choiceMessage = $selectedLabel; @@ -157,11 +172,19 @@ private function getBadgeCssClass($badgeSelector, $value, FieldDtoInterface $fie } elseif (\is_callable($badgeSelector)) { $badgeType = $badgeSelector($value, $field); if (!\in_array($badgeType, ChoiceField::VALID_BADGE_TYPES, true)) { - throw new \RuntimeException(sprintf('The value returned by the callable passed to the "renderAsBadges()" method must be one of the following valid badge types: "%s" ("%s" given).', implode(', ', ChoiceField::VALID_BADGE_TYPES), $badgeType)); + throw new \RuntimeException( + sprintf( + 'The value returned by the callable passed to the "renderAsBadges()" method must be one of the following valid badge types: "%s" ("%s" given).', + implode(', ', ChoiceField::VALID_BADGE_TYPES), + $badgeType + ) + ); } } - $badgeTypeCssClass = (null === $badgeType || '' === $badgeType) ? '' : u($badgeType)->ensureStart('badge-')->toString(); + $badgeTypeCssClass = (null === $badgeType || '' === $badgeType) ? '' : u($badgeType)->ensureStart( + 'badge-' + )->toString(); return $commonBadgeCssClass.' '.$badgeTypeCssClass; } diff --git a/src/Field/Configurator/CodeEditorConfigurator.php b/src/Field/Configurator/CodeEditorConfigurator.php index ba5fa1be5a..2e6d58a963 100644 --- a/src/Field/Configurator/CodeEditorConfigurator.php +++ b/src/Field/Configurator/CodeEditorConfigurator.php @@ -5,9 +5,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Asset; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\CodeEditorField; diff --git a/src/Field/Configurator/CollectionConfigurator.php b/src/Field/Configurator/CollectionConfigurator.php index 8579536123..8f09bd6d92 100644 --- a/src/Field/Configurator/CollectionConfigurator.php +++ b/src/Field/Configurator/CollectionConfigurator.php @@ -4,19 +4,13 @@ use Doctrine\ORM\PersistentCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\ControllerFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\ControllerFactoryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactoryInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\CrudFormType; @@ -27,6 +21,7 @@ use Symfony\Component\Form\Extension\Core\Type\TimezoneType; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; + use function Symfony\Component\String\u; /** @@ -35,11 +30,16 @@ final class CollectionConfigurator implements FieldConfiguratorInterface { private RequestStack $requestStack; - private EntityFactory $entityFactory; - private ControllerFactory $controllerFactory; - public function __construct(RequestStack $requestStack, EntityFactoryInterface $entityFactory, ControllerFactoryInterface $controllerFactory) - { + private EntityFactoryInterface $entityFactory; + + private ControllerFactoryInterface $controllerFactory; + + public function __construct( + RequestStack $requestStack, + EntityFactoryInterface $entityFactory, + ControllerFactoryInterface $controllerFactory + ) { $this->requestStack = $requestStack; $this->entityFactory = $entityFactory; $this->controllerFactory = $controllerFactory; @@ -56,7 +56,13 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $field->setFormTypeOption('entry_type', $entryTypeFqcn); } - $autocompletableFormTypes = [CountryType::class, CurrencyType::class, LanguageType::class, LocaleType::class, TimezoneType::class]; + $autocompletableFormTypes = [ + CountryType::class, + CurrencyType::class, + LanguageType::class, + LocaleType::class, + TimezoneType::class, + ]; if (\in_array($entryTypeFqcn, $autocompletableFormTypes, true)) { $field->setFormTypeOption('entry_options.attr.data-ea-widget', 'ea-autocomplete'); } @@ -64,22 +70,33 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt // the contents of this field are a collection of other fields, so it cannot be sorted $field->setSortable(false); - $field->setFormTypeOptionIfNotSet('allow_add', $field->getCustomOptions()->get(CollectionField::OPTION_ALLOW_ADD)); - $field->setFormTypeOptionIfNotSet('allow_delete', $field->getCustomOptions()->get(CollectionField::OPTION_ALLOW_DELETE)); + $field->setFormTypeOptionIfNotSet( + 'allow_add', + $field->getCustomOptions()->get(CollectionField::OPTION_ALLOW_ADD) + ); + $field->setFormTypeOptionIfNotSet( + 'allow_delete', + $field->getCustomOptions()->get(CollectionField::OPTION_ALLOW_DELETE) + ); $field->setFormTypeOptionIfNotSet('by_reference', false); $field->setFormTypeOptionIfNotSet('delete_empty', true); $field->setFormTypeOptionIfNotSet('prototype_name', '__'.u($field->getProperty())->replace('.', '_').'name__'); // TODO: check why this label (hidden by default) is not working properly // (generated values are always the same for all elements) - $field->setFormTypeOptionIfNotSet('entry_options.label', $field->getCustomOptions()->get(CollectionField::OPTION_SHOW_ENTRY_LABEL)); + $field->setFormTypeOptionIfNotSet( + 'entry_options.label', + $field->getCustomOptions()->get(CollectionField::OPTION_SHOW_ENTRY_LABEL) + ); // collection items range from a simple to a complex multi-field form // the 'entryIsComplex' setting tells if the collection item is so complex that needs a special // rendering not applied to simple collection items if (null === $field->getCustomOption(CollectionField::OPTION_ENTRY_IS_COMPLEX)) { $definesEntryType = null !== $entryTypeFqcn = $field->getCustomOption(CollectionField::OPTION_ENTRY_TYPE); - $isSymfonyCoreFormType = null !== u($entryTypeFqcn ?? '')->indexOf('Symfony\Component\Form\Extension\Core\Type'); + $isSymfonyCoreFormType = null !== u($entryTypeFqcn ?? '')->indexOf( + 'Symfony\Component\Form\Extension\Core\Type' + ); $isComplexEntry = $definesEntryType && !$isSymfonyCoreFormType; $field->setCustomOption(CollectionField::OPTION_ENTRY_IS_COMPLEX, $isComplexEntry); @@ -89,11 +106,23 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt if (true === $field->getCustomOption(CollectionField::OPTION_ENTRY_USES_CRUD_FORM)) { if (!$entityDto->isAssociation($field->getProperty())) { - throw new \RuntimeException(sprintf('The "%s" collection field of "%s" cannot use the "useEntryCrudForm()" method because it is not a Doctrine association.', $field->getProperty(), $context->getCrud()?->getControllerFqcn())); + throw new \RuntimeException( + sprintf( + 'The "%s" collection field of "%s" cannot use the "useEntryCrudForm()" method because it is not a Doctrine association.', + $field->getProperty(), + $context->getCrud()?->getControllerFqcn() + ) + ); } if (null !== $field->getCustomOptions()->get(CollectionField::OPTION_ENTRY_TYPE)) { - throw new \RuntimeException(sprintf('The "%s" collection field of "%s" can render its entries using a Symfony Form (via the "setEntryType()" method) or using an EasyAdmin CRUD Form (via the "useEntryCrudForm()" method) but you cannot use both methods at the same time. Remove one of those two methods.', $field->getProperty(), $context->getCrud()?->getControllerFqcn())); + throw new \RuntimeException( + sprintf( + 'The "%s" collection field of "%s" can render its entries using a Symfony Form (via the "setEntryType()" method) or using an EasyAdmin CRUD Form (via the "useEntryCrudForm()" method) but you cannot use both methods at the same time. Remove one of those two methods.', + $field->getProperty(), + $context->getCrud()?->getControllerFqcn() + ) + ); } $field->setFormTypeOption('entry_type', CrudFormType::class); @@ -103,20 +132,47 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt ?? $context->getCrudControllers()->findCrudFqcnByEntityFqcn($targetEntityFqcn); if (null === $targetCrudControllerFqcn) { - throw new \RuntimeException(sprintf('The "%s" collection field of "%s" wants to render its entries using an EasyAdmin CRUD form. However, no CRUD form was found related to this field. You can either create a CRUD controller for the entity "%s" or pass the CRUD controller to use as the first argument of the "useEntryCrudForm()" method.', $field->getProperty(), $context->getCrud()?->getControllerFqcn(), $targetEntityFqcn)); + throw new \RuntimeException( + sprintf( + 'The "%s" collection field of "%s" wants to render its entries using an EasyAdmin CRUD form. However, no CRUD form was found related to this field. You can either create a CRUD controller for the entity "%s" or pass the CRUD controller to use as the first argument of the "useEntryCrudForm()" method.', + $field->getProperty(), + $context->getCrud()?->getControllerFqcn(), + $targetEntityFqcn + ) + ); } - $crudEditPageName = $field->getCustomOption(CollectionField::OPTION_ENTRY_CRUD_EDIT_PAGE_NAME) ?? CrudInterface::PAGE_EDIT; - $editEntityDto = $this->createEntityDto($targetEntityFqcn, $targetCrudControllerFqcn, ActionInterface::EDIT, $crudEditPageName); + $crudEditPageName = $field->getCustomOption( + CollectionField::OPTION_ENTRY_CRUD_EDIT_PAGE_NAME + ) ?? CrudInterface::PAGE_EDIT; + $editEntityDto = $this->createEntityDto( + $targetEntityFqcn, + $targetCrudControllerFqcn, + ActionInterface::EDIT, + $crudEditPageName + ); $field->setFormTypeOption('entry_options.entityDto', $editEntityDto); - $crudNewPageName = $field->getCustomOption(CollectionField::OPTION_ENTRY_CRUD_NEW_PAGE_NAME) ?? CrudInterface::PAGE_NEW; - $newEntityDto = $this->createEntityDto($targetEntityFqcn, $targetCrudControllerFqcn, ActionInterface::NEW, $crudNewPageName); + $crudNewPageName = $field->getCustomOption( + CollectionField::OPTION_ENTRY_CRUD_NEW_PAGE_NAME + ) ?? CrudInterface::PAGE_NEW; + $newEntityDto = $this->createEntityDto( + $targetEntityFqcn, + $targetCrudControllerFqcn, + ActionInterface::NEW, + $crudNewPageName + ); try { $field->setFormTypeOption('prototype_options.entityDto', $newEntityDto); } catch (UndefinedOptionsException $exception) { - throw new \RuntimeException(sprintf('The "%s" collection field of "%s" uses the "useEntryCrudForm()" method, which requires Symfony 6.1 or newer to work. Upgrade your Symfony version or use instead the "setEntryType()" method to render the collection entries using a Symfony form.', $field->getProperty(), $context->getCrud()?->getControllerFqcn()), 0, $exception); + throw new \RuntimeException( + sprintf( + 'The "%s" collection field of "%s" uses the "useEntryCrudForm()" method, which requires Symfony 6.1 or newer to work. Upgrade your Symfony version or use instead the "setEntryType()" method to render the collection entries using a Symfony form.', + $field->getProperty(), + $context->getCrud()?->getControllerFqcn() + ), 0, $exception + ); } } } @@ -134,7 +190,7 @@ private function formatCollection(FieldDtoInterface $field, AdminContext $contex return $this->countNumElements($field->getValue()); } - $collectionItemsAsText[] = (string) $item; + $collectionItemsAsText[] = (string)$item; } $isDetailAction = ActionInterface::DETAIL === $context->getCrud()->getCurrentAction(); @@ -159,8 +215,12 @@ private function countNumElements($collection): int return 0; } - private function createEntityDto(string $targetEntityFqcn, string $targetCrudControllerFqcn, string $crudAction, string $pageName): EntityDtoInterface - { + private function createEntityDto( + string $targetEntityFqcn, + string $targetCrudControllerFqcn, + string $crudAction, + string $pageName + ): EntityDtoInterface { $entityDto = $this->entityFactory->create($targetEntityFqcn); $crudController = $this->controllerFactory->getCrudControllerInstance( diff --git a/src/Field/Configurator/CommonPostConfigurator.php b/src/Field/Configurator/CommonPostConfigurator.php index 413aa09aa4..1dce34760e 100644 --- a/src/Field/Configurator/CommonPostConfigurator.php +++ b/src/Field/Configurator/CommonPostConfigurator.php @@ -2,26 +2,24 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; -use function Symfony\Component\String\u; use Twig\Markup; +use function Symfony\Component\String\u; + /** * @author Javier Eguiluz */ final class CommonPostConfigurator implements FieldConfiguratorInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; + private string $charset; public function __construct(AdminContextProviderInterface $adminContextProvider, string $charset) @@ -38,7 +36,11 @@ public function supports(FieldDtoInterface $field, EntityDtoInterface $entityDto public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDto, AdminContext $context): void { - if (\in_array($context->getCrud()->getCurrentPage(), [CrudInterface::PAGE_INDEX, CrudInterface::PAGE_DETAIL], true)) { + if (\in_array( + $context->getCrud()->getCurrentPage(), + [CrudInterface::PAGE_INDEX, CrudInterface::PAGE_DETAIL], + true + )) { $formattedValue = $this->buildFormattedValueOption($field->getFormattedValue(), $field, $entityDto); $field->setFormattedValue($formattedValue); } diff --git a/src/Field/Configurator/CommonPreConfigurator.php b/src/Field/Configurator/CommonPreConfigurator.php index 982ddad514..585fffcf07 100644 --- a/src/Field/Configurator/CommonPreConfigurator.php +++ b/src/Field/Configurator/CommonPreConfigurator.php @@ -2,26 +2,22 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactoryInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\AvatarField; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use Symfony\Component\PropertyAccess\Exception\AccessException; use Symfony\Component\PropertyAccess\Exception\UnexpectedTypeException; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; +use Symfony\Contracts\Translation\TranslatableInterface; + use function Symfony\Component\String\u; use function Symfony\Component\Translation\t; -use Symfony\Contracts\Translation\TranslatableInterface; /** * @author Javier Eguiluz @@ -29,7 +25,7 @@ final class CommonPreConfigurator implements FieldConfiguratorInterface { private PropertyAccessorInterface $propertyAccessor; - private EntityFactory $entityFactory; + private EntityFactoryInterface $entityFactory; public function __construct(PropertyAccessorInterface $propertyAccessor, EntityFactoryInterface $entityFactory) { @@ -52,7 +48,10 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $isReadable = true; if (null === $value = $field->getValue()) { try { - $value = null === $entityDto->getInstance() ? null : $this->propertyAccessor->getValue($entityDto->getInstance(), $field->getProperty()); + $value = null === $entityDto->getInstance() ? null : $this->propertyAccessor->getValue( + $entityDto->getInstance(), + $field->getProperty() + ); } catch (AccessException|UnexpectedTypeException) { $isReadable = false; } @@ -78,7 +77,9 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $templatePath = $this->buildTemplatePathOption($context, $field, $entityDto, $isReadable); $field->setTemplatePath($templatePath); - $doctrineMetadata = $entityDto->hasProperty($field->getProperty()) ? $entityDto->getPropertyMetadata($field->getProperty())->all() : []; + $doctrineMetadata = $entityDto->hasProperty($field->getProperty()) ? $entityDto->getPropertyMetadata( + $field->getProperty() + )->all() : []; $field->setDoctrineMetadata($doctrineMetadata); if (null !== $helpMessage = $this->buildHelpOption($field, $translationDomain)) { @@ -121,12 +122,17 @@ private function buildLabelOption(FieldDtoInterface $field, string $translationD return $label; } - return (null === $label || false === $label || '' === $label) ? $label : t($label, $field->getTranslationParameters(), $translationDomain); + return (null === $label || false === $label || '' === $label) ? $label : t( + $label, + $field->getTranslationParameters(), + $translationDomain + ); } // if an Avatar field doesn't define its label, don't autogenerate it for the 'index' page // (because the table of the 'index' page looks better without a header in the avatar column) - if (ActionInterface::INDEX === $currentPage && null === $field->getLabel() && AvatarField::class === $field->getFieldFqcn()) { + if (ActionInterface::INDEX === $currentPage && null === $field->getLabel( + ) && AvatarField::class === $field->getFieldFqcn()) { $field->setLabel(false); } @@ -167,8 +173,12 @@ private function buildVirtualOption(FieldDtoInterface $field, EntityDtoInterface return !$entityDto->hasProperty($field->getProperty()); } - private function buildTemplatePathOption(AdminContext $adminContext, FieldDtoInterface $field, EntityDtoInterface $entityDto, bool $isReadable): string - { + private function buildTemplatePathOption( + AdminContext $adminContext, + FieldDtoInterface $field, + EntityDtoInterface $entityDto, + bool $isReadable + ): string { if (null !== $templatePath = $field->getTemplatePath()) { return $templatePath; } @@ -179,7 +189,12 @@ private function buildTemplatePathOption(AdminContext $adminContext, FieldDtoInt } if (null === $templateName = $field->getTemplateName()) { - throw new \RuntimeException(sprintf('Fields must define either their templateName or their templatePath. None given for "%s" field.', $field->getProperty())); + throw new \RuntimeException( + sprintf( + 'Fields must define either their templateName or their templatePath. None given for "%s" field.', + $field->getProperty() + ) + ); } return $adminContext->getTemplatePath($templateName); @@ -200,7 +215,9 @@ private function buildRequiredOption(FieldDtoInterface $field, EntityDtoInterfac // If at least one join column of an association field isn't nullable then the field is "required" by default, otherwise the field is optional if ($entityDto->isAssociation($field->getProperty())) { - $associatedEntityMetadata = $this->entityFactory->getEntityMetadata($doctrinePropertyMetadata->get('targetEntity')); + $associatedEntityMetadata = $this->entityFactory->getEntityMetadata( + $doctrinePropertyMetadata->get('targetEntity') + ); foreach ($doctrinePropertyMetadata->get('joinColumns', []) as $joinColumn) { $propertyNameInAssociatedEntity = $joinColumn['referencedColumnName']; $associatedPropertyMetadata = $associatedEntityMetadata->fieldMappings[$propertyNameInAssociatedEntity] ?? []; diff --git a/src/Field/Configurator/CountryConfigurator.php b/src/Field/Configurator/CountryConfigurator.php index d0d957da66..5603827f30 100644 --- a/src/Field/Configurator/CountryConfigurator.php +++ b/src/Field/Configurator/CountryConfigurator.php @@ -2,14 +2,11 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\TextAlign; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\CountryField; use Symfony\Component\Asset\PackageInterface; @@ -37,14 +34,27 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt { $field->setFormTypeOption('attr.data-ea-widget', 'ea-autocomplete'); $countryCodeFormat = $field->getCustomOption(CountryField::OPTION_COUNTRY_CODE_FORMAT); - $field->setFormattedValue($this->getCountryNames((array) $field->getValue(), $countryCodeFormat, $context->getRequest()->getLocale())); + $field->setFormattedValue( + $this->getCountryNames((array)$field->getValue(), $countryCodeFormat, $context->getRequest()->getLocale()) + ); if (null === $field->getTextAlign() && false === $field->getCustomOption(CountryField::OPTION_SHOW_NAME)) { $field->setTextAlign(TextAlign::CENTER); } - if (\in_array($context->getCrud()->getCurrentPage(), [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], true)) { - $field->setFormTypeOption('choices', $this->generateFormTypeChoices($countryCodeFormat, $field->getCustomOption(CountryField::OPTION_COUNTRY_CODES_TO_KEEP), $field->getCustomOption(CountryField::OPTION_COUNTRY_CODES_TO_REMOVE))); + if (\in_array( + $context->getCrud()->getCurrentPage(), + [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], + true + )) { + $field->setFormTypeOption( + 'choices', + $this->generateFormTypeChoices( + $countryCodeFormat, + $field->getCustomOption(CountryField::OPTION_COUNTRY_CODES_TO_KEEP), + $field->getCustomOption(CountryField::OPTION_COUNTRY_CODES_TO_REMOVE) + ) + ); // the value of this form option must be a string to properly propagate it as an HTML attribute value $field->setFormTypeOption('attr.data-ea-autocomplete-render-items-as-html', 'true'); @@ -70,7 +80,10 @@ private function getCountryNames(?array $countryCodes, string $countryCodeFormat try { $alpha2CountryCode = $usesAlpha3Codes ? Countries::getAlpha2Code($countryCode) : $countryCode; - $countryNames[$alpha2CountryCode] = $usesAlpha3Codes ? Countries::getAlpha3Name($countryCode, $displayLocale) : Countries::getName($countryCode, $displayLocale); + $countryNames[$alpha2CountryCode] = $usesAlpha3Codes ? Countries::getAlpha3Name( + $countryCode, + $displayLocale + ) : Countries::getName($countryCode, $displayLocale); } catch (MissingResourceException) { $countryNames['UNKNOWN'] = sprintf('Unknown "%s" country code', $countryCode); } @@ -79,8 +92,11 @@ private function getCountryNames(?array $countryCodes, string $countryCodeFormat return $countryNames; } - private function generateFormTypeChoices(string $countryCodeFormat, ?array $countryCodesToKeep, ?array $countryCodesToRemove): array - { + private function generateFormTypeChoices( + string $countryCodeFormat, + ?array $countryCodesToKeep, + ?array $countryCodesToRemove + ): array { $usesAlpha3Codes = CountryField::FORMAT_ISO_3166_ALPHA3 === $countryCodeFormat; $choices = []; @@ -96,7 +112,12 @@ private function generateFormTypeChoices(string $countryCodeFormat, ?array $coun $countryCodeAlpha2 = $usesAlpha3Codes ? Countries::getAlpha2Code($countryCode) : $countryCode; $flagImagePath = $this->assetPackage->getUrl(sprintf('images/flags/%s.svg', $countryCodeAlpha2)); - $choiceKey = sprintf('
%s %s
', $flagImagePath, $countryName, $countryName); + $choiceKey = sprintf( + '
%s %s
', + $flagImagePath, + $countryName, + $countryName + ); $choices[$choiceKey] = $countryCode; } diff --git a/src/Field/Configurator/CurrencyConfigurator.php b/src/Field/Configurator/CurrencyConfigurator.php index 0e8cfdde06..af89150dcd 100644 --- a/src/Field/Configurator/CurrencyConfigurator.php +++ b/src/Field/Configurator/CurrencyConfigurator.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\CurrencyField; use Symfony\Component\Intl\Currencies; @@ -32,12 +30,24 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $currencyName = $this->getCurrencyName($currencyCode); if (null === $currencyName) { - throw new \InvalidArgumentException(sprintf('The "%s" value used as the currency code of the "%s" field is not a valid ICU currency code.', $currencyCode, $field->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" value used as the currency code of the "%s" field is not a valid ICU currency code.', + $currencyCode, + $field->getProperty() + ) + ); } $currencySymbol = $this->getCurrencySymbol($currencyCode); if (null === $currencySymbol) { - throw new \InvalidArgumentException(sprintf('The "%s" value used as the currency code of the "%s" field has no valid ICU currency symbol associated to it.', $currencyCode, $field->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" value used as the currency code of the "%s" field has no valid ICU currency symbol associated to it.', + $currencyCode, + $field->getProperty() + ) + ); } $field->setFormattedValue([ diff --git a/src/Field/Configurator/DateTimeConfigurator.php b/src/Field/Configurator/DateTimeConfigurator.php index ab36b1a3e2..39e61b1fc8 100644 --- a/src/Field/Configurator/DateTimeConfigurator.php +++ b/src/Field/Configurator/DateTimeConfigurator.php @@ -5,14 +5,11 @@ use Doctrine\DBAL\Types\Types; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\DateField; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField; -use EasyCorp\Bundle\EasyAdminBundle\Intl\IntlFormatter; use EasyCorp\Bundle\EasyAdminBundle\Intl\IntlFormatterInterface; /** @@ -20,7 +17,7 @@ */ final class DateTimeConfigurator implements FieldConfiguratorInterface { - private IntlFormatter $intlFormatter; + private IntlFormatterInterface $intlFormatter; public function __construct(IntlFormatterInterface $intlFormatter) { @@ -37,7 +34,9 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt // we don't require this PHP extension in composer.json because it's not mandatory to display // date/time fields in backends, so this is not a hard dependency if (!\extension_loaded('intl')) { - throw new \LogicException('When using date/time fields in EasyAdmin backends, you must install and enable the PHP Intl extension, which is used to format date/time values.'); + throw new \LogicException( + 'When using date/time fields in EasyAdmin backends, you must install and enable the PHP Intl extension, which is used to format date/time values.' + ); } $crud = $context->getCrud(); @@ -61,7 +60,13 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $icuDateTimePattern = $datePattern; } - $formattedValue = $this->intlFormatter->formatDateTime($field->getValue(), $dateFormat, $timeFormat, $icuDateTimePattern, $timezone); + $formattedValue = $this->intlFormatter->formatDateTime( + $field->getValue(), + $dateFormat, + $timeFormat, + $icuDateTimePattern, + $timezone + ); } elseif (DateField::class === $field->getFieldFqcn()) { $dateFormatOrPattern = $field->getCustomOption(DateField::OPTION_DATE_PATTERN) ?? $crud->getDatePattern(); if (\in_array($dateFormatOrPattern, DateTimeField::VALID_DATE_FORMATS, true)) { @@ -70,7 +75,12 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $icuDateTimePattern = $dateFormatOrPattern; } - $formattedValue = $this->intlFormatter->formatDate($field->getValue(), $dateFormat, $icuDateTimePattern, $timezone); + $formattedValue = $this->intlFormatter->formatDate( + $field->getValue(), + $dateFormat, + $icuDateTimePattern, + $timezone + ); } elseif (TimeField::class === $field->getFieldFqcn()) { $timeFormatOrPattern = $field->getCustomOption(TimeField::OPTION_TIME_PATTERN) ?? $crud->getTimePattern(); if (\in_array($timeFormatOrPattern, DateTimeField::VALID_DATE_FORMATS, true)) { @@ -79,7 +89,12 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $icuDateTimePattern = $timeFormatOrPattern; } - $formattedValue = $this->intlFormatter->formatTime($field->getValue(), $timeFormat, $icuDateTimePattern, $timezone); + $formattedValue = $this->intlFormatter->formatTime( + $field->getValue(), + $timeFormat, + $icuDateTimePattern, + $timezone + ); } $widgetOption = $field->getCustomOption(DateTimeField::OPTION_WIDGET); @@ -101,7 +116,11 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt return; } $doctrineDataType = $entityDto->getPropertyMetadata($field->getProperty())->get('type'); - $isImmutableDateTime = \in_array($doctrineDataType, [Types::DATETIMETZ_IMMUTABLE, Types::DATETIME_IMMUTABLE, Types::DATE_IMMUTABLE, Types::TIME_IMMUTABLE], true); + $isImmutableDateTime = \in_array( + $doctrineDataType, + [Types::DATETIMETZ_IMMUTABLE, Types::DATETIME_IMMUTABLE, Types::DATE_IMMUTABLE, Types::TIME_IMMUTABLE], + true + ); if ($isImmutableDateTime) { $field->setFormTypeOptionIfNotSet('input', 'datetime_immutable'); } diff --git a/src/Field/Configurator/EmailConfigurator.php b/src/Field/Configurator/EmailConfigurator.php index f2d8606f8a..c27ab92549 100644 --- a/src/Field/Configurator/EmailConfigurator.php +++ b/src/Field/Configurator/EmailConfigurator.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField; diff --git a/src/Field/Configurator/FormConfigurator.php b/src/Field/Configurator/FormConfigurator.php index f8185fd9af..19a0adf59b 100644 --- a/src/Field/Configurator/FormConfigurator.php +++ b/src/Field/Configurator/FormConfigurator.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\EaFormRowType; diff --git a/src/Field/Configurator/IdConfigurator.php b/src/Field/Configurator/IdConfigurator.php index 8423871330..363f3de9ce 100644 --- a/src/Field/Configurator/IdConfigurator.php +++ b/src/Field/Configurator/IdConfigurator.php @@ -2,15 +2,13 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; + use function Symfony\Component\String\u; /** diff --git a/src/Field/Configurator/ImageConfigurator.php b/src/Field/Configurator/ImageConfigurator.php index f8195b5df7..0d8443e69b 100644 --- a/src/Field/Configurator/ImageConfigurator.php +++ b/src/Field/Configurator/ImageConfigurator.php @@ -2,15 +2,13 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField; + use function Symfony\Component\String\u; /** @@ -39,22 +37,38 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt : $this->getImagePath($field->getValue(), $configuredBasePath); $field->setFormattedValue($formattedValue); - $field->setFormTypeOption('upload_filename', $field->getCustomOption(ImageField::OPTION_UPLOADED_FILE_NAME_PATTERN)); + $field->setFormTypeOption( + 'upload_filename', + $field->getCustomOption(ImageField::OPTION_UPLOADED_FILE_NAME_PATTERN) + ); // this check is needed to avoid displaying broken images when image properties are optional - if (null === $formattedValue || '' === $formattedValue || (\is_array($formattedValue) && 0 === \count($formattedValue)) || $formattedValue === rtrim($configuredBasePath ?? '', '/')) { + if (null === $formattedValue || '' === $formattedValue || (\is_array($formattedValue) && 0 === \count( + $formattedValue + )) || $formattedValue === rtrim($configuredBasePath ?? '', '/')) { $field->setTemplateName('label/empty'); } - if (!\in_array($context->getCrud()->getCurrentPage(), [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], true)) { + if (!\in_array( + $context->getCrud()->getCurrentPage(), + [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], + true + )) { return; } $relativeUploadDir = $field->getCustomOption(ImageField::OPTION_UPLOAD_DIR); if (null === $relativeUploadDir) { - throw new \InvalidArgumentException(sprintf('The "%s" image field must define the directory where the images are uploaded using the setUploadDir() method.', $field->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" image field must define the directory where the images are uploaded using the setUploadDir() method.', + $field->getProperty() + ) + ); } - $relativeUploadDir = u($relativeUploadDir)->trimStart(\DIRECTORY_SEPARATOR)->ensureEnd(\DIRECTORY_SEPARATOR)->toString(); + $relativeUploadDir = u($relativeUploadDir)->trimStart(\DIRECTORY_SEPARATOR)->ensureEnd( + \DIRECTORY_SEPARATOR + )->toString(); $isStreamWrapper = filter_var($relativeUploadDir, \FILTER_VALIDATE_URL); if ($isStreamWrapper) { $absoluteUploadDir = $relativeUploadDir; diff --git a/src/Field/Configurator/IntegerConfigurator.php b/src/Field/Configurator/IntegerConfigurator.php index 4508c2ac60..c3886d9d90 100644 --- a/src/Field/Configurator/IntegerConfigurator.php +++ b/src/Field/Configurator/IntegerConfigurator.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; diff --git a/src/Field/Configurator/LanguageConfigurator.php b/src/Field/Configurator/LanguageConfigurator.php index ab7fb41d10..c7fae16a54 100644 --- a/src/Field/Configurator/LanguageConfigurator.php +++ b/src/Field/Configurator/LanguageConfigurator.php @@ -2,13 +2,10 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\LanguageField; use Symfony\Component\Intl\Exception\MissingResourceException; @@ -31,11 +28,18 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $languageCodeFormat = $field->getCustomOption(LanguageField::OPTION_LANGUAGE_CODE_FORMAT); $usesAlpha3Codes = LanguageField::FORMAT_ISO_639_ALPHA3 === $languageCodeFormat; - if (\in_array($context->getCrud()->getCurrentPage(), [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], true)) { - $field->setFormTypeOption('choices', $this->generateFormTypeChoices( - $usesAlpha3Codes, - $field->getCustomOption(LanguageField::OPTION_LANGUAGE_CODES_TO_KEEP), - $field->getCustomOption(LanguageField::OPTION_LANGUAGE_CODES_TO_REMOVE)) + if (\in_array( + $context->getCrud()->getCurrentPage(), + [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], + true + )) { + $field->setFormTypeOption( + 'choices', + $this->generateFormTypeChoices( + $usesAlpha3Codes, + $field->getCustomOption(LanguageField::OPTION_LANGUAGE_CODES_TO_KEEP), + $field->getCustomOption(LanguageField::OPTION_LANGUAGE_CODES_TO_REMOVE) + ) ); $field->setFormTypeOption('choice_loader', null); } @@ -46,7 +50,13 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $languageName = $this->getLanguageName($languageCode, $usesAlpha3Codes); if (null === $languageName) { - throw new \InvalidArgumentException(sprintf('The "%s" value used as the language code of the "%s" field is not a valid ICU language code.', $languageCode, $field->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" value used as the language code of the "%s" field is not a valid ICU language code.', + $languageCode, + $field->getProperty() + ) + ); } $field->setFormattedValue($languageName); @@ -61,8 +71,11 @@ private function getLanguageName(string $languageCode, bool $usesAlpha3Codes): ? } } - private function generateFormTypeChoices(bool $usesAlpha3Codes, ?array $languageCodesToKeep, ?array $languageCodesToRemove): array - { + private function generateFormTypeChoices( + bool $usesAlpha3Codes, + ?array $languageCodesToKeep, + ?array $languageCodesToRemove + ): array { $choices = []; $languages = $usesAlpha3Codes ? Languages::getAlpha3Names() : Languages::getNames(); diff --git a/src/Field/Configurator/LocaleConfigurator.php b/src/Field/Configurator/LocaleConfigurator.php index 2ded941764..98867f4380 100644 --- a/src/Field/Configurator/LocaleConfigurator.php +++ b/src/Field/Configurator/LocaleConfigurator.php @@ -2,13 +2,10 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\LocaleField; use Symfony\Component\Intl\Exception\MissingResourceException; @@ -28,8 +25,18 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt { $field->setFormTypeOptionIfNotSet('attr.data-ea-widget', 'ea-autocomplete'); - if (\in_array($context->getCrud()->getCurrentPage(), [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], true)) { - $field->setFormTypeOption('choices', $this->generateFormTypeChoices($field->getCustomOption(LocaleField::OPTION_LOCALE_CODES_TO_KEEP), $field->getCustomOption(LocaleField::OPTION_LOCALE_CODES_TO_REMOVE))); + if (\in_array( + $context->getCrud()->getCurrentPage(), + [CrudInterface::PAGE_EDIT, CrudInterface::PAGE_NEW], + true + )) { + $field->setFormTypeOption( + 'choices', + $this->generateFormTypeChoices( + $field->getCustomOption(LocaleField::OPTION_LOCALE_CODES_TO_KEEP), + $field->getCustomOption(LocaleField::OPTION_LOCALE_CODES_TO_REMOVE) + ) + ); $field->setFormTypeOption('choice_loader', null); } @@ -39,7 +46,13 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $localeName = $this->getLocaleName($localeCode); if (null === $localeName) { - throw new \InvalidArgumentException(sprintf('The "%s" value used as the locale code of the "%s" field is not a valid ICU locale code.', $localeCode, $field->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" value used as the locale code of the "%s" field is not a valid ICU locale code.', + $localeCode, + $field->getProperty() + ) + ); } $field->setFormattedValue($localeName); diff --git a/src/Field/Configurator/MoneyConfigurator.php b/src/Field/Configurator/MoneyConfigurator.php index ac62340a9a..80a9e970f1 100644 --- a/src/Field/Configurator/MoneyConfigurator.php +++ b/src/Field/Configurator/MoneyConfigurator.php @@ -4,12 +4,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField; -use EasyCorp\Bundle\EasyAdminBundle\Intl\IntlFormatter; use EasyCorp\Bundle\EasyAdminBundle\Intl\IntlFormatterInterface; use Symfony\Component\Intl\Currencies; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; @@ -19,7 +16,7 @@ */ final class MoneyConfigurator implements FieldConfiguratorInterface { - private IntlFormatter $intlFormatter; + private IntlFormatterInterface $intlFormatter; private PropertyAccessorInterface $propertyAccessor; public function __construct(IntlFormatterInterface $intlFormatter, PropertyAccessorInterface $propertyAccessor) @@ -37,7 +34,13 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt { $currencyCode = $this->getCurrency($field, $entityDto); if (null !== $currencyCode && !Currencies::exists($currencyCode)) { - throw new \InvalidArgumentException(sprintf('The "%s" value used as the currency of the "%s" money field is not a valid ICU currency code.', $currencyCode, $field->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" value used as the currency of the "%s" money field is not a valid ICU currency code.', + $currencyCode, + $field->getProperty() + ) + ); } $field->setFormTypeOption('currency', $currencyCode); @@ -53,7 +56,11 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt $amount = $isStoredAsCents ? $field->getValue() / 100 : $field->getValue(); - $formattedValue = $this->intlFormatter->formatCurrency($amount, $currencyCode, ['fraction_digit' => $numDecimals]); + $formattedValue = $this->intlFormatter->formatCurrency( + $amount, + $currencyCode, + ['fraction_digit' => $numDecimals] + ); $field->setFormattedValue($formattedValue); } @@ -64,7 +71,9 @@ private function getCurrency(FieldDtoInterface $field, EntityDtoInterface $entit } if (null === $currencyPropertyPath = $field->getCustomOption(MoneyField::OPTION_CURRENCY_PROPERTY_PATH)) { - throw new \InvalidArgumentException(sprintf('You must define the currency for the "%s" money field.', $field->getProperty())); + throw new \InvalidArgumentException( + sprintf('You must define the currency for the "%s" money field.', $field->getProperty()) + ); } if (null === $field->getValue()) { @@ -72,13 +81,30 @@ private function getCurrency(FieldDtoInterface $field, EntityDtoInterface $entit } $entityInstance = $entityDto->getInstance(); - $isPropertyReadable = (null !== $entityInstance) && $this->propertyAccessor->isReadable($entityInstance, $currencyPropertyPath); + $isPropertyReadable = (null !== $entityInstance) && $this->propertyAccessor->isReadable( + $entityInstance, + $currencyPropertyPath + ); if (!$isPropertyReadable) { - throw new \InvalidArgumentException(sprintf('The "%s" field path used by the "%s" field to get the currency value from the "%s" entity is not readable.', $currencyPropertyPath, $field->getProperty(), $entityDto->getName())); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" field path used by the "%s" field to get the currency value from the "%s" entity is not readable.', + $currencyPropertyPath, + $field->getProperty(), + $entityDto->getName() + ) + ); } if (null === $currencyCode = $this->propertyAccessor->getValue($entityInstance, $currencyPropertyPath)) { - throw new \InvalidArgumentException(sprintf('The currency value for the "%s" field cannot be null, but that\'s the value returned by the "%s" field path applied on the "%s" entity.', $field->getProperty(), $currencyPropertyPath, $entityDto->getName())); + throw new \InvalidArgumentException( + sprintf( + 'The currency value for the "%s" field cannot be null, but that\'s the value returned by the "%s" field path applied on the "%s" entity.', + $field->getProperty(), + $currencyPropertyPath, + $entityDto->getName() + ) + ); } return $currencyCode; diff --git a/src/Field/Configurator/NumberConfigurator.php b/src/Field/Configurator/NumberConfigurator.php index 53c321678c..929e7fa9e4 100644 --- a/src/Field/Configurator/NumberConfigurator.php +++ b/src/Field/Configurator/NumberConfigurator.php @@ -4,12 +4,9 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; -use EasyCorp\Bundle\EasyAdminBundle\Intl\IntlFormatter; use EasyCorp\Bundle\EasyAdminBundle\Intl\IntlFormatterInterface; /** @@ -17,7 +14,7 @@ */ final class NumberConfigurator implements FieldConfiguratorInterface { - private IntlFormatter $intlFormatter; + private IntlFormatterInterface $intlFormatter; public function __construct(IntlFormatterInterface $intlFormatter) { diff --git a/src/Field/Configurator/PercentConfigurator.php b/src/Field/Configurator/PercentConfigurator.php index a6ca0e41fe..8ee59c7966 100644 --- a/src/Field/Configurator/PercentConfigurator.php +++ b/src/Field/Configurator/PercentConfigurator.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\PercentField; diff --git a/src/Field/Configurator/SlugConfigurator.php b/src/Field/Configurator/SlugConfigurator.php index ad8aa834dc..c3396c5656 100644 --- a/src/Field/Configurator/SlugConfigurator.php +++ b/src/Field/Configurator/SlugConfigurator.php @@ -4,14 +4,13 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\SlugField; -use function Symfony\Component\Translation\t; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\Translation\t; + /** * @author Javier Eguiluz */ @@ -24,16 +23,27 @@ public function supports(FieldDtoInterface $field, EntityDtoInterface $entityDto public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDto, AdminContext $context): void { - $targetFieldNames = (array) $field->getCustomOption(SlugField::OPTION_TARGET_FIELD_NAME); + $targetFieldNames = (array)$field->getCustomOption(SlugField::OPTION_TARGET_FIELD_NAME); if ([] === $targetFieldNames) { - throw new \RuntimeException(sprintf('The "%s" field must define the name(s) of the field(s) whose contents are used for the slug using the "setTargetFieldName()" method.', $field->getProperty())); + throw new \RuntimeException( + sprintf( + 'The "%s" field must define the name(s) of the field(s) whose contents are used for the slug using the "setTargetFieldName()" method.', + $field->getProperty() + ) + ); } $field->setFormTypeOption('target', implode('|', $targetFieldNames)); - if (null !== $unlockConfirmationMessage = $field->getCustomOption(SlugField::OPTION_UNLOCK_CONFIRMATION_MESSAGE)) { + if (null !== $unlockConfirmationMessage = $field->getCustomOption( + SlugField::OPTION_UNLOCK_CONFIRMATION_MESSAGE + )) { if (!$unlockConfirmationMessage instanceof TranslatableInterface) { - $unlockConfirmationMessage = t($unlockConfirmationMessage, [], $context->getI18n()->getTranslationDomain()); + $unlockConfirmationMessage = t( + $unlockConfirmationMessage, + [], + $context->getI18n()->getTranslationDomain() + ); } $field->setFormTypeOption('attr.data-confirm-text', $unlockConfirmationMessage); diff --git a/src/Field/Configurator/TelephoneConfigurator.php b/src/Field/Configurator/TelephoneConfigurator.php index 50126087ea..dd8d540c06 100644 --- a/src/Field/Configurator/TelephoneConfigurator.php +++ b/src/Field/Configurator/TelephoneConfigurator.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\TelephoneField; diff --git a/src/Field/Configurator/TextConfigurator.php b/src/Field/Configurator/TextConfigurator.php index ef1e5f8e93..785004a0b3 100644 --- a/src/Field/Configurator/TextConfigurator.php +++ b/src/Field/Configurator/TextConfigurator.php @@ -2,16 +2,14 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; + use function Symfony\Component\String\u; /** @@ -36,17 +34,23 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt } if (!\is_string($value) && !(\is_object($value) && method_exists($value, '__toString'))) { - throw new \RuntimeException(sprintf('The value of the "%s" field of the entity with ID = "%s" can\'t be converted into a string, so it cannot be represented by a TextField or a TextareaField.', $field->getProperty(), $entityDto->getPrimaryKeyValue())); + throw new \RuntimeException( + sprintf( + 'The value of the "%s" field of the entity with ID = "%s" can\'t be converted into a string, so it cannot be represented by a TextField or a TextareaField.', + $field->getProperty(), + $entityDto->getPrimaryKeyValue() + ) + ); } $renderAsHtml = true === $field->getCustomOption(TextField::OPTION_RENDER_AS_HTML); $stripTags = true === $field->getCustomOption(TextField::OPTION_STRIP_TAGS); if ($renderAsHtml) { - $formattedValue = (string) $field->getValue(); + $formattedValue = (string)$field->getValue(); } elseif ($stripTags) { - $formattedValue = strip_tags((string) $field->getValue()); + $formattedValue = strip_tags((string)$field->getValue()); } else { - $formattedValue = htmlspecialchars((string) $field->getValue(), \ENT_NOQUOTES, null, false); + $formattedValue = htmlspecialchars((string)$field->getValue(), \ENT_NOQUOTES, null, false); } $configuredMaxLength = $field->getCustomOption(TextField::OPTION_MAX_LENGTH); diff --git a/src/Field/Configurator/TextEditorConfigurator.php b/src/Field/Configurator/TextEditorConfigurator.php index 3bb07c324d..36c198b82f 100644 --- a/src/Field/Configurator/TextEditorConfigurator.php +++ b/src/Field/Configurator/TextEditorConfigurator.php @@ -5,9 +5,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Asset; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; diff --git a/src/Field/Configurator/TimezoneConfigurator.php b/src/Field/Configurator/TimezoneConfigurator.php index 3abf764647..911f49794e 100644 --- a/src/Field/Configurator/TimezoneConfigurator.php +++ b/src/Field/Configurator/TimezoneConfigurator.php @@ -4,9 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\TimezoneField; diff --git a/src/Field/Configurator/UrlConfigurator.php b/src/Field/Configurator/UrlConfigurator.php index 7b4e1dd3bd..cdac4de9fb 100644 --- a/src/Field/Configurator/UrlConfigurator.php +++ b/src/Field/Configurator/UrlConfigurator.php @@ -2,15 +2,13 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field\Configurator; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField; + use function Symfony\Component\String\u; /** @@ -27,7 +25,9 @@ public function configure(FieldDtoInterface $field, EntityDtoInterface $entityDt { $field->setFormTypeOptionIfNotSet('attr.inputmode', 'url'); - $prettyUrl = str_replace(['http://www.', 'https://www.', 'http://', 'https://'], '', (string) $field->getValue()); + $prettyUrl = str_replace(['http://www.', 'https://www.', 'http://', 'https://'], + '', + (string)$field->getValue()); $prettyUrl = rtrim($prettyUrl, '/'); if (ActionInterface::INDEX === $context->getCrud()->getCurrentAction()) { diff --git a/src/Field/CountryField.php b/src/Field/CountryField.php index 09c73c48f4..a435cc711b 100644 --- a/src/Field/CountryField.php +++ b/src/Field/CountryField.php @@ -59,7 +59,10 @@ public function showName(bool $isShown = true): self public function useAlpha3Codes(bool $useAlpha3 = true): self { - $this->setCustomOption(self::OPTION_COUNTRY_CODE_FORMAT, $useAlpha3 ? self::FORMAT_ISO_3166_ALPHA3 : self::FORMAT_ISO_3166_ALPHA2); + $this->setCustomOption( + self::OPTION_COUNTRY_CODE_FORMAT, + $useAlpha3 ? self::FORMAT_ISO_3166_ALPHA3 : self::FORMAT_ISO_3166_ALPHA2 + ); return $this; } diff --git a/src/Field/DateField.php b/src/Field/DateField.php index df213330f8..41cc41e46f 100644 --- a/src/Field/DateField.php +++ b/src/Field/DateField.php @@ -40,7 +40,12 @@ public static function new(string $propertyName, $label = null): self public function setTimezone(string $timezoneId): self { if (!\in_array($timezoneId, timezone_identifiers_list(), true)) { - throw new \InvalidArgumentException(sprintf('The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', $timezoneId)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', + $timezoneId + ) + ); } $this->setCustomOption(DateTimeField::OPTION_TIMEZONE, $timezoneId); @@ -56,10 +61,17 @@ public function setFormat(string $dateFormatOrPattern): self if (DateTimeField::FORMAT_NONE === $dateFormatOrPattern || '' === trim($dateFormatOrPattern)) { $validDateFormatsWithoutNone = array_filter( DateTimeField::VALID_DATE_FORMATS, - static fn (string $format): bool => DateTimeField::FORMAT_NONE !== $format + static fn(string $format): bool => DateTimeField::FORMAT_NONE !== $format ); - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method cannot be "%s" or an empty string. Use either the special date formats (%s) or a datetime Intl pattern.', __METHOD__, DateTimeField::FORMAT_NONE, implode(', ', $validDateFormatsWithoutNone))); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s()" method cannot be "%s" or an empty string. Use either the special date formats (%s) or a datetime Intl pattern.', + __METHOD__, + DateTimeField::FORMAT_NONE, + implode(', ', $validDateFormatsWithoutNone) + ) + ); } $this->setCustomOption(self::OPTION_DATE_PATTERN, $dateFormatOrPattern); diff --git a/src/Field/DateTimeField.php b/src/Field/DateTimeField.php index 4d573d0773..be6c1281a6 100644 --- a/src/Field/DateTimeField.php +++ b/src/Field/DateTimeField.php @@ -19,7 +19,13 @@ final class DateTimeField implements FieldInterface public const FORMAT_SHORT = 'short'; public const FORMAT_NONE = 'none'; - public const VALID_DATE_FORMATS = [self::FORMAT_NONE, self::FORMAT_SHORT, self::FORMAT_MEDIUM, self::FORMAT_LONG, self::FORMAT_FULL]; + public const VALID_DATE_FORMATS = [ + self::FORMAT_NONE, + self::FORMAT_SHORT, + self::FORMAT_MEDIUM, + self::FORMAT_LONG, + self::FORMAT_FULL, + ]; public const INTL_DATE_PATTERNS = [ self::FORMAT_FULL => 'EEEE, MMMM d, y', @@ -71,7 +77,12 @@ public static function new(string $propertyName, $label = null): self public function setTimezone(string $timezoneId): self { if (!\in_array($timezoneId, timezone_identifiers_list(), true)) { - throw new \InvalidArgumentException(sprintf('The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', $timezoneId)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', + $timezoneId + ) + ); } $this->setCustomOption(self::OPTION_TIMEZONE, $timezoneId); @@ -81,18 +92,30 @@ public function setTimezone(string $timezoneId): self /** * @param string $dateFormatOrPattern A format name ('none', 'short', 'medium', 'long', 'full') or a valid ICU Datetime Pattern (see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#formatting-dates) - * @param string $timeFormat A format name ('none', 'short', 'medium', 'long', 'full') + * @param string $timeFormat A format name ('none', 'short', 'medium', 'long', 'full') */ public function setFormat(string $dateFormatOrPattern, string $timeFormat = self::FORMAT_NONE): self { if ('' === trim($dateFormatOrPattern)) { - throw new \InvalidArgumentException(sprintf('The first argument of the "%s()" method cannot be an empty string. Use either a date format (%s) or a datetime Intl pattern.', __METHOD__, implode(', ', self::VALID_DATE_FORMATS))); + throw new \InvalidArgumentException( + sprintf( + 'The first argument of the "%s()" method cannot be an empty string. Use either a date format (%s) or a datetime Intl pattern.', + __METHOD__, + implode(', ', self::VALID_DATE_FORMATS) + ) + ); } $datePatternIsEmpty = self::FORMAT_NONE === $dateFormatOrPattern; $timePatternIsEmpty = self::FORMAT_NONE === $timeFormat || '' === trim($timeFormat); if ($datePatternIsEmpty && $timePatternIsEmpty) { - throw new \InvalidArgumentException(sprintf('The values of the arguments of "%s()" cannot be "%s" or an empty string at the same time. Change any of them (or both).', __METHOD__, self::FORMAT_NONE)); + throw new \InvalidArgumentException( + sprintf( + 'The values of the arguments of "%s()" cannot be "%s" or an empty string at the same time. Change any of them (or both).', + __METHOD__, + self::FORMAT_NONE + ) + ); } // when date format/pattern is none and time format is a pattern, @@ -105,11 +128,22 @@ public function setFormat(string $dateFormatOrPattern, string $timeFormat = self $isDatePattern = !\in_array($dateFormatOrPattern, self::VALID_DATE_FORMATS, true); if ($isDatePattern && self::FORMAT_NONE !== $timeFormat) { - throw new \InvalidArgumentException(sprintf('When the first argument of "%s()" is a datetime pattern, you cannot set the time format in the second argument (define the time format inside the datetime pattern).', __METHOD__)); + throw new \InvalidArgumentException( + sprintf( + 'When the first argument of "%s()" is a datetime pattern, you cannot set the time format in the second argument (define the time format inside the datetime pattern).', + __METHOD__ + ) + ); } if (!$isDatePattern && !\in_array($timeFormat, self::VALID_DATE_FORMATS, true)) { - throw new \InvalidArgumentException(sprintf('The value of the time format can only be one of the following: %s (but "%s" was given).', implode(', ', self::VALID_DATE_FORMATS), $timeFormat)); + throw new \InvalidArgumentException( + sprintf( + 'The value of the time format can only be one of the following: %s (but "%s" was given).', + implode(', ', self::VALID_DATE_FORMATS), + $timeFormat + ) + ); } $this->setCustomOption(self::OPTION_DATE_PATTERN, $dateFormatOrPattern); diff --git a/src/Field/FieldTrait.php b/src/Field/FieldTrait.php index 8f66ab2d08..fd89411998 100644 --- a/src/Field/FieldTrait.php +++ b/src/Field/FieldTrait.php @@ -2,9 +2,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Field; -use EasyCorp\Bundle\EasyAdminBundle\Config\Asset; use EasyCorp\Bundle\EasyAdminBundle\Config\AssetInterface; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\TextAlign; @@ -153,7 +151,13 @@ public function setTextAlign(string $textAlign): self { $validOptions = [TextAlign::LEFT, TextAlign::CENTER, TextAlign::RIGHT]; if (!\in_array($textAlign, $validOptions, true)) { - throw new \InvalidArgumentException(sprintf('The value of the "textAlign" option can only be one of these: "%s" ("%s" was given).', implode(',', $validOptions), $textAlign)); + throw new \InvalidArgumentException( + sprintf( + 'The value of the "textAlign" option can only be one of these: "%s" ("%s" was given).', + implode(',', $validOptions), + $textAlign + ) + ); } $this->dto->setTextAlign($textAlign); @@ -217,7 +221,9 @@ public function addFormTheme(string ...$formThemePaths): self public function addWebpackEncoreEntries(AssetInterface|string ...$entryNamesOrAssets): self { if (!class_exists('Symfony\\WebpackEncoreBundle\\Twig\\EntryFilesTwigExtension')) { - throw new \RuntimeException('You are trying to add Webpack Encore entries in a field but Webpack Encore is not installed in your project. Try running "composer require symfony/webpack-encore-bundle"'); + throw new \RuntimeException( + 'You are trying to add Webpack Encore entries in a field but Webpack Encore is not installed in your project. Try running "composer require symfony/webpack-encore-bundle"' + ); } foreach ($entryNamesOrAssets as $entryNameOrAsset) { @@ -349,10 +355,12 @@ public function onlyOnDetail(): self public function onlyOnForms(): self { - $this->dto->setDisplayedOn(KeyValueStore::new([ - CrudInterface::PAGE_NEW => CrudInterface::PAGE_NEW, - CrudInterface::PAGE_EDIT => CrudInterface::PAGE_EDIT, - ])); + $this->dto->setDisplayedOn( + KeyValueStore::new([ + CrudInterface::PAGE_NEW => CrudInterface::PAGE_NEW, + CrudInterface::PAGE_EDIT => CrudInterface::PAGE_EDIT, + ]) + ); return $this; } diff --git a/src/Field/FormField.php b/src/Field/FormField.php index 2a72ac5454..6490b7081c 100644 --- a/src/Field/FormField.php +++ b/src/Field/FormField.php @@ -22,9 +22,9 @@ final class FormField implements FieldInterface public const OPTION_ROW_BREAKPOINT = 'rowBreakPoint'; /** + * @param string|false|null $label * @internal Use the other named constructors instead (addPanel(), etc.) * - * @param string|false|null $label */ public static function new(string $propertyName, $label = null) { @@ -33,7 +33,7 @@ public static function new(string $propertyName, $label = null) /** * @param TranslatableInterface|string|false|null $label - * @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free) + * @param string|null $icon The full CSS classes of the FontAwesome icon to render (see https://fontawesome.com/v6/search?m=free) */ public static function addPanel($label = false, ?string $icon = null): self { @@ -64,7 +64,13 @@ public static function addRow(string $breakpointName = ''): self $validBreakpointNames = ['', 'sm', 'md', 'lg', 'xl', 'xxl']; if (!\in_array($breakpointName, $validBreakpointNames, true)) { - throw new \InvalidArgumentException(sprintf('The value passed to the "addRow()" method of "FormField" can only be one of these values: "%s" ("%s" was given).', implode(', ', $validBreakpointNames), $breakpointName)); + throw new \InvalidArgumentException( + sprintf( + 'The value passed to the "addRow()" method of "FormField" can only be one of these values: "%s" ("%s" was given).', + implode(', ', $validBreakpointNames), + $breakpointName + ) + ); } return $field @@ -109,7 +115,12 @@ public function setIcon(string $iconCssClass): self public function collapsible(bool $collapsible = true): self { if (!$this->hasLabelOrIcon()) { - throw new \InvalidArgumentException(sprintf('The %s() method used in one of your panels requires that the panel defines either a label or an icon, but it defines none of them.', __METHOD__)); + throw new \InvalidArgumentException( + sprintf( + 'The %s() method used in one of your panels requires that the panel defines either a label or an icon, but it defines none of them.', + __METHOD__ + ) + ); } $this->setCustomOption(self::OPTION_COLLAPSIBLE, $collapsible); @@ -120,7 +131,12 @@ public function collapsible(bool $collapsible = true): self public function renderCollapsed(bool $collapsed = true): self { if (!$this->hasLabelOrIcon()) { - throw new \InvalidArgumentException(sprintf('The %s() method used in one of your panels requires that the panel defines either a label or an icon, but it defines none of them.', __METHOD__)); + throw new \InvalidArgumentException( + sprintf( + 'The %s() method used in one of your panels requires that the panel defines either a label or an icon, but it defines none of them.', + __METHOD__ + ) + ); } $this->setCustomOption(self::OPTION_COLLAPSIBLE, true); @@ -143,7 +159,12 @@ private function fixIconFormat(?string $icon, string $methodName): ?string } if (!str_contains($icon, 'fa-') && !str_contains($icon, 'far-') && !str_contains($icon, 'fab-')) { - trigger_deprecation('easycorp/easyadmin-bundle', '4.4.0', 'The value passed as the $icon argument in "%s" method must be the full FontAwesome CSS class of the icon. For example, if you passed "user" before, you now must pass "fa fa-user" (or any style variant like "fa fa-solid fa-user").', $methodName); + trigger_deprecation( + 'easycorp/easyadmin-bundle', + '4.4.0', + 'The value passed as the $icon argument in "%s" method must be the full FontAwesome CSS class of the icon. For example, if you passed "user" before, you now must pass "fa fa-user" (or any style variant like "fa fa-solid fa-user").', + $methodName + ); $icon = sprintf('fa fa-%s', $icon); } diff --git a/src/Field/IdField.php b/src/Field/IdField.php index 2f2cced6e1..828c21e231 100644 --- a/src/Field/IdField.php +++ b/src/Field/IdField.php @@ -36,7 +36,13 @@ public static function new(string $propertyName, $label = null): self public function setMaxLength(int $length): self { if (0 === $length) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be a positive integer or -1 (for unlimited length) (%d given).', __METHOD__, $length)); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s()" method must be a positive integer or -1 (for unlimited length) (%d given).', + __METHOD__, + $length + ) + ); } $this->setCustomOption(self::OPTION_MAX_LENGTH, $length); diff --git a/src/Field/ImageField.php b/src/Field/ImageField.php index 1ca2fe85ad..4b1dfe81da 100644 --- a/src/Field/ImageField.php +++ b/src/Field/ImageField.php @@ -30,7 +30,10 @@ public static function new(string $propertyName, $label = null): self ->setTemplateName('crud/field/image') ->setFormType(FileUploadType::class) ->addCssClass('field-image') - ->addJsFiles(Asset::fromEasyAdminAssetPackage('field-image.js'), Asset::fromEasyAdminAssetPackage('field-file-upload.js')) + ->addJsFiles( + Asset::fromEasyAdminAssetPackage('field-image.js'), + Asset::fromEasyAdminAssetPackage('field-file-upload.js') + ) ->setDefaultColumns('col-md-7 col-xxl-5') ->setTextAlign(TextAlign::CENTER) ->setCustomOption(self::OPTION_BASE_PATH, null) diff --git a/src/Field/LanguageField.php b/src/Field/LanguageField.php index dd26f36b27..71d5ecb6bf 100644 --- a/src/Field/LanguageField.php +++ b/src/Field/LanguageField.php @@ -57,7 +57,10 @@ public function showName(bool $isShown = true): self public function useAlpha3Codes(bool $useAlpha3 = true): self { - $this->setCustomOption(self::OPTION_LANGUAGE_CODE_FORMAT, $useAlpha3 ? self::FORMAT_ISO_639_ALPHA3 : self::FORMAT_ISO_639_ALPHA2); + $this->setCustomOption( + self::OPTION_LANGUAGE_CODE_FORMAT, + $useAlpha3 ? self::FORMAT_ISO_639_ALPHA3 : self::FORMAT_ISO_639_ALPHA2 + ); return $this; } diff --git a/src/Field/MoneyField.php b/src/Field/MoneyField.php index 5d0963b700..4acb5e8f7f 100644 --- a/src/Field/MoneyField.php +++ b/src/Field/MoneyField.php @@ -42,7 +42,13 @@ public static function new(string $propertyName, $label = null): self public function setCurrency(string $currencyCode): self { if (!Currencies::exists($currencyCode)) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be a valid currency code according to ICU data ("%s" given).', __METHOD__, $currencyCode)); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s()" method must be a valid currency code according to ICU data ("%s" given).', + __METHOD__, + $currencyCode + ) + ); } $this->setCustomOption(self::OPTION_CURRENCY, $currencyCode); @@ -60,7 +66,9 @@ public function setCurrencyPropertyPath(string $propertyPath): self public function setNumDecimals(int $num): self { if ($num < 0) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 0 or higher (%d given).', __METHOD__, $num)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 0 or higher (%d given).', __METHOD__, $num) + ); } $this->setCustomOption(self::OPTION_NUM_DECIMALS, $num); diff --git a/src/Field/NumberField.php b/src/Field/NumberField.php index a391c8a7f6..a9f5bda986 100644 --- a/src/Field/NumberField.php +++ b/src/Field/NumberField.php @@ -39,7 +39,9 @@ public static function new(string $propertyName, $label = null): self public function setNumDecimals(int $num): self { if ($num < 0) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 0 or higher (%d given).', __METHOD__, $num)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 0 or higher (%d given).', __METHOD__, $num) + ); } $this->setCustomOption(self::OPTION_NUM_DECIMALS, $num); @@ -60,7 +62,14 @@ public function setRoundingMode(int $mode): self ]; if (!\in_array($mode, $validModes, true)) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be the value of any of the following constants from the %s class: %s.', __METHOD__, \NumberFormatter::class, implode(', ', array_keys($validModes)))); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s()" method must be the value of any of the following constants from the %s class: %s.', + __METHOD__, + \NumberFormatter::class, + implode(', ', array_keys($validModes)) + ) + ); } $this->setCustomOption(self::OPTION_ROUNDING_MODE, $mode); diff --git a/src/Field/PercentField.php b/src/Field/PercentField.php index c8e3e2e4b5..c030eac6a5 100644 --- a/src/Field/PercentField.php +++ b/src/Field/PercentField.php @@ -35,14 +35,15 @@ public static function new(string $propertyName, $label = null): self ->setCustomOption(self::OPTION_NUM_DECIMALS, 0) ->setCustomOption(self::OPTION_STORED_AS_FRACTIONAL, true) ->setCustomOption(self::OPTION_SYMBOL, '%') - ->setCustomOption(self::OPTION_ROUNDING_MODE, \NumberFormatter::ROUND_HALFUP) - ; + ->setCustomOption(self::OPTION_ROUNDING_MODE, \NumberFormatter::ROUND_HALFUP); } public function setNumDecimals(int $num): self { if ($num < 0) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 0 or higher (%d given).', __METHOD__, $num)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 0 or higher (%d given).', __METHOD__, $num) + ); } $this->setCustomOption(self::OPTION_NUM_DECIMALS, $num); @@ -84,7 +85,14 @@ public function setRoundingMode(int $mode): self ]; if (!\in_array($mode, $validModes, true)) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be the value of any of the following constants from the %s class: %s.', __METHOD__, \NumberFormatter::class, implode(', ', array_keys($validModes)))); + throw new \InvalidArgumentException( + sprintf( + 'The argument of the "%s()" method must be the value of any of the following constants from the %s class: %s.', + __METHOD__, + \NumberFormatter::class, + implode(', ', array_keys($validModes)) + ) + ); } $this->setCustomOption(self::OPTION_ROUNDING_MODE, $mode); diff --git a/src/Field/SlugField.php b/src/Field/SlugField.php index 88c38032b9..30bebf2a1c 100644 --- a/src/Field/SlugField.php +++ b/src/Field/SlugField.php @@ -31,8 +31,7 @@ public static function new(string $propertyName, $label = null): self ->addJsFiles(Asset::fromEasyAdminAssetPackage('field-slug.js')->onlyOnForms()) ->setDefaultColumns('col-md-6 col-xxl-5') ->setCustomOption(self::OPTION_TARGET_FIELD_NAME, null) - ->setCustomOption(self::OPTION_UNLOCK_CONFIRMATION_MESSAGE, null) - ; + ->setCustomOption(self::OPTION_UNLOCK_CONFIRMATION_MESSAGE, null); } /** diff --git a/src/Field/TextEditorField.php b/src/Field/TextEditorField.php index f68245933b..bb8b9d9469 100644 --- a/src/Field/TextEditorField.php +++ b/src/Field/TextEditorField.php @@ -38,7 +38,9 @@ public static function new(string $propertyName, $label = null): self public function setNumOfRows(int $rows): self { if ($rows < 1) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $rows)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $rows) + ); } $this->setCustomOption(self::OPTION_NUM_OF_ROWS, $rows); diff --git a/src/Field/TextField.php b/src/Field/TextField.php index 3bb0314e18..5730333471 100644 --- a/src/Field/TextField.php +++ b/src/Field/TextField.php @@ -41,7 +41,9 @@ public static function new(string $propertyName, $label = null): self public function setMaxLength(int $length): self { if ($length < 1) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $length)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $length) + ); } $this->setCustomOption(self::OPTION_MAX_LENGTH, $length); diff --git a/src/Field/TextareaField.php b/src/Field/TextareaField.php index 90c92b8e9e..372bb28ea9 100644 --- a/src/Field/TextareaField.php +++ b/src/Field/TextareaField.php @@ -45,7 +45,9 @@ public static function new(string $propertyName, $label = null): self public function setMaxLength(int $length): self { if ($length < 1) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $length)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $length) + ); } $this->setCustomOption(self::OPTION_MAX_LENGTH, $length); @@ -56,7 +58,9 @@ public function setMaxLength(int $length): self public function setNumOfRows(int $rows): self { if ($rows < 1) { - throw new \InvalidArgumentException(sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $rows)); + throw new \InvalidArgumentException( + sprintf('The argument of the "%s()" method must be 1 or higher (%d given).', __METHOD__, $rows) + ); } $this->setCustomOption(self::OPTION_NUM_OF_ROWS, $rows); diff --git a/src/Field/TimeField.php b/src/Field/TimeField.php index f0162f5bcf..108e1148fd 100644 --- a/src/Field/TimeField.php +++ b/src/Field/TimeField.php @@ -40,7 +40,12 @@ public static function new(string $propertyName, $label = null): self public function setTimezone(string $timezoneId): self { if (!\in_array($timezoneId, timezone_identifiers_list(), true)) { - throw new \InvalidArgumentException(sprintf('The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', $timezoneId)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" timezone is not a valid PHP timezone ID. Use any of the values listed at https://www.php.net/manual/en/timezones.php', + $timezoneId + ) + ); } $this->setCustomOption(DateTimeField::OPTION_TIMEZONE, $timezoneId); @@ -54,10 +59,17 @@ public function setTimezone(string $timezoneId): self public function setFormat(string $timeFormatOrPattern): self { if (DateTimeField::FORMAT_NONE === $timeFormatOrPattern || '' === trim($timeFormatOrPattern)) { - $callable = static fn (string $format): bool => DateTimeField::FORMAT_NONE !== $format; + $callable = static fn(string $format): bool => DateTimeField::FORMAT_NONE !== $format; $validTimeFormatsWithoutNone = array_filter(DateTimeField::VALID_DATE_FORMATS, $callable); - throw new \InvalidArgumentException(sprintf('The first argument of the "%s()" method cannot be "%s" or an empty string. Use either the special time formats (%s) or a datetime Intl pattern.', __METHOD__, DateTimeField::FORMAT_NONE, implode(', ', $validTimeFormatsWithoutNone))); + throw new \InvalidArgumentException( + sprintf( + 'The first argument of the "%s()" method cannot be "%s" or an empty string. Use either the special time formats (%s) or a datetime Intl pattern.', + __METHOD__, + DateTimeField::FORMAT_NONE, + implode(', ', $validTimeFormatsWithoutNone) + ) + ); } $this->setCustomOption(self::OPTION_TIME_PATTERN, $timeFormatOrPattern); diff --git a/src/Filter/ArrayFilter.php b/src/Filter/ArrayFilter.php index 112271cf8d..ce15c7d340 100644 --- a/src/Filter/ArrayFilter.php +++ b/src/Filter/ArrayFilter.php @@ -6,11 +6,8 @@ use Doctrine\ORM\Query\Expr\Orx; use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\ArrayFilterType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\ComparisonType; @@ -47,8 +44,12 @@ public function canSelectMultiple(bool $selectMultiple = true): self return $this; } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $alias = $filterDataDto->getEntityAlias(); $property = $filterDataDto->getProperty(); $comparison = $filterDataDto->getComparison(); diff --git a/src/Filter/BooleanFilter.php b/src/Filter/BooleanFilter.php index 9930540a95..4955efb9e4 100644 --- a/src/Filter/BooleanFilter.php +++ b/src/Filter/BooleanFilter.php @@ -4,11 +4,8 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\BooleanFilterType; @@ -30,10 +27,22 @@ public static function new(string $propertyName, $label = null): self ->setFormTypeOption('translation_domain', 'EasyAdminBundle'); } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $queryBuilder - ->andWhere(sprintf('%s.%s %s :%s', $filterDataDto->getEntityAlias(), $filterDataDto->getProperty(), $filterDataDto->getComparison(), $filterDataDto->getParameterName())) + ->andWhere( + sprintf( + '%s.%s %s :%s', + $filterDataDto->getEntityAlias(), + $filterDataDto->getProperty(), + $filterDataDto->getComparison(), + $filterDataDto->getParameterName() + ) + ) ->setParameter($filterDataDto->getParameterName(), $filterDataDto->getValue()); } } diff --git a/src/Filter/ChoiceFilter.php b/src/Filter/ChoiceFilter.php index e70d2f9fb3..4a5b23e07f 100644 --- a/src/Filter/ChoiceFilter.php +++ b/src/Filter/ChoiceFilter.php @@ -5,11 +5,8 @@ use Doctrine\ORM\Query\Expr\Orx; use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\ChoiceFilterType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\ComparisonType; @@ -53,8 +50,12 @@ public function canSelectMultiple(bool $selectMultiple = true): self return $this; } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $alias = $filterDataDto->getEntityAlias(); $property = $filterDataDto->getProperty(); $comparison = $filterDataDto->getComparison(); diff --git a/src/Filter/ComparisonFilter.php b/src/Filter/ComparisonFilter.php index f41d998539..6d97e14fbb 100644 --- a/src/Filter/ComparisonFilter.php +++ b/src/Filter/ComparisonFilter.php @@ -4,11 +4,8 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\ComparisonFilterType; @@ -30,8 +27,12 @@ public static function new(string $propertyName, $label = null): self ->setFormTypeOption('translation_domain', 'EasyAdminBundle'); } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $alias = $filterDataDto->getEntityAlias(); $property = $filterDataDto->getProperty(); $comparison = $filterDataDto->getComparison(); diff --git a/src/Filter/Configurator/ChoiceConfigurator.php b/src/Filter/Configurator/ChoiceConfigurator.php index 3343243eac..2e0ae8f2d8 100644 --- a/src/Filter/Configurator/ChoiceConfigurator.php +++ b/src/Filter/Configurator/ChoiceConfigurator.php @@ -4,11 +4,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\ChoiceFilter; @@ -17,17 +14,30 @@ */ final class ChoiceConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return ChoiceFilter::class === $filterDto->getFqcn(); } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { $choices = $filterDto->getFormTypeOption('value_type_options.choices'); if (null === $choices || 0 === \count($choices)) { - throw new \InvalidArgumentException(sprintf('The choice filter associated to the "%s" property does not define its choices. Define them with the setChoices() method.', $filterDto->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The choice filter associated to the "%s" property does not define its choices. Define them with the setChoices() method.', + $filterDto->getProperty() + ) + ); } } } diff --git a/src/Filter/Configurator/CommonConfigurator.php b/src/Filter/Configurator/CommonConfigurator.php index 9de3acfe95..4078043fd2 100644 --- a/src/Filter/Configurator/CommonConfigurator.php +++ b/src/Filter/Configurator/CommonConfigurator.php @@ -4,11 +4,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use function Symfony\Component\String\u; @@ -18,13 +15,21 @@ */ final class CommonConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return true; } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { if (null === $filterDto->getLabel()) { $fieldLabel = null !== $fieldDto ? $fieldDto->getLabel() : null; $label = $fieldLabel ?? u($filterDto->getProperty())->title()->toString(); diff --git a/src/Filter/Configurator/ComparisonConfigurator.php b/src/Filter/Configurator/ComparisonConfigurator.php index df263580c4..f8fb3e997c 100644 --- a/src/Filter/Configurator/ComparisonConfigurator.php +++ b/src/Filter/Configurator/ComparisonConfigurator.php @@ -5,11 +5,8 @@ use Doctrine\DBAL\Types\Types; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\ComparisonFilter; use Symfony\Component\Form\Extension\Core\Type\DateIntervalType; @@ -20,13 +17,21 @@ */ final class ComparisonConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return ComparisonFilter::class === $filterDto->getFqcn(); } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { $propertyType = $entityDto->getPropertyMetadata($filterDto->getProperty())->get('type'); if (Types::DATEINTERVAL === $propertyType) { diff --git a/src/Filter/Configurator/DateTimeConfigurator.php b/src/Filter/Configurator/DateTimeConfigurator.php index 63d83642d4..60c685e133 100644 --- a/src/Filter/Configurator/DateTimeConfigurator.php +++ b/src/Filter/Configurator/DateTimeConfigurator.php @@ -5,11 +5,8 @@ use Doctrine\DBAL\Types\Types; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; use Symfony\Component\Form\Extension\Core\Type\DateType; @@ -21,13 +18,21 @@ */ final class DateTimeConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return DateTimeFilter::class === $filterDto->getFqcn(); } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { $propertyType = $entityDto->getPropertyMetadata($filterDto->getProperty())->get('type'); if (Types::DATE_MUTABLE === $propertyType) { diff --git a/src/Filter/Configurator/EntityConfigurator.php b/src/Filter/Configurator/EntityConfigurator.php index e13761e959..a31a48a884 100644 --- a/src/Filter/Configurator/EntityConfigurator.php +++ b/src/Filter/Configurator/EntityConfigurator.php @@ -4,11 +4,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter; @@ -18,13 +15,21 @@ */ final class EntityConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return EntityFilter::class === $filterDto->getFqcn(); } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { $propertyName = $filterDto->getProperty(); if (!$entityDto->isAssociation($propertyName)) { return; @@ -33,18 +38,25 @@ public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fie $doctrineMetadata = $entityDto->getPropertyMetadata($propertyName); // TODO: add the 'em' form type option too? $filterDto->setFormTypeOptionIfNotSet('value_type_options.class', $doctrineMetadata->get('targetEntity')); - $filterDto->setFormTypeOptionIfNotSet('value_type_options.multiple', $entityDto->isToManyAssociation($propertyName)); + $filterDto->setFormTypeOptionIfNotSet( + 'value_type_options.multiple', + $entityDto->isToManyAssociation($propertyName) + ); $filterDto->setFormTypeOptionIfNotSet('value_type_options.attr.data-ea-widget', 'ea-autocomplete'); if ($entityDto->isToOneAssociation($propertyName)) { // don't show the 'empty value' placeholder when all join columns are required, // because an empty filter value would always return no result - $numberOfRequiredJoinColumns = \count(array_filter( - $doctrineMetadata->get('joinColumns'), - static fn (array $joinColumn): bool => false === ($joinColumn['nullable'] ?? false)) + $numberOfRequiredJoinColumns = \count( + array_filter( + $doctrineMetadata->get('joinColumns'), + static fn(array $joinColumn): bool => false === ($joinColumn['nullable'] ?? false) + ) ); - $someJoinColumnsAreNullable = \count($doctrineMetadata->get('joinColumns')) !== $numberOfRequiredJoinColumns; + $someJoinColumnsAreNullable = \count( + $doctrineMetadata->get('joinColumns') + ) !== $numberOfRequiredJoinColumns; if ($someJoinColumnsAreNullable) { $filterDto->setFormTypeOptionIfNotSet('value_type_options.placeholder', 'label.form.empty_value'); diff --git a/src/Filter/Configurator/NullConfigurator.php b/src/Filter/Configurator/NullConfigurator.php index b3bc63b602..29456a5aff 100644 --- a/src/Filter/Configurator/NullConfigurator.php +++ b/src/Filter/Configurator/NullConfigurator.php @@ -4,11 +4,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\NullFilter; @@ -17,17 +14,30 @@ */ final class NullConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return NullFilter::class === $filterDto->getFqcn(); } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { $choices = $filterDto->getFormTypeOption('choices'); if (null === $choices || 0 === \count($choices)) { - throw new \InvalidArgumentException(sprintf('The Null filter associated to the "%s" property does not define the labels of the NULL and NOT NULL options. Define them with the setChoiceLabels() method.', $filterDto->getProperty())); + throw new \InvalidArgumentException( + sprintf( + 'The Null filter associated to the "%s" property does not define the labels of the NULL and NOT NULL options. Define them with the setChoiceLabels() method.', + $filterDto->getProperty() + ) + ); } } } diff --git a/src/Filter/Configurator/NumericConfigurator.php b/src/Filter/Configurator/NumericConfigurator.php index c7e6c0d6fa..58500e1f99 100644 --- a/src/Filter/Configurator/NumericConfigurator.php +++ b/src/Filter/Configurator/NumericConfigurator.php @@ -5,11 +5,8 @@ use Doctrine\DBAL\Types\Types; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\NumericFilter; use Symfony\Component\Form\Extension\Core\Type\IntegerType; @@ -20,13 +17,21 @@ */ final class NumericConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return NumericFilter::class === $filterDto->getFqcn(); } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { $propertyType = $entityDto->getPropertyMetadata($filterDto->getProperty())->get('type'); if (Types::DECIMAL === $propertyType) { diff --git a/src/Filter/Configurator/TextConfigurator.php b/src/Filter/Configurator/TextConfigurator.php index ce2c5ce14f..e560fe3f5d 100644 --- a/src/Filter/Configurator/TextConfigurator.php +++ b/src/Filter/Configurator/TextConfigurator.php @@ -5,11 +5,8 @@ use Doctrine\DBAL\Types\Types; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterConfiguratorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; use Symfony\Component\Form\Extension\Core\Type\TextareaType; @@ -20,13 +17,21 @@ */ final class TextConfigurator implements FilterConfiguratorInterface { - public function supports(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): bool - { + public function supports( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): bool { return TextFilter::class === $filterDto->getFqcn(); } - public function configure(FilterDtoInterface $filterDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto, AdminContext $context): void - { + public function configure( + FilterDtoInterface $filterDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto, + AdminContext $context + ): void { $propertyType = $entityDto->getPropertyMetadata($filterDto->getProperty())->get('type'); if (Types::JSON === $propertyType) { diff --git a/src/Filter/DateTimeFilter.php b/src/Filter/DateTimeFilter.php index 5ec61ad2fd..4fcf6b665e 100644 --- a/src/Filter/DateTimeFilter.php +++ b/src/Filter/DateTimeFilter.php @@ -4,11 +4,8 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\DateTimeFilterType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\ComparisonType; @@ -31,8 +28,12 @@ public static function new(string $propertyName, $label = null): self ->setFormTypeOption('translation_domain', 'EasyAdminBundle'); } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $alias = $filterDataDto->getEntityAlias(); $property = $filterDataDto->getProperty(); $comparison = $filterDataDto->getComparison(); @@ -42,7 +43,9 @@ public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filter $value2 = $filterDataDto->getValue2(); if (ComparisonType::BETWEEN === $comparison) { - $queryBuilder->andWhere(sprintf('%s.%s BETWEEN :%s and :%s', $alias, $property, $parameterName, $parameter2Name)) + $queryBuilder->andWhere( + sprintf('%s.%s BETWEEN :%s and :%s', $alias, $property, $parameterName, $parameter2Name) + ) ->setParameter($parameterName, $value) ->setParameter($parameter2Name, $value2); } else { diff --git a/src/Filter/EntityFilter.php b/src/Filter/EntityFilter.php index 4ba564029d..dee97c187a 100644 --- a/src/Filter/EntityFilter.php +++ b/src/Filter/EntityFilter.php @@ -8,11 +8,8 @@ use Doctrine\ORM\Query\Expr\Orx; use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\EntityFilterType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\ComparisonType; @@ -44,8 +41,12 @@ public function canSelectMultiple(bool $selectMultiple = true): self return $this; } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $alias = $filterDataDto->getEntityAlias(); $property = $filterDataDto->getProperty(); $comparison = $filterDataDto->getComparison(); @@ -89,7 +90,7 @@ private function processParameterValue(QueryBuilder $queryBuilder, mixed $parame return $this->processSingleParameterValue($queryBuilder, $parameterValue); } - return $parameterValue->map(fn ($element) => $this->processSingleParameterValue($queryBuilder, $element)); + return $parameterValue->map(fn($element) => $this->processSingleParameterValue($queryBuilder, $element)); } /** @@ -129,7 +130,12 @@ private function processSingleParameterValue(QueryBuilder $queryBuilder, mixed $ try { $identifierType = $classMetadata->getTypeOfField($classMetadata->getSingleIdentifierFieldName()); } catch (MappingException) { - throw new \RuntimeException(sprintf('The EntityFilter does not support entities with a composite primary key or entities without an identifier. Please check your entity "%s".', $parameterValue::class)); + throw new \RuntimeException( + sprintf( + 'The EntityFilter does not support entities with a composite primary key or entities without an identifier. Please check your entity "%s".', + $parameterValue::class + ) + ); } $identifierValue = $entityManager->getUnitOfWork()->getSingleIdentifierValue($parameterValue); diff --git a/src/Filter/FilterTrait.php b/src/Filter/FilterTrait.php index fa8e728704..822efdcb7d 100644 --- a/src/Filter/FilterTrait.php +++ b/src/Filter/FilterTrait.php @@ -3,11 +3,8 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Filter; use Doctrine\ORM\QueryBuilder; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; @@ -22,7 +19,14 @@ trait FilterTrait private function __construct() { $dto = new FilterDto(); - $dto->setApplyCallable(fn (QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto) => $this->apply($queryBuilder, $filterDataDto, $fieldDto, $entityDto)); + $dto->setApplyCallable( + fn( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ) => $this->apply($queryBuilder, $filterDataDto, $fieldDto, $entityDto) + ); $this->dto = $dto; } diff --git a/src/Filter/NullFilter.php b/src/Filter/NullFilter.php index 4b73ef5054..1adae241f6 100644 --- a/src/Filter/NullFilter.php +++ b/src/Filter/NullFilter.php @@ -4,11 +4,8 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\NullFilterType; @@ -42,10 +39,16 @@ public function setChoiceLabels(string $nullChoiceLabel, string $notNullChoiceLa return $this; } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $comparison = self::CHOICE_VALUE_NULL === $filterDataDto->getValue() ? 'IS' : 'IS NOT'; $queryBuilder - ->andWhere(sprintf('%s.%s %s NULL', $filterDataDto->getEntityAlias(), $filterDataDto->getProperty(), $comparison)); + ->andWhere( + sprintf('%s.%s %s NULL', $filterDataDto->getEntityAlias(), $filterDataDto->getProperty(), $comparison) + ); } } diff --git a/src/Filter/NumericFilter.php b/src/Filter/NumericFilter.php index 2fd1c7eaa6..d8b9ab9f9c 100644 --- a/src/Filter/NumericFilter.php +++ b/src/Filter/NumericFilter.php @@ -4,11 +4,8 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\NumericFilterType; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\ComparisonType; @@ -31,8 +28,12 @@ public static function new(string $propertyName, $label = null): self ->setFormTypeOption('translation_domain', 'EasyAdminBundle'); } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $alias = $filterDataDto->getEntityAlias(); $property = $filterDataDto->getProperty(); $comparison = $filterDataDto->getComparison(); @@ -42,7 +43,9 @@ public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filter $value2 = $filterDataDto->getValue2(); if (ComparisonType::BETWEEN === $comparison) { - $queryBuilder->andWhere(sprintf('%s.%s BETWEEN :%s and :%s', $alias, $property, $parameterName, $parameter2Name)) + $queryBuilder->andWhere( + sprintf('%s.%s BETWEEN :%s and :%s', $alias, $property, $parameterName, $parameter2Name) + ) ->setParameter($parameterName, $value) ->setParameter($parameter2Name, $value2); } else { diff --git a/src/Filter/TextFilter.php b/src/Filter/TextFilter.php index 748148a103..f3ab06f162 100644 --- a/src/Filter/TextFilter.php +++ b/src/Filter/TextFilter.php @@ -4,11 +4,8 @@ use Doctrine\ORM\QueryBuilder; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Filter\FilterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Filter\Type\TextFilterType; @@ -30,8 +27,12 @@ public static function new(string $propertyName, $label = null): self ->setFormTypeOption('translation_domain', 'EasyAdminBundle'); } - public function apply(QueryBuilder $queryBuilder, FilterDataDtoInterface $filterDataDto, ?FieldDtoInterface $fieldDto, EntityDtoInterface $entityDto): void - { + public function apply( + QueryBuilder $queryBuilder, + FilterDataDtoInterface $filterDataDto, + ?FieldDtoInterface $fieldDto, + EntityDtoInterface $entityDto + ): void { $alias = $filterDataDto->getEntityAlias(); $property = $filterDataDto->getProperty(); $comparison = $filterDataDto->getComparison(); diff --git a/src/Form/Extension/EaCrudFormTypeExtension.php b/src/Form/Extension/EaCrudFormTypeExtension.php index acab4d0d2f..c621fa57b5 100644 --- a/src/Form/Extension/EaCrudFormTypeExtension.php +++ b/src/Form/Extension/EaCrudFormTypeExtension.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Form\Extension; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\Extension\Core\Type\FormType; @@ -18,7 +17,7 @@ */ final class EaCrudFormTypeExtension extends AbstractTypeExtension { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; public function __construct(AdminContextProviderInterface $adminContextProvider) { diff --git a/src/Form/Filter/Type/ArrayFilterType.php b/src/Form/Filter/Type/ArrayFilterType.php index 0c0c50a749..477ca37e0a 100644 --- a/src/Form/Filter/Type/ArrayFilterType.php +++ b/src/Form/Filter/Type/ArrayFilterType.php @@ -23,18 +23,20 @@ public function buildForm(FormBuilderInterface $builder, array $options): void } $builder->add('value', $options['value_type'], $options['value_type_options'] + $defaultOptions); - $builder->addModelTransformer(new CallbackTransformer( - static fn ($data) => $data, - static function ($data) { - if (null === $data['value'] || [] === $data['value']) { - $data['comparison'] = ComparisonType::CONTAINS === $data['comparison'] ? 'IS NULL' : 'IS NOT NULL'; - } else { - $data['value'] = (array) $data['value']; - } + $builder->addModelTransformer( + new CallbackTransformer( + static fn($data) => $data, + static function ($data) { + if (null === $data['value'] || [] === $data['value']) { + $data['comparison'] = ComparisonType::CONTAINS === $data['comparison'] ? 'IS NULL' : 'IS NOT NULL'; + } else { + $data['value'] = (array)$data['value']; + } - return $data; - } - )); + return $data; + } + ) + ); } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Filter/Type/ChoiceFilterType.php b/src/Form/Filter/Type/ChoiceFilterType.php index c80506681c..14238542aa 100644 --- a/src/Form/Filter/Type/ChoiceFilterType.php +++ b/src/Form/Filter/Type/ChoiceFilterType.php @@ -17,31 +17,33 @@ final class ChoiceFilterType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { - $multiple = (bool) $builder->get('value')->getOption('multiple'); + $multiple = (bool)$builder->get('value')->getOption('multiple'); - $builder->addModelTransformer(new CallbackTransformer( - static fn ($data) => $data, - static function ($data) use ($multiple) { - switch ($data['comparison']) { - case ComparisonType::EQ: - if (null === $data['value'] || ($multiple && 0 === \count($data['value']))) { - $data['comparison'] = 'IS NULL'; - } else { - $data['comparison'] = $multiple ? 'IN' : '='; - } - break; - case ComparisonType::NEQ: - if (null === $data['value'] || ($multiple && 0 === \count($data['value']))) { - $data['comparison'] = 'IS NOT NULL'; - } else { - $data['comparison'] = $multiple ? 'NOT IN' : '!='; - } - break; - } + $builder->addModelTransformer( + new CallbackTransformer( + static fn($data) => $data, + static function ($data) use ($multiple) { + switch ($data['comparison']) { + case ComparisonType::EQ: + if (null === $data['value'] || ($multiple && 0 === \count($data['value']))) { + $data['comparison'] = 'IS NULL'; + } else { + $data['comparison'] = $multiple ? 'IN' : '='; + } + break; + case ComparisonType::NEQ: + if (null === $data['value'] || ($multiple && 0 === \count($data['value']))) { + $data['comparison'] = 'IS NOT NULL'; + } else { + $data['comparison'] = $multiple ? 'NOT IN' : '!='; + } + break; + } - return $data; - } - )); + return $data; + } + ) + ); } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Filter/Type/ComparisonFilterType.php b/src/Form/Filter/Type/ComparisonFilterType.php index 19c0e63550..adb818aadb 100644 --- a/src/Form/Filter/Type/ComparisonFilterType.php +++ b/src/Form/Filter/Type/ComparisonFilterType.php @@ -17,8 +17,12 @@ final class ComparisonFilterType extends AbstractType private string $comparisonType; private array $comparisonTypeOptions; - public function __construct(?string $valueType = null, array $valueTypeOptions = [], ?string $comparisonType = null, array $comparisonTypeOptions = []) - { + public function __construct( + ?string $valueType = null, + array $valueTypeOptions = [], + ?string $comparisonType = null, + array $comparisonTypeOptions = [] + ) { $this->valueType = $valueType; $this->valueTypeOptions = $valueTypeOptions; $this->comparisonType = $comparisonType ?? ComparisonType::class; @@ -28,9 +32,13 @@ public function __construct(?string $valueType = null, array $valueTypeOptions = public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('comparison', $options['comparison_type'], $options['comparison_type_options']); - $builder->add('value', $options['value_type'], $options['value_type_options'] + [ - 'label' => false, - ]); + $builder->add( + 'value', + $options['value_type'], + $options['value_type_options'] + [ + 'label' => false, + ] + ); } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Filter/Type/DateTimeFilterType.php b/src/Form/Filter/Type/DateTimeFilterType.php index 39510cb106..b23c445aaa 100644 --- a/src/Form/Filter/Type/DateTimeFilterType.php +++ b/src/Form/Filter/Type/DateTimeFilterType.php @@ -26,43 +26,51 @@ public function __construct(?string $valueType = null) public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('value2', $options['value_type'], $options['value_type_options'] + [ - 'label' => false, - ]); + $builder->add( + 'value2', + $options['value_type'], + $options['value_type_options'] + [ + 'label' => false, + ] + ); - $builder->addModelTransformer(new CallbackTransformer( - static fn ($data) => $data, - static function ($data) use ($options) { - if (ComparisonType::BETWEEN === $data['comparison']) { - if (null === $data['value'] || '' === $data['value'] || null === $data['value2'] || '' === $data['value2']) { - throw new TransformationFailedException('Two values must be provided when "BETWEEN" comparison is selected.'); - } + $builder->addModelTransformer( + new CallbackTransformer( + static fn($data) => $data, + static function ($data) use ($options) { + if (ComparisonType::BETWEEN === $data['comparison']) { + if (null === $data['value'] || '' === $data['value'] || null === $data['value2'] || '' === $data['value2']) { + throw new TransformationFailedException( + 'Two values must be provided when "BETWEEN" comparison is selected.' + ); + } - // make sure end datetime is greater than start datetime - if ($data['value'] > $data['value2']) { - [$data['value'], $data['value2']] = [$data['value2'], $data['value']]; - } + // make sure end datetime is greater than start datetime + if ($data['value'] > $data['value2']) { + [$data['value'], $data['value2']] = [$data['value2'], $data['value']]; + } - if (DateType::class === $options['value_type']) { - $data['value2'] = $data['value2']->format('Y-m-d'); - } elseif (TimeType::class === $options['value_type']) { - $data['value2'] = $data['value2']->format('H:i:s'); + if (DateType::class === $options['value_type']) { + $data['value2'] = $data['value2']->format('Y-m-d'); + } elseif (TimeType::class === $options['value_type']) { + $data['value2'] = $data['value2']->format('H:i:s'); + } } - } - if ($data['value'] instanceof \DateTimeInterface) { - if (DateType::class === $options['value_type']) { - // sqlite: Don't include time format for date comparison - $data['value'] = $data['value']->format('Y-m-d'); - } elseif (TimeType::class === $options['value_type']) { - // sqlite: Don't include date format for time comparison - $data['value'] = $data['value']->format('H:i:s'); + if ($data['value'] instanceof \DateTimeInterface) { + if (DateType::class === $options['value_type']) { + // sqlite: Don't include time format for date comparison + $data['value'] = $data['value']->format('Y-m-d'); + } elseif (TimeType::class === $options['value_type']) { + // sqlite: Don't include date format for time comparison + $data['value'] = $data['value']->format('H:i:s'); + } } - } - return $data; - } - )); + return $data; + } + ) + ); } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Filter/Type/NumericFilterType.php b/src/Form/Filter/Type/NumericFilterType.php index 126c243e0d..d463306dfb 100644 --- a/src/Form/Filter/Type/NumericFilterType.php +++ b/src/Form/Filter/Type/NumericFilterType.php @@ -26,27 +26,35 @@ public function __construct(?string $valueType = null, array $valueTypeOptions = public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->add('value2', $options['value_type'], $options['value_type_options'] + [ - 'label' => false, - ]); + $builder->add( + 'value2', + $options['value_type'], + $options['value_type_options'] + [ + 'label' => false, + ] + ); - $builder->addModelTransformer(new CallbackTransformer( - static fn ($data) => $data, - static function ($data) { - if (ComparisonType::BETWEEN === $data['comparison']) { - if (null === $data['value'] || '' === $data['value'] || null === $data['value2'] || '' === $data['value2']) { - throw new TransformationFailedException('Two values must be provided when "BETWEEN" comparison is selected.'); - } + $builder->addModelTransformer( + new CallbackTransformer( + static fn($data) => $data, + static function ($data) { + if (ComparisonType::BETWEEN === $data['comparison']) { + if (null === $data['value'] || '' === $data['value'] || null === $data['value2'] || '' === $data['value2']) { + throw new TransformationFailedException( + 'Two values must be provided when "BETWEEN" comparison is selected.' + ); + } - // make sure value 2 is greater than value 1 - if ($data['value'] > $data['value2']) { - [$data['value'], $data['value2']] = [$data['value2'], $data['value']]; + // make sure value 2 is greater than value 1 + if ($data['value'] > $data['value2']) { + [$data['value'], $data['value2']] = [$data['value2'], $data['value']]; + } } - } - return $data; - } - )); + return $data; + } + ) + ); } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Filter/Type/TextFilterType.php b/src/Form/Filter/Type/TextFilterType.php index 13b34a5eaa..5bfec38da7 100644 --- a/src/Form/Filter/Type/TextFilterType.php +++ b/src/Form/Filter/Type/TextFilterType.php @@ -25,26 +25,28 @@ public function __construct(?string $valueType = null) public function buildForm(FormBuilderInterface $builder, array $options): void { - $builder->addModelTransformer(new CallbackTransformer( - static fn ($data) => $data, - static function ($data) { - switch ($data['comparison']) { - case ComparisonType::STARTS_WITH: - $data['comparison'] = ComparisonType::CONTAINS; - $data['value'] .= '%'; - break; - case ComparisonType::ENDS_WITH: - $data['comparison'] = ComparisonType::CONTAINS; - $data['value'] = '%'.$data['value']; - break; - case ComparisonType::CONTAINS: - case ComparisonType::NOT_CONTAINS: - $data['value'] = '%'.$data['value'].'%'; - } + $builder->addModelTransformer( + new CallbackTransformer( + static fn($data) => $data, + static function ($data) { + switch ($data['comparison']) { + case ComparisonType::STARTS_WITH: + $data['comparison'] = ComparisonType::CONTAINS; + $data['value'] .= '%'; + break; + case ComparisonType::ENDS_WITH: + $data['comparison'] = ComparisonType::CONTAINS; + $data['value'] = '%'.$data['value']; + break; + case ComparisonType::CONTAINS: + case ComparisonType::NOT_CONTAINS: + $data['value'] = '%'.$data['value'].'%'; + } - return $data; - } - )); + return $data; + } + ) + ); } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Type/CrudFormType.php b/src/Form/Type/CrudFormType.php index 9eac0adcc6..0e995c3c1a 100644 --- a/src/Form/Type/CrudFormType.php +++ b/src/Form/Type/CrudFormType.php @@ -2,8 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Form\Type; -use ArrayObject; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; use EasyCorp\Bundle\EasyAdminBundle\Form\EventListener\EasyAdminTabSubscriber; @@ -87,7 +85,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $metadata['label'] = $fieldDto->getLabel(); $metadata['help'] = $fieldDto->getHelp(); $metadata[FormField::OPTION_ICON] = $fieldDto->getCustomOption(FormField::OPTION_ICON); - $currentFormTab = (string) $fieldDto->getLabel(); + $currentFormTab = (string)$fieldDto->getLabel(); // plain arrays are not enough for tabs because they are modified in the // lifecycle of a form (e.g. add info about form errors). Use an ArrayObject instead. @@ -135,7 +133,8 @@ public function configureOptions(OptionsResolver $resolver): void $resolver ->setDefaults([ 'allow_extra_fields' => true, - 'data_class' => static fn (Options $options, $dataClass) => $dataClass ?? $options['entityDto']->getFqcn(), + 'data_class' => static fn(Options $options, $dataClass) => $dataClass ?? $options['entityDto']->getFqcn( + ), ]) ->setDefined(['entityDto', 'ea_form_panel', 'ea_form_tab']) ->setRequired(['entityDto']); diff --git a/src/Form/Type/FileUploadType.php b/src/Form/Type/FileUploadType.php index 190a9e4e96..fe11b7bb59 100644 --- a/src/Form/Type/FileUploadType.php +++ b/src/Form/Type/FileUploadType.php @@ -45,7 +45,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->setDataMapper($this); $builder->setAttribute('state', new FileUploadState($allowAdd)); - $builder->addModelTransformer(new StringToFileTransformer($uploadDir, $uploadFilename, $uploadValidate, $options['multiple'])); + $builder->addModelTransformer( + new StringToFileTransformer($uploadDir, $uploadFilename, $uploadValidate, $options['multiple']) + ); } public function buildView(FormView $view, FormInterface $form, array $options): void @@ -84,7 +86,7 @@ public function configureOptions(OptionsResolver $resolver): void unlink($file->getPathname()); }; - $uploadFilename = static fn (UploadedFile $file): string => $file->getClientOriginalName(); + $uploadFilename = static fn(UploadedFile $file): string => $file->getClientOriginalName(); $uploadValidate = static function (string $filename): string { if (!file_exists($filename)) { @@ -93,20 +95,31 @@ public function configureOptions(OptionsResolver $resolver): void $index = 1; $pathInfo = pathinfo($filename); - while (file_exists($filename = sprintf('%s/%s_%d.%s', $pathInfo['dirname'], $pathInfo['filename'], $index, $pathInfo['extension']))) { + while (file_exists( + $filename = sprintf( + '%s/%s_%d.%s', + $pathInfo['dirname'], + $pathInfo['filename'], + $index, + $pathInfo['extension'] + ) + )) { ++$index; } return $filename; }; - $downloadPath = fn (Options $options) => mb_substr($options['upload_dir'], mb_strlen($this->projectDir.'/public/')); + $downloadPath = fn(Options $options) => mb_substr( + $options['upload_dir'], + mb_strlen($this->projectDir.'/public/') + ); - $allowAdd = static fn (Options $options) => $options['multiple']; + $allowAdd = static fn(Options $options) => $options['multiple']; - $dataClass = static fn (Options $options) => $options['multiple'] ? null : File::class; + $dataClass = static fn(Options $options) => $options['multiple'] ? null : File::class; - $emptyData = static fn (Options $options) => $options['multiple'] ? [] : null; + $emptyData = static fn(Options $options) => $options['multiple'] ? [] : null; $resolver->setDefaults([ 'upload_dir' => $this->projectDir.'/public/uploads/files/', @@ -145,7 +158,9 @@ public function configureOptions(OptionsResolver $resolver): void } if ('' !== $value && (!is_dir($value) || !is_writable($value))) { - throw new InvalidArgumentException(sprintf('Invalid upload directory "%s" it does not exist or is not writable.', $value)); + throw new InvalidArgumentException( + sprintf('Invalid upload directory "%s" it does not exist or is not writable.', $value) + ); } return $value; @@ -175,11 +190,13 @@ public function configureOptions(OptionsResolver $resolver): void }; }); $resolver->setNormalizer('allow_add', static function (Options $options, string $value): bool { - if ((bool) $value && !$options['multiple']) { - throw new InvalidArgumentException('Setting "allow_add" option to "true" when "multiple" option is "false" is not supported.'); + if ((bool)$value && !$options['multiple']) { + throw new InvalidArgumentException( + 'Setting "allow_add" option to "true" when "multiple" option is "false" is not supported.' + ); } - return (bool) $value; + return (bool)$value; }); } diff --git a/src/Form/Type/FiltersFormType.php b/src/Form/Type/FiltersFormType.php index 8588ee873d..c04954ebed 100644 --- a/src/Form/Type/FiltersFormType.php +++ b/src/Form/Type/FiltersFormType.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Form\Type; use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDtoInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Form/Type/SlugType.php b/src/Form/Type/SlugType.php index d68eaa90f1..cb1e0bc106 100644 --- a/src/Form/Type/SlugType.php +++ b/src/Form/Type/SlugType.php @@ -22,8 +22,7 @@ public function configureOptions(OptionsResolver $resolver): void { $resolver ->setRequired(['target']) - ->setAllowedTypes('target', ['string']) - ; + ->setAllowedTypes('target', ['string']); } public function buildView(FormView $view, FormInterface $form, array $options): void diff --git a/src/Inspector/DataCollector.php b/src/Inspector/DataCollector.php index dee09f43d7..a2fdbfc1f5 100644 --- a/src/Inspector/DataCollector.php +++ b/src/Inspector/DataCollector.php @@ -4,7 +4,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -12,7 +11,7 @@ final class DataCollector extends BaseDataCollector implements DataCollectorInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; public function __construct(AdminContextProviderInterface $adminContextProvider) { diff --git a/src/Intl/IntlFormatter.php b/src/Intl/IntlFormatter.php index 6523f61da3..8bfcc88b22 100644 --- a/src/Intl/IntlFormatter.php +++ b/src/Intl/IntlFormatter.php @@ -86,10 +86,21 @@ public function formatCurrency($amount, string $currency, array $attrs = [], ?st return $formattedCurrency; } - public function formatNumber($number, array $attrs = [], string $style = 'decimal', string $type = 'default', ?string $locale = null): string - { + public function formatNumber( + $number, + array $attrs = [], + string $style = 'decimal', + string $type = 'default', + ?string $locale = null + ): string { if (!isset(self::NUMBER_TYPES[$type])) { - throw new RuntimeError(sprintf('The type "%s" does not exist, known types are: "%s".', $type, implode('", "', array_keys(self::NUMBER_TYPES)))); + throw new RuntimeError( + sprintf( + 'The type "%s" does not exist, known types are: "%s".', + $type, + implode('", "', array_keys(self::NUMBER_TYPES)) + ) + ); } $formatter = $this->createNumberFormatter($locale, $style, $attrs); @@ -101,36 +112,80 @@ public function formatNumber($number, array $attrs = [], string $style = 'decima return $ret; } - public function formatDateTime(?\DateTimeInterface $date, ?string $dateFormat = 'medium', ?string $timeFormat = 'medium', string $pattern = '', $timezone = null, string $calendar = 'gregorian', ?string $locale = null): ?string - { + public function formatDateTime( + ?\DateTimeInterface $date, + ?string $dateFormat = 'medium', + ?string $timeFormat = 'medium', + string $pattern = '', + $timezone = null, + string $calendar = 'gregorian', + ?string $locale = null + ): ?string { if (null === $date = $this->convertDate($date, $timezone)) { return null; } - $formatter = $this->createDateFormatter($locale, $dateFormat, $timeFormat, $pattern, $date->getTimezone(), $calendar); + $formatter = $this->createDateFormatter( + $locale, + $dateFormat, + $timeFormat, + $pattern, + $date->getTimezone(), + $calendar + ); $formattedDateTime = $formatter->format($date); return false !== $formattedDateTime ? $formattedDateTime : null; } - public function formatDate(?\DateTimeInterface $date, ?string $dateFormat = 'medium', string $pattern = '', $timezone = null, string $calendar = 'gregorian', ?string $locale = null): ?string - { + public function formatDate( + ?\DateTimeInterface $date, + ?string $dateFormat = 'medium', + string $pattern = '', + $timezone = null, + string $calendar = 'gregorian', + ?string $locale = null + ): ?string { return $this->formatDateTime($date, $dateFormat, 'none', $pattern, $timezone, $calendar, $locale); } - public function formatTime(?\DateTimeInterface $date, ?string $timeFormat = 'medium', string $pattern = '', $timezone = null, string $calendar = 'gregorian', ?string $locale = null): ?string - { + public function formatTime( + ?\DateTimeInterface $date, + ?string $timeFormat = 'medium', + string $pattern = '', + $timezone = null, + string $calendar = 'gregorian', + ?string $locale = null + ): ?string { return $this->formatDateTime($date, 'none', $timeFormat, $pattern, $timezone, $calendar, $locale); } - private function createDateFormatter(?string $locale, ?string $dateFormat, ?string $timeFormat, string $pattern = '', ?\DateTimeZone $timezone = null, string $calendarName = 'gregorian'): \IntlDateFormatter - { + private function createDateFormatter( + ?string $locale, + ?string $dateFormat, + ?string $timeFormat, + string $pattern = '', + ?\DateTimeZone $timezone = null, + string $calendarName = 'gregorian' + ): \IntlDateFormatter { if (null !== $dateFormat && !isset(self::DATE_FORMATS[$dateFormat])) { - throw new RuntimeError(sprintf('The date format "%s" does not exist, known formats are: "%s".', $dateFormat, implode('", "', array_keys(self::DATE_FORMATS)))); + throw new RuntimeError( + sprintf( + 'The date format "%s" does not exist, known formats are: "%s".', + $dateFormat, + implode('", "', array_keys(self::DATE_FORMATS)) + ) + ); } if (null !== $timeFormat && !isset(self::DATE_FORMATS[$timeFormat])) { - throw new RuntimeError(sprintf('The time format "%s" does not exist, known formats are: "%s".', $timeFormat, implode('", "', array_keys(self::DATE_FORMATS)))); + throw new RuntimeError( + sprintf( + 'The time format "%s" does not exist, known formats are: "%s".', + $timeFormat, + implode('", "', array_keys(self::DATE_FORMATS)) + ) + ); } if (null === $locale) { @@ -145,7 +200,14 @@ private function createDateFormatter(?string $locale, ?string $dateFormat, ?stri $hash = $locale.'|'.$dateFormatValue.'|'.$timeFormatValue.'|'.$timezone->getName().'|'.$calendar.'|'.$pattern; if (!isset($this->dateFormatters[$hash])) { - $this->dateFormatters[$hash] = new \IntlDateFormatter($locale, $dateFormatValue, $timeFormatValue, $timezone, $calendar, $pattern); + $this->dateFormatters[$hash] = new \IntlDateFormatter( + $locale, + $dateFormatValue, + $timeFormatValue, + $timezone, + $calendar, + $pattern + ); } return $this->dateFormatters[$hash]; @@ -154,7 +216,13 @@ private function createDateFormatter(?string $locale, ?string $dateFormat, ?stri private function createNumberFormatter(?string $locale, string $style, array $attrs = []): \NumberFormatter { if (!isset(self::NUMBER_STYLES[$style])) { - throw new RuntimeError(sprintf('The style "%s" does not exist, known styles are: "%s".', $style, implode('", "', array_keys(self::NUMBER_STYLES)))); + throw new RuntimeError( + sprintf( + 'The style "%s" does not exist, known styles are: "%s".', + $style, + implode('", "', array_keys(self::NUMBER_STYLES)) + ) + ); } if (null === $locale) { @@ -170,18 +238,36 @@ private function createNumberFormatter(?string $locale, string $style, array $at foreach ($attrs as $name => $value) { if (!isset(self::NUMBER_ATTRIBUTES[$name])) { - throw new RuntimeError(sprintf('The number formatter attribute "%s" does not exist, known attributes are: "%s".', $name, implode('", "', array_keys(self::NUMBER_ATTRIBUTES)))); + throw new RuntimeError( + sprintf( + 'The number formatter attribute "%s" does not exist, known attributes are: "%s".', + $name, + implode('", "', array_keys(self::NUMBER_ATTRIBUTES)) + ) + ); } if ('rounding_mode' === $name) { if (!isset(self::NUMBER_ROUNDING_ATTRIBUTES[$value])) { - throw new RuntimeError(sprintf('The number formatter rounding mode "%s" does not exist, known modes are: "%s".', $value, implode('", "', array_keys(self::NUMBER_ROUNDING_ATTRIBUTES)))); + throw new RuntimeError( + sprintf( + 'The number formatter rounding mode "%s" does not exist, known modes are: "%s".', + $value, + implode('", "', array_keys(self::NUMBER_ROUNDING_ATTRIBUTES)) + ) + ); } $value = self::NUMBER_ROUNDING_ATTRIBUTES[$value]; } elseif ('padding_position' === $name) { if (!isset(self::NUMBER_PADDING_ATTRIBUTES[$value])) { - throw new RuntimeError(sprintf('The number formatter padding position "%s" does not exist, known positions are: "%s".', $value, implode('", "', array_keys(self::NUMBER_PADDING_ATTRIBUTES)))); + throw new RuntimeError( + sprintf( + 'The number formatter padding position "%s" does not exist, known positions are: "%s".', + $value, + implode('", "', array_keys(self::NUMBER_PADDING_ATTRIBUTES)) + ) + ); } $value = self::NUMBER_PADDING_ATTRIBUTES[$value]; diff --git a/src/Maker/ClassMaker.php b/src/Maker/ClassMaker.php index e841af6762..4cb88d2004 100644 --- a/src/Maker/ClassMaker.php +++ b/src/Maker/ClassMaker.php @@ -4,6 +4,7 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\KernelInterface; + use function Symfony\Component\String\u; final class ClassMaker implements ClassMakerInterface @@ -21,21 +22,30 @@ public function __construct(KernelInterface $kernel, string $projectDir) public function make(string $generatedFilePathPattern, string $skeletonName, array $skeletonParameters): string { - $skeletonPath = sprintf('%s/%s', $this->kernel->locateResource('@EasyAdminBundle/Resources/skeleton'), $skeletonName); + $skeletonPath = sprintf( + '%s/%s', + $this->kernel->locateResource('@EasyAdminBundle/Resources/skeleton'), + $skeletonName + ); $generatedFileRelativeDir = u($generatedFilePathPattern)->beforeLast('/')->trimEnd('/')->toString(); $generatedFileNamePattern = u($generatedFilePathPattern)->afterLast('/')->trimStart('/'); $generatedFileDir = sprintf('%s/%s', $this->projectDir, $generatedFileRelativeDir); $this->fs->mkdir($generatedFileDir); if (!$this->fs->exists($generatedFileDir)) { - throw new \RuntimeException(sprintf('The "%s" directory does not exist and cannot be created, so the class generated by this command cannot be created.', $generatedFileDir)); + throw new \RuntimeException( + sprintf( + 'The "%s" directory does not exist and cannot be created, so the class generated by this command cannot be created.', + $generatedFileDir + ) + ); } // first, try to create a file name without any autoincrement index in it $generatedFileName = $generatedFileNamePattern->replace('{number}', ''); $i = 1; while ($this->fs->exists(sprintf('%s/%s', $generatedFileDir, $generatedFileName))) { - $generatedFileName = $generatedFileNamePattern->replace('{number}', (string) ++$i); + $generatedFileName = $generatedFileNamePattern->replace('{number}', (string)++$i); } $generatedFilePath = sprintf('%s/%s', $generatedFileDir, $generatedFileName); diff --git a/src/Menu/MenuItemMatcher.php b/src/Menu/MenuItemMatcher.php index 660e52aa85..b95d069a98 100644 --- a/src/Menu/MenuItemMatcher.php +++ b/src/Menu/MenuItemMatcher.php @@ -2,12 +2,9 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Menu; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; /** @@ -27,7 +24,10 @@ public function isSelected(MenuItemDtoInterface $menuItemDto): bool } $currentPageQueryParameters = $adminContext->getRequest()->query->all(); - $menuItemQueryString = null === $menuItemDto->getLinkUrl() ? null : parse_url($menuItemDto->getLinkUrl(), \PHP_URL_QUERY); + $menuItemQueryString = null === $menuItemDto->getLinkUrl() ? null : parse_url( + $menuItemDto->getLinkUrl(), + \PHP_URL_QUERY + ); $menuItemQueryParameters = []; if (null !== $menuItemQueryString) { parse_str($menuItemQueryString, $menuItemQueryParameters); @@ -38,8 +38,14 @@ public function isSelected(MenuItemDtoInterface $menuItemDto): bool } $menuItemLinksToIndexCrudAction = CrudInterface::PAGE_INDEX === ($menuItemQueryParameters[EA::CRUD_ACTION] ?? false); - $menuItemQueryParameters = $this->filterIrrelevantQueryParameters($menuItemQueryParameters, $menuItemLinksToIndexCrudAction); - $currentPageQueryParameters = $this->filterIrrelevantQueryParameters($currentPageQueryParameters, $menuItemLinksToIndexCrudAction); + $menuItemQueryParameters = $this->filterIrrelevantQueryParameters( + $menuItemQueryParameters, + $menuItemLinksToIndexCrudAction + ); + $currentPageQueryParameters = $this->filterIrrelevantQueryParameters( + $currentPageQueryParameters, + $menuItemLinksToIndexCrudAction + ); // needed so you can pass route parameters in any order sort($menuItemQueryParameters); @@ -68,8 +74,10 @@ public function isExpanded(MenuItemDtoInterface $menuItemDto): bool * should be ignored when deciding if some menu item matches the current page * (such as the applied filters or sorting, the listing page number, etc.). */ - private function filterIrrelevantQueryParameters(array $queryStringParameters, bool $menuItemLinksToIndexCrudAction): array - { + private function filterIrrelevantQueryParameters( + array $queryStringParameters, + bool $menuItemLinksToIndexCrudAction + ): array { $paramsToRemove = [EA::REFERRER, EA::PAGE, EA::FILTERS, EA::SORT]; // if the menu item being inspected links to the 'index' action of some entity, @@ -82,6 +90,10 @@ private function filterIrrelevantQueryParameters(array $queryStringParameters, b $paramsToRemove[] = EA::ENTITY_ID; } - return array_filter($queryStringParameters, static fn ($k) => !\in_array($k, $paramsToRemove, true), \ARRAY_FILTER_USE_KEY); + return array_filter( + $queryStringParameters, + static fn($k) => !\in_array($k, $paramsToRemove, true), + \ARRAY_FILTER_USE_KEY + ); } } diff --git a/src/Menu/MenuItemMatcherInterface.php b/src/Menu/MenuItemMatcherInterface.php index b7292cd884..580e9e1a0d 100644 --- a/src/Menu/MenuItemMatcherInterface.php +++ b/src/Menu/MenuItemMatcherInterface.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Menu; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDtoInterface; /** diff --git a/src/Orm/EntityPaginator.php b/src/Orm/EntityPaginator.php index 74e1e8b705..14826d50c4 100644 --- a/src/Orm/EntityPaginator.php +++ b/src/Orm/EntityPaginator.php @@ -7,11 +7,8 @@ use Doctrine\ORM\Tools\Pagination\Paginator; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityPaginatorInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\PaginatorDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\PaginatorDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactoryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; /** @@ -19,19 +16,21 @@ */ final class EntityPaginator implements EntityPaginatorInterface { - private AdminUrlGenerator $adminUrlGenerator; - private EntityFactory $entityFactory; + private AdminUrlGeneratorInterface $adminUrlGenerator; + private EntityFactoryInterface $entityFactory; private ?int $currentPage = null; private ?int $pageSize = null; private ?int $rangeSize = null; private ?int $rangeEdgeSize = null; - private $results; - private $numResults; + private ?iterable $results = null; + private ?int $numResults = null; private ?int $rangeFirstResultNumber = null; private ?int $rangeLastResultNumber = null; - public function __construct(AdminUrlGeneratorInterface $adminUrlGenerator, EntityFactoryInterface $entityFactory) - { + public function __construct( + AdminUrlGeneratorInterface $adminUrlGenerator, + EntityFactoryInterface $entityFactory + ) { $this->adminUrlGenerator = $adminUrlGenerator; $this->entityFactory = $entityFactory; } @@ -88,7 +87,7 @@ public function getCurrentPage(): int public function getLastPage(): int { - return (int) ceil($this->numResults / $this->pageSize); + return (int)ceil($this->numResults / $this->pageSize); } /** @@ -213,7 +212,10 @@ public function getResultsAsJson(): string ]; } - $nextPageUrl = !$this->hasNextPage() ? null : $this->adminUrlGenerator->set(EA::PAGE, $this->getNextPage())->removeReferrer()->generateUrl(); + $nextPageUrl = !$this->hasNextPage() ? null : $this->adminUrlGenerator->set( + EA::PAGE, + $this->getNextPage() + )->removeReferrer()->generateUrl(); $jsonResult['next_page'] = $nextPageUrl; return json_encode($jsonResult, \JSON_THROW_ON_ERROR); diff --git a/src/Orm/EntityRepository.php b/src/Orm/EntityRepository.php index f8034fe4fd..c00792fd50 100644 --- a/src/Orm/EntityRepository.php +++ b/src/Orm/EntityRepository.php @@ -10,18 +10,13 @@ use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityRepositoryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Dto\FilterDataDto; -use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntitySearchEvent; -use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\EntityFactoryInterface; -use EasyCorp\Bundle\EasyAdminBundle\Factory\FormFactory; use EasyCorp\Bundle\EasyAdminBundle\Factory\FormFactoryInterface; use EasyCorp\Bundle\EasyAdminBundle\Form\Type\ComparisonType; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Uid\Ulid; use Symfony\Component\Uid\Uuid; @@ -32,14 +27,23 @@ */ final class EntityRepository implements EntityRepositoryInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; + private ManagerRegistry $doctrine; - private EntityFactory $entityFactory; - private FormFactory $formFactory; + + private EntityFactoryInterface $entityFactory; + + private FormFactoryInterface $formFactory; + private EventDispatcherInterface $eventDispatcher; - public function __construct(AdminContextProviderInterface $adminContextProvider, ManagerRegistry $doctrine, EntityFactoryInterface $entityFactory, FormFactoryInterface $formFactory, EventDispatcherInterface $eventDispatcher) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + ManagerRegistry $doctrine, + EntityFactoryInterface $entityFactory, + FormFactoryInterface $formFactory, + EventDispatcherInterface $eventDispatcher + ) { $this->adminContextProvider = $adminContextProvider; $this->doctrine = $doctrine; $this->entityFactory = $entityFactory; @@ -47,14 +51,17 @@ public function __construct(AdminContextProviderInterface $adminContextProvider, $this->eventDispatcher = $eventDispatcher; } - public function createQueryBuilder(SearchDtoInterface $searchDto, EntityDtoInterface $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder - { + public function createQueryBuilder( + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto, + FieldCollection $fields, + FilterCollection $filters + ): QueryBuilder { /** @var EntityManagerInterface $entityManager */ $entityManager = $this->doctrine->getManagerForClass($entityDto->getFqcn()); $queryBuilder = $entityManager->createQueryBuilder() ->select('entity') - ->from($entityDto->getFqcn(), 'entity') - ; + ->from($entityDto->getFqcn(), 'entity'); if ('' !== $searchDto->getQuery()) { try { @@ -77,9 +84,16 @@ public function createQueryBuilder(SearchDtoInterface $searchDto, EntityDtoInter return $queryBuilder; } - private function addSearchClause(QueryBuilder $queryBuilder, SearchDtoInterface $searchDto, EntityDtoInterface $entityDto, string $databasePlatformFqcn): void - { - $isPostgreSql = PostgreSQLPlatform::class === $databasePlatformFqcn || is_subclass_of($databasePlatformFqcn, PostgreSQLPlatform::class); + private function addSearchClause( + QueryBuilder $queryBuilder, + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto, + string $databasePlatformFqcn + ): void { + $isPostgreSql = PostgreSQLPlatform::class === $databasePlatformFqcn || is_subclass_of( + $databasePlatformFqcn, + PostgreSQLPlatform::class + ); $searchablePropertiesConfig = $this->getSearchablePropertiesConfig($queryBuilder, $searchDto, $entityDto); $queryTerms = $searchDto->getQueryTerms(); @@ -111,24 +125,38 @@ private function addSearchClause(QueryBuilder $queryBuilder, SearchDtoInterface || ($propertyConfig['is_numeric'] && $isNumericQueryTerm) ) { $parameterName = sprintf('query_for_numbers_%d', $queryTermIndex); - $queryBuilder->orWhere(sprintf('%s.%s = :%s', $entityName, $propertyConfig['property_name'], $parameterName)) + $queryBuilder->orWhere( + sprintf('%s.%s = :%s', $entityName, $propertyConfig['property_name'], $parameterName) + ) ->setParameter($parameterName, $dqlParameters['numeric_query']); } elseif ($propertyConfig['is_guid'] && $isUuidQueryTerm) { $parameterName = sprintf('query_for_uuids_%d', $queryTermIndex); - $queryBuilder->orWhere(sprintf('%s.%s = :%s', $entityName, $propertyConfig['property_name'], $parameterName)) - ->setParameter($parameterName, $dqlParameters['uuid_query'], 'uuid' === $propertyConfig['property_data_type'] ? 'uuid' : null); + $queryBuilder->orWhere( + sprintf('%s.%s = :%s', $entityName, $propertyConfig['property_name'], $parameterName) + ) + ->setParameter( + $parameterName, + $dqlParameters['uuid_query'], + 'uuid' === $propertyConfig['property_data_type'] ? 'uuid' : null + ); } elseif ($propertyConfig['is_ulid'] && $isUlidQueryTerm) { $parameterName = sprintf('query_for_ulids_%d', $queryTermIndex); - $queryBuilder->orWhere(sprintf('%s.%s = :%s', $entityName, $propertyConfig['property_name'], $parameterName)) + $queryBuilder->orWhere( + sprintf('%s.%s = :%s', $entityName, $propertyConfig['property_name'], $parameterName) + ) ->setParameter($parameterName, $dqlParameters['uuid_query'], 'ulid'); } elseif ($propertyConfig['is_text']) { $parameterName = sprintf('query_for_text_%d', $queryTermIndex); - $queryBuilder->orWhere(sprintf('LOWER(%s.%s) LIKE :%s', $entityName, $propertyConfig['property_name'], $parameterName)) + $queryBuilder->orWhere( + sprintf('LOWER(%s.%s) LIKE :%s', $entityName, $propertyConfig['property_name'], $parameterName) + ) ->setParameter($parameterName, $dqlParameters['text_query']); } elseif ($propertyConfig['is_json'] && !$isPostgreSql) { // neither LOWER() nor LIKE() are supported for JSON columns by all PostgreSQL installations $parameterName = sprintf('query_for_text_%d', $queryTermIndex); - $queryBuilder->orWhere(sprintf('LOWER(%s.%s) LIKE :%s', $entityName, $propertyConfig['property_name'], $parameterName)) + $queryBuilder->orWhere( + sprintf('LOWER(%s.%s) LIKE :%s', $entityName, $propertyConfig['property_name'], $parameterName) + ) ->setParameter($parameterName, $dqlParameters['text_query']); } } @@ -137,8 +165,11 @@ private function addSearchClause(QueryBuilder $queryBuilder, SearchDtoInterface $this->eventDispatcher->dispatch(new AfterEntitySearchEvent($queryBuilder, $searchDto, $entityDto)); } - private function addOrderClause(QueryBuilder $queryBuilder, SearchDtoInterface $searchDto, EntityDtoInterface $entityDto): void - { + private function addOrderClause( + QueryBuilder $queryBuilder, + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto + ): void { foreach ($searchDto->getSort() as $sortProperty => $sortOrder) { $aliases = $queryBuilder->getAllAliases(); $sortFieldIsDoctrineAssociation = $entityDto->isAssociation($sortProperty); @@ -173,7 +204,9 @@ private function addOrderClause(QueryBuilder $queryBuilder, SearchDtoInterface $ ->where(sprintf('subQueryEntity.%s = entity', $metadata->get('mappedBy'))); } - $queryBuilder->addSelect(sprintf('(%s) as HIDDEN sub_query_sort', $countQueryBuilder->getDQL())); + $queryBuilder->addSelect( + sprintf('(%s) as HIDDEN sub_query_sort', $countQueryBuilder->getDQL()) + ); $queryBuilder->addOrderBy('sub_query_sort', $sortOrder); $queryBuilder->addOrderBy('entity.'.$entityDto->getPrimaryKeyName(), $sortOrder); } else { @@ -188,9 +221,17 @@ private function addOrderClause(QueryBuilder $queryBuilder, SearchDtoInterface $ } } - private function addFilterClause(QueryBuilder $queryBuilder, SearchDtoInterface $searchDto, EntityDtoInterface $entityDto, FilterCollection $configuredFilters, FieldCollection $fields): void - { - $filtersForm = $this->formFactory->createFiltersForm($configuredFilters, $this->adminContextProvider->getContext()->getRequest()); + private function addFilterClause( + QueryBuilder $queryBuilder, + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto, + FilterCollection $configuredFilters, + FieldCollection $fields + ): void { + $filtersForm = $this->formFactory->createFiltersForm( + $configuredFilters, + $this->adminContextProvider->getContext()->getRequest() + ); if (!$filtersForm->isSubmitted()) { return; } @@ -226,11 +267,16 @@ private function addFilterClause(QueryBuilder $queryBuilder, SearchDtoInterface } } - private function getSearchablePropertiesConfig(QueryBuilder $queryBuilder, SearchDtoInterface $searchDto, EntityDtoInterface $entityDto): array - { + private function getSearchablePropertiesConfig( + QueryBuilder $queryBuilder, + SearchDtoInterface $searchDto, + EntityDtoInterface $entityDto + ): array { $searchablePropertiesConfig = []; $configuredSearchableProperties = $searchDto->getSearchableProperties(); - $searchableProperties = (null === $configuredSearchableProperties || 0 === \count($configuredSearchableProperties)) ? $entityDto->getAllPropertyNames() : $configuredSearchableProperties; + $searchableProperties = (null === $configuredSearchableProperties || 0 === \count( + $configuredSearchableProperties + )) ? $entityDto->getAllPropertyNames() : $configuredSearchableProperties; $entitiesAlreadyJoined = []; foreach ($searchableProperties as $propertyName) { @@ -240,7 +286,14 @@ private function getSearchablePropertiesConfig(QueryBuilder $queryBuilder, Searc $numAssociatedProperties = \count($associatedProperties); if (1 === $numAssociatedProperties) { - throw new \InvalidArgumentException(sprintf('The "%s" property included in the setSearchFields() method is not a valid search field. When using associated properties in search, you must also define the exact field used in the search (e.g. \'%s.id\', \'%s.name\', etc.)', $propertyName, $propertyName, $propertyName)); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" property included in the setSearchFields() method is not a valid search field. When using associated properties in search, you must also define the exact field used in the search (e.g. \'%s.id\', \'%s.name\', etc.)', + $propertyName, + $propertyName, + $propertyName + ) + ); } $originalPropertyName = $associatedProperties[0]; @@ -255,7 +308,10 @@ private function getSearchablePropertiesConfig(QueryBuilder $queryBuilder, Searc if (!\in_array($associatedEntityName, $entitiesAlreadyJoined, true)) { $parentEntityName = 0 === $i ? 'entity' : $associatedProperties[$i - 1]; - $queryBuilder->leftJoin(Escaper::escapeDqlAlias($parentEntityName).'.'.$associatedEntityName, $associatedEntityAlias); + $queryBuilder->leftJoin( + Escaper::escapeDqlAlias($parentEntityName).'.'.$associatedEntityName, + $associatedEntityAlias + ); $entitiesAlreadyJoined[] = $associatedEntityName; } @@ -295,8 +351,7 @@ private function getSearchablePropertiesConfig(QueryBuilder $queryBuilder, Searc ) { $entityFqcn = 'entity' !== $entityName && isset($associatedEntityDto) ? $associatedEntityDto->getFqcn() - : $entityDto->getFqcn() - ; + : $entityDto->getFqcn(); /** @var \ReflectionNamedType|\ReflectionUnionType|null $idClassType */ $idClassType = (new \ReflectionProperty($entityFqcn, $propertyName))->getType(); diff --git a/src/Orm/EntityUpdater.php b/src/Orm/EntityUpdater.php index 1ee4049d4e..e4a4920e72 100644 --- a/src/Orm/EntityUpdater.php +++ b/src/Orm/EntityUpdater.php @@ -3,7 +3,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Orm; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Orm\EntityUpdaterInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Validator\ConstraintViolationList; @@ -26,7 +25,9 @@ public function __construct(PropertyAccessorInterface $propertyAccessor, Validat public function updateProperty(EntityDtoInterface $entityDto, string $propertyName, $value): void { if (!$this->propertyAccessor->isWritable($entityDto->getInstance(), $propertyName)) { - throw new \RuntimeException(sprintf('The "%s" property of the "%s" entity is not writable.', $propertyName, $entityDto->getName())); + throw new \RuntimeException( + sprintf('The "%s" property of the "%s" entity is not writable.', $propertyName, $entityDto->getName()) + ); } $entityInstance = $entityDto->getInstance(); @@ -35,7 +36,7 @@ public function updateProperty(EntityDtoInterface $entityDto, string $propertyNa /** @var ConstraintViolationList $violations */ $violations = $this->validator->validate($entityInstance); if (0 < \count($violations)) { - throw new \RuntimeException((string) $violations); + throw new \RuntimeException((string)$violations); } $entityDto->setInstance($entityInstance); diff --git a/src/Provider/FieldProvider.php b/src/Provider/FieldProvider.php index dce61e0ff0..9a784094bb 100644 --- a/src/Provider/FieldProvider.php +++ b/src/Provider/FieldProvider.php @@ -3,13 +3,12 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Provider; use Doctrine\DBAL\Types\Types; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Field\Field; final class FieldProvider implements FieldProviderInterface { - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; public function __construct(AdminContextProviderInterface $adminContextProvider) { @@ -24,7 +23,14 @@ public function getDefaultFields(string $pageName): array $excludedPropertyTypes = [ CrudInterface::PAGE_EDIT => [Types::BINARY, Types::BLOB, Types::JSON, Types::OBJECT], - CrudInterface::PAGE_INDEX => [Types::BINARY, Types::BLOB, Types::GUID, Types::JSON, Types::OBJECT, Types::TEXT], + CrudInterface::PAGE_INDEX => [ + Types::BINARY, + Types::BLOB, + Types::GUID, + Types::JSON, + Types::OBJECT, + Types::TEXT, + ], CrudInterface::PAGE_NEW => [Types::BINARY, Types::BLOB, Types::JSON, Types::OBJECT], CrudInterface::PAGE_DETAIL => [Types::BINARY, Types::JSON, Types::OBJECT], ]; @@ -38,7 +44,11 @@ public function getDefaultFields(string $pageName): array foreach ($entityDto->getAllPropertyNames() as $propertyName) { $metadata = $entityDto->getPropertyMetadata($propertyName); - if (!\in_array($propertyName, $excludedPropertyNames[$pageName], true) && !\in_array($metadata->get('type'), $excludedPropertyTypes[$pageName], true)) { + if (!\in_array($propertyName, $excludedPropertyNames[$pageName], true) && !\in_array( + $metadata->get('type'), + $excludedPropertyTypes[$pageName], + true + )) { $defaultPropertyNames[] = $propertyName; } } @@ -47,6 +57,6 @@ public function getDefaultFields(string $pageName): array $defaultPropertyNames = \array_slice($defaultPropertyNames, 0, $maxNumProperties, true); } - return array_map(static fn (string $fieldName) => Field::new($fieldName), $defaultPropertyNames); + return array_map(static fn(string $fieldName) => Field::new($fieldName), $defaultPropertyNames); } } diff --git a/src/Registry/CrudControllerRegistry.php b/src/Registry/CrudControllerRegistry.php index f58d26df34..07e453df2d 100644 --- a/src/Registry/CrudControllerRegistry.php +++ b/src/Registry/CrudControllerRegistry.php @@ -15,8 +15,12 @@ final class CrudControllerRegistry implements CrudControllerRegistryInterface * @param array $crudIdToCrudFqcnMap * @param array $entityFqcnToCrudFqcnMap */ - public function __construct(array $crudFqcnToEntityFqcnMap, array $crudFqcnToCrudIdMap, array $entityFqcnToCrudFqcnMap, array $crudIdToCrudFqcnMap) - { + public function __construct( + array $crudFqcnToEntityFqcnMap, + array $crudFqcnToCrudIdMap, + array $entityFqcnToCrudFqcnMap, + array $crudIdToCrudFqcnMap + ) { $this->crudFqcnToEntityFqcnMap = $crudFqcnToEntityFqcnMap; $this->crudFqcnToCrudIdMap = $crudFqcnToCrudIdMap; $this->entityFqcnToCrudFqcnMap = $entityFqcnToCrudFqcnMap; diff --git a/src/Registry/DashboardControllerRegistry.php b/src/Registry/DashboardControllerRegistry.php index ca33844a97..cd254e67a7 100644 --- a/src/Registry/DashboardControllerRegistry.php +++ b/src/Registry/DashboardControllerRegistry.php @@ -3,6 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Registry; use EasyCorp\Bundle\EasyAdminBundle\Cache\CacheWarmer; + use function Symfony\Component\String\u; final class DashboardControllerRegistry implements DashboardControllerRegistryInterface @@ -16,8 +17,11 @@ final class DashboardControllerRegistry implements DashboardControllerRegistryIn * @param string[] $controllerFqcnToContextIdMap * @param string[] $contextIdToControllerFqcnMap */ - public function __construct(string $cacheDir, array $controllerFqcnToContextIdMap, array $contextIdToControllerFqcnMap) - { + public function __construct( + string $cacheDir, + array $controllerFqcnToContextIdMap, + array $contextIdToControllerFqcnMap + ) { $this->controllerFqcnToContextIdMap = $controllerFqcnToContextIdMap; $this->contextIdToControllerFqcnMap = $contextIdToControllerFqcnMap; @@ -57,6 +61,8 @@ public function getNumberOfDashboards(): int public function getFirstDashboardRoute(): ?string { - return \count($this->controllerFqcnToRouteMap) < 1 ? null : $this->controllerFqcnToRouteMap[array_key_first($this->controllerFqcnToRouteMap)]; + return \count($this->controllerFqcnToRouteMap) < 1 ? null : $this->controllerFqcnToRouteMap[array_key_first( + $this->controllerFqcnToRouteMap + )]; } } diff --git a/src/Registry/TemplateRegistry.php b/src/Registry/TemplateRegistry.php index 72ed34344a..12187fadf3 100644 --- a/src/Registry/TemplateRegistry.php +++ b/src/Registry/TemplateRegistry.php @@ -76,7 +76,13 @@ public function has(string $templateName): bool public function get(string $templateName): string { if (!$this->has($templateName)) { - throw new \InvalidArgumentException(sprintf('The "%s" template is not defined in EasyAdmin. Use one of these allowed template names: %s', $templateName, implode(', ', array_keys($this->templates)))); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" template is not defined in EasyAdmin. Use one of these allowed template names: %s', + $templateName, + implode(', ', array_keys($this->templates)) + ) + ); } return $this->templates[$templateName]; @@ -85,7 +91,13 @@ public function get(string $templateName): string public function setTemplate(string $templateName, string $templatePath): void { if (!$this->has($templateName)) { - throw new \InvalidArgumentException(sprintf('The "%s" template is not defined in EasyAdmin. Use one of these allowed template names: %s', $templateName, implode(', ', array_keys($this->templates)))); + throw new \InvalidArgumentException( + sprintf( + 'The "%s" template is not defined in EasyAdmin. Use one of these allowed template names: %s', + $templateName, + implode(', ', array_keys($this->templates)) + ) + ); } $this->templates[$templateName] = $templatePath; diff --git a/src/Resources/bin/fix-assets-manifest-file.php b/src/Resources/bin/fix-assets-manifest-file.php index 4c7c324322..ba00634c54 100644 --- a/src/Resources/bin/fix-assets-manifest-file.php +++ b/src/Resources/bin/fix-assets-manifest-file.php @@ -24,7 +24,11 @@ // when assets contain RTL variants. function fixManifestJsonRtlEntries(string $manifestJsonPath) { - $manifestJsonContents = json_decode(file_get_contents($manifestJsonPath), associative: true, flags: \JSON_THROW_ON_ERROR); + $manifestJsonContents = json_decode( + file_get_contents($manifestJsonPath), + associative: true, + flags: \JSON_THROW_ON_ERROR + ); $fixedManifestJsonContents = []; foreach ($manifestJsonContents as $assetName => $assetPath) { // only the assets that include '.rtl.' extensions in their paths are wrong; ignore the rest @@ -50,7 +54,10 @@ function fixManifestJsonRtlEntries(string $manifestJsonPath) $fixedManifestJsonContents[$rtlAssetName] = $rtlAssetPath; } - $newJsonManifestContents = json_encode($fixedManifestJsonContents, flags: \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES); + $newJsonManifestContents = json_encode( + $fixedManifestJsonContents, + flags: \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES + ); // the original manifest.json file uses a 2 white space indentation, so keep that $newJsonManifestContents = str_replace(' ', ' ', $newJsonManifestContents); file_put_contents($manifestJsonPath, $newJsonManifestContents); @@ -70,14 +77,21 @@ function fixManifestJsonRtlEntries(string $manifestJsonPath) // This function removes that leading slash from all asset paths. function fixManifestJsonEntriesPaths(string $manifestJsonPath) { - $manifestJsonContents = json_decode(file_get_contents($manifestJsonPath), associative: true, flags: \JSON_THROW_ON_ERROR); + $manifestJsonContents = json_decode( + file_get_contents($manifestJsonPath), + associative: true, + flags: \JSON_THROW_ON_ERROR + ); $fixedManifestJsonContents = []; foreach ($manifestJsonContents as $assetName => $assetPath) { $assetPath = ltrim($assetPath, '/'); $fixedManifestJsonContents[$assetName] = $assetPath; } - $newJsonManifestContents = json_encode($fixedManifestJsonContents, flags: \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES); + $newJsonManifestContents = json_encode( + $fixedManifestJsonContents, + flags: \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES + ); // the original manifest.json file uses a 2 white space indentation, so keep that $newJsonManifestContents = str_replace(' ', ' ', $newJsonManifestContents); file_put_contents($manifestJsonPath, $newJsonManifestContents); @@ -91,7 +105,11 @@ function fixManifestJsonEntriesPaths(string $manifestJsonPath) // There might be some way of doing this in Webpack Encore, but I can't find it, so let's be pragmatic. function fixFontPathsInCssFiles(string $manifestJsonPath) { - $manifestJsonContents = json_decode(file_get_contents($manifestJsonPath), associative: true, flags: \JSON_THROW_ON_ERROR); + $manifestJsonContents = json_decode( + file_get_contents($manifestJsonPath), + associative: true, + flags: \JSON_THROW_ON_ERROR + ); foreach ($manifestJsonContents as $assetName => $assetPath) { if (!str_ends_with($assetPath, '.css')) { continue; diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php index 268768f36a..8842ca4fe9 100644 --- a/src/Resources/config/services.php +++ b/src/Resources/config/services.php @@ -95,279 +95,203 @@ $services ->set(MakeAdminDashboardCommand::class)->public() - ->arg(0, service(ClassMaker::class)) - ->arg(1, param('kernel.project_dir')) - ->tag('console.command') - + ->arg(0, service(ClassMaker::class)) + ->arg(1, param('kernel.project_dir')) + ->tag('console.command') ->set(MakeCrudControllerCommand::class)->public() - ->arg(0, param('kernel.project_dir')) - ->arg(1, service(ClassMaker::class)) - ->arg(2, service('doctrine')) - ->tag('console.command') - + ->arg(0, param('kernel.project_dir')) + ->arg(1, service(ClassMaker::class)) + ->arg(2, service('doctrine')) + ->tag('console.command') ->set(ClassMaker::class) - ->arg(0, service(KernelInterface::class)) - ->arg(1, param('kernel.project_dir')) - + ->arg(0, service(KernelInterface::class)) + ->arg(1, param('kernel.project_dir')) ->set(CacheWarmer::class) - ->arg(0, service('router')) - ->tag('kernel.cache_warmer') - + ->arg(0, service('router')) + ->tag('kernel.cache_warmer') ->set(DataCollector::class) - ->arg(0, service(AdminContextProvider::class)) - ->tag('data_collector', ['id' => 'easyadmin', 'template' => '@EasyAdmin/inspector/data_collector.html.twig']) - + ->arg(0, service(AdminContextProvider::class)) + ->tag('data_collector', ['id' => 'easyadmin', 'template' => '@EasyAdmin/inspector/data_collector.html.twig']) ->set(ExceptionListener::class) - ->arg(0, '%kernel.debug%') - ->arg(1, service(AdminContextProvider::class)) - ->arg(2, service('twig')) - ->tag('kernel.event_listener', ['event' => 'kernel.exception', 'priority' => -64]) - + ->arg(0, '%kernel.debug%') + ->arg(1, service(AdminContextProvider::class)) + ->arg(2, service('twig')) + ->tag('kernel.event_listener', ['event' => 'kernel.exception', 'priority' => -64]) ->set(EasyAdminTwigExtension::class) - // I don't know if we truly need the locator to get a new instance of the - // service whenever we generate a new URL, Maybe it's enough with the route parameter - // initialization done after generating each URL - ->arg(0, service('service_locator_'.AdminUrlGenerator::class)) - ->arg(1, service(AdminContextProvider::class)) - ->arg(2, new Reference('security.csrf.token_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE)) - ->tag('twig.extension') - + // I don't know if we truly need the locator to get a new instance of the + // service whenever we generate a new URL, Maybe it's enough with the route parameter + // initialization done after generating each URL + ->arg(0, service('service_locator_'.AdminUrlGenerator::class)) + ->arg(1, service(AdminContextProvider::class)) + ->arg(2, new Reference('security.csrf.token_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE)) + ->tag('twig.extension') ->set(EaCrudFormTypeExtension::class) - ->arg(0, service(AdminContextProvider::class)) - ->tag('form.type_extension') - + ->arg(0, service(AdminContextProvider::class)) + ->tag('form.type_extension') ->set(CollectionTypeExtension::class) - ->tag('form.type_extension') - + ->tag('form.type_extension') ->set(AuthorizationChecker::class) - ->arg(0, new Reference('security.authorization_checker', ContainerInterface::NULL_ON_INVALID_REFERENCE)) - + ->arg(0, new Reference('security.authorization_checker', ContainerInterface::NULL_ON_INVALID_REFERENCE)) ->set(IntlFormatter::class) - ->set(AdminContextProvider::class) - ->arg(0, service('request_stack')) - + ->arg(0, service('request_stack')) ->set(AdminContextResolver::class) - ->arg(0, service(AdminContextProvider::class)) - ->tag('controller.argument_value_resolver') - + ->arg(0, service(AdminContextProvider::class)) + ->tag('controller.argument_value_resolver') ->set(BatchActionDtoResolver::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, service(AdminUrlGenerator::class)) - ->tag('controller.argument_value_resolver') - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, service(AdminUrlGenerator::class)) + ->tag('controller.argument_value_resolver') ->set(AdminRouterSubscriber::class) - ->arg(0, service(AdminContextFactory::class)) - ->arg(1, service(ControllerFactory::class)) - ->arg(2, service('controller_resolver')) - ->arg(3, service('router')) - ->arg(4, service('router')) - ->tag('kernel.event_subscriber') - + ->arg(0, service(AdminContextFactory::class)) + ->arg(1, service(ControllerFactory::class)) + ->arg(2, service('controller_resolver')) + ->arg(3, service('router')) + ->arg(4, service('router')) + ->tag('kernel.event_subscriber') ->set(ControllerFactory::class) - ->arg(0, service('controller_resolver')) - + ->arg(0, service('controller_resolver')) ->set(CrudResponseListener::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, service('twig')) - ->tag('kernel.event_listener', ['event' => ViewEvent::class]) - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, service('twig')) + ->tag('kernel.event_listener', ['event' => ViewEvent::class]) ->set(AdminContextFactory::class) - ->arg(0, '%kernel.cache_dir%') - ->arg(1, new Reference('security.token_storage', ContainerInterface::NULL_ON_INVALID_REFERENCE)) - ->arg(2, new Reference(MenuFactory::class)) - ->arg(3, new Reference(CrudControllerRegistry::class)) - ->arg(4, new Reference(EntityFactory::class)) - + ->arg(0, '%kernel.cache_dir%') + ->arg(1, new Reference('security.token_storage', ContainerInterface::NULL_ON_INVALID_REFERENCE)) + ->arg(2, new Reference(MenuFactory::class)) + ->arg(3, new Reference(CrudControllerRegistry::class)) + ->arg(4, new Reference(EntityFactory::class)) ->set(AdminUrlGenerator::class) - // I don't know if we truly need the share() method to get a new instance of the - // service whenever we generate a new URL. Maybe it's enough with the route parameter - // initialization done after generating each URL - ->share(false) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, service('router')) - ->arg(2, service(DashboardControllerRegistry::class)) - + // I don't know if we truly need the share() method to get a new instance of the + // service whenever we generate a new URL. Maybe it's enough with the route parameter + // initialization done after generating each URL + ->share(false) + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, service('router')) + ->arg(2, service(DashboardControllerRegistry::class)) ->set('service_locator_'.AdminUrlGenerator::class, ServiceLocator::class) - ->args([[AdminUrlGenerator::class => service(AdminUrlGenerator::class)]]) - ->tag('container.service_locator') - + ->args([[AdminUrlGenerator::class => service(AdminUrlGenerator::class)]]) + ->tag('container.service_locator') ->set(UrlSigner::class) - ->arg(0, '%kernel.secret%') - + ->arg(0, '%kernel.secret%') ->set(MenuFactory::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, service(AuthorizationChecker::class)) - ->arg(2, service('security.logout_url_generator')) - ->arg(3, service(AdminUrlGenerator::class)) - ->arg(4, service(MenuItemMatcherInterface::class)) - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, service(AuthorizationChecker::class)) + ->arg(2, service('security.logout_url_generator')) + ->arg(3, service(AdminUrlGenerator::class)) + ->arg(4, service(MenuItemMatcherInterface::class)) ->set(MenuItemMatcher::class) - ->arg(0, service(AdminContextProvider::class)) - + ->arg(0, service(AdminContextProvider::class)) ->alias(MenuItemMatcherInterface::class, MenuItemMatcher::class) - ->set(EntityRepository::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, service('doctrine')) - ->arg(2, service(EntityFactory::class)) - ->arg(3, service(FormFactory::class)) - ->arg(4, service('event_dispatcher')) - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, service('doctrine')) + ->arg(2, service(EntityFactory::class)) + ->arg(3, service(FormFactory::class)) + ->arg(4, service('event_dispatcher')) ->set(EntityFactory::class) - ->arg(0, service(FieldFactory::class)) - ->arg(1, service(ActionFactory::class)) - ->arg(2, service(AuthorizationChecker::class)) - ->arg(3, service('doctrine')) - ->arg(4, service('event_dispatcher')) - + ->arg(0, service(FieldFactory::class)) + ->arg(1, service(ActionFactory::class)) + ->arg(2, service(AuthorizationChecker::class)) + ->arg(3, service('doctrine')) + ->arg(4, service('event_dispatcher')) ->set(EntityPaginator::class) - ->arg(0, service(AdminUrlGenerator::class)) - ->arg(1, service(EntityFactory::class)) - + ->arg(0, service(AdminUrlGenerator::class)) + ->arg(1, service(EntityFactory::class)) ->set(EntityUpdater::class) - ->arg(0, service('property_accessor')) - ->arg(1, service('validator')) - + ->arg(0, service('property_accessor')) + ->arg(1, service('validator')) ->set(PaginatorFactory::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, service(EntityPaginator::class)) - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, service(EntityPaginator::class)) ->set(FormFactory::class) - ->arg(0, service('form.factory')) - + ->arg(0, service('form.factory')) ->set(FieldFactory::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, service(AuthorizationChecker::class)) - ->arg(2, tagged_iterator(EasyAdminExtension::TAG_FIELD_CONFIGURATOR)) - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, service(AuthorizationChecker::class)) + ->arg(2, tagged_iterator(EasyAdminExtension::TAG_FIELD_CONFIGURATOR)) ->set(FieldProvider::class) - ->arg(0, service(AdminContextProvider::class)) - + ->arg(0, service(AdminContextProvider::class)) ->set(FilterFactory::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, tagged_iterator(EasyAdminExtension::TAG_FILTER_CONFIGURATOR)) - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, tagged_iterator(EasyAdminExtension::TAG_FILTER_CONFIGURATOR)) ->set(FiltersFormType::class) - ->tag('form.type', ['alias' => 'ea_filters']) - + ->tag('form.type', ['alias' => 'ea_filters']) ->set(FileUploadType::class) - ->arg(0, param('kernel.project_dir')) - ->tag('form.type') - + ->arg(0, param('kernel.project_dir')) + ->tag('form.type') ->set(ChoiceFilterConfigurator::class) - ->set(CommonFilterConfigurator::class) - ->tag(EasyAdminExtension::TAG_FILTER_CONFIGURATOR, ['priority' => 9999]) - + ->tag(EasyAdminExtension::TAG_FILTER_CONFIGURATOR, ['priority' => 9999]) ->set(ComparisonFilterConfigurator::class) - ->set(DateTimeFilterConfigurator::class) - ->set(EntityFilterConfigurator::class) - ->set(NullFilterConfigurator::class) - ->set(NumericFilterConfigurator::class) - ->set(TextFilterConfigurator::class) - ->set(ActionFactory::class) - ->arg(0, new Reference(AdminContextProvider::class)) - ->arg(1, new Reference(AuthorizationChecker::class)) - ->arg(2, new Reference(AdminUrlGenerator::class)) - ->arg(3, new Reference('security.csrf.token_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE)) - + ->arg(0, new Reference(AdminContextProvider::class)) + ->arg(1, new Reference(AuthorizationChecker::class)) + ->arg(2, new Reference(AdminUrlGenerator::class)) + ->arg(3, new Reference('security.csrf.token_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE)) ->set(SecurityVoter::class) - ->arg(0, service(AuthorizationChecker::class)) - ->arg(1, service(AdminContextProvider::class)) - ->tag('security.voter') - + ->arg(0, service(AuthorizationChecker::class)) + ->arg(1, service(AdminContextProvider::class)) + ->tag('security.voter') ->set(CrudFormType::class) - ->arg(0, service('form.type_guesser.doctrine')) - ->tag('form.type', ['alias' => 'ea_crud']) - + ->arg(0, service('form.type_guesser.doctrine')) + ->tag('form.type', ['alias' => 'ea_crud']) ->set(ArrayConfigurator::class) - ->set(AssociationConfigurator::class) - ->arg(0, new Reference(EntityFactory::class)) - ->arg(1, new Reference(AdminUrlGenerator::class)) - ->arg(2, service('request_stack')) - ->arg(3, service(ControllerFactory::class)) - + ->arg(0, new Reference(EntityFactory::class)) + ->arg(1, new Reference(AdminUrlGenerator::class)) + ->arg(2, service('request_stack')) + ->arg(3, service(ControllerFactory::class)) ->set(AvatarConfigurator::class) - ->set(BooleanConfigurator::class) - ->arg(0, service(AdminUrlGenerator::class)) - ->arg(1, new Reference('security.csrf.token_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE)) - + ->arg(0, service(AdminUrlGenerator::class)) + ->arg(1, new Reference('security.csrf.token_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE)) ->set(CodeEditorConfigurator::class) - ->set(CollectionConfigurator::class) - ->set(CommonPostConfigurator::class) - ->arg(0, service(AdminContextProvider::class)) - ->arg(1, '%kernel.charset%') - ->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR, ['priority' => -9999]) - + ->arg(0, service(AdminContextProvider::class)) + ->arg(1, '%kernel.charset%') + ->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR, ['priority' => -9999]) ->set(CommonPreConfigurator::class) - ->arg(0, new Reference('property_accessor')) - ->arg(1, service(EntityFactory::class)) - ->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR, ['priority' => 9999]) - + ->arg(0, new Reference('property_accessor')) + ->arg(1, service(EntityFactory::class)) + ->tag(EasyAdminExtension::TAG_FIELD_CONFIGURATOR, ['priority' => 9999]) ->set(CountryConfigurator::class) - ->arg(0, service(AssetPackage::class)) - + ->arg(0, service(AssetPackage::class)) ->set(CurrencyConfigurator::class) - ->set(DateTimeConfigurator::class) - ->arg(0, service(IntlFormatter::class)) - + ->arg(0, service(IntlFormatter::class)) ->set(EmailConfigurator::class) - ->set(FormConfigurator::class) - ->set(IdConfigurator::class) - ->set(ImageConfigurator::class) - ->arg(0, param('kernel.project_dir')) - + ->arg(0, param('kernel.project_dir')) ->set(IntegerConfigurator::class) - ->set(LanguageConfigurator::class) - ->set(LocaleConfigurator::class) - ->set(MoneyConfigurator::class) - ->arg(0, service(IntlFormatter::class)) - ->arg(1, service('property_accessor')) - + ->arg(0, service(IntlFormatter::class)) + ->arg(1, service('property_accessor')) ->set(NumberConfigurator::class) - ->arg(0, service(IntlFormatter::class)) - + ->arg(0, service(IntlFormatter::class)) ->set(PercentConfigurator::class) - ->set(ChoiceConfigurator::class) - ->set(CollectionConfigurator::class) - ->arg(0, service('request_stack')) - ->arg(1, service(EntityFactory::class)) - ->arg(2, service(ControllerFactory::class)) - + ->arg(0, service('request_stack')) + ->arg(1, service(EntityFactory::class)) + ->arg(2, service(ControllerFactory::class)) ->set(SlugConfigurator::class) - ->set(TelephoneConfigurator::class) - ->set(TextConfigurator::class) - ->set(TextEditorConfigurator::class) - ->set(TimezoneConfigurator::class) - ->set(UrlConfigurator::class) - ->set(AssetPackage::class) - ->arg(0, service('request_stack')) - ->tag('assets.package', ['package' => AssetPackage::PACKAGE_NAME]) - ; + ->arg(0, service('request_stack')) + ->tag('assets.package', ['package' => AssetPackage::PACKAGE_NAME]); }; diff --git a/src/Resources/public/images/flags/AC.svg b/src/Resources/public/images/flags/AC.svg index 533933266e..ed192f32e3 100644 --- a/src/Resources/public/images/flags/AC.svg +++ b/src/Resources/public/images/flags/AC.svg @@ -1 +1,32 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/AD.svg b/src/Resources/public/images/flags/AD.svg index 5b5c6c6dd7..b5edce5e60 100644 --- a/src/Resources/public/images/flags/AD.svg +++ b/src/Resources/public/images/flags/AD.svg @@ -1 +1,16 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/AE.svg b/src/Resources/public/images/flags/AE.svg index 59ddafd6a7..bdc9935dc0 100644 --- a/src/Resources/public/images/flags/AE.svg +++ b/src/Resources/public/images/flags/AE.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/AF.svg b/src/Resources/public/images/flags/AF.svg index 9cec9d8aaf..d1596ea1d3 100644 --- a/src/Resources/public/images/flags/AF.svg +++ b/src/Resources/public/images/flags/AF.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/AG.svg b/src/Resources/public/images/flags/AG.svg index 16881fe0e0..61421f71b4 100644 --- a/src/Resources/public/images/flags/AG.svg +++ b/src/Resources/public/images/flags/AG.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/AI.svg b/src/Resources/public/images/flags/AI.svg index a7fcfd0e82..218db6a909 100644 --- a/src/Resources/public/images/flags/AI.svg +++ b/src/Resources/public/images/flags/AI.svg @@ -1 +1,17 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/AL.svg b/src/Resources/public/images/flags/AL.svg index d7989d9fd4..2ca60e90bc 100644 --- a/src/Resources/public/images/flags/AL.svg +++ b/src/Resources/public/images/flags/AL.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/AM.svg b/src/Resources/public/images/flags/AM.svg index d49087d8a7..6df0ead0a7 100644 --- a/src/Resources/public/images/flags/AM.svg +++ b/src/Resources/public/images/flags/AM.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/AO.svg b/src/Resources/public/images/flags/AO.svg index ec0d1e6a4a..f720411b45 100644 --- a/src/Resources/public/images/flags/AO.svg +++ b/src/Resources/public/images/flags/AO.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/AQ.svg b/src/Resources/public/images/flags/AQ.svg index 14d59c7b52..e2182ecf77 100644 --- a/src/Resources/public/images/flags/AQ.svg +++ b/src/Resources/public/images/flags/AQ.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/AR.svg b/src/Resources/public/images/flags/AR.svg index 8dfd3df754..381287c9da 100644 --- a/src/Resources/public/images/flags/AR.svg +++ b/src/Resources/public/images/flags/AR.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/AS.svg b/src/Resources/public/images/flags/AS.svg index bd00809cf1..1be1a99e3a 100644 --- a/src/Resources/public/images/flags/AS.svg +++ b/src/Resources/public/images/flags/AS.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/AT.svg b/src/Resources/public/images/flags/AT.svg index 6ccf7c44ff..f82215067e 100644 --- a/src/Resources/public/images/flags/AT.svg +++ b/src/Resources/public/images/flags/AT.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/AU.svg b/src/Resources/public/images/flags/AU.svg index f91b01301e..a78857589e 100644 --- a/src/Resources/public/images/flags/AU.svg +++ b/src/Resources/public/images/flags/AU.svg @@ -1 +1,18 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/AW.svg b/src/Resources/public/images/flags/AW.svg index cff670d9cc..6c04429aa4 100644 --- a/src/Resources/public/images/flags/AW.svg +++ b/src/Resources/public/images/flags/AW.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/AX.svg b/src/Resources/public/images/flags/AX.svg index 9bbfa5165f..fec7391884 100644 --- a/src/Resources/public/images/flags/AX.svg +++ b/src/Resources/public/images/flags/AX.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/AZ.svg b/src/Resources/public/images/flags/AZ.svg index 486d3b8d73..5dc6098dcc 100644 --- a/src/Resources/public/images/flags/AZ.svg +++ b/src/Resources/public/images/flags/AZ.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/BA.svg b/src/Resources/public/images/flags/BA.svg index 1731a3af10..cfc76f7ef3 100644 --- a/src/Resources/public/images/flags/BA.svg +++ b/src/Resources/public/images/flags/BA.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/BB.svg b/src/Resources/public/images/flags/BB.svg index 05e0dd9022..3666bfaa9c 100644 --- a/src/Resources/public/images/flags/BB.svg +++ b/src/Resources/public/images/flags/BB.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/BD.svg b/src/Resources/public/images/flags/BD.svg index e3c7267d2c..bc12b4c2fb 100644 --- a/src/Resources/public/images/flags/BD.svg +++ b/src/Resources/public/images/flags/BD.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/BE.svg b/src/Resources/public/images/flags/BE.svg index cc1b013869..3b1abf6b37 100644 --- a/src/Resources/public/images/flags/BE.svg +++ b/src/Resources/public/images/flags/BE.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/BF.svg b/src/Resources/public/images/flags/BF.svg index 126e61f11e..309c913409 100644 --- a/src/Resources/public/images/flags/BF.svg +++ b/src/Resources/public/images/flags/BF.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/BG.svg b/src/Resources/public/images/flags/BG.svg index 7ebee3839e..da517931cc 100644 --- a/src/Resources/public/images/flags/BG.svg +++ b/src/Resources/public/images/flags/BG.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/BH.svg b/src/Resources/public/images/flags/BH.svg index 5134d60044..d145e91082 100644 --- a/src/Resources/public/images/flags/BH.svg +++ b/src/Resources/public/images/flags/BH.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/BI.svg b/src/Resources/public/images/flags/BI.svg index 68ac163012..fd933b2902 100644 --- a/src/Resources/public/images/flags/BI.svg +++ b/src/Resources/public/images/flags/BI.svg @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/BJ.svg b/src/Resources/public/images/flags/BJ.svg index 63a6f9ba6a..49bd22e307 100644 --- a/src/Resources/public/images/flags/BJ.svg +++ b/src/Resources/public/images/flags/BJ.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/BL.svg b/src/Resources/public/images/flags/BL.svg index dd9cdb581d..cf9a196087 100644 --- a/src/Resources/public/images/flags/BL.svg +++ b/src/Resources/public/images/flags/BL.svg @@ -1 +1,21 @@ - \ No newline at end of file + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/BM.svg b/src/Resources/public/images/flags/BM.svg index 97a7d2b385..1ccf4a0910 100644 --- a/src/Resources/public/images/flags/BM.svg +++ b/src/Resources/public/images/flags/BM.svg @@ -1 +1,17 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/BN.svg b/src/Resources/public/images/flags/BN.svg index 3b758a0440..690a37d369 100644 --- a/src/Resources/public/images/flags/BN.svg +++ b/src/Resources/public/images/flags/BN.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/BO.svg b/src/Resources/public/images/flags/BO.svg index 6a0996e9cf..7c5db4bd3e 100644 --- a/src/Resources/public/images/flags/BO.svg +++ b/src/Resources/public/images/flags/BO.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/BQ.svg b/src/Resources/public/images/flags/BQ.svg index 6318504bd1..df78e1aebe 100644 --- a/src/Resources/public/images/flags/BQ.svg +++ b/src/Resources/public/images/flags/BQ.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/BR.svg b/src/Resources/public/images/flags/BR.svg index f4dbb020aa..c1a3f381db 100644 --- a/src/Resources/public/images/flags/BR.svg +++ b/src/Resources/public/images/flags/BR.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/BS.svg b/src/Resources/public/images/flags/BS.svg index aac6004747..01962b5dd6 100644 --- a/src/Resources/public/images/flags/BS.svg +++ b/src/Resources/public/images/flags/BS.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/BT.svg b/src/Resources/public/images/flags/BT.svg index ed53f32268..b4b0684509 100644 --- a/src/Resources/public/images/flags/BT.svg +++ b/src/Resources/public/images/flags/BT.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/BV.svg b/src/Resources/public/images/flags/BV.svg index c3652bf504..b629ed2928 100644 --- a/src/Resources/public/images/flags/BV.svg +++ b/src/Resources/public/images/flags/BV.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/BW.svg b/src/Resources/public/images/flags/BW.svg index 5343de6e22..7d3be45bd4 100644 --- a/src/Resources/public/images/flags/BW.svg +++ b/src/Resources/public/images/flags/BW.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/BY.svg b/src/Resources/public/images/flags/BY.svg index 86a423adfe..e743d7832a 100644 --- a/src/Resources/public/images/flags/BY.svg +++ b/src/Resources/public/images/flags/BY.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/BZ.svg b/src/Resources/public/images/flags/BZ.svg index 9ac59b0c1e..9dc9a99f64 100644 --- a/src/Resources/public/images/flags/BZ.svg +++ b/src/Resources/public/images/flags/BZ.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/CA.svg b/src/Resources/public/images/flags/CA.svg index 457d316fed..38c2366bb1 100644 --- a/src/Resources/public/images/flags/CA.svg +++ b/src/Resources/public/images/flags/CA.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/CC.svg b/src/Resources/public/images/flags/CC.svg index 16c3b6672f..34ce746c02 100644 --- a/src/Resources/public/images/flags/CC.svg +++ b/src/Resources/public/images/flags/CC.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/CD.svg b/src/Resources/public/images/flags/CD.svg index 203b3c65dc..77021e8d39 100644 --- a/src/Resources/public/images/flags/CD.svg +++ b/src/Resources/public/images/flags/CD.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/CF.svg b/src/Resources/public/images/flags/CF.svg index f7eaa95425..faca2ed4a5 100644 --- a/src/Resources/public/images/flags/CF.svg +++ b/src/Resources/public/images/flags/CF.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/CG.svg b/src/Resources/public/images/flags/CG.svg index d8b6c13b5f..25e41009f1 100644 --- a/src/Resources/public/images/flags/CG.svg +++ b/src/Resources/public/images/flags/CG.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/CH.svg b/src/Resources/public/images/flags/CH.svg index 498b7d18c2..798b6a3bb8 100644 --- a/src/Resources/public/images/flags/CH.svg +++ b/src/Resources/public/images/flags/CH.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/CI.svg b/src/Resources/public/images/flags/CI.svg index 24ae0ea160..afa6ba81e1 100644 --- a/src/Resources/public/images/flags/CI.svg +++ b/src/Resources/public/images/flags/CI.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/CK.svg b/src/Resources/public/images/flags/CK.svg index 0e21062405..a0099bda48 100644 --- a/src/Resources/public/images/flags/CK.svg +++ b/src/Resources/public/images/flags/CK.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/CL.svg b/src/Resources/public/images/flags/CL.svg index cd2f03a5b6..1f57f3daf8 100644 --- a/src/Resources/public/images/flags/CL.svg +++ b/src/Resources/public/images/flags/CL.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/CM.svg b/src/Resources/public/images/flags/CM.svg index f564968c3e..eab795bec0 100644 --- a/src/Resources/public/images/flags/CM.svg +++ b/src/Resources/public/images/flags/CM.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/CN.svg b/src/Resources/public/images/flags/CN.svg index 64629b25e2..f8b9b3738d 100644 --- a/src/Resources/public/images/flags/CN.svg +++ b/src/Resources/public/images/flags/CN.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/CO.svg b/src/Resources/public/images/flags/CO.svg index dc46df0ae8..c037bb1343 100644 --- a/src/Resources/public/images/flags/CO.svg +++ b/src/Resources/public/images/flags/CO.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/CR.svg b/src/Resources/public/images/flags/CR.svg index 57ce8cb13d..cdf3d66f03 100644 --- a/src/Resources/public/images/flags/CR.svg +++ b/src/Resources/public/images/flags/CR.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/CU.svg b/src/Resources/public/images/flags/CU.svg index 780e99c248..ef4a3536c3 100644 --- a/src/Resources/public/images/flags/CU.svg +++ b/src/Resources/public/images/flags/CU.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/CV.svg b/src/Resources/public/images/flags/CV.svg index a3e3ed487c..e51e4767ee 100644 --- a/src/Resources/public/images/flags/CV.svg +++ b/src/Resources/public/images/flags/CV.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/CW.svg b/src/Resources/public/images/flags/CW.svg index 6fdf2234e0..746c69b6ef 100644 --- a/src/Resources/public/images/flags/CW.svg +++ b/src/Resources/public/images/flags/CW.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/CX.svg b/src/Resources/public/images/flags/CX.svg index 197201d091..c6e2110196 100644 --- a/src/Resources/public/images/flags/CX.svg +++ b/src/Resources/public/images/flags/CX.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/CY.svg b/src/Resources/public/images/flags/CY.svg index 3998689462..cd41b46635 100644 --- a/src/Resources/public/images/flags/CY.svg +++ b/src/Resources/public/images/flags/CY.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/CZ.svg b/src/Resources/public/images/flags/CZ.svg index 9eb556b68b..8be8ee4a76 100644 --- a/src/Resources/public/images/flags/CZ.svg +++ b/src/Resources/public/images/flags/CZ.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/DE.svg b/src/Resources/public/images/flags/DE.svg index 295d13e1bc..bcb4636082 100644 --- a/src/Resources/public/images/flags/DE.svg +++ b/src/Resources/public/images/flags/DE.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/DJ.svg b/src/Resources/public/images/flags/DJ.svg index e79b3bdce5..0a33143eba 100644 --- a/src/Resources/public/images/flags/DJ.svg +++ b/src/Resources/public/images/flags/DJ.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/DK.svg b/src/Resources/public/images/flags/DK.svg index 1fecf561fe..49bdf5b9ac 100644 --- a/src/Resources/public/images/flags/DK.svg +++ b/src/Resources/public/images/flags/DK.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/DM.svg b/src/Resources/public/images/flags/DM.svg index 6b8da647ec..c7cd316670 100644 --- a/src/Resources/public/images/flags/DM.svg +++ b/src/Resources/public/images/flags/DM.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/DO.svg b/src/Resources/public/images/flags/DO.svg index 4fa38174a8..b0bea82577 100644 --- a/src/Resources/public/images/flags/DO.svg +++ b/src/Resources/public/images/flags/DO.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/DZ.svg b/src/Resources/public/images/flags/DZ.svg index fe8bb71411..aa4b7b01cc 100644 --- a/src/Resources/public/images/flags/DZ.svg +++ b/src/Resources/public/images/flags/DZ.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/EC.svg b/src/Resources/public/images/flags/EC.svg index bb8e07f521..f292428b36 100644 --- a/src/Resources/public/images/flags/EC.svg +++ b/src/Resources/public/images/flags/EC.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/EE.svg b/src/Resources/public/images/flags/EE.svg index 28a9e16f9f..c8ed25c9d4 100644 --- a/src/Resources/public/images/flags/EE.svg +++ b/src/Resources/public/images/flags/EE.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/EG.svg b/src/Resources/public/images/flags/EG.svg index 3aa0feecf4..f35df57640 100644 --- a/src/Resources/public/images/flags/EG.svg +++ b/src/Resources/public/images/flags/EG.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/EH.svg b/src/Resources/public/images/flags/EH.svg index c2e0c07e44..4a1fe474f9 100644 --- a/src/Resources/public/images/flags/EH.svg +++ b/src/Resources/public/images/flags/EH.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/ER.svg b/src/Resources/public/images/flags/ER.svg index b361debcbe..f853a625c7 100644 --- a/src/Resources/public/images/flags/ER.svg +++ b/src/Resources/public/images/flags/ER.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/ES.svg b/src/Resources/public/images/flags/ES.svg index e143324945..c4e7d7aa12 100644 --- a/src/Resources/public/images/flags/ES.svg +++ b/src/Resources/public/images/flags/ES.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/ET.svg b/src/Resources/public/images/flags/ET.svg index a4c6e32175..9219a3888f 100644 --- a/src/Resources/public/images/flags/ET.svg +++ b/src/Resources/public/images/flags/ET.svg @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/EU.svg b/src/Resources/public/images/flags/EU.svg index a359b058a5..489f005d79 100644 --- a/src/Resources/public/images/flags/EU.svg +++ b/src/Resources/public/images/flags/EU.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/FI.svg b/src/Resources/public/images/flags/FI.svg index 285363ee84..9b8f028fbd 100644 --- a/src/Resources/public/images/flags/FI.svg +++ b/src/Resources/public/images/flags/FI.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/FJ.svg b/src/Resources/public/images/flags/FJ.svg index 9fdf4ac529..0eeff97e3f 100644 --- a/src/Resources/public/images/flags/FJ.svg +++ b/src/Resources/public/images/flags/FJ.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/FK.svg b/src/Resources/public/images/flags/FK.svg index 3c17685bb4..d56017f810 100644 --- a/src/Resources/public/images/flags/FK.svg +++ b/src/Resources/public/images/flags/FK.svg @@ -1 +1,24 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/FM.svg b/src/Resources/public/images/flags/FM.svg index 36aec4c8e4..50d5508e7c 100644 --- a/src/Resources/public/images/flags/FM.svg +++ b/src/Resources/public/images/flags/FM.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/FO.svg b/src/Resources/public/images/flags/FO.svg index 524e87b8be..a6f62ae354 100644 --- a/src/Resources/public/images/flags/FO.svg +++ b/src/Resources/public/images/flags/FO.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/FR.svg b/src/Resources/public/images/flags/FR.svg index 67479849bc..c3b506fded 100644 --- a/src/Resources/public/images/flags/FR.svg +++ b/src/Resources/public/images/flags/FR.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GA.svg b/src/Resources/public/images/flags/GA.svg index 7291224181..571a036028 100644 --- a/src/Resources/public/images/flags/GA.svg +++ b/src/Resources/public/images/flags/GA.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GB.svg b/src/Resources/public/images/flags/GB.svg index 91f11d83b2..6037e645b1 100644 --- a/src/Resources/public/images/flags/GB.svg +++ b/src/Resources/public/images/flags/GB.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/GD.svg b/src/Resources/public/images/flags/GD.svg index e257d21051..432bfa8807 100644 --- a/src/Resources/public/images/flags/GD.svg +++ b/src/Resources/public/images/flags/GD.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/GE-AB.svg b/src/Resources/public/images/flags/GE-AB.svg index 544852e4f5..3c2b3efb85 100644 --- a/src/Resources/public/images/flags/GE-AB.svg +++ b/src/Resources/public/images/flags/GE-AB.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/GE-OS.svg b/src/Resources/public/images/flags/GE-OS.svg index 18344e23bb..13f35df690 100644 --- a/src/Resources/public/images/flags/GE-OS.svg +++ b/src/Resources/public/images/flags/GE-OS.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GE.svg b/src/Resources/public/images/flags/GE.svg index b418200650..32c6873fb0 100644 --- a/src/Resources/public/images/flags/GE.svg +++ b/src/Resources/public/images/flags/GE.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GF.svg b/src/Resources/public/images/flags/GF.svg index a163357a68..a4e6d992d9 100644 --- a/src/Resources/public/images/flags/GF.svg +++ b/src/Resources/public/images/flags/GF.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GG.svg b/src/Resources/public/images/flags/GG.svg index 48f90b5579..7d485ee407 100644 --- a/src/Resources/public/images/flags/GG.svg +++ b/src/Resources/public/images/flags/GG.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GH.svg b/src/Resources/public/images/flags/GH.svg index f59c0a4055..6d8e43f3d1 100644 --- a/src/Resources/public/images/flags/GH.svg +++ b/src/Resources/public/images/flags/GH.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/GI.svg b/src/Resources/public/images/flags/GI.svg index da68f69c85..d171890591 100644 --- a/src/Resources/public/images/flags/GI.svg +++ b/src/Resources/public/images/flags/GI.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/GL.svg b/src/Resources/public/images/flags/GL.svg index 0cbd6ff437..5f60e79131 100644 --- a/src/Resources/public/images/flags/GL.svg +++ b/src/Resources/public/images/flags/GL.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/GM.svg b/src/Resources/public/images/flags/GM.svg index 30e0c6a5c5..dc225179bf 100644 --- a/src/Resources/public/images/flags/GM.svg +++ b/src/Resources/public/images/flags/GM.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/GN.svg b/src/Resources/public/images/flags/GN.svg index 62427f4a7b..441d395138 100644 --- a/src/Resources/public/images/flags/GN.svg +++ b/src/Resources/public/images/flags/GN.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GP.svg b/src/Resources/public/images/flags/GP.svg index 67479849bc..c3b506fded 100644 --- a/src/Resources/public/images/flags/GP.svg +++ b/src/Resources/public/images/flags/GP.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/GQ.svg b/src/Resources/public/images/flags/GQ.svg index 42f6b11ae1..23302bf08b 100644 --- a/src/Resources/public/images/flags/GQ.svg +++ b/src/Resources/public/images/flags/GQ.svg @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/GR.svg b/src/Resources/public/images/flags/GR.svg index 00671707e4..26edb4ce3c 100644 --- a/src/Resources/public/images/flags/GR.svg +++ b/src/Resources/public/images/flags/GR.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/GS.svg b/src/Resources/public/images/flags/GS.svg index 0706e7b29f..73c1281a7b 100644 --- a/src/Resources/public/images/flags/GS.svg +++ b/src/Resources/public/images/flags/GS.svg @@ -1 +1,25 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/GT.svg b/src/Resources/public/images/flags/GT.svg index 20882e97a9..d0236c4c21 100644 --- a/src/Resources/public/images/flags/GT.svg +++ b/src/Resources/public/images/flags/GT.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/GU.svg b/src/Resources/public/images/flags/GU.svg index 553d206d5c..10fb35048b 100644 --- a/src/Resources/public/images/flags/GU.svg +++ b/src/Resources/public/images/flags/GU.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/GW.svg b/src/Resources/public/images/flags/GW.svg index 48d9a9c034..e3a9207fcb 100644 --- a/src/Resources/public/images/flags/GW.svg +++ b/src/Resources/public/images/flags/GW.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/GY.svg b/src/Resources/public/images/flags/GY.svg index f2d09f0a82..274ec09146 100644 --- a/src/Resources/public/images/flags/GY.svg +++ b/src/Resources/public/images/flags/GY.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/HK.svg b/src/Resources/public/images/flags/HK.svg index 284a722bb6..894a44b06a 100644 --- a/src/Resources/public/images/flags/HK.svg +++ b/src/Resources/public/images/flags/HK.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/HM.svg b/src/Resources/public/images/flags/HM.svg index a0e8ac2289..f39ae73cd9 100644 --- a/src/Resources/public/images/flags/HM.svg +++ b/src/Resources/public/images/flags/HM.svg @@ -1 +1,18 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/HN.svg b/src/Resources/public/images/flags/HN.svg index 15ec213103..2fc9d4d731 100644 --- a/src/Resources/public/images/flags/HN.svg +++ b/src/Resources/public/images/flags/HN.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/HR.svg b/src/Resources/public/images/flags/HR.svg index c61e8c8a58..155036c460 100644 --- a/src/Resources/public/images/flags/HR.svg +++ b/src/Resources/public/images/flags/HR.svg @@ -1 +1,16 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/HT.svg b/src/Resources/public/images/flags/HT.svg index 3120c71676..6e621fb0c5 100644 --- a/src/Resources/public/images/flags/HT.svg +++ b/src/Resources/public/images/flags/HT.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/HU.svg b/src/Resources/public/images/flags/HU.svg index 8d92a84d14..31f329d8c3 100644 --- a/src/Resources/public/images/flags/HU.svg +++ b/src/Resources/public/images/flags/HU.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/IC.svg b/src/Resources/public/images/flags/IC.svg index 0370157ac7..baaac991cf 100644 --- a/src/Resources/public/images/flags/IC.svg +++ b/src/Resources/public/images/flags/IC.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/ID.svg b/src/Resources/public/images/flags/ID.svg index 2684a3d746..94f3657d6c 100644 --- a/src/Resources/public/images/flags/ID.svg +++ b/src/Resources/public/images/flags/ID.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/IE.svg b/src/Resources/public/images/flags/IE.svg index f3f99d989d..7c8f4aa989 100644 --- a/src/Resources/public/images/flags/IE.svg +++ b/src/Resources/public/images/flags/IE.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/IL.svg b/src/Resources/public/images/flags/IL.svg index da4121810f..e1ba326feb 100644 --- a/src/Resources/public/images/flags/IL.svg +++ b/src/Resources/public/images/flags/IL.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/IM.svg b/src/Resources/public/images/flags/IM.svg index 26c2721fe7..4072871581 100644 --- a/src/Resources/public/images/flags/IM.svg +++ b/src/Resources/public/images/flags/IM.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/IN.svg b/src/Resources/public/images/flags/IN.svg index 6e5ffe325f..c689acb0f4 100644 --- a/src/Resources/public/images/flags/IN.svg +++ b/src/Resources/public/images/flags/IN.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/IO.svg b/src/Resources/public/images/flags/IO.svg index 0f3ef148e9..f78b0075c6 100644 --- a/src/Resources/public/images/flags/IO.svg +++ b/src/Resources/public/images/flags/IO.svg @@ -1 +1,20 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/IQ.svg b/src/Resources/public/images/flags/IQ.svg index 59373217cb..7799843aa0 100644 --- a/src/Resources/public/images/flags/IQ.svg +++ b/src/Resources/public/images/flags/IQ.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/IR.svg b/src/Resources/public/images/flags/IR.svg index 5f4ba039d7..70998344ab 100644 --- a/src/Resources/public/images/flags/IR.svg +++ b/src/Resources/public/images/flags/IR.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/IS.svg b/src/Resources/public/images/flags/IS.svg index 43cf1d4f75..f32aea8e52 100644 --- a/src/Resources/public/images/flags/IS.svg +++ b/src/Resources/public/images/flags/IS.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/IT.svg b/src/Resources/public/images/flags/IT.svg index 36677a0b9d..ff1b318256 100644 --- a/src/Resources/public/images/flags/IT.svg +++ b/src/Resources/public/images/flags/IT.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/JE.svg b/src/Resources/public/images/flags/JE.svg index 63726b69d7..de61503191 100644 --- a/src/Resources/public/images/flags/JE.svg +++ b/src/Resources/public/images/flags/JE.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/JM.svg b/src/Resources/public/images/flags/JM.svg index e8fbf60bc1..9ea88462f7 100644 --- a/src/Resources/public/images/flags/JM.svg +++ b/src/Resources/public/images/flags/JM.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/JO.svg b/src/Resources/public/images/flags/JO.svg index e034216bad..915fd44587 100644 --- a/src/Resources/public/images/flags/JO.svg +++ b/src/Resources/public/images/flags/JO.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/JP.svg b/src/Resources/public/images/flags/JP.svg index 92eb885cb3..ca99b751ac 100644 --- a/src/Resources/public/images/flags/JP.svg +++ b/src/Resources/public/images/flags/JP.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/KE.svg b/src/Resources/public/images/flags/KE.svg index 016d67bd36..2792598a8f 100644 --- a/src/Resources/public/images/flags/KE.svg +++ b/src/Resources/public/images/flags/KE.svg @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/KG.svg b/src/Resources/public/images/flags/KG.svg index 2d78279ddc..cca13d6d6b 100644 --- a/src/Resources/public/images/flags/KG.svg +++ b/src/Resources/public/images/flags/KG.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/KH.svg b/src/Resources/public/images/flags/KH.svg index a39d464903..84b3bf9721 100644 --- a/src/Resources/public/images/flags/KH.svg +++ b/src/Resources/public/images/flags/KH.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/KI.svg b/src/Resources/public/images/flags/KI.svg index 2f4abd8f5d..102c1bc453 100644 --- a/src/Resources/public/images/flags/KI.svg +++ b/src/Resources/public/images/flags/KI.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/KM.svg b/src/Resources/public/images/flags/KM.svg index 72cc566366..39a71008b8 100644 --- a/src/Resources/public/images/flags/KM.svg +++ b/src/Resources/public/images/flags/KM.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/KN.svg b/src/Resources/public/images/flags/KN.svg index 1ad001b7fc..cf7b010f8a 100644 --- a/src/Resources/public/images/flags/KN.svg +++ b/src/Resources/public/images/flags/KN.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/KP.svg b/src/Resources/public/images/flags/KP.svg index d883f2da61..d9dc4a2e28 100644 --- a/src/Resources/public/images/flags/KP.svg +++ b/src/Resources/public/images/flags/KP.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/KR.svg b/src/Resources/public/images/flags/KR.svg index 93b93ec017..519566553f 100644 --- a/src/Resources/public/images/flags/KR.svg +++ b/src/Resources/public/images/flags/KR.svg @@ -1 +1,17 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/KW.svg b/src/Resources/public/images/flags/KW.svg index c3387d8e1e..edb9c0579e 100644 --- a/src/Resources/public/images/flags/KW.svg +++ b/src/Resources/public/images/flags/KW.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/KY.svg b/src/Resources/public/images/flags/KY.svg index ea85f940a4..b0e7c2d9ed 100644 --- a/src/Resources/public/images/flags/KY.svg +++ b/src/Resources/public/images/flags/KY.svg @@ -1 +1,20 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/KZ.svg b/src/Resources/public/images/flags/KZ.svg index bb020c9c49..4307ec8c42 100644 --- a/src/Resources/public/images/flags/KZ.svg +++ b/src/Resources/public/images/flags/KZ.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/LA.svg b/src/Resources/public/images/flags/LA.svg index 09281c36ea..1f1034d3c8 100644 --- a/src/Resources/public/images/flags/LA.svg +++ b/src/Resources/public/images/flags/LA.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/LB.svg b/src/Resources/public/images/flags/LB.svg index bd663ac08b..0cb629bed5 100644 --- a/src/Resources/public/images/flags/LB.svg +++ b/src/Resources/public/images/flags/LB.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/LC.svg b/src/Resources/public/images/flags/LC.svg index 33511bbc58..c673feefe3 100644 --- a/src/Resources/public/images/flags/LC.svg +++ b/src/Resources/public/images/flags/LC.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/LI.svg b/src/Resources/public/images/flags/LI.svg index 20e2ca3e0e..34457d4940 100644 --- a/src/Resources/public/images/flags/LI.svg +++ b/src/Resources/public/images/flags/LI.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/LK.svg b/src/Resources/public/images/flags/LK.svg index 78b239cdba..1a40e45f89 100644 --- a/src/Resources/public/images/flags/LK.svg +++ b/src/Resources/public/images/flags/LK.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/LR.svg b/src/Resources/public/images/flags/LR.svg index 9866be4fda..eb09ab6f59 100644 --- a/src/Resources/public/images/flags/LR.svg +++ b/src/Resources/public/images/flags/LR.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/LS.svg b/src/Resources/public/images/flags/LS.svg index 245049262f..78d5e9f323 100644 --- a/src/Resources/public/images/flags/LS.svg +++ b/src/Resources/public/images/flags/LS.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/LT.svg b/src/Resources/public/images/flags/LT.svg index d944b86a4d..98198f1cdf 100644 --- a/src/Resources/public/images/flags/LT.svg +++ b/src/Resources/public/images/flags/LT.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/LU.svg b/src/Resources/public/images/flags/LU.svg index 2ac20755e2..f9bd3bb29c 100644 --- a/src/Resources/public/images/flags/LU.svg +++ b/src/Resources/public/images/flags/LU.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/LV.svg b/src/Resources/public/images/flags/LV.svg index a420dbfd6f..96874ebbbe 100644 --- a/src/Resources/public/images/flags/LV.svg +++ b/src/Resources/public/images/flags/LV.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/LY.svg b/src/Resources/public/images/flags/LY.svg index 85905c4d00..c3baa63431 100644 --- a/src/Resources/public/images/flags/LY.svg +++ b/src/Resources/public/images/flags/LY.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/MA.svg b/src/Resources/public/images/flags/MA.svg index 7f10d2aebf..6e001d1070 100644 --- a/src/Resources/public/images/flags/MA.svg +++ b/src/Resources/public/images/flags/MA.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/MC.svg b/src/Resources/public/images/flags/MC.svg index 06df3878a8..c34a8a9556 100644 --- a/src/Resources/public/images/flags/MC.svg +++ b/src/Resources/public/images/flags/MC.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/MD.svg b/src/Resources/public/images/flags/MD.svg index c755eee8bc..83b58242a8 100644 --- a/src/Resources/public/images/flags/MD.svg +++ b/src/Resources/public/images/flags/MD.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/ME.svg b/src/Resources/public/images/flags/ME.svg index 35ccee26c9..ec8c25541b 100644 --- a/src/Resources/public/images/flags/ME.svg +++ b/src/Resources/public/images/flags/ME.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/MF.svg b/src/Resources/public/images/flags/MF.svg index ff13ef7570..7033b00b3a 100644 --- a/src/Resources/public/images/flags/MF.svg +++ b/src/Resources/public/images/flags/MF.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/MG.svg b/src/Resources/public/images/flags/MG.svg index 25fb05d9aa..d0fd6d65d1 100644 --- a/src/Resources/public/images/flags/MG.svg +++ b/src/Resources/public/images/flags/MG.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/MH.svg b/src/Resources/public/images/flags/MH.svg index ee87421619..d29988ca6b 100644 --- a/src/Resources/public/images/flags/MH.svg +++ b/src/Resources/public/images/flags/MH.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/MK.svg b/src/Resources/public/images/flags/MK.svg index 56ee6e1eae..8b18be4105 100644 --- a/src/Resources/public/images/flags/MK.svg +++ b/src/Resources/public/images/flags/MK.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/ML.svg b/src/Resources/public/images/flags/ML.svg index 1727bc8169..c2e561f34b 100644 --- a/src/Resources/public/images/flags/ML.svg +++ b/src/Resources/public/images/flags/ML.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/MM.svg b/src/Resources/public/images/flags/MM.svg index 4eff4eee40..33f93bf190 100644 --- a/src/Resources/public/images/flags/MM.svg +++ b/src/Resources/public/images/flags/MM.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/MN.svg b/src/Resources/public/images/flags/MN.svg index 6624023e97..3b6114d9c7 100644 --- a/src/Resources/public/images/flags/MN.svg +++ b/src/Resources/public/images/flags/MN.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/MO.svg b/src/Resources/public/images/flags/MO.svg index cf248f94d8..f1c8d84643 100644 --- a/src/Resources/public/images/flags/MO.svg +++ b/src/Resources/public/images/flags/MO.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/MP.svg b/src/Resources/public/images/flags/MP.svg index 0bd240acdc..b2901dde42 100644 --- a/src/Resources/public/images/flags/MP.svg +++ b/src/Resources/public/images/flags/MP.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/MQ.svg b/src/Resources/public/images/flags/MQ.svg index 282c7d57a4..7dd57dc599 100644 --- a/src/Resources/public/images/flags/MQ.svg +++ b/src/Resources/public/images/flags/MQ.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/MR.svg b/src/Resources/public/images/flags/MR.svg index 0311a1c06e..7a56930710 100644 --- a/src/Resources/public/images/flags/MR.svg +++ b/src/Resources/public/images/flags/MR.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/MS.svg b/src/Resources/public/images/flags/MS.svg index f4f973548d..fa74005b59 100644 --- a/src/Resources/public/images/flags/MS.svg +++ b/src/Resources/public/images/flags/MS.svg @@ -1 +1,16 @@ - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/MT.svg b/src/Resources/public/images/flags/MT.svg index cc11c9ed29..a718b3f84e 100644 --- a/src/Resources/public/images/flags/MT.svg +++ b/src/Resources/public/images/flags/MT.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/MU.svg b/src/Resources/public/images/flags/MU.svg index a367b14034..b6605582a7 100644 --- a/src/Resources/public/images/flags/MU.svg +++ b/src/Resources/public/images/flags/MU.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/MV.svg b/src/Resources/public/images/flags/MV.svg index 4cc7ebcc2a..6a02148541 100644 --- a/src/Resources/public/images/flags/MV.svg +++ b/src/Resources/public/images/flags/MV.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/MW.svg b/src/Resources/public/images/flags/MW.svg index 44fb0cb3fd..22f094ef11 100644 --- a/src/Resources/public/images/flags/MW.svg +++ b/src/Resources/public/images/flags/MW.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/MX.svg b/src/Resources/public/images/flags/MX.svg index bbdf84d857..15355eebf1 100644 --- a/src/Resources/public/images/flags/MX.svg +++ b/src/Resources/public/images/flags/MX.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/MY.svg b/src/Resources/public/images/flags/MY.svg index 38cc877217..2fb32940df 100644 --- a/src/Resources/public/images/flags/MY.svg +++ b/src/Resources/public/images/flags/MY.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/MZ.svg b/src/Resources/public/images/flags/MZ.svg index a11eeda28f..605598405a 100644 --- a/src/Resources/public/images/flags/MZ.svg +++ b/src/Resources/public/images/flags/MZ.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/NA.svg b/src/Resources/public/images/flags/NA.svg index a9f5a41088..35544e1e04 100644 --- a/src/Resources/public/images/flags/NA.svg +++ b/src/Resources/public/images/flags/NA.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/NC.svg b/src/Resources/public/images/flags/NC.svg index 09ee863e2a..084e86e4cb 100644 --- a/src/Resources/public/images/flags/NC.svg +++ b/src/Resources/public/images/flags/NC.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/NE.svg b/src/Resources/public/images/flags/NE.svg index 3c09399023..443563a3bd 100644 --- a/src/Resources/public/images/flags/NE.svg +++ b/src/Resources/public/images/flags/NE.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/NF.svg b/src/Resources/public/images/flags/NF.svg index f08fdbd4a6..1b3f5a93b5 100644 --- a/src/Resources/public/images/flags/NF.svg +++ b/src/Resources/public/images/flags/NF.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/NG.svg b/src/Resources/public/images/flags/NG.svg index 624166b306..b7bfb4b047 100644 --- a/src/Resources/public/images/flags/NG.svg +++ b/src/Resources/public/images/flags/NG.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/NI.svg b/src/Resources/public/images/flags/NI.svg index c0a05ca438..f510948010 100644 --- a/src/Resources/public/images/flags/NI.svg +++ b/src/Resources/public/images/flags/NI.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/NL.svg b/src/Resources/public/images/flags/NL.svg index 016746af64..9e3c02c1f3 100644 --- a/src/Resources/public/images/flags/NL.svg +++ b/src/Resources/public/images/flags/NL.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/NO.svg b/src/Resources/public/images/flags/NO.svg index 28a0c5df3a..3a37b501cd 100644 --- a/src/Resources/public/images/flags/NO.svg +++ b/src/Resources/public/images/flags/NO.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/NP.svg b/src/Resources/public/images/flags/NP.svg index 373df1ea65..e0fb9096aa 100644 --- a/src/Resources/public/images/flags/NP.svg +++ b/src/Resources/public/images/flags/NP.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/NR.svg b/src/Resources/public/images/flags/NR.svg index 9552cc305d..047088dfd5 100644 --- a/src/Resources/public/images/flags/NR.svg +++ b/src/Resources/public/images/flags/NR.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/NU.svg b/src/Resources/public/images/flags/NU.svg index fc5183e6b2..8ffb3e3c42 100644 --- a/src/Resources/public/images/flags/NU.svg +++ b/src/Resources/public/images/flags/NU.svg @@ -1 +1,35 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/NZ.svg b/src/Resources/public/images/flags/NZ.svg index c5b41b55ab..6aac3a1b6c 100644 --- a/src/Resources/public/images/flags/NZ.svg +++ b/src/Resources/public/images/flags/NZ.svg @@ -1 +1,19 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/OM.svg b/src/Resources/public/images/flags/OM.svg index 3fba67985e..62092c8af3 100644 --- a/src/Resources/public/images/flags/OM.svg +++ b/src/Resources/public/images/flags/OM.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/PA.svg b/src/Resources/public/images/flags/PA.svg index a6f5940aa1..450e4499e7 100644 --- a/src/Resources/public/images/flags/PA.svg +++ b/src/Resources/public/images/flags/PA.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/PE.svg b/src/Resources/public/images/flags/PE.svg index 16360e31d9..af84a1471c 100644 --- a/src/Resources/public/images/flags/PE.svg +++ b/src/Resources/public/images/flags/PE.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/PF.svg b/src/Resources/public/images/flags/PF.svg index a66c420fe1..84489ba128 100644 --- a/src/Resources/public/images/flags/PF.svg +++ b/src/Resources/public/images/flags/PF.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/PG.svg b/src/Resources/public/images/flags/PG.svg index 6ef2aa39c1..83bfcd3c0e 100644 --- a/src/Resources/public/images/flags/PG.svg +++ b/src/Resources/public/images/flags/PG.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/PH.svg b/src/Resources/public/images/flags/PH.svg index 7533140493..ded4a1d9a1 100644 --- a/src/Resources/public/images/flags/PH.svg +++ b/src/Resources/public/images/flags/PH.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/PK.svg b/src/Resources/public/images/flags/PK.svg index f16fe95145..831fc6db11 100644 --- a/src/Resources/public/images/flags/PK.svg +++ b/src/Resources/public/images/flags/PK.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/PL.svg b/src/Resources/public/images/flags/PL.svg index 82b564b8cf..48f1a28f66 100644 --- a/src/Resources/public/images/flags/PL.svg +++ b/src/Resources/public/images/flags/PL.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/PM.svg b/src/Resources/public/images/flags/PM.svg index 85259e28a1..f8667e22bb 100644 --- a/src/Resources/public/images/flags/PM.svg +++ b/src/Resources/public/images/flags/PM.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/PN.svg b/src/Resources/public/images/flags/PN.svg index 1593ef62c9..a915ef3420 100644 --- a/src/Resources/public/images/flags/PN.svg +++ b/src/Resources/public/images/flags/PN.svg @@ -1 +1,24 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/PR.svg b/src/Resources/public/images/flags/PR.svg index c0878bb483..a637964dff 100644 --- a/src/Resources/public/images/flags/PR.svg +++ b/src/Resources/public/images/flags/PR.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/PS.svg b/src/Resources/public/images/flags/PS.svg index 3f5fed7ba9..eddd8229bf 100644 --- a/src/Resources/public/images/flags/PS.svg +++ b/src/Resources/public/images/flags/PS.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/PT.svg b/src/Resources/public/images/flags/PT.svg index 407b0ec4f2..89f6fb5b05 100644 --- a/src/Resources/public/images/flags/PT.svg +++ b/src/Resources/public/images/flags/PT.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/PW.svg b/src/Resources/public/images/flags/PW.svg index 1ac841915c..146eeb7026 100644 --- a/src/Resources/public/images/flags/PW.svg +++ b/src/Resources/public/images/flags/PW.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/PY.svg b/src/Resources/public/images/flags/PY.svg index 967a7e73b7..bd87d6d0ae 100644 --- a/src/Resources/public/images/flags/PY.svg +++ b/src/Resources/public/images/flags/PY.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/QA.svg b/src/Resources/public/images/flags/QA.svg index a0a666f41e..b88c342367 100644 --- a/src/Resources/public/images/flags/QA.svg +++ b/src/Resources/public/images/flags/QA.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/RE.svg b/src/Resources/public/images/flags/RE.svg index 85259e28a1..f8667e22bb 100644 --- a/src/Resources/public/images/flags/RE.svg +++ b/src/Resources/public/images/flags/RE.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/RO.svg b/src/Resources/public/images/flags/RO.svg index fabf12eaa6..3c398f1de9 100644 --- a/src/Resources/public/images/flags/RO.svg +++ b/src/Resources/public/images/flags/RO.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/RS.svg b/src/Resources/public/images/flags/RS.svg index de18ca11df..6af971e38a 100644 --- a/src/Resources/public/images/flags/RS.svg +++ b/src/Resources/public/images/flags/RS.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/RU.svg b/src/Resources/public/images/flags/RU.svg index 1117270bd3..c7dd86aacc 100644 --- a/src/Resources/public/images/flags/RU.svg +++ b/src/Resources/public/images/flags/RU.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/RW.svg b/src/Resources/public/images/flags/RW.svg index 73a7a7c3fa..53f054ed76 100644 --- a/src/Resources/public/images/flags/RW.svg +++ b/src/Resources/public/images/flags/RW.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/SA.svg b/src/Resources/public/images/flags/SA.svg index d898f67381..182fb58d11 100644 --- a/src/Resources/public/images/flags/SA.svg +++ b/src/Resources/public/images/flags/SA.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/SB.svg b/src/Resources/public/images/flags/SB.svg index 9970ee866b..1acb8f6960 100644 --- a/src/Resources/public/images/flags/SB.svg +++ b/src/Resources/public/images/flags/SB.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/SC.svg b/src/Resources/public/images/flags/SC.svg index df5386be26..429202e129 100644 --- a/src/Resources/public/images/flags/SC.svg +++ b/src/Resources/public/images/flags/SC.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/SD.svg b/src/Resources/public/images/flags/SD.svg index 0a5f70f766..516cc07fe2 100644 --- a/src/Resources/public/images/flags/SD.svg +++ b/src/Resources/public/images/flags/SD.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/SE.svg b/src/Resources/public/images/flags/SE.svg index 7ec1787a59..2e61e29093 100644 --- a/src/Resources/public/images/flags/SE.svg +++ b/src/Resources/public/images/flags/SE.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/SG.svg b/src/Resources/public/images/flags/SG.svg index c374c478d2..ae2e533f6e 100644 --- a/src/Resources/public/images/flags/SG.svg +++ b/src/Resources/public/images/flags/SG.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/SH.svg b/src/Resources/public/images/flags/SH.svg index 67f09f77c9..91fd58ee37 100644 --- a/src/Resources/public/images/flags/SH.svg +++ b/src/Resources/public/images/flags/SH.svg @@ -1 +1,23 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/SI.svg b/src/Resources/public/images/flags/SI.svg index 8d8c70c8f9..025e7f305e 100644 --- a/src/Resources/public/images/flags/SI.svg +++ b/src/Resources/public/images/flags/SI.svg @@ -1 +1,11 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/SJ.svg b/src/Resources/public/images/flags/SJ.svg index 28a0c5df3a..3a37b501cd 100644 --- a/src/Resources/public/images/flags/SJ.svg +++ b/src/Resources/public/images/flags/SJ.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/SK.svg b/src/Resources/public/images/flags/SK.svg index 300f814d0f..785e33b33f 100644 --- a/src/Resources/public/images/flags/SK.svg +++ b/src/Resources/public/images/flags/SK.svg @@ -1 +1,13 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/SL.svg b/src/Resources/public/images/flags/SL.svg index 588393d428..789a9236de 100644 --- a/src/Resources/public/images/flags/SL.svg +++ b/src/Resources/public/images/flags/SL.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/SM.svg b/src/Resources/public/images/flags/SM.svg index cfd3f1a79b..fabccc2d47 100644 --- a/src/Resources/public/images/flags/SM.svg +++ b/src/Resources/public/images/flags/SM.svg @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/SN.svg b/src/Resources/public/images/flags/SN.svg index 85b2c8510a..5a57c68a16 100644 --- a/src/Resources/public/images/flags/SN.svg +++ b/src/Resources/public/images/flags/SN.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/SO.svg b/src/Resources/public/images/flags/SO.svg index 1ee75a6e72..695d158615 100644 --- a/src/Resources/public/images/flags/SO.svg +++ b/src/Resources/public/images/flags/SO.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/SR.svg b/src/Resources/public/images/flags/SR.svg index c6e1ba641c..d877bbeb6a 100644 --- a/src/Resources/public/images/flags/SR.svg +++ b/src/Resources/public/images/flags/SR.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/SS.svg b/src/Resources/public/images/flags/SS.svg index 65f8191b99..7665dab680 100644 --- a/src/Resources/public/images/flags/SS.svg +++ b/src/Resources/public/images/flags/SS.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/ST.svg b/src/Resources/public/images/flags/ST.svg index 2f4f5f4fed..d2de82c97a 100644 --- a/src/Resources/public/images/flags/ST.svg +++ b/src/Resources/public/images/flags/ST.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/SV.svg b/src/Resources/public/images/flags/SV.svg index c4b1c3004b..9ffc80c414 100644 --- a/src/Resources/public/images/flags/SV.svg +++ b/src/Resources/public/images/flags/SV.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/SX.svg b/src/Resources/public/images/flags/SX.svg index 5511e2fafc..280d505cf6 100644 --- a/src/Resources/public/images/flags/SX.svg +++ b/src/Resources/public/images/flags/SX.svg @@ -1 +1,15 @@ - \ No newline at end of file + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/SY.svg b/src/Resources/public/images/flags/SY.svg index cb41573c38..c79dbc2bc1 100644 --- a/src/Resources/public/images/flags/SY.svg +++ b/src/Resources/public/images/flags/SY.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/SZ.svg b/src/Resources/public/images/flags/SZ.svg index acf86aa6fb..f90a34748b 100644 --- a/src/Resources/public/images/flags/SZ.svg +++ b/src/Resources/public/images/flags/SZ.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/TA.svg b/src/Resources/public/images/flags/TA.svg index 502683a93c..87ef4879d5 100644 --- a/src/Resources/public/images/flags/TA.svg +++ b/src/Resources/public/images/flags/TA.svg @@ -1 +1,28 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/TC.svg b/src/Resources/public/images/flags/TC.svg index b510da0807..aa8a659c1d 100644 --- a/src/Resources/public/images/flags/TC.svg +++ b/src/Resources/public/images/flags/TC.svg @@ -1 +1,26 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/TD.svg b/src/Resources/public/images/flags/TD.svg index 3c11067416..12d2e8bfa6 100644 --- a/src/Resources/public/images/flags/TD.svg +++ b/src/Resources/public/images/flags/TD.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/TF.svg b/src/Resources/public/images/flags/TF.svg index 2796744f92..4188e43f59 100644 --- a/src/Resources/public/images/flags/TF.svg +++ b/src/Resources/public/images/flags/TF.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/TG.svg b/src/Resources/public/images/flags/TG.svg index e1e26c26e8..a4d23554a8 100644 --- a/src/Resources/public/images/flags/TG.svg +++ b/src/Resources/public/images/flags/TG.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/TH.svg b/src/Resources/public/images/flags/TH.svg index 01b837ca87..21b3046ca8 100644 --- a/src/Resources/public/images/flags/TH.svg +++ b/src/Resources/public/images/flags/TH.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/TJ.svg b/src/Resources/public/images/flags/TJ.svg index f9d8ffa635..421647ef75 100644 --- a/src/Resources/public/images/flags/TJ.svg +++ b/src/Resources/public/images/flags/TJ.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/TK.svg b/src/Resources/public/images/flags/TK.svg index 080b4afa27..2068fe21ce 100644 --- a/src/Resources/public/images/flags/TK.svg +++ b/src/Resources/public/images/flags/TK.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/TL.svg b/src/Resources/public/images/flags/TL.svg index c2d3e1efe3..0933a65b90 100644 --- a/src/Resources/public/images/flags/TL.svg +++ b/src/Resources/public/images/flags/TL.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/TM.svg b/src/Resources/public/images/flags/TM.svg index 75d107f622..f54d9713c9 100644 --- a/src/Resources/public/images/flags/TM.svg +++ b/src/Resources/public/images/flags/TM.svg @@ -1 +1,26 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/TN.svg b/src/Resources/public/images/flags/TN.svg index 7cbdb9079f..9151b6257a 100644 --- a/src/Resources/public/images/flags/TN.svg +++ b/src/Resources/public/images/flags/TN.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/TO.svg b/src/Resources/public/images/flags/TO.svg index 4e31c7095b..51f17e03b6 100644 --- a/src/Resources/public/images/flags/TO.svg +++ b/src/Resources/public/images/flags/TO.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/TR.svg b/src/Resources/public/images/flags/TR.svg index 1e08e2357d..375fbf65ac 100644 --- a/src/Resources/public/images/flags/TR.svg +++ b/src/Resources/public/images/flags/TR.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/TT.svg b/src/Resources/public/images/flags/TT.svg index 23886ae892..c5ed7e864b 100644 --- a/src/Resources/public/images/flags/TT.svg +++ b/src/Resources/public/images/flags/TT.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/TV.svg b/src/Resources/public/images/flags/TV.svg index d8caff3458..7740cc6276 100644 --- a/src/Resources/public/images/flags/TV.svg +++ b/src/Resources/public/images/flags/TV.svg @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/TW.svg b/src/Resources/public/images/flags/TW.svg index c3660f131d..4133a68743 100644 --- a/src/Resources/public/images/flags/TW.svg +++ b/src/Resources/public/images/flags/TW.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/TZ.svg b/src/Resources/public/images/flags/TZ.svg index 480cbec3d8..a0248d8630 100644 --- a/src/Resources/public/images/flags/TZ.svg +++ b/src/Resources/public/images/flags/TZ.svg @@ -1 +1,6 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/UA.svg b/src/Resources/public/images/flags/UA.svg index 8eaa507ee7..522e6e4ff4 100644 --- a/src/Resources/public/images/flags/UA.svg +++ b/src/Resources/public/images/flags/UA.svg @@ -1 +1,4 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/UG.svg b/src/Resources/public/images/flags/UG.svg index 488d395a49..0afd9a4115 100644 --- a/src/Resources/public/images/flags/UG.svg +++ b/src/Resources/public/images/flags/UG.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/UM.svg b/src/Resources/public/images/flags/UM.svg index dc427e711a..679947b34b 100644 --- a/src/Resources/public/images/flags/UM.svg +++ b/src/Resources/public/images/flags/UM.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/UNKNOWN.svg b/src/Resources/public/images/flags/UNKNOWN.svg index 37f57693fe..c6e23878a4 100644 --- a/src/Resources/public/images/flags/UNKNOWN.svg +++ b/src/Resources/public/images/flags/UNKNOWN.svg @@ -1 +1,3 @@ - + + + diff --git a/src/Resources/public/images/flags/US.svg b/src/Resources/public/images/flags/US.svg index dc427e711a..679947b34b 100644 --- a/src/Resources/public/images/flags/US.svg +++ b/src/Resources/public/images/flags/US.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/UY.svg b/src/Resources/public/images/flags/UY.svg index 9ee475c776..204aa72425 100644 --- a/src/Resources/public/images/flags/UY.svg +++ b/src/Resources/public/images/flags/UY.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/UZ.svg b/src/Resources/public/images/flags/UZ.svg index cec70f0e46..3c0dff43ed 100644 --- a/src/Resources/public/images/flags/UZ.svg +++ b/src/Resources/public/images/flags/UZ.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/VA.svg b/src/Resources/public/images/flags/VA.svg index 15621e7a91..482b5e248d 100644 --- a/src/Resources/public/images/flags/VA.svg +++ b/src/Resources/public/images/flags/VA.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/VC.svg b/src/Resources/public/images/flags/VC.svg index 2db54149ae..908816ed52 100644 --- a/src/Resources/public/images/flags/VC.svg +++ b/src/Resources/public/images/flags/VC.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/VE.svg b/src/Resources/public/images/flags/VE.svg index 07cf3a812c..863af8f286 100644 --- a/src/Resources/public/images/flags/VE.svg +++ b/src/Resources/public/images/flags/VE.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + diff --git a/src/Resources/public/images/flags/VG.svg b/src/Resources/public/images/flags/VG.svg index a66195e707..e506b41814 100644 --- a/src/Resources/public/images/flags/VG.svg +++ b/src/Resources/public/images/flags/VG.svg @@ -1 +1,26 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/VI.svg b/src/Resources/public/images/flags/VI.svg index 3d5556ef79..d13fee9b0a 100644 --- a/src/Resources/public/images/flags/VI.svg +++ b/src/Resources/public/images/flags/VI.svg @@ -1 +1,22 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + diff --git a/src/Resources/public/images/flags/VN.svg b/src/Resources/public/images/flags/VN.svg index d52233d807..d8a4838022 100644 --- a/src/Resources/public/images/flags/VN.svg +++ b/src/Resources/public/images/flags/VN.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + diff --git a/src/Resources/public/images/flags/VU.svg b/src/Resources/public/images/flags/VU.svg index a1c93974ea..d4e95fa57e 100644 --- a/src/Resources/public/images/flags/VU.svg +++ b/src/Resources/public/images/flags/VU.svg @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + + + + diff --git a/src/Resources/public/images/flags/WF.svg b/src/Resources/public/images/flags/WF.svg index 2ed18a4be6..93a8944f01 100644 --- a/src/Resources/public/images/flags/WF.svg +++ b/src/Resources/public/images/flags/WF.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/WS.svg b/src/Resources/public/images/flags/WS.svg index b198a8f847..4263021c03 100644 --- a/src/Resources/public/images/flags/WS.svg +++ b/src/Resources/public/images/flags/WS.svg @@ -1 +1,7 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/XK.svg b/src/Resources/public/images/flags/XK.svg index d31fca8883..8b288e9108 100644 --- a/src/Resources/public/images/flags/XK.svg +++ b/src/Resources/public/images/flags/XK.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/YE.svg b/src/Resources/public/images/flags/YE.svg index 014923266c..482a6f2944 100644 --- a/src/Resources/public/images/flags/YE.svg +++ b/src/Resources/public/images/flags/YE.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/src/Resources/public/images/flags/YT.svg b/src/Resources/public/images/flags/YT.svg index 1196883eb5..e3349a0e8d 100644 --- a/src/Resources/public/images/flags/YT.svg +++ b/src/Resources/public/images/flags/YT.svg @@ -1 +1,12 @@ - \ No newline at end of file + + + + + + + + + diff --git a/src/Resources/public/images/flags/ZA.svg b/src/Resources/public/images/flags/ZA.svg index 1b294c90f9..1f3a3e5f24 100644 --- a/src/Resources/public/images/flags/ZA.svg +++ b/src/Resources/public/images/flags/ZA.svg @@ -1 +1,9 @@ - \ No newline at end of file + + + + + + + + diff --git a/src/Resources/public/images/flags/ZM.svg b/src/Resources/public/images/flags/ZM.svg index 5ab44eca5b..3988767e30 100644 --- a/src/Resources/public/images/flags/ZM.svg +++ b/src/Resources/public/images/flags/ZM.svg @@ -1 +1,8 @@ - \ No newline at end of file + + + + + + + diff --git a/src/Resources/public/images/flags/ZW.svg b/src/Resources/public/images/flags/ZW.svg index 8bba16a40c..2d39248d36 100644 --- a/src/Resources/public/images/flags/ZW.svg +++ b/src/Resources/public/images/flags/ZW.svg @@ -1 +1,17 @@ - \ No newline at end of file + + + + + + + + + + + + + + + diff --git a/src/Resources/skeleton/crud_controller.tpl b/src/Resources/skeleton/crud_controller.tpl index 3c58d9262b..1e6e3c8fd7 100644 --- a/src/Resources/skeleton/crud_controller.tpl +++ b/src/Resources/skeleton/crud_controller.tpl @@ -7,19 +7,19 @@ use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; final class extends AbstractCrudController { - public static function getEntityFqcn(): string - { - return ::class; - } +public static function getEntityFqcn(): string +{ +return ::class; +} - /* - public function configureFields(string $pageName): iterable - { - return [ - IdField::new('id'), - TextField::new('title'), - TextEditorField::new('description'), - ]; - } - */ +/* +public function configureFields(string $pageName): iterable +{ +return [ +IdField::new('id'), +TextField::new('title'), +TextEditorField::new('description'), +]; +} +*/ } diff --git a/src/Resources/skeleton/dashboard.tpl b/src/Resources/skeleton/dashboard.tpl index 8711fb3ef0..7b658d83d0 100644 --- a/src/Resources/skeleton/dashboard.tpl +++ b/src/Resources/skeleton/dashboard.tpl @@ -10,37 +10,37 @@ use Symfony\Component\Routing\Annotation\Route; final class extends AbstractDashboardController { - #[Route('/admin', name: 'admin')] - public function index(): Response - { - return parent::index(); - - // Option 1. You can make your dashboard redirect to some common page of your backend - // - // $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class); - // return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl()); - - // Option 2. You can make your dashboard redirect to different pages depending on the user - // - // if ('jane' === $this->getUser()->getUsername()) { - // return $this->redirect('...'); - // } - - // Option 3. You can render some custom template to display a proper dashboard with widgets, etc. - // (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig) - // - // return $this->render('some/path/my-dashboard.html.twig'); - } - - public function configureDashboard(): Dashboard - { - return Dashboard::new() - ->setTitle(''); - } - - public function configureMenuItems(): iterable - { - yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home'); - // yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class); - } +#[Route('/admin', name: 'admin')] +public function index(): Response +{ +return parent::index(); + +// Option 1. You can make your dashboard redirect to some common page of your backend +// +// $adminUrlGenerator = $this->container->get(AdminUrlGenerator::class); +// return $this->redirect($adminUrlGenerator->setController(OneOfYourCrudController::class)->generateUrl()); + +// Option 2. You can make your dashboard redirect to different pages depending on the user +// +// if ('jane' === $this->getUser()->getUsername()) { +// return $this->redirect('...'); +// } + +// Option 3. You can render some custom template to display a proper dashboard with widgets, etc. +// (tip: it's easier if your template extends from @EasyAdmin/page/content.html.twig) +// +// return $this->render('some/path/my-dashboard.html.twig'); +} + +public function configureDashboard(): Dashboard +{ +return Dashboard::new() +->setTitle(''); +} + +public function configureMenuItems(): iterable +{ +yield MenuItem::linkToDashboard('Dashboard', 'fa fa-home'); +// yield MenuItem::linkToCrud('The Label', 'fas fa-list', EntityClass::class); +} } diff --git a/src/Resources/translations/EasyAdminBundle.el.php b/src/Resources/translations/EasyAdminBundle.el.php index 0d5e85208d..c43bd697db 100644 --- a/src/Resources/translations/EasyAdminBundle.el.php +++ b/src/Resources/translations/EasyAdminBundle.el.php @@ -36,8 +36,8 @@ ], 'field' => [ - 'code_editor.view_code' => 'Προβολή κώδικα', - 'text_editor.view_content' => 'Προβολή περιεχομένου', + 'code_editor.view_code' => 'Προβολή κώδικα', + 'text_editor.view_content' => 'Προβολή περιεχομένου', ], 'action' => [ @@ -73,28 +73,28 @@ ], 'filter' => [ - 'title' => 'Φίλτρα', - 'button.clear' => 'Καθαρισμός', - 'button.apply' => 'Εφαρμογή', - 'label.is_equal_to' => 'είναι ίσο με', - 'label.is_not_equal_to' => 'δεν είναι ίσο με', - 'label.is_greater_than' => 'είναι μεγαλύτερο από', - 'label.is_greater_than_or_equal_to' => 'είναι μεγαλύτερο ή ίσο με', - 'label.is_less_than' => 'είναι μικρότερο από', - 'label.is_less_than_or_equal_to' => 'είναι μικρότερο ή ίσο με', - 'label.is_between' => 'είναι μεταξύ', - 'label.contains' => 'περιέχει', - 'label.not_contains' => 'δεν περιέχει', - 'label.starts_with' => 'ξεκινάει με', - 'label.ends_with' => 'τελειώνει με', - 'label.exactly' => 'ακριβώς', - 'label.not_exactly' => 'όχι ακριβώς', - 'label.is_same' => 'είναι ίδιο', - 'label.is_not_same' => 'δεν είναι το ίδιο', - 'label.is_after' => 'είναι μετά', - 'label.is_after_or_same' => 'είναι μετά ή το ίδιο', - 'label.is_before' => 'είναι πριν', - 'label.is_before_or_same' => 'είναι πριν ή το ίδιο', + 'title' => 'Φίλτρα', + 'button.clear' => 'Καθαρισμός', + 'button.apply' => 'Εφαρμογή', + 'label.is_equal_to' => 'είναι ίσο με', + 'label.is_not_equal_to' => 'δεν είναι ίσο με', + 'label.is_greater_than' => 'είναι μεγαλύτερο από', + 'label.is_greater_than_or_equal_to' => 'είναι μεγαλύτερο ή ίσο με', + 'label.is_less_than' => 'είναι μικρότερο από', + 'label.is_less_than_or_equal_to' => 'είναι μικρότερο ή ίσο με', + 'label.is_between' => 'είναι μεταξύ', + 'label.contains' => 'περιέχει', + 'label.not_contains' => 'δεν περιέχει', + 'label.starts_with' => 'ξεκινάει με', + 'label.ends_with' => 'τελειώνει με', + 'label.exactly' => 'ακριβώς', + 'label.not_exactly' => 'όχι ακριβώς', + 'label.is_same' => 'είναι ίδιο', + 'label.is_not_same' => 'δεν είναι το ίδιο', + 'label.is_after' => 'είναι μετά', + 'label.is_after_or_same' => 'είναι μετά ή το ίδιο', + 'label.is_before' => 'είναι πριν', + 'label.is_before_or_same' => 'είναι πριν ή το ίδιο', ], 'form' => [ diff --git a/src/Resources/views/crud/action.html.twig b/src/Resources/views/crud/action.html.twig index a7ec8fa6b2..04f11b9e0b 100644 --- a/src/Resources/views/crud/action.html.twig +++ b/src/Resources/views/crud/action.html.twig @@ -2,17 +2,17 @@ {# @var action \EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if 'a' == action.htmlElement %} - - {%- if action.icon %} {% endif -%} - {%- if action.label is not empty -%}{{ action.label|trans|raw }}{%- endif -%} - + + {%- if action.icon %} {% endif -%} + {%- if action.label is not empty -%}{{ action.label|trans|raw }}{%- endif -%} + {% elseif 'button' == action.htmlElement %} - + {% endif %} diff --git a/src/Resources/views/crud/detail.html.twig b/src/Resources/views/crud/detail.html.twig index f605c9546c..fb0a6736d5 100644 --- a/src/Resources/views/crud/detail.html.twig +++ b/src/Resources/views/crud/detail.html.twig @@ -8,122 +8,124 @@ {% set ea_field_assets = ea.crud.fieldAssets(constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Crud::PAGE_DETAIL')) %} {% block configured_head_contents %} - {{ parent() }} - {% for htmlContent in ea_field_assets.headContents %} - {{ htmlContent|raw }} - {% endfor %} + {{ parent() }} + {% for htmlContent in ea_field_assets.headContents %} + {{ htmlContent|raw }} + {% endfor %} {% endblock %} {% block configured_body_contents %} - {{ parent() }} - {% for htmlContent in ea_field_assets.bodyContents %} - {{ htmlContent|raw }} - {% endfor %} + {{ parent() }} + {% for htmlContent in ea_field_assets.bodyContents %} + {{ htmlContent|raw }} + {% endfor %} {% endblock %} {% block configured_stylesheets %} - {{ parent() }} - {{ include('@EasyAdmin/includes/_css_assets.html.twig', { assets: ea_field_assets.cssAssets }, with_context = false) }} - {{ include('@EasyAdmin/includes/_encore_link_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} + {{ parent() }} + {{ include('@EasyAdmin/includes/_css_assets.html.twig', { assets: ea_field_assets.cssAssets }, with_context = false) }} + {{ include('@EasyAdmin/includes/_encore_link_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} {% endblock %} {% block configured_javascripts %} - {{ parent() }} - {{ include('@EasyAdmin/includes/_js_assets.html.twig', { assets: ea_field_assets.jsAssets }, with_context = false) }} - {{ include('@EasyAdmin/includes/_encore_script_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} + {{ parent() }} + {{ include('@EasyAdmin/includes/_js_assets.html.twig', { assets: ea_field_assets.jsAssets }, with_context = false) }} + {{ include('@EasyAdmin/includes/_encore_script_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} {% endblock %} {% block content_title %} - {%- apply spaceless -%} - {% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters) %} - {{ custom_page_title is null - ? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw - : custom_page_title|trans|raw }} - {%- endapply -%} + {%- apply spaceless -%} + {% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters) %} + {{ custom_page_title is null + ? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw + : custom_page_title|trans|raw }} + {%- endapply -%} {% endblock %} {% block page_actions %} - {% for action in entity.actions %} - {{ include(action.templatePath, { action: action }, with_context = false) }} - {% endfor %} + {% for action in entity.actions %} + {{ include(action.templatePath, { action: action }, with_context = false) }} + {% endfor %} {% endblock %} {% block content_footer_wrapper '' %} {% block main %} - {% set field_layout = ea_create_field_layout(entity.fields) %} - {% block detail_fields %} - {% if field_layout.hasTabs %} - {{ _self.render_detail_fields_with_tabs(entity, field_layout) }} - {% else %} - {{ _self.render_detail_fields(entity, field_layout.fields) }} - {% endif %} - {% endblock detail_fields %} - - {% block delete_form %} - {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }} - {% endblock delete_form %} + {% set field_layout = ea_create_field_layout(entity.fields) %} + {% block detail_fields %} + {% if field_layout.hasTabs %} + {{ _self.render_detail_fields_with_tabs(entity, field_layout) }} + {% else %} + {{ _self.render_detail_fields(entity, field_layout.fields) }} + {% endif %} + {% endblock detail_fields %} + + {% block delete_form %} + {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }} + {% endblock delete_form %} {% endblock %} {% macro render_detail_fields_with_tabs(entity, field_layout) %} -
- -
+
+ +
{% endmacro %} {% macro render_detail_fields(entity, fields) %} - {% set form_panel_is_already_open = false %} - {% for field in fields %} - {% set is_form_field_panel = 'field-form_panel' in field.cssClass %} - - {% if is_form_field_panel or (loop.first and not is_form_field_panel) %} - {% if form_panel_is_already_open %} - {{ _self.close_form_field_panel() }} - {% set form_panel_is_already_open = false %} - {% endif %} - - {{ _self.open_form_field_panel(is_form_field_panel ? field : null) }} - {% set form_panel_is_already_open = true %} - {% endif %} - - {% block detail_field %} - {% if not is_form_field_panel %} - {{ _self.render_field(entity, field) }} - {% endif %} - {% endblock %} - {% endfor %} - - {% if form_panel_is_already_open %} - {{ _self.close_form_field_panel() }} - {% set form_panel_is_already_open = false %} - {% endif %} + {% set form_panel_is_already_open = false %} + {% for field in fields %} + {% set is_form_field_panel = 'field-form_panel' in field.cssClass %} + + {% if is_form_field_panel or (loop.first and not is_form_field_panel) %} + {% if form_panel_is_already_open %} + {{ _self.close_form_field_panel() }} + {% set form_panel_is_already_open = false %} + {% endif %} + + {{ _self.open_form_field_panel(is_form_field_panel ? field : null) }} + {% set form_panel_is_already_open = true %} + {% endif %} + + {% block detail_field %} + {% if not is_form_field_panel %} + {{ _self.render_field(entity, field) }} + {% endif %} + {% endblock %} + {% endfor %} + + {% if form_panel_is_already_open %} + {{ _self.close_form_field_panel() }} + {% set form_panel_is_already_open = false %} + {% endif %} {% endmacro %} {% macro open_form_field_panel(field = null) %} @@ -132,63 +134,67 @@ {% set collapsed = field is null ? false : field.customOption('collapsed') %} {% set panel_icon = field is null ? null : (field.customOptions.get('icon')|default(false)) %} {% set panel_label = field is null ? null : field.label %} - {% set panel_help = field is null ? null : field.help|default(false)%} + {% set panel_help = field is null ? null : field.help|default(false) %} {% set panel_has_header = collapsible or panel_icon or panel_label or panel_help %} -
-
- {% if panel_has_header %} -
- -
- {% endif %} - - -
+
+
+ {% if panel_has_header %} +
+ +
+ {% endif %} + + +
{% endmacro %} {% macro render_field(entity, field) %} -
-
- {{ field.label|trans|raw }} - - {% if field.help is not empty %} - - - - {% endif %} -
-
- {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }} -
-
+
+
+ {{ field.label|trans|raw }} + + {% if field.help is not empty %} + + + + {% endif %} +
+
+ {{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }} +
+
{% endmacro %} diff --git a/src/Resources/views/crud/edit.html.twig b/src/Resources/views/crud/edit.html.twig index 77210d508f..add444c096 100644 --- a/src/Resources/views/crud/edit.html.twig +++ b/src/Resources/views/crud/edit.html.twig @@ -11,57 +11,57 @@ {% set ea_field_assets = ea.crud.fieldAssets(constant('EasyCorp\\Bundle\\EasyAdminBundle\\Config\\Crud::PAGE_EDIT')) %} {% block head_javascript %} - {{ parent() }} - + {{ parent() }} + {% endblock head_javascript %} {% block configured_head_contents %} - {{ parent() }} - {% for htmlContent in ea_field_assets.headContents %} - {{ htmlContent|raw }} - {% endfor %} + {{ parent() }} + {% for htmlContent in ea_field_assets.headContents %} + {{ htmlContent|raw }} + {% endfor %} {% endblock %} {% block configured_body_contents %} - {{ parent() }} - {% for htmlContent in ea_field_assets.bodyContents %} - {{ htmlContent|raw }} - {% endfor %} + {{ parent() }} + {% for htmlContent in ea_field_assets.bodyContents %} + {{ htmlContent|raw }} + {% endfor %} {% endblock %} {% block configured_stylesheets %} - {{ parent() }} - {{ include('@EasyAdmin/includes/_css_assets.html.twig', { assets: ea_field_assets.cssAssets }, with_context = false) }} - {{ include('@EasyAdmin/includes/_encore_link_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} + {{ parent() }} + {{ include('@EasyAdmin/includes/_css_assets.html.twig', { assets: ea_field_assets.cssAssets }, with_context = false) }} + {{ include('@EasyAdmin/includes/_encore_link_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} {% endblock %} {% block configured_javascripts %} - {{ parent() }} - {{ include('@EasyAdmin/includes/_js_assets.html.twig', { assets: ea_field_assets.jsAssets }, with_context = false) }} - {{ include('@EasyAdmin/includes/_encore_script_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} + {{ parent() }} + {{ include('@EasyAdmin/includes/_js_assets.html.twig', { assets: ea_field_assets.jsAssets }, with_context = false) }} + {{ include('@EasyAdmin/includes/_encore_script_tags.html.twig', { assets: ea_field_assets.webpackEncoreAssets }, with_context = false) }} {% endblock %} {% block content_title %} - {%- apply spaceless -%} - {% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters) %} - {{ custom_page_title is null - ? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw - : custom_page_title|trans|raw }} - {%- endapply -%} + {%- apply spaceless -%} + {% set custom_page_title = ea.crud.customPageTitle(pageName, entity ? entity.instance : null, ea.i18n.translationParameters) %} + {{ custom_page_title is null + ? ea.crud.defaultPageTitle(null, null, ea.i18n.translationParameters)|trans|raw + : custom_page_title|trans|raw }} + {%- endapply -%} {% endblock %} {% block page_actions %} - {% for action in entity.actions %} - {{ include(action.templatePath, { action: action }, with_context = false) }} - {% endfor %} + {% for action in entity.actions %} + {{ include(action.templatePath, { action: action }, with_context = false) }} + {% endfor %} {% endblock %} {% block main %} - {% block edit_form %} - {{ form(edit_form) }} - {% endblock edit_form %} + {% block edit_form %} + {{ form(edit_form) }} + {% endblock edit_form %} - {% block delete_form %} - {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }} - {% endblock delete_form %} + {% block delete_form %} + {{ include('@EasyAdmin/crud/includes/_delete_form.html.twig', { entity_id: entity.primaryKeyValue }, with_context = false) }} + {% endblock delete_form %} {% endblock %} diff --git a/src/Resources/views/crud/field/array.html.twig b/src/Resources/views/crud/field/array.html.twig index bc1535faa6..00add745cf 100644 --- a/src/Resources/views/crud/field/array.html.twig +++ b/src/Resources/views/crud/field/array.html.twig @@ -2,11 +2,11 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if ea.crud.currentAction == 'detail' %} -
    - {% for item in field.value %} -
  • {{ item }}
  • - {% endfor %} -
+
    + {% for item in field.value %} +
  • {{ item }}
  • + {% endfor %} +
{% else %} - {{ field.formattedValue }} + {{ field.formattedValue }} {% endif %} diff --git a/src/Resources/views/crud/field/association.html.twig b/src/Resources/views/crud/field/association.html.twig index 20d76c3a2e..5174f67ba9 100644 --- a/src/Resources/views/crud/field/association.html.twig +++ b/src/Resources/views/crud/field/association.html.twig @@ -2,11 +2,11 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if 'toMany' == field.customOptions.get('associationType') %} - {{ field.formattedValue }} + {{ field.formattedValue }} {% else %} - {% if field.customOptions.get('relatedUrl') is not null %} - {{ field.formattedValue }} - {% else %} - {{ field.formattedValue }} - {% endif %} + {% if field.customOptions.get('relatedUrl') is not null %} + {{ field.formattedValue }} + {% else %} + {{ field.formattedValue }} + {% endif %} {% endif %} diff --git a/src/Resources/views/crud/field/avatar.html.twig b/src/Resources/views/crud/field/avatar.html.twig index 4846ff00c4..d4701c9f4d 100644 --- a/src/Resources/views/crud/field/avatar.html.twig +++ b/src/Resources/views/crud/field/avatar.html.twig @@ -1,4 +1,5 @@ {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} - + diff --git a/src/Resources/views/crud/field/boolean.html.twig b/src/Resources/views/crud/field/boolean.html.twig index 33f21e33f9..05c35daee5 100644 --- a/src/Resources/views/crud/field/boolean.html.twig +++ b/src/Resources/views/crud/field/boolean.html.twig @@ -4,23 +4,23 @@ {% trans_default_domain 'EasyAdminBundle' %} {% if ea.crud.currentAction == 'detail' or not field.customOptions.get('renderAsSwitch') %} - {% set badge_is_hidden = ea.crud.currentAction == 'index' - and ( - (field.value == true and field.customOptions.get('hideValueWhenTrue') == true) - or - (field.value == false and field.customOptions.get('hideValueWhenFalse') == true) - ) %} + {% set badge_is_hidden = ea.crud.currentAction == 'index' + and ( + (field.value == true and field.customOptions.get('hideValueWhenTrue') == true) + or + (field.value == false and field.customOptions.get('hideValueWhenFalse') == true) + ) %} - {% if not badge_is_hidden %} - + {% if not badge_is_hidden %} + {{ (field.value == true ? 'label.true' : 'label.false')|trans }} - {% endif %} + {% endif %} {% else %} -
- - -
+
+ + +
{% endif %} diff --git a/src/Resources/views/crud/field/code_editor.html.twig b/src/Resources/views/crud/field/code_editor.html.twig index 3b65f9fc94..d3476c3117 100644 --- a/src/Resources/views/crud/field/code_editor.html.twig +++ b/src/Resources/views/crud/field/code_editor.html.twig @@ -2,29 +2,30 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if ea.crud.currentAction == 'detail' %} - {# TODO: improve this to highlight code #} - {% set configuredHeight = field.customOptions.get('height') %} -
+	{# TODO: improve this to highlight code #}
+	{% set configuredHeight = field.customOptions.get('height') %}
+	
         {{- field.formattedValue|escape -}}
     
{% else %} - {% set html_id = 'ea-code-editor-' ~ field.uniqueId %} - - {{ 'field.code_editor.view_code'|trans([], domain = 'EasyAdminBundle') }} - + {% set html_id = 'ea-code-editor-' ~ field.uniqueId %} + + {{ 'field.code_editor.view_code'|trans([], domain = 'EasyAdminBundle') }} + - + {% endif %} diff --git a/src/Resources/views/crud/field/collection.html.twig b/src/Resources/views/crud/field/collection.html.twig index b5d5d8a4c8..9c59265c2e 100644 --- a/src/Resources/views/crud/field/collection.html.twig +++ b/src/Resources/views/crud/field/collection.html.twig @@ -3,7 +3,7 @@ {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {# this is a bit ugly, but Twig doesn't have a 'is numeric' test #} {% if field.formattedValue matches '/^\\d+$/' %} - {{ field.formattedValue }} + {{ field.formattedValue }} {% else %} - {{ field.formattedValue }} + {{ field.formattedValue }} {% endif %} diff --git a/src/Resources/views/crud/field/color.html.twig b/src/Resources/views/crud/field/color.html.twig index c5aa3560e0..349b8108c6 100644 --- a/src/Resources/views/crud/field/color.html.twig +++ b/src/Resources/views/crud/field/color.html.twig @@ -2,8 +2,10 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if field.customOptions.get('showSample') %} -   +   {% endif %} {% if field.customOptions.get('showValue') %} - {{ field.formattedValue }} + {{ field.formattedValue }} {% endif %} diff --git a/src/Resources/views/crud/field/country.html.twig b/src/Resources/views/crud/field/country.html.twig index 48112fcdfa..e4f9b0528c 100644 --- a/src/Resources/views/crud/field/country.html.twig +++ b/src/Resources/views/crud/field/country.html.twig @@ -7,25 +7,27 @@ {% set show_name = field.customOptions.get('showName') %} {% if show_flag and not show_name %} - {% for flag_code, country_name in field.formattedValue %} - {% if flag_code is not null %} - {{ country_name }} - {% endif %} - {% endfor %} -{% elseif show_name and not show_flag %} - {{ field.formattedValue|join(', ') }} + {% for flag_code, country_name in field.formattedValue %} + {% if flag_code is not null %} + {{ country_name }} + {% endif %} + {% endfor %} +{% elseif show_name and not show_flag %} + {{ field.formattedValue|join(', ') }} {% else %} - {% for flag_code, country_name in field.formattedValue %} - + {% for flag_code, country_name in field.formattedValue %} + {%- if show_flag -%} - {%- if flag_code is not null -%} - {{ country_name }} - {%- endif -%} - {%- endif -%} + {%- if flag_code is not null -%} + {{ country_name }} + {%- endif -%} + {%- endif -%} - {%- if show_name -%} - {{- country_name ?? '' -}} - {%- endif -%} + {%- if show_name -%} + {{- country_name ?? '' -}} + {%- endif -%} - {% endfor %} + {% endfor %} {% endif %} diff --git a/src/Resources/views/crud/field/currency.html.twig b/src/Resources/views/crud/field/currency.html.twig index cbf6a510b0..5fcfd72fc7 100644 --- a/src/Resources/views/crud/field/currency.html.twig +++ b/src/Resources/views/crud/field/currency.html.twig @@ -2,11 +2,11 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if field.customOptions.get('showCode') %} - {{ field.value }} + {{ field.value }} {% endif %} {% if field.customOptions.get('showSymbol') %} - {{ field.formattedValue.symbol }} + {{ field.formattedValue.symbol }} {% endif %} {% if field.customOptions.get('showName') %} - {{ field.formattedValue.name }} + {{ field.formattedValue.name }} {% endif %} diff --git a/src/Resources/views/crud/field/image.html.twig b/src/Resources/views/crud/field/image.html.twig index b4e303a29a..043c995d71 100644 --- a/src/Resources/views/crud/field/image.html.twig +++ b/src/Resources/views/crud/field/image.html.twig @@ -3,16 +3,16 @@ {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% set images = field.formattedValue %} {% if images is not iterable %} - {% set images = [images] %} + {% set images = [images] %} {% endif %} {% for image in images %} - {% set html_id = 'ea-lightbox-' ~ field.uniqueId ~ '-' ~ loop.index %} - - - + {% set html_id = 'ea-lightbox-' ~ field.uniqueId ~ '-' ~ loop.index %} + + + -
- -
+
+ +
{% endfor %} diff --git a/src/Resources/views/crud/field/language.html.twig b/src/Resources/views/crud/field/language.html.twig index eb23a5ea38..c05a9d69ee 100644 --- a/src/Resources/views/crud/field/language.html.twig +++ b/src/Resources/views/crud/field/language.html.twig @@ -2,8 +2,8 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if field.customOptions.get('showCode') %} - {{ field.value }} + {{ field.value }} {% endif %} {% if field.customOptions.get('showName') %} - {{ field.formattedValue ?? '' }} + {{ field.formattedValue ?? '' }} {% endif %} diff --git a/src/Resources/views/crud/field/locale.html.twig b/src/Resources/views/crud/field/locale.html.twig index eb23a5ea38..c05a9d69ee 100644 --- a/src/Resources/views/crud/field/locale.html.twig +++ b/src/Resources/views/crud/field/locale.html.twig @@ -2,8 +2,8 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if field.customOptions.get('showCode') %} - {{ field.value }} + {{ field.value }} {% endif %} {% if field.customOptions.get('showName') %} - {{ field.formattedValue ?? '' }} + {{ field.formattedValue ?? '' }} {% endif %} diff --git a/src/Resources/views/crud/field/text.html.twig b/src/Resources/views/crud/field/text.html.twig index fa3bff5585..2d69b3c201 100644 --- a/src/Resources/views/crud/field/text.html.twig +++ b/src/Resources/views/crud/field/text.html.twig @@ -2,7 +2,7 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if ea.crud.currentAction == 'detail' %} - {{ field.formattedValue|raw|nl2br }} + {{ field.formattedValue|raw|nl2br }} {% else %} - {{ field.formattedValue|raw }} + {{ field.formattedValue|raw }} {% endif %} diff --git a/src/Resources/views/crud/field/text_editor.html.twig b/src/Resources/views/crud/field/text_editor.html.twig index 67c96ccfdc..7d5da3b4e7 100644 --- a/src/Resources/views/crud/field/text_editor.html.twig +++ b/src/Resources/views/crud/field/text_editor.html.twig @@ -2,25 +2,26 @@ {# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #} {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% if ea.crud.currentAction == 'detail' %} - {{ field.formattedValue|nl2br }} + {{ field.formattedValue|nl2br }} {% else %} - {% set html_id = 'ea-text-editor-' ~ field.uniqueId %} - - {{ 'field.text_editor.view_content'|trans([], domain = 'EasyAdminBundle') }} - + {% set html_id = 'ea-text-editor-' ~ field.uniqueId %} + + {{ 'field.text_editor.view_content'|trans([], domain = 'EasyAdminBundle') }} + - + {% endif %} diff --git a/src/Resources/views/crud/field/textarea.html.twig b/src/Resources/views/crud/field/textarea.html.twig index fec5c5a1a5..b89324889e 100644 --- a/src/Resources/views/crud/field/textarea.html.twig +++ b/src/Resources/views/crud/field/textarea.html.twig @@ -3,11 +3,11 @@ {# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #} {% set render_as_html = field.customOptions.get('renderAsHtml') %} {% if ea.crud.currentAction == 'detail' %} - + {{ render_as_html ? field.formattedValue|raw|nl2br : field.formattedValue|nl2br }} {% else %} - + {{ render_as_html ? field.formattedValue|raw : field.formattedValue|striptags }} {% endif %} diff --git a/src/Resources/views/crud/field/url.html.twig b/src/Resources/views/crud/field/url.html.twig index fadf941026..a6ec693064 100644 --- a/src/Resources/views/crud/field/url.html.twig +++ b/src/Resources/views/crud/field/url.html.twig @@ -4,7 +4,7 @@ {# NOTE: the rel="noopener" attr is needed to avoid performance and security issues (see https://web.dev/external-anchors-use-rel-noopener/) #} {% if ea.crud.currentAction == 'detail' %} - {{ field.value }} + {{ field.value }} {% else %} - {{ field.formattedValue }} + {{ field.formattedValue }} {% endif %} diff --git a/src/Resources/views/crud/filters.html.twig b/src/Resources/views/crud/filters.html.twig index 2a8c120b32..7570349e04 100644 --- a/src/Resources/views/crud/filters.html.twig +++ b/src/Resources/views/crud/filters.html.twig @@ -3,14 +3,14 @@ {% form_theme filters_form with ea.crud.formThemes only %} {{ form_start(filters_form, { attr: { - id: filters_form.vars.id, - 'data-ea-filters-form-id': filters_form.vars.id + id: filters_form.vars.id, + 'data-ea-filters-form-id': filters_form.vars.id } }) }} {# browsers remove the query string when submitting forms using GET; that's why all query string parameters are added as hidden form fields #} {% for paramName, paramValue in form_action_query_string_as_array|ea_flatten_array %} - - {% endfor %} + + {% endfor %} {{ form_widget(filters_form) }} {{ form_end(filters_form) }} diff --git a/src/Resources/views/crud/form_theme.html.twig b/src/Resources/views/crud/form_theme.html.twig index 92320e2ce4..ea28ac77e9 100644 --- a/src/Resources/views/crud/form_theme.html.twig +++ b/src/Resources/views/crud/form_theme.html.twig @@ -3,768 +3,786 @@ {% block form_start %} {% if form.vars.errors|length > 0 and 'ea_crud' in form.vars.block_prefixes|default([]) %} - {{ form_errors(form, {attr: { class: 'global-invalid-feedback' }}) }} - {% endif %} + {{ form_errors(form, {attr: { class: 'global-invalid-feedback' }}) }} + {% endif %} {{ parent() }} -
{# this is closed in form_end #} - -{% endblock form_start %} +
{# this is closed in form_end #} + + {% endblock form_start %} -{% block form_end %} - {% if not render_rest is defined or render_rest %} - {{ form_rest(form) }} - {% endif %} -
{# this closes the '
' of form_start #} - + {% block form_end %} + {% if not render_rest is defined or render_rest %} + {{ form_rest(form) }} + {% endif %} +
{# this closes the '
' of form_start #} + {% endblock %} {% block form_errors %} - {% if errors|length > 0 %} - {% for error in errors %} -
{{ error.message }}
- {% endfor %} - {% endif %} + {% if errors|length > 0 %} + {% for error in errors %} +
{{ error.message }}
+ {% endfor %} + {% endif %} {% endblock form_errors %} {# Widgets #} {% block form_widget_simple -%} - {% if type is not defined or type not in ['file', 'hidden'] %} - {%- set attr = attr|merge({class: (attr.class|default(''))|trim}) -%} - {% endif %} - {%- if type is defined and (type == 'range' or type == 'color') %} - {# Attribute "required" is not supported #} - {%- set required = false -%} - {% endif %} - {{- parent() -}} + {% if type is not defined or type not in ['file', 'hidden'] %} + {%- set attr = attr|merge({class: (attr.class|default(''))|trim}) -%} + {% endif %} + {%- if type is defined and (type == 'range' or type == 'color') %} + {# Attribute "required" is not supported #} + {%- set required = false -%} + {% endif %} + {{- parent() -}} {%- endblock form_widget_simple %} {% block datetime_widget %} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} -
- {{- parent() -}} -
+ {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} +
+ {{- parent() -}} +
{% endblock datetime_widget %} {% block date_widget -%} -
- {{- parent() -}} -
+
+ {{- parent() -}} +
{%- endblock date_widget %} {% block time_widget -%} -
- {{- parent() -}} -
+
+ {{- parent() -}} +
{%- endblock time_widget %} {% block file_widget -%} - {% if vich|default(false) %} - {%- set type = type|default('file') -%} - {{- block('form_widget_simple') -}} - {% else %} - {{- block('form_widget_simple') -}} - {% endif %} + {% if vich|default(false) %} + {%- set type = type|default('file') -%} + {{- block('form_widget_simple') -}} + {% else %} + {{- block('form_widget_simple') -}} + {% endif %} {%- endblock %} {# Rows #} {% block form_row %} - {% set row_attr = row_attr|merge({ - class: row_attr.class|default('') ~ ' form-group' - }) %} - -
-
- {{- form_label(form) -}} -
- {% set has_prepend_html = ea.field.prepend_html|default(null) is not null %} - {% set has_append_html = ea.field.append_html|default(null) is not null %} - {% set has_input_groups = has_prepend_html or has_append_html %} - - {% if has_input_groups %}
{% endif %} - {% if has_prepend_html %} -
- {{ ea.field.prepend_html|raw }} -
- {% endif %} - - {{ form_widget(form) }} - - {% if has_append_html %} - {{ ea.field.append_html|raw }} - {% endif %} - {% if has_input_groups %}
{% endif %} - - {% if ea.field.help ?? false %} - {{ ea.field.help|raw }} - {% elseif form.vars.help ?? false %} - {{ form.vars.help|trans(form.vars.help_translation_parameters, form.vars.translation_domain)|raw }} - {% endif %} - - {{- form_errors(form) -}} -
-
-
- - {# if a field doesn't define its columns explicitly, insert a fill element to make the field take the entire row space #} - {% if form.vars.ea_crud_form.ea_field.columns|default(null) is null %} -
- {% endif %} + {% set row_attr = row_attr|merge({ + class: row_attr.class|default('') ~ ' form-group' + }) %} + +
+
+ {{- form_label(form) -}} +
+ {% set has_prepend_html = ea.field.prepend_html|default(null) is not null %} + {% set has_append_html = ea.field.append_html|default(null) is not null %} + {% set has_input_groups = has_prepend_html or has_append_html %} + + {% if has_input_groups %} +
{% endif %} + {% if has_prepend_html %} +
+ {{ ea.field.prepend_html|raw }} +
+ {% endif %} + + {{ form_widget(form) }} + + {% if has_append_html %} + {{ ea.field.append_html|raw }} + {% endif %} + {% if has_input_groups %}
{% endif %} + + {% if ea.field.help ?? false %} + {{ ea.field.help|raw }} + {% elseif form.vars.help ?? false %} + {{ form.vars.help|trans(form.vars.help_translation_parameters, form.vars.translation_domain)|raw }} + {% endif %} + + {{- form_errors(form) -}} +
+
+
+ + {# if a field doesn't define its columns explicitly, insert a fill element to make the field take the entire row space #} + {% if form.vars.ea_crud_form.ea_field.columns|default(null) is null %} +
+ {% endif %} {% endblock form_row %} {% block choice_widget_collapsed %} - {% if 'ea-autocomplete' == attr['data-ea-widget']|default(false) %} - {% set attr = attr|merge({ - 'data-ea-i18n-no-results-found': 'autocomplete.no-results-found'|trans({}, 'EasyAdminBundle'), - 'data-ea-i18n-no-more-results': 'autocomplete.no-more-results'|trans({}, 'EasyAdminBundle'), - 'data-ea-i18n-loading-more-results': 'autocomplete.loading-more-results'|trans({}, 'EasyAdminBundle'), - }) %} - {% endif %} - - {{ parent() }} + {% if 'ea-autocomplete' == attr['data-ea-widget']|default(false) %} + {% set attr = attr|merge({ + 'data-ea-i18n-no-results-found': 'autocomplete.no-results-found'|trans({}, 'EasyAdminBundle'), + 'data-ea-i18n-no-more-results': 'autocomplete.no-more-results'|trans({}, 'EasyAdminBundle'), + 'data-ea-i18n-loading-more-results': 'autocomplete.loading-more-results'|trans({}, 'EasyAdminBundle'), + }) %} + {% endif %} + + {{ parent() }} {% endblock choice_widget_collapsed %} {% block collection_row %} - {% if prototype is defined and not prototype.rendered %} - {% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %} - {% endif %} - - {% set row_attr = row_attr|merge({ - 'data-ea-collection-field': 'true', - 'data-entry-is-complex': form.vars.ea_crud_form.ea_field and form.vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ? 'true' : 'false', - 'data-allow-add': allow_add ? 'true' : 'false', - 'data-allow-delete': allow_delete ? 'true' : 'false', - 'data-num-items': form.children is empty ? 0 : max(form.children|keys), - 'data-form-type-name-placeholder': prototype is defined ? prototype.vars.name : '', - }) %} - - {{ block('form_row') }} + {% if prototype is defined and not prototype.rendered %} + {% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %} + {% endif %} + + {% set row_attr = row_attr|merge({ + 'data-ea-collection-field': 'true', + 'data-entry-is-complex': form.vars.ea_crud_form.ea_field and form.vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ? 'true' : 'false', + 'data-allow-add': allow_add ? 'true' : 'false', + 'data-allow-delete': allow_delete ? 'true' : 'false', + 'data-num-items': form.children is empty ? 0 : max(form.children|keys), + 'data-form-type-name-placeholder': prototype is defined ? prototype.vars.name : '', + }) %} + + {{ block('form_row') }} {% endblock collection_row %} {% block collection_widget %} - {# the "is iterable" check is needed because if an object implements __toString() and + {# the "is iterable" check is needed because if an object implements __toString() and returns an empty string, "is empty" returns true even if it's not a collection #} - {% set isEmptyCollection = value is null or (value is iterable and value is empty) %} - {% set is_array_field = 'EasyCorp\\Bundle\\EasyAdminBundle\\Field\\ArrayField' == form.vars.ea_crud_form.ea_field.fieldFqcn ?? false %} - -
- {% if isEmptyCollection %} - {{ block('empty_collection') }} - {% elseif is_array_field %} - {{ block('form_widget') }} - {% else %} -
- {{ block('form_widget') }} -
- {% endif %} -
- - {% if isEmptyCollection or form.vars.prototype is defined %} - {% set attr = attr|merge({'data-empty-collection': block('empty_collection') }) %} - {% endif %} - - {% if allow_add|default(false) and not disabled %} - - {% endif %} + {% set isEmptyCollection = value is null or (value is iterable and value is empty) %} + {% set is_array_field = 'EasyCorp\\Bundle\\EasyAdminBundle\\Field\\ArrayField' == form.vars.ea_crud_form.ea_field.fieldFqcn ?? false %} + +
+ {% if isEmptyCollection %} + {{ block('empty_collection') }} + {% elseif is_array_field %} + {{ block('form_widget') }} + {% else %} +
+ {{ block('form_widget') }} +
+ {% endif %} +
+ + {% if isEmptyCollection or form.vars.prototype is defined %} + {% set attr = attr|merge({'data-empty-collection': block('empty_collection') }) %} + {% endif %} + + {% if allow_add|default(false) and not disabled %} + + {% endif %} {% endblock collection_widget %} {% block collection_entry_row %} - {% set is_array_field = 'EasyCorp\\Bundle\\EasyAdminBundle\\Field\\ArrayField' == form_parent(form).vars.ea_crud_form.ea_field.fieldFqcn ?? false %} - {% set is_complex = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ?? false %} - {% set allows_deleting_items = form_parent(form).vars.allow_delete|default(false) %} - {% set render_expanded = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('renderExpanded') ?? false %} - {% set delete_item_button %} - - {% endset %} - -
- {% if is_array_field|default(false) %} - {{ form_widget(form) }} - {% if allows_deleting_items and not disabled %} - {{ delete_item_button }} - {% endif %} - {% else %} -
-

- - - {% if allows_deleting_items and not disabled %} - {{ delete_item_button }} - {% endif %} -

-
-
- {{ form_widget(form) }} -
-
-
- {% endif %} -
+ {% set is_array_field = 'EasyCorp\\Bundle\\EasyAdminBundle\\Field\\ArrayField' == form_parent(form).vars.ea_crud_form.ea_field.fieldFqcn ?? false %} + {% set is_complex = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('entryIsComplex') ?? false %} + {% set allows_deleting_items = form_parent(form).vars.allow_delete|default(false) %} + {% set render_expanded = form_parent(form).vars.ea_crud_form.ea_field.customOptions.get('renderExpanded') ?? false %} + {% set delete_item_button %} + + {% endset %} + +
+ {% if is_array_field|default(false) %} + {{ form_widget(form) }} + {% if allows_deleting_items and not disabled %} + {{ delete_item_button }} + {% endif %} + {% else %} +
+

+ + + {% if allows_deleting_items and not disabled %} + {{ delete_item_button }} + {% endif %} +

+
+
+ {{ form_widget(form) }} +
+
+
+ {% endif %} +
{% endblock collection_entry_row %} {% block form_widget_compound %} -
- {% if 'collection' in block_prefixes %} - {# the "is iterable" check is needed because if an object implements __toString() and +
+ {% if 'collection' in block_prefixes %} + {# the "is iterable" check is needed because if an object implements __toString() and returns an empty string, "is empty" returns true even if it's not a collection #} - {% set isEmptyCollection = value is null or (value is iterable and value is empty) %} - {% if isEmptyCollection %} - {{ block('empty_collection') }} - {% endif %} - {% if isEmptyCollection or form.vars.prototype is defined %} - {% set attr = attr|merge({'data-empty-collection': block('empty_collection') }) %} - {% endif %} - {% endif %} - - {{ parent() }} -
+ {% set isEmptyCollection = value is null or (value is iterable and value is empty) %} + {% if isEmptyCollection %} + {{ block('empty_collection') }} + {% endif %} + {% if isEmptyCollection or form.vars.prototype is defined %} + {% set attr = attr|merge({'data-empty-collection': block('empty_collection') }) %} + {% endif %} + {% endif %} + + {{ parent() }} +
{% endblock form_widget_compound %} {% block button_row -%} -
- {{- form_widget(form) -}} -
+
+ {{- form_widget(form) -}} +
{%- endblock button_row %} {# Labels #} {% block form_label -%} - {% if label is same as(false) -%} -
+ + {{- form_widget(form) -}} +
{%- endblock button_row %} {% block choice_row -%} - {%- set force_error = true -%} - {{- block('form_row') -}} + {%- set force_error = true -%} + {{- block('form_row') -}} {%- endblock choice_row %} {% block date_row -%} - {%- set force_error = true -%} - {{- block('form_row') -}} + {%- set force_error = true -%} + {{- block('form_row') -}} {%- endblock date_row %} {% block time_row -%} - {%- set force_error = true -%} - {{- block('form_row') -}} + {%- set force_error = true -%} + {{- block('form_row') -}} {%- endblock time_row %} {% block datetime_row -%} - {%- set force_error = true -%} - {{- block('form_row') -}} + {%- set force_error = true -%} + {{- block('form_row') -}} {%- endblock datetime_row %} diff --git a/src/Resources/views/symfony-form-themes/form_div_layout.html.twig b/src/Resources/views/symfony-form-themes/form_div_layout.html.twig index 601b136583..ead0e8d4e3 100644 --- a/src/Resources/views/symfony-form-themes/form_div_layout.html.twig +++ b/src/Resources/views/symfony-form-themes/form_div_layout.html.twig @@ -1,321 +1,336 @@ {# Widgets #} {%- block form_widget -%} - {% if compound %} - {{- block('form_widget_compound') -}} - {% else %} - {{- block('form_widget_simple') -}} - {% endif %} + {% if compound %} + {{- block('form_widget_compound') -}} + {% else %} + {{- block('form_widget_simple') -}} + {% endif %} {%- endblock form_widget -%} {%- block form_widget_simple -%} - {%- set type = type|default('text') -%} - {%- if type == 'range' or type == 'color' -%} - {# Attribute "required" is not supported #} - {%- set required = false -%} - {%- endif -%} - + {%- set type = type|default('text') -%} + {%- if type == 'range' or type == 'color' -%} + {# Attribute "required" is not supported #} + {%- set required = false -%} + {%- endif -%} + {%- endblock form_widget_simple -%} {%- block form_widget_compound -%} -
- {%- if form is rootform -%} - {{ form_errors(form) }} - {%- endif -%} - {{- block('form_rows') -}} - {{- form_rest(form) -}} -
+
+ {%- if form is rootform -%} + {{ form_errors(form) }} + {%- endif -%} + {{- block('form_rows') -}} + {{- form_rest(form) -}} +
{%- endblock form_widget_compound -%} {%- block collection_widget -%} - {% if prototype is defined and not prototype.rendered %} - {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%} - {% endif %} - {{- block('form_widget') -}} + {% if prototype is defined and not prototype.rendered %} + {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%} + {% endif %} + {{- block('form_widget') -}} {%- endblock collection_widget -%} {%- block textarea_widget -%} - + {%- endblock textarea_widget -%} {%- block choice_widget -%} - {% if expanded %} - {{- block('choice_widget_expanded') -}} - {% else %} - {{- block('choice_widget_collapsed') -}} - {% endif %} + {% if expanded %} + {{- block('choice_widget_expanded') -}} + {% else %} + {{- block('choice_widget_collapsed') -}} + {% endif %} {%- endblock choice_widget -%} {%- block choice_widget_expanded -%} -
- {%- for child in form %} - {{- form_widget(child) -}} - {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} - {% endfor -%} -
+
+ {%- for child in form %} + {{- form_widget(child) -}} + {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} + {% endfor -%} +
{%- endblock choice_widget_expanded -%} {%- block choice_widget_collapsed -%} - {%- if required and placeholder is none and not placeholder_in_choices and not multiple and (attr.size is not defined or attr.size <= 1) -%} - {% set required = false %} - {%- endif -%} - + {%- if required and placeholder is none and not placeholder_in_choices and not multiple and (attr.size is not defined or attr.size <= 1) -%} + {% set required = false %} + {%- endif -%} + {%- endblock choice_widget_collapsed -%} {%- block choice_widget_options -%} - {% for group_label, choice in options %} - {%- if choice is iterable -%} - - {% set options = choice %} - {{- block('choice_widget_options') -}} - - {%- else -%} - - {%- endif -%} - {% endfor %} + {% for group_label, choice in options %} + {%- if choice is iterable -%} + + {% set options = choice %} + {{- block('choice_widget_options') -}} + + {%- else -%} + + {%- endif -%} + {% endfor %} {%- endblock choice_widget_options -%} {%- block checkbox_widget -%} - + {%- endblock checkbox_widget -%} {%- block radio_widget -%} - + {%- endblock radio_widget -%} {%- block datetime_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {%- else -%} -
- {{- form_errors(form.date) -}} - {{- form_errors(form.time) -}} - {{- form_widget(form.date) -}} - {{- form_widget(form.time) -}} -
- {%- endif -%} + {% if widget == 'single_text' %} + {{- block('form_widget_simple') -}} + {%- else -%} +
+ {{- form_errors(form.date) -}} + {{- form_errors(form.time) -}} + {{- form_widget(form.date) -}} + {{- form_widget(form.time) -}} +
+ {%- endif -%} {%- endblock datetime_widget -%} {%- block date_widget -%} - {%- if widget == 'single_text' -%} - {{ block('form_widget_simple') }} - {%- else -%} -
- {{- date_pattern|replace({ - '{{ year }}': form_widget(form.year), - '{{ month }}': form_widget(form.month), - '{{ day }}': form_widget(form.day), - })|raw -}} -
- {%- endif -%} + {%- if widget == 'single_text' -%} + {{ block('form_widget_simple') }} + {%- else -%} +
+ {{- date_pattern|replace({ + '{{ year }}': form_widget(form.year), + '{{ month }}': form_widget(form.month), + '{{ day }}': form_widget(form.day), + })|raw -}} +
+ {%- endif -%} {%- endblock date_widget -%} {%- block time_widget -%} - {%- if widget == 'single_text' -%} - {{ block('form_widget_simple') }} - {%- else -%} - {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%} -
- {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %} -
- {%- endif -%} + {%- if widget == 'single_text' -%} + {{ block('form_widget_simple') }} + {%- else -%} + {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%} +
+ {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %} +
+ {%- endif -%} {%- endblock time_widget -%} {%- block dateinterval_widget -%} - {%- if widget == 'single_text' -%} - {{- block('form_widget_simple') -}} - {%- else -%} -
- {{- form_errors(form) -}} - - - - {%- if with_years %}{% endif -%} - {%- if with_months %}{% endif -%} - {%- if with_weeks %}{% endif -%} - {%- if with_days %}{% endif -%} - {%- if with_hours %}{% endif -%} - {%- if with_minutes %}{% endif -%} - {%- if with_seconds %}{% endif -%} - - - - - {%- if with_years %}{% endif -%} - {%- if with_months %}{% endif -%} - {%- if with_weeks %}{% endif -%} - {%- if with_days %}{% endif -%} - {%- if with_hours %}{% endif -%} - {%- if with_minutes %}{% endif -%} - {%- if with_seconds %}{% endif -%} - - - - {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%} -
- {%- endif -%} + {%- if widget == 'single_text' -%} + {{- block('form_widget_simple') -}} + {%- else -%} +
+ {{- form_errors(form) -}} + + + + {%- if with_years %} + {% endif -%} + {%- if with_months %} + {% endif -%} + {%- if with_weeks %} + {% endif -%} + {%- if with_days %} + {% endif -%} + {%- if with_hours %} + {% endif -%} + {%- if with_minutes %} + {% endif -%} + {%- if with_seconds %} + {% endif -%} + + + + + {%- if with_years %} + {% endif -%} + {%- if with_months %} + {% endif -%} + {%- if with_weeks %} + {% endif -%} + {%- if with_days %} + {% endif -%} + {%- if with_hours %} + {% endif -%} + {%- if with_minutes %} + {% endif -%} + {%- if with_seconds %} + {% endif -%} + + + + {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%} +
+ {%- endif -%} {%- endblock dateinterval_widget -%} {%- block number_widget -%} - {# type="number" doesn't work with floats in localized formats #} - {%- set type = type|default('text') -%} - {{ block('form_widget_simple') }} + {# type="number" doesn't work with floats in localized formats #} + {%- set type = type|default('text') -%} + {{ block('form_widget_simple') }} {%- endblock number_widget -%} {%- block integer_widget -%} - {%- set type = type|default('number') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('number') -%} + {{ block('form_widget_simple') }} {%- endblock integer_widget -%} {%- block money_widget -%} - {{ money_pattern|form_encode_currency(block('form_widget_simple')) }} + {{ money_pattern|form_encode_currency(block('form_widget_simple')) }} {%- endblock money_widget -%} {%- block url_widget -%} - {%- set type = type|default('url') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('url') -%} + {{ block('form_widget_simple') }} {%- endblock url_widget -%} {%- block search_widget -%} - {%- set type = type|default('search') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('search') -%} + {{ block('form_widget_simple') }} {%- endblock search_widget -%} {%- block percent_widget -%} - {%- set type = type|default('text') -%} - {{ block('form_widget_simple') }}{% if symbol %} {{ symbol|default('%') }}{% endif %} + {%- set type = type|default('text') -%} + {{ block('form_widget_simple') }}{% if symbol %} {{ symbol|default('%') }}{% endif %} {%- endblock percent_widget -%} {%- block password_widget -%} - {%- set type = type|default('password') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('password') -%} + {{ block('form_widget_simple') }} {%- endblock password_widget -%} {%- block hidden_widget -%} - {%- set type = type|default('hidden') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('hidden') -%} + {{ block('form_widget_simple') }} {%- endblock hidden_widget -%} {%- block email_widget -%} - {%- set type = type|default('email') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('email') -%} + {{ block('form_widget_simple') }} {%- endblock email_widget -%} {%- block range_widget -%} - {% set type = type|default('range') %} - {{- block('form_widget_simple') -}} + {% set type = type|default('range') %} + {{- block('form_widget_simple') -}} {%- endblock range_widget %} {%- block button_widget -%} - {%- if label is empty -%} - {%- if label_format is not empty -%} - {% set label = label_format|replace({ - '%name%': name, - '%id%': id, - }) %} - {%- elseif label is not same as(false) -%} - {% set label = name|humanize %} - {%- endif -%} - {%- endif -%} - + {%- if label is empty -%} + {%- if label_format is not empty -%} + {% set label = label_format|replace({ + '%name%': name, + '%id%': id, + }) %} + {%- elseif label is not same as(false) -%} + {% set label = name|humanize %} + {%- endif -%} + {%- endif -%} + {%- endblock button_widget -%} {%- block submit_widget -%} - {%- set type = type|default('submit') -%} - {{ block('button_widget') }} + {%- set type = type|default('submit') -%} + {{ block('button_widget') }} {%- endblock submit_widget -%} {%- block reset_widget -%} - {%- set type = type|default('reset') -%} - {{ block('button_widget') }} + {%- set type = type|default('reset') -%} + {{ block('button_widget') }} {%- endblock reset_widget -%} {%- block tel_widget -%} - {%- set type = type|default('tel') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('tel') -%} + {{ block('form_widget_simple') }} {%- endblock tel_widget -%} {%- block color_widget -%} - {%- set type = type|default('color') -%} - {{ block('form_widget_simple') }} + {%- set type = type|default('color') -%} + {{ block('form_widget_simple') }} {%- endblock color_widget -%} {%- block week_widget -%} - {%- if widget == 'single_text' -%} - {{ block('form_widget_simple') }} - {%- else -%} - {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%} -
- {{ form_widget(form.year, vars) }}-{{ form_widget(form.week, vars) }} -
- {%- endif -%} + {%- if widget == 'single_text' -%} + {{ block('form_widget_simple') }} + {%- else -%} + {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%} +
+ {{ form_widget(form.year, vars) }}-{{ form_widget(form.week, vars) }} +
+ {%- endif -%} {%- endblock week_widget -%} {# Labels #} {%- block form_label -%} - {% if label is not same as(false) -%} - {% if not compound -%} - {% set label_attr = label_attr|merge({'for': id}) %} - {%- endif -%} - {% if required -%} - {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} - {%- endif -%} - {% if label is empty -%} - {%- if label_format is not empty -%} - {% set label = label_format|replace({ - '%name%': name, - '%id%': id, - }) %} - {%- else -%} - {% set label = name|humanize %} - {%- endif -%} - {%- endif -%} - <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}> - {%- if translation_domain is same as(false) -%} - {%- if label_html is defined and label_html is same as(false) -%} - {{- label -}} - {%- else -%} - {{- label|raw -}} - {%- endif -%} - {%- else -%} - {%- if label_html is defined and label_html is same as(false) -%} - {{- label|trans(label_translation_parameters|default({}), translation_domain) -}} - {%- else -%} - {{- label|trans(label_translation_parameters|default({}), translation_domain)|raw -}} - {%- endif -%} - {%- endif -%} - - {%- endif -%} + {% if label is not same as(false) -%} + {% if not compound -%} + {% set label_attr = label_attr|merge({'for': id}) %} + {%- endif -%} + {% if required -%} + {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} + {%- endif -%} + {% if label is empty -%} + {%- if label_format is not empty -%} + {% set label = label_format|replace({ + '%name%': name, + '%id%': id, + }) %} + {%- else -%} + {% set label = name|humanize %} + {%- endif -%} + {%- endif -%} + <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}> + {%- if translation_domain is same as(false) -%} + {%- if label_html is defined and label_html is same as(false) -%} + {{- label -}} + {%- else -%} + {{- label|raw -}} + {%- endif -%} + {%- else -%} + {%- if label_html is defined and label_html is same as(false) -%} + {{- label|trans(label_translation_parameters|default({}), translation_domain) -}} + {%- else -%} + {{- label|trans(label_translation_parameters|default({}), translation_domain)|raw -}} + {%- endif -%} + {%- endif -%} + + {%- endif -%} {%- endblock form_label -%} {%- block button_label -%}{%- endblock -%} @@ -323,154 +338,155 @@ {# Help #} {% block form_help -%} - {%- if help is not empty -%} - {%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' help-text')|trim}) -%} -

- {%- if translation_domain is same as(false) -%} - {%- if help_html is same as(false) -%} - {{- help -}} - {%- else -%} - {{- help|raw -}} - {%- endif -%} - {%- else -%} - {%- if help_html is same as(false) -%} - {{- help|trans(help_translation_parameters, translation_domain) -}} - {%- else -%} - {{- help|trans(help_translation_parameters, translation_domain)|raw -}} - {%- endif -%} - {%- endif -%} -

- {%- endif -%} + {%- if help is not empty -%} + {%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' help-text')|trim}) -%} +

+ {%- if translation_domain is same as(false) -%} + {%- if help_html is same as(false) -%} + {{- help -}} + {%- else -%} + {{- help|raw -}} + {%- endif -%} + {%- else -%} + {%- if help_html is same as(false) -%} + {{- help|trans(help_translation_parameters, translation_domain) -}} + {%- else -%} + {{- help|trans(help_translation_parameters, translation_domain)|raw -}} + {%- endif -%} + {%- endif -%} +

+ {%- endif -%} {%- endblock form_help %} {# Rows #} {%- block repeated_row -%} - {# - No need to render the errors here, as all errors are mapped - to the first child (see RepeatedTypeValidatorExtension). - #} - {{- block('form_rows') -}} + {# + No need to render the errors here, as all errors are mapped + to the first child (see RepeatedTypeValidatorExtension). + #} + {{- block('form_rows') -}} {%- endblock repeated_row -%} {%- block form_row -%} - {%- set widget_attr = {} -%} - {%- if help is not empty -%} - {%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} - {%- endif -%} - - {{- form_label(form) -}} - {{- form_errors(form) -}} - {{- form_widget(form, widget_attr) -}} - {{- form_help(form) -}} -
+ {%- set widget_attr = {} -%} + {%- if help is not empty -%} + {%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} + {%- endif -%} + + {{- form_label(form) -}} + {{- form_errors(form) -}} + {{- form_widget(form, widget_attr) -}} + {{- form_help(form) -}} + {%- endblock form_row -%} {%- block button_row -%} - - {{- form_widget(form) -}} - + + {{- form_widget(form) -}} + {%- endblock button_row -%} {%- block hidden_row -%} - {{ form_widget(form) }} + {{ form_widget(form) }} {%- endblock hidden_row -%} {# Misc #} {%- block form -%} - {{ form_start(form) }} - {{- form_widget(form) -}} - {{ form_end(form) }} + {{ form_start(form) }} + {{- form_widget(form) -}} + {{ form_end(form) }} {%- endblock form -%} {%- block form_start -%} {%- do form.setMethodRendered() -%} {% set method = method|upper %} {%- if method in ["GET", "POST"] -%} - {% set form_method = method %} - {%- else -%} - {% set form_method = "POST" %} - {%- endif -%} - - {%- if form_method != method -%} - - {%- endif -%} - {%- endblock form_start -%} - - {%- block form_end -%} - {%- if not render_rest is defined or render_rest -%} - {{ form_rest(form) }} - {%- endif -%} + {% set form_method = method %} + {%- else -%} + {% set form_method = "POST" %} + {%- endif -%} + + {%- if form_method != method -%} + + {%- endif -%} + {%- endblock form_start -%} + + {%- block form_end -%} + {%- if not render_rest is defined or render_rest -%} + {{ form_rest(form) }} + {%- endif -%} {%- endblock form_end -%} {%- block form_errors -%} - {%- if errors|length > 0 -%} -
    - {%- for error in errors -%} -
  • {{ error.message }}
  • - {%- endfor -%} -
- {%- endif -%} + {%- if errors|length > 0 -%} +
    + {%- for error in errors -%} +
  • {{ error.message }}
  • + {%- endfor -%} +
+ {%- endif -%} {%- endblock form_errors -%} {%- block form_rest -%} - {% for child in form -%} - {% if not child.rendered %} - {{- form_row(child) -}} - {% endif %} - {%- endfor -%} - - {% if not form.methodRendered and form is rootform %} - {%- do form.setMethodRendered() -%} - {% set method = method|upper %} - {%- if method in ["GET", "POST"] -%} - {% set form_method = method %} - {%- else -%} - {% set form_method = "POST" %} - {%- endif -%} - - {%- if form_method != method -%} - - {%- endif -%} - {% endif -%} + {% for child in form -%} + {% if not child.rendered %} + {{- form_row(child) -}} + {% endif %} + {%- endfor -%} + + {% if not form.methodRendered and form is rootform %} + {%- do form.setMethodRendered() -%} + {% set method = method|upper %} + {%- if method in ["GET", "POST"] -%} + {% set form_method = method %} + {%- else -%} + {% set form_method = "POST" %} + {%- endif -%} + + {%- if form_method != method -%} + + {%- endif -%} + {% endif -%} {% endblock form_rest %} {# Support #} {%- block form_rows -%} - {% for child in form|filter(child => not child.rendered) %} - {{- form_row(child) -}} - {% endfor %} + {% for child in form|filter(child => not child.rendered) %} + {{- form_row(child) -}} + {% endfor %} {%- endblock form_rows -%} {%- block widget_attributes -%} - id="{{ id }}" name="{{ full_name }}" - {%- if disabled %} disabled="disabled"{% endif -%} - {%- if required %} required="required"{% endif -%} - {{ block('attributes') }} + id="{{ id }}" name="{{ full_name }}" + {%- if disabled %} disabled="disabled"{% endif -%} + {%- if required %} required="required"{% endif -%} + {{ block('attributes') }} {%- endblock widget_attributes -%} {%- block widget_container_attributes -%} - {%- if id is not empty %}id="{{ id }}"{% endif -%} - {{ block('attributes') }} + {%- if id is not empty %}id="{{ id }}"{% endif -%} + {{ block('attributes') }} {%- endblock widget_container_attributes -%} {%- block button_attributes -%} - id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif -%} - {{ block('attributes') }} + id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif -%} + {{ block('attributes') }} {%- endblock button_attributes -%} {% block attributes -%} - {%- for attrname, attrvalue in attr -%} - {{- " " -}} - {%- if attrname in ['placeholder', 'title'] -%} - {{- attrname }}="{{ translation_domain is same as(false) or attrvalue is null ? attrvalue : attrvalue|trans(attr_translation_parameters, translation_domain) }}" - {%- elseif attrvalue is same as(true) -%} - {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not same as(false) -%} - {{- attrname }}="{{ attrvalue }}" - {%- endif -%} - {%- endfor -%} + {%- for attrname, attrvalue in attr -%} + {{- " " -}} + {%- if attrname in ['placeholder', 'title'] -%} + {{- attrname }}="{{ translation_domain is same as(false) or attrvalue is null ? attrvalue : attrvalue|trans(attr_translation_parameters, translation_domain) }}" + {%- elseif attrvalue is same as(true) -%} + {{- attrname }}="{{ attrname }}" + {%- elseif attrvalue is not same as(false) -%} + {{- attrname }}="{{ attrvalue }}" + {%- endif -%} + {%- endfor -%} {%- endblock attributes -%} diff --git a/src/Resources/views/welcome.html.twig b/src/Resources/views/welcome.html.twig index 68dd12c2e4..f8e0c9b6d8 100644 --- a/src/Resources/views/welcome.html.twig +++ b/src/Resources/views/welcome.html.twig @@ -1,15 +1,15 @@ - - - - - + + + + + - Welcome to EasyAdmin 4 + Welcome to EasyAdmin 4 - - - +
-

Welcome to EasyAdmin 4

- -

- You have successfully installed EasyAdmin 4 in your application. -

- - - -
-

Why am I seeing this page? Where's my backend menu?

-

- This page is the default EasyAdmin dashboard page. You are seeing this page - because you never customized the dashboard of your backend. -

-

- Edit the following file and use any of the ways to - customize your dashboard contents: -

- -
{{ dashboard_controller_filepath }}
-
+

Welcome to EasyAdmin 4

+ +

+ You have successfully installed EasyAdmin 4 in your application. +

+ + + +
+

Why am I seeing this page? Where's my backend menu?

+

+ This page is the default EasyAdmin dashboard page. You are seeing this page + because you never customized the dashboard of your backend. +

+

+ Edit the following file and use any of the ways to + customize + your dashboard contents: +

+ +
{{ dashboard_controller_filepath }}
+
diff --git a/src/Router/AdminUrlGenerator.php b/src/Router/AdminUrlGenerator.php index 0f1fc296c3..5bce7db37d 100644 --- a/src/Router/AdminUrlGenerator.php +++ b/src/Router/AdminUrlGenerator.php @@ -2,14 +2,11 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Router; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Option\EA; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; -use EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistry; use EasyCorp\Bundle\EasyAdminBundle\Registry\DashboardControllerRegistryInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -25,8 +22,11 @@ final class AdminUrlGenerator implements AdminUrlGeneratorInterface private ?string $currentPageReferrer = null; private ?string $customPageReferrer = null; - public function __construct(AdminContextProviderInterface $adminContextProvider, UrlGeneratorInterface $urlGenerator, DashboardControllerRegistryInterface $dashboardControllerRegistry) - { + public function __construct( + AdminContextProviderInterface $adminContextProvider, + UrlGeneratorInterface $urlGenerator, + DashboardControllerRegistryInterface $dashboardControllerRegistry + ) { $this->adminContextProvider = $adminContextProvider; $this->urlGenerator = $urlGenerator; $this->dashboardControllerRegistry = $dashboardControllerRegistry; @@ -226,8 +226,17 @@ public function generateUrl(): string // if the Dashboard FQCN is defined, find its route and use it to override // the current route (this is needed to allow generating links to different dashboards) if (null !== $dashboardControllerFqcn = $this->get(EA::DASHBOARD_CONTROLLER_FQCN)) { - if (null === $dashboardRoute = $this->dashboardControllerRegistry->getRouteByControllerFqcn($dashboardControllerFqcn)) { - throw new \InvalidArgumentException(sprintf('The given "%s" class is not a valid Dashboard controller. Make sure it extends from "%s" or implements "%s".', $dashboardControllerFqcn, AbstractDashboardController::class, DashboardControllerInterface::class)); + if (null === $dashboardRoute = $this->dashboardControllerRegistry->getRouteByControllerFqcn( + $dashboardControllerFqcn + )) { + throw new \InvalidArgumentException( + sprintf( + 'The given "%s" class is not a valid Dashboard controller. Make sure it extends from "%s" or implements "%s".', + $dashboardControllerFqcn, + AbstractDashboardController::class, + DashboardControllerInterface::class + ) + ); } $this->dashboardRoute = $dashboardRoute; @@ -238,7 +247,9 @@ public function generateUrl(): string // no Dashboard FQCN has been defined explicitly if (null === $this->dashboardRoute) { if ($this->dashboardControllerRegistry->getNumberOfDashboards() > 1) { - throw new \RuntimeException('When generating admin URLs from outside EasyAdmin or without a related HTTP request (e.g. in tests, console commands, etc.), if your application has more than one Dashboard, you must associate the URL to a specific Dashboard using the "setDashboard()" method.'); + throw new \RuntimeException( + 'When generating admin URLs from outside EasyAdmin or without a related HTTP request (e.g. in tests, console commands, etc.), if your application has more than one Dashboard, you must associate the URL to a specific Dashboard using the "setDashboard()" method.' + ); } $this->dashboardRoute = $this->dashboardControllerRegistry->getFirstDashboardRoute(); @@ -251,12 +262,13 @@ public function generateUrl(): string // this removes any parameter with a NULL value $routeParameters = array_filter( $this->routeParameters, - static fn ($parameterValue): bool => null !== $parameterValue + static fn($parameterValue): bool => null !== $parameterValue ); ksort($routeParameters, \SORT_STRING); $context = $this->adminContextProvider->getContext(); - $urlType = null !== $context && false === $context->getAbsoluteUrls() ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_URL; + $urlType = null !== $context && false === $context->getAbsoluteUrls( + ) ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_URL; $url = $this->urlGenerator->generate($this->dashboardRoute, $routeParameters, $urlType); $url = '' === $url ? '?' : $url; @@ -274,14 +286,24 @@ private function setRouteParameter(string $paramName, $paramValue): void } if (\is_resource($paramValue)) { - throw new \InvalidArgumentException(sprintf('The value of the "%s" parameter is a PHP resource, which is not supported as a route parameter.', $paramName)); + throw new \InvalidArgumentException( + sprintf( + 'The value of the "%s" parameter is a PHP resource, which is not supported as a route parameter.', + $paramName + ) + ); } if (\is_object($paramValue)) { if (method_exists($paramValue, '__toString')) { - $paramValue = (string) $paramValue; + $paramValue = (string)$paramValue; } else { - throw new \InvalidArgumentException(sprintf('The object passed as the value of the "%s" parameter must implement the "__toString()" method to allow using its value as a route parameter.', $paramName)); + throw new \InvalidArgumentException( + sprintf( + 'The object passed as the value of the "%s" parameter must implement the "__toString()" method to allow using its value as a route parameter.', + $paramName + ) + ); } } @@ -302,7 +324,12 @@ private function initialize(): void $this->dashboardRoute = $adminContext->getDashboardRouteName(); $currentRouteParameters = $routeParametersForReferrer = $adminContext->getRequest()->query->all(); unset($routeParametersForReferrer[EA::REFERRER]); - $this->currentPageReferrer = sprintf('%s%s?%s', $adminContext->getRequest()->getBaseUrl(), $adminContext->getRequest()->getPathInfo(), http_build_query($routeParametersForReferrer)); + $this->currentPageReferrer = sprintf( + '%s%s?%s', + $adminContext->getRequest()->getBaseUrl(), + $adminContext->getRequest()->getPathInfo(), + http_build_query($routeParametersForReferrer) + ); } $this->includeReferrer = null; diff --git a/src/Security/SecurityVoter.php b/src/Security/SecurityVoter.php index 32a5c81b90..c85b9967a3 100644 --- a/src/Security/SecurityVoter.php +++ b/src/Security/SecurityVoter.php @@ -2,17 +2,11 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Security; -use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\ActionDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\CrudDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\MenuItemDtoInterface; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; @@ -21,13 +15,16 @@ /* * @author Javier Eguiluz */ + final class SecurityVoter extends Voter { private AuthorizationCheckerInterface $authorizationChecker; - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; - public function __construct(AuthorizationCheckerInterface $authorizationChecker, AdminContextProviderInterface $adminContextProvider) - { + public function __construct( + AuthorizationCheckerInterface $authorizationChecker, + AdminContextProviderInterface $adminContextProvider + ) { $this->authorizationChecker = $authorizationChecker; $this->adminContextProvider = $adminContextProvider; } @@ -44,7 +41,11 @@ protected function voteOnAttribute($permissionName, $subject, TokenInterface $to } if (PermissionInterface::EA_EXECUTE_ACTION === $permissionName) { - return $this->voteOnExecuteActionPermission($this->adminContextProvider->getContext()->getCrud(), $subject['action'] ?? null, $subject['entity'] ?? null); + return $this->voteOnExecuteActionPermission( + $this->adminContextProvider->getContext()->getCrud(), + $subject['action'] ?? null, + $subject['entity'] ?? null + ); } if (PermissionInterface::EA_VIEW_FIELD === $permissionName) { @@ -68,8 +69,11 @@ private function voteOnViewMenuItemPermission(MenuItemDtoInterface $menuItemDto) return $this->authorizationChecker->isGranted($menuItemDto->getPermission(), $menuItemDto); } - private function voteOnExecuteActionPermission(CrudDtoInterface $crudDto, ActionDtoInterface|string $actionNameOrDto, ?EntityDtoInterface $entityDto): bool - { + private function voteOnExecuteActionPermission( + CrudDtoInterface $crudDto, + ActionDtoInterface|string $actionNameOrDto, + ?EntityDtoInterface $entityDto + ): bool { // users can run the Crud action if: // * they have the required permission to execute the action on the given entity instance // * the action is not disabled @@ -81,7 +85,11 @@ private function voteOnExecuteActionPermission(CrudDtoInterface $crudDto, Action $subject = null === $entityDto ? null : $entityDto->getInstance(); - return $this->authorizationChecker->isGranted($actionPermission, $subject) && !\in_array($actionName, $disabledActionNames, true); + return $this->authorizationChecker->isGranted($actionPermission, $subject) && !\in_array( + $actionName, + $disabledActionNames, + true + ); } private function voteOnViewPropertyPermission(FieldDtoInterface $field): bool diff --git a/src/Test/PhpUnitExtension.php b/src/Test/PhpUnitExtension.php index 1b2c644288..b435d3c1d9 100644 --- a/src/Test/PhpUnitExtension.php +++ b/src/Test/PhpUnitExtension.php @@ -29,7 +29,11 @@ private function restoreFinalClasses(): void $sourceFilePath = realpath($sourceFilePath); $sourceFileContents = file_get_contents($sourceFilePath); $sourceFileContentsWithFinalClasses = preg_replace( - sprintf('/^%s final %s class (.*)$/m', preg_quote(self::EA_TEST_COMMENT_MARKER_START, '/'), preg_quote(self::EA_TEST_COMMENT_MARKER_END, '/')), + sprintf( + '/^%s final %s class (.*)$/m', + preg_quote(self::EA_TEST_COMMENT_MARKER_START, '/'), + preg_quote(self::EA_TEST_COMMENT_MARKER_END, '/') + ), 'final class \1', $sourceFileContents ); diff --git a/src/Test/Trait/CrudTestIndexAsserts.php b/src/Test/Trait/CrudTestIndexAsserts.php index dff9c53f12..3ce9331b43 100644 --- a/src/Test/Trait/CrudTestIndexAsserts.php +++ b/src/Test/Trait/CrudTestIndexAsserts.php @@ -6,8 +6,10 @@ trait CrudTestIndexAsserts { use CrudTestSelectors; - protected static function assertIndexFullEntityCount(int $expectedIndexFullEntityCount, ?string $message = null): void - { + protected static function assertIndexFullEntityCount( + int $expectedIndexFullEntityCount, + ?string $message = null + ): void { if (0 > $expectedIndexFullEntityCount) { throw new \InvalidArgumentException(); } @@ -19,9 +21,16 @@ protected static function assertIndexFullEntityCount(int $expectedIndexFullEntit return; } - $message ??= sprintf('There should be a total of %d results found in the index table', $expectedIndexFullEntityCount); + $message ??= sprintf( + 'There should be a total of %d results found in the index table', + $expectedIndexFullEntityCount + ); static::assertSelectorNotExists('.no-results'); - static::assertSelectorTextSame('.list-pagination-counter strong', (string) $expectedIndexFullEntityCount, $message); + static::assertSelectorTextSame( + '.list-pagination-counter strong', + (string)$expectedIndexFullEntityCount, + $message + ); } protected function assertIndexPageEntityCount(int $expectedIndexPageEntityCount, ?string $message = null): void @@ -37,8 +46,11 @@ protected function assertIndexPageEntityCount(int $expectedIndexPageEntityCount, return; } - $message ??= sprintf('There should be %d results found in the current index page', $expectedIndexPageEntityCount); - static::assertSelectorNotExists('tr.no-results', ); + $message ??= sprintf( + 'There should be %d results found in the current index page', + $expectedIndexPageEntityCount + ); + static::assertSelectorNotExists('tr.no-results',); static::assertSelectorExists('tbody tr'); $indexPageEntityRows = $this->client->getCrawler()->filter('tbody tr'); @@ -58,45 +70,63 @@ protected function assertIndexPagesCount(int $expectedIndexPagesCount, ?string $ $pageItems = $this->client->getCrawler()->filter($pageItemsSelector); $lastNumberedPageItem = $pageItems->slice($pageItems->count() - 2, 1); - static::assertEquals((string) $expectedIndexPagesCount, $lastNumberedPageItem->filter('a')->text(), $message); + static::assertEquals((string)$expectedIndexPagesCount, $lastNumberedPageItem->filter('a')->text(), $message); } - protected function assertIndexEntityActionExists(string $action, string|int $entityId, ?string $message = null): void - { - $message ??= sprintf('The action %s has not been found for entity id %s', $action, (string) $entityId); + protected function assertIndexEntityActionExists( + string $action, + string|int $entityId, + ?string $message = null + ): void { + $message ??= sprintf('The action %s has not been found for entity id %s', $action, (string)$entityId); $entityRow = $this->client->getCrawler()->filter($this->getIndexEntityRowSelector($entityId)); - self::assertCount(1, $entityRow, sprintf('The entity %s is not existing in the table', (string) $entityId)); + self::assertCount(1, $entityRow, sprintf('The entity %s is not existing in the table', (string)$entityId)); $action = $entityRow->first()->filter($this->getActionSelector($action)); self::assertCount(1, $action, $message); } - protected function assertIndexEntityActionNotExists(string $action, string|int $entityId, ?string $message = null): void - { - $message ??= sprintf('The action %s has been found for entity id %s', $action, (string) $entityId); + protected function assertIndexEntityActionNotExists( + string $action, + string|int $entityId, + ?string $message = null + ): void { + $message ??= sprintf('The action %s has been found for entity id %s', $action, (string)$entityId); $entityRow = $this->client->getCrawler()->filter($this->getIndexEntityRowSelector($entityId)); - self::assertCount(1, $entityRow, sprintf('The entity %s is not existing in the table', (string) $entityId)); + self::assertCount(1, $entityRow, sprintf('The entity %s is not existing in the table', (string)$entityId)); $action = $entityRow->first()->filter($this->getActionSelector($action)); self::assertCount(0, $action, $message); } - protected function assertIndexEntityActionTextSame(string $action, string $actionDisplay, string|int $entityId, ?string $message = null): void - { + protected function assertIndexEntityActionTextSame( + string $action, + string $actionDisplay, + string|int $entityId, + ?string $message = null + ): void { $this->assertIndexEntityActionExists($action, $entityId); $message ??= sprintf('The action %s is not labelled with the following text : %s', $action, $actionDisplay); self::assertSelectorTextSame($this->getIndexEntityActionSelector($action, $entityId), $actionDisplay, $message); } - protected function assertIndexEntityActionNotTextSame(string $action, string $actionDisplay, string|int $entityId, ?string $message = null): void - { + protected function assertIndexEntityActionNotTextSame( + string $action, + string $actionDisplay, + string|int $entityId, + ?string $message = null + ): void { $this->assertIndexEntityActionExists($action, $entityId); $message ??= sprintf('The action %s is labelled with the following text : %s', $action, $actionDisplay); - self::assertSelectorTextNotContains($this->getIndexEntityActionSelector($action, $entityId), $actionDisplay, $message); + self::assertSelectorTextNotContains( + $this->getIndexEntityActionSelector($action, $entityId), + $actionDisplay, + $message + ); } protected function assertGlobalActionExists(string $action, ?string $message = null): void @@ -117,8 +147,11 @@ protected function assertGlobalActionDisplays(string $action, string $actionDisp self::assertSelectorTextSame($this->getGlobalActionSelector($action), $actionDisplay, $message); } - protected function assertGlobalActionNotDisplays(string $action, string $actionDisplay, ?string $message = null): void - { + protected function assertGlobalActionNotDisplays( + string $action, + string $actionDisplay, + ?string $message = null + ): void { $message ??= sprintf('The global action %s does display %s', $action, $actionDisplay); self::assertSelectorTextNotContains($this->getGlobalActionSelector($action), $actionDisplay, $message); } @@ -135,15 +168,25 @@ protected function assertIndexColumnNotExists(string $columnName, ?string $messa self::assertSelectorNotExists($this->getIndexHeaderColumnSelector($columnName), $message); } - protected function assertIndexColumnHeaderContains(string $columnName, string $columnHeaderValue, ?string $message = null): void - { + protected function assertIndexColumnHeaderContains( + string $columnName, + string $columnHeaderValue, + ?string $message = null + ): void { $message ??= sprintf('The column %s does not contain %s', $columnName, $columnHeaderValue); self::assertSelectorTextSame($this->getIndexHeaderColumnSelector($columnName), $columnHeaderValue, $message); } - protected function assertIndexColumnHeaderNotContains(string $columnName, string $columnHeaderValue, ?string $message = null): void - { + protected function assertIndexColumnHeaderNotContains( + string $columnName, + string $columnHeaderValue, + ?string $message = null + ): void { $message ??= sprintf('The column %s contains %s', $columnName, $columnHeaderValue); - self::assertSelectorTextNotContains($this->getIndexHeaderColumnSelector($columnName), $columnHeaderValue, $message); + self::assertSelectorTextNotContains( + $this->getIndexHeaderColumnSelector($columnName), + $columnHeaderValue, + $message + ); } } diff --git a/src/Test/Trait/CrudTestSelectors.php b/src/Test/Trait/CrudTestSelectors.php index 503343090f..16019660e5 100644 --- a/src/Test/Trait/CrudTestSelectors.php +++ b/src/Test/Trait/CrudTestSelectors.php @@ -11,7 +11,7 @@ protected function getIndexEntityActionSelector(string $action, string|int $enti protected function getIndexEntityRowSelector(string|int $entityId): string { - return sprintf('tbody tr[data-id=%s]', (string) $entityId); + return sprintf('tbody tr[data-id=%s]', (string)$entityId); } protected function getActionSelector(string $action): string diff --git a/src/Test/Trait/CrudTestUrlGeneration.php b/src/Test/Trait/CrudTestUrlGeneration.php index 57bf658ff7..8ea7ed3bf1 100644 --- a/src/Test/Trait/CrudTestUrlGeneration.php +++ b/src/Test/Trait/CrudTestUrlGeneration.php @@ -2,7 +2,6 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Test\Trait; -use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\ActionInterface; use EasyCorp\Bundle\EasyAdminBundle\Test\Exception\InvalidClassPropertyTypeException; use EasyCorp\Bundle\EasyAdminBundle\Test\Exception\MissingClassMethodException; @@ -15,16 +14,20 @@ trait CrudTestUrlGeneration * @throws InvalidClassPropertyTypeException * @throws MissingClassMethodException */ - protected function getCrudUrl(string $action, string|int|null $entityId = null, array $options = [], ?string $dashboardFqcn = null, ?string $controllerFqcn = null): string - { + protected function getCrudUrl( + string $action, + string|int|null $entityId = null, + array $options = [], + ?string $dashboardFqcn = null, + ?string $controllerFqcn = null + ): string { $dashboardFqcn ??= $this->getDashboardFqcn(); $controllerFqcn ??= $this->getControllerFqcn(); $this->adminUrlGenerator ->setDashboard($dashboardFqcn) ->setController($controllerFqcn) - ->setAction($action) - ; + ->setAction($action); if (null !== $entityId) { $this->adminUrlGenerator->setEntityId($entityId); @@ -37,8 +40,11 @@ protected function getCrudUrl(string $action, string|int|null $entityId = null, return $this->adminUrlGenerator->generateUrl(); } - protected function generateIndexUrl(?string $query = null, ?string $dashboardFqcn = null, ?string $controllerFqcn = null): string - { + protected function generateIndexUrl( + ?string $query = null, + ?string $dashboardFqcn = null, + ?string $controllerFqcn = null + ): string { $options = []; if (null !== $query) { @@ -53,14 +59,30 @@ protected function generateNewFormUrl(?string $dashboardFqcn = null, ?string $co return $this->getCrudUrl(ActionInterface::NEW, dashboardFqcn: $dashboardFqcn, controllerFqcn: $controllerFqcn); } - protected function generateEditFormUrl(string|int $id, ?string $dashboardFqcn = null, ?string $controllerFqcn = null): string - { - return $this->getCrudUrl(ActionInterface::EDIT, $id, dashboardFqcn: $dashboardFqcn, controllerFqcn: $controllerFqcn); + protected function generateEditFormUrl( + string|int $id, + ?string $dashboardFqcn = null, + ?string $controllerFqcn = null + ): string { + return $this->getCrudUrl( + ActionInterface::EDIT, + $id, + dashboardFqcn: $dashboardFqcn, + controllerFqcn: $controllerFqcn + ); } - protected function generateDetailUrl(string|int $id, ?string $dashboardFqcn = null, ?string $controllerFqcn = null): string - { - return $this->getCrudUrl(ActionInterface::DETAIL, $id, dashboardFqcn: $dashboardFqcn, controllerFqcn: $controllerFqcn); + protected function generateDetailUrl( + string|int $id, + ?string $dashboardFqcn = null, + ?string $controllerFqcn = null + ): string { + return $this->getCrudUrl( + ActionInterface::DETAIL, + $id, + dashboardFqcn: $dashboardFqcn, + controllerFqcn: $controllerFqcn + ); } protected function generateFilterRenderUrl(?string $dashboardFqcn = null, ?string $controllerFqcn = null): string @@ -68,6 +90,12 @@ protected function generateFilterRenderUrl(?string $dashboardFqcn = null, ?strin // Use the index URL as referrer but remove scheme, host and port $referrer = preg_replace('/^.*(\/.*)$/', '$1', $this->generateIndexUrl()); - return $this->getCrudUrl('renderFilters', null, ['referrer' => $referrer], dashboardFqcn: $dashboardFqcn, controllerFqcn: $controllerFqcn); + return $this->getCrudUrl( + 'renderFilters', + null, + ['referrer' => $referrer], + dashboardFqcn: $dashboardFqcn, + controllerFqcn: $controllerFqcn + ); } } diff --git a/src/Translation/TranslatableChoiceMessage.php b/src/Translation/TranslatableChoiceMessage.php index 51f289acb2..9a8d08e3df 100644 --- a/src/Translation/TranslatableChoiceMessage.php +++ b/src/Translation/TranslatableChoiceMessage.php @@ -39,6 +39,6 @@ public function __toString(): string return sprintf('%s', $this->cssClass, $this->message); } - return (string) $this->message; + return (string)$this->message; } } diff --git a/src/Translation/TranslatableChoiceMessageCollection.php b/src/Translation/TranslatableChoiceMessageCollection.php index a167c00f1e..e16eef059a 100644 --- a/src/Translation/TranslatableChoiceMessageCollection.php +++ b/src/Translation/TranslatableChoiceMessageCollection.php @@ -24,7 +24,7 @@ public function trans(TranslatorInterface $translator, ?string $locale = null): return implode( $this->isRenderedAsBadge ? '' : ', ', array_map( - static fn (TranslatableChoiceMessage $message) => $message->trans($translator, $locale), + static fn(TranslatableChoiceMessage $message) => $message->trans($translator, $locale), $this->choices ) ); diff --git a/src/Translation/TranslatableMessageBuilder.php b/src/Translation/TranslatableMessageBuilder.php index 2c1048d06e..1a44fb8913 100644 --- a/src/Translation/TranslatableMessageBuilder.php +++ b/src/Translation/TranslatableMessageBuilder.php @@ -2,10 +2,11 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Translation; -use function Symfony\Component\Translation\t; use Symfony\Component\Translation\TranslatableMessage; use Symfony\Contracts\Translation\TranslatableInterface; +use function Symfony\Component\Translation\t; + /** * @author Jakub Caban */ diff --git a/src/Twig/EasyAdminTwigExtension.php b/src/Twig/EasyAdminTwigExtension.php index a1bce6956f..d68a26f9a4 100644 --- a/src/Twig/EasyAdminTwigExtension.php +++ b/src/Twig/EasyAdminTwigExtension.php @@ -3,10 +3,8 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Twig; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; -use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldLayoutDto; use EasyCorp\Bundle\EasyAdminBundle\Dto\FieldLayoutDtoInterface; use EasyCorp\Bundle\EasyAdminBundle\Factory\FieldLayoutFactory; -use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProviderInterface; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGeneratorInterface; @@ -29,11 +27,14 @@ final class EasyAdminTwigExtension extends AbstractExtension implements GlobalsInterface { private ServiceLocator $serviceLocator; - private AdminContextProvider $adminContextProvider; + private AdminContextProviderInterface $adminContextProvider; private ?CsrfTokenManagerInterface $csrfTokenManager; - public function __construct(ServiceLocator $serviceLocator, AdminContextProviderInterface $adminContextProvider, ?CsrfTokenManagerInterface $csrfTokenManager) - { + public function __construct( + ServiceLocator $serviceLocator, + AdminContextProviderInterface $adminContextProvider, + ?CsrfTokenManagerInterface $csrfTokenManager + ) { $this->serviceLocator = $serviceLocator; $this->adminContextProvider = $adminContextProvider; $this->csrfTokenManager = $csrfTokenManager; @@ -44,7 +45,11 @@ public function getFunctions(): array return [ new TwigFunction('ea_url', [$this, 'getAdminUrlGenerator']), new TwigFunction('ea_csrf_token', [$this, 'renderCsrfToken']), - new TwigFunction('ea_call_function_if_exists', [$this, 'callFunctionIfExists'], ['needs_environment' => true, 'is_safe' => ['html' => true]]), + new TwigFunction( + 'ea_call_function_if_exists', + [$this, 'callFunctionIfExists'], + ['needs_environment' => true, 'is_safe' => ['html' => true]] + ), new TwigFunction('ea_create_field_layout', [$this, 'createFieldLayout']), ]; } @@ -91,9 +96,9 @@ public function flattenArray($array, $parentKey = null): array public function fileSize(int $bytes): string { $size = ['B', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; - $factor = (int) floor(log($bytes) / log(1024)); + $factor = (int)floor(log($bytes) / log(1024)); - return (int) ($bytes / (1024 ** $factor)).@$size[$factor]; + return (int)($bytes / (1024 ** $factor)).@$size[$factor]; } /** @@ -141,7 +146,7 @@ public function representAsString($value): string } if (is_numeric($value)) { - return (string) $value; + return (string)$value; } if (\is_bool($value)) { @@ -154,7 +159,7 @@ public function representAsString($value): string if (\is_object($value)) { if (method_exists($value, '__toString')) { - return (string) $value; + return (string)$value; } if (method_exists($value, 'getId')) { diff --git a/tests/TestApplication/src/Controller/ActionsCrudController.php b/tests/TestApplication/src/Controller/ActionsCrudController.php index 9a85aaf727..46cfb773f3 100644 --- a/tests/TestApplication/src/Controller/ActionsCrudController.php +++ b/tests/TestApplication/src/Controller/ActionsCrudController.php @@ -4,6 +4,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; +use EasyCorp\Bundle\EasyAdminBundle\Config\ActionsInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; @@ -26,7 +27,7 @@ public function configureFields(string $pageName): iterable ]; } - public function configureActions(Actions $actions): Actions + public function configureActions(ActionsInterface $actions): Actions { $action1 = Action::new('action1')->linkToCrudAction(''); $action2 = Action::new('action2')->linkToCrudAction('')->setCssClass('foo'); diff --git a/tests/TestApplication/src/Controller/CategoryCrudController.php b/tests/TestApplication/src/Controller/CategoryCrudController.php index 47ce0b2e93..8a1250af45 100644 --- a/tests/TestApplication/src/Controller/CategoryCrudController.php +++ b/tests/TestApplication/src/Controller/CategoryCrudController.php @@ -4,9 +4,11 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; +use EasyCorp\Bundle\EasyAdminBundle\Config\ActionsInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Assets; use EasyCorp\Bundle\EasyAdminBundle\Config\AssetsInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Config\FiltersInterface; use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; @@ -16,6 +18,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; +use EasyCorp\Bundle\EasyAdminBundle\Security\PermissionInterface; use EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Config\Action as AppAction; use EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Entity\Category; use Symfony\Component\HttpFoundation\Response; @@ -31,8 +34,7 @@ public function configureAssets(AssetsInterface $assets): AssetsInterface { return parent::configureAssets($assets) ->addHtmlContentToHead('') - ->addHtmlContentToBody('') - ; + ->addHtmlContentToBody(''); } public function configureFields(string $pageName): iterable @@ -45,13 +47,13 @@ public function configureFields(string $pageName): iterable ]; } - public function configureActions(Actions $actions): Actions + public function configureActions(ActionsInterface $actions): Actions { $customPageAction = Action::new(AppAction::CUSTOM_ACTION) ->createAsGlobalAction() ->linkToCrudAction('customPage'); - return $actions->add(Crud::PAGE_INDEX, $customPageAction) + return $actions->add(CrudInterface::PAGE_INDEX, $customPageAction) ->setPermission(AppAction::CUSTOM_ACTION, 'ROLE_ADMIN'); } @@ -64,7 +66,10 @@ public function configureFilters(FiltersInterface $filters): FiltersInterface public function customAction(AdminContext $context): Response { - if (!$this->isGranted(Permission::EA_EXECUTE_ACTION, ['action' => AppAction::CUSTOM_ACTION, 'entity' => $context->getEntity()])) { + if (!$this->isGranted( + PermissionInterface::EA_EXECUTE_ACTION, + ['action' => AppAction::CUSTOM_ACTION, 'entity' => $context->getEntity()] + )) { throw new ForbiddenActionException($context); } diff --git a/tests/TestApplication/src/Controller/Search/CustomCrudSearchController.php b/tests/TestApplication/src/Controller/Search/CustomCrudSearchController.php index cfe3d39eef..84689af6cf 100644 --- a/tests/TestApplication/src/Controller/Search/CustomCrudSearchController.php +++ b/tests/TestApplication/src/Controller/Search/CustomCrudSearchController.php @@ -3,6 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Controller\Search; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Entity\BlogPost; @@ -13,7 +14,7 @@ public static function getEntityFqcn(): string return BlogPost::class; } - public function configureCrud(Crud $crud): Crud + public function configureCrud(CrudInterface $crud): CrudInterface { return parent::configureCrud($crud) ->setSearchFields(['id', 'author.email', 'publisher.email']); diff --git a/tests/TestApplication/src/Controller/Sort/BillCrudController.php b/tests/TestApplication/src/Controller/Sort/BillCrudController.php index fc26b7a9f5..8f3af1dcd3 100644 --- a/tests/TestApplication/src/Controller/Sort/BillCrudController.php +++ b/tests/TestApplication/src/Controller/Sort/BillCrudController.php @@ -3,6 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Controller\Sort; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; @@ -23,7 +24,7 @@ public function configureFields(string $pageName): iterable ]; } - public function configureCrud(Crud $crud): Crud + public function configureCrud(CrudInterface $crud): CrudInterface { return parent::configureCrud($crud) ->setPaginatorPageSize(100); diff --git a/tests/TestApplication/src/Controller/Sort/CustomerCrudController.php b/tests/TestApplication/src/Controller/Sort/CustomerCrudController.php index 0fd4e95b5e..a6516c581b 100644 --- a/tests/TestApplication/src/Controller/Sort/CustomerCrudController.php +++ b/tests/TestApplication/src/Controller/Sort/CustomerCrudController.php @@ -3,6 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Controller\Sort; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; @@ -23,7 +24,7 @@ public function configureFields(string $pageName): iterable ]; } - public function configureCrud(Crud $crud): Crud + public function configureCrud(CrudInterface $crud): CrudInterface { return parent::configureCrud($crud) ->setPaginatorPageSize(100); diff --git a/tests/TestApplication/src/Controller/Sort/PageCrudController.php b/tests/TestApplication/src/Controller/Sort/PageCrudController.php index 22149ef099..3771193b83 100644 --- a/tests/TestApplication/src/Controller/Sort/PageCrudController.php +++ b/tests/TestApplication/src/Controller/Sort/PageCrudController.php @@ -3,6 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Controller\Sort; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; @@ -23,7 +24,7 @@ public function configureFields(string $pageName): iterable ]; } - public function configureCrud(Crud $crud): Crud + public function configureCrud(CrudInterface $crud): CrudInterface { return parent::configureCrud($crud) ->setPaginatorPageSize(100); diff --git a/tests/TestApplication/src/Controller/Sort/WebsiteCrudController.php b/tests/TestApplication/src/Controller/Sort/WebsiteCrudController.php index 80737bbfbe..61e66771e2 100644 --- a/tests/TestApplication/src/Controller/Sort/WebsiteCrudController.php +++ b/tests/TestApplication/src/Controller/Sort/WebsiteCrudController.php @@ -3,6 +3,7 @@ namespace EasyCorp\Bundle\EasyAdminBundle\Tests\TestApplication\Controller\Sort; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Config\CrudInterface; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; @@ -23,7 +24,7 @@ public function configureFields(string $pageName): iterable ]; } - public function configureCrud(Crud $crud): Crud + public function configureCrud(CrudInterface $crud): CrudInterface { return parent::configureCrud($crud) ->setPaginatorPageSize(100);