From 40b1e424e79ac935bd6e0a6e48d623de951ba31b Mon Sep 17 00:00:00 2001 From: Tom Udding Date: Tue, 3 Dec 2024 23:30:26 +0100 Subject: [PATCH] chore: move everything to factories Moves _everything_ to factories (except some things that require duplication in the `Education` and `User` module). --- README.md | 3 +- .../doctrine.local.development.php.dist | 2 +- config/autoload/local.development.php.dist | 5 +- config/autoload/local.production.php.dist | 5 +- .../Activity/src/Command/CalendarNotify.php | 10 +- .../Command/Factory/CalendarNotifyFactory.php | 24 ++ .../Factory/DeleteOldSignupsFactory.php | 5 +- .../ActivityCalendarControllerFactory.php | 12 +- .../Factory/ActivityControllerFactory.php | 15 +- .../AdminApprovalControllerFactory.php | 9 +- .../AdminCategoryControllerFactory.php | 6 +- .../Factory/AdminControllerFactory.php | 18 +- .../Factory/AdminOptionControllerFactory.php | 12 +- .../Factory/ApiControllerFactory.php | 6 +- .../src/Form/ActivityCalendarPeriod.php | 1 + .../Factory/ActivityCalendarOptionFactory.php | 28 ++ .../Factory/ActivityCalendarPeriodFactory.php | 24 ++ .../ActivityCalendarProposalFactory.php | 30 ++ .../Form/Factory/ActivityCategoryFactory.php | 24 ++ .../src/Form/Factory/ActivityFactory.php | 27 ++ .../src/Form/Factory/SignupFactory.php} | 12 +- .../src/Form/Factory/SignupListFactory.php | 27 ++ .../Form/Factory/SignupListFieldFactory.php | 27 ++ .../src/Form/{ => Fieldset}/MaxActivities.php | 2 +- module/Activity/src/Module.php | 279 +++------------- .../Factory/ActivityCalendarFactory.php | 45 +++ .../Factory/ActivityCalendarFormFactory.php | 34 ++ .../Factory/ActivityCategoryFactory.php | 32 ++ .../src/Service/Factory/ActivityFactory.php | 39 +++ .../Service/Factory/ActivityQueryFactory.php | 34 ++ .../src/Service/Factory/SignupFactory.php | 35 +++ .../Factory/SignupListQueryFactory.php | 30 ++ .../test/Mapper/ActivityMapperTest.php | 2 +- .../view/activity/activity/index.phtml | 5 +- .../view/activity/activity/view.phtml | 9 +- module/Application/config/module.config.php | 98 +++++- .../VideoIframe/Parsers/VimeoUrlParser.php | 2 +- .../VideoIframe/Parsers/YouTubeUrlParser.php | 2 +- .../src/Mapper/Factory/BaseMapperFactory.php | 27 ++ module/Application/src/Module.php | 147 +-------- .../src/Service/Factory/EmailFactory.php | 27 ++ .../Service/Factory/FileStorageFactory.php | 29 ++ .../src/Service/Factory/InfimumFactory.php | 28 ++ .../src/Service/Factory/WatermarkFactory.php | 33 ++ .../Application/src/Service/FileStorage.php | 2 +- .../{WatermarkService.php => Watermark.php} | 2 +- .../Application/test/BaseControllerTrait.php | 32 +- module/Application/view/partial/admin.phtml | 45 +-- module/Application/view/partial/footer.phtml | 3 +- .../Application/view/partial/main-nav.phtml | 35 ++- .../AdminApprovalControllerFactory.php | 12 +- .../Factory/AdminControllerFactory.php | 9 +- .../CompanyAccountControllerFactory.php | 15 +- .../Factory/CompanyControllerFactory.php | 6 +- .../src/Form/Factory/CompanyFactory.php | 28 ++ .../src/Form/Factory/JobCategoryFactory.php | 28 ++ .../Company/src/Form/Factory/JobFactory.php | 32 ++ .../src/Form/Factory/JobLabelFactory.php | 26 ++ .../src/Form/Factory/JobsTransferFactory.php | 24 ++ module/Company/src/Module.php | 232 +++----------- .../src/Service/Factory/CompanyFactory.php | 60 ++++ .../Service/Factory/CompanyQueryFactory.php | 34 ++ module/Decision/config/module.config.php | 3 +- .../Factory/AdminControllerFactory.php | 6 +- .../Factory/AdminMemberControllerFactory.php | 6 +- .../Factory/DecisionControllerFactory.php | 9 +- .../Factory/MemberControllerFactory.php | 12 +- .../Factory/OrganAdminControllerFactory.php | 3 +- .../Factory/OrganControllerFactory.php | 3 +- .../Factory/LocalFileReaderFactory.php | 28 ++ .../src/Form/Factory/AuthorizationFactory.php | 26 ++ .../AuthorizationRevocationFactory.php | 26 ++ .../src/Form/Factory/DocumentFactory.php | 26 ++ .../src/Form/Factory/MinutesFactory.php | 26 ++ .../Form/Factory/OrganInformationFactory.php | 29 ++ .../Form/Factory/ReorderDocumentFactory.php | 28 ++ .../Form/Factory/SearchDecisionFactory.php | 26 ++ module/Decision/src/Module.php | 271 +++------------- .../src/Service/Factory/DecisionFactory.php | 56 ++++ .../src/Service/Factory/GdprFactory.php | 62 ++++ .../src/Service/Factory/MemberFactory.php | 32 ++ .../src/Service/Factory/MemberInfoFactory.php | 35 +++ .../src/Service/Factory/OrganFactory.php | 40 +++ .../view/decision/decision/view.phtml | 3 +- .../Decision/view/decision/member/index.phtml | 7 +- .../Decision/view/decision/member/view.phtml | 7 +- .../view/decision/organ-admin/edit.phtml | 3 +- module/Education/config/module.config.php | 15 + .../Factory/AdminControllerFactory.php | 6 +- .../Factory/EducationControllerFactory.php | 6 +- .../src/Form/Factory/CourseFactory.php | 31 ++ .../src/Form/Factory/SearchCourseFactory.php | 26 ++ .../src/Form/Factory/TempUploadFactory.php | 26 ++ .../src/Form/Fieldset/Factory/ExamFactory.php | 35 +++ .../Form/Fieldset/Factory/SummaryFactory.php | 32 ++ module/Education/src/Module.php | 130 ++------ .../src/Service/Factory/CourseFactory.php | 41 +++ .../view/education/education/course.phtml | 3 +- .../Factory/FrontpageControllerFactory.php | 3 +- .../Factory/InfimumControllerFactory.php | 6 +- .../Factory/NewsAdminControllerFactory.php | 6 +- .../Factory/OrganControllerFactory.php | 6 +- .../Factory/PageAdminControllerFactory.php | 6 +- .../Factory/PageControllerFactory.php | 3 +- .../Factory/PollAdminControllerFactory.php | 6 +- .../Factory/PollControllerFactory.php | 9 +- .../src/Form/Factory/NewsItemFactory.php | 29 ++ .../src/Form/Factory/PageFactory.php | 31 ++ .../src/Form/Factory/PollApprovalFactory.php | 29 ++ .../src/Form/Factory/PollCommentFactory.php | 29 ++ .../src/Form/Factory/PollFactory.php | 29 ++ .../src/Form/{ => Fieldset}/PollOption.php | 2 +- module/Frontpage/src/Form/Poll.php | 2 +- module/Frontpage/src/Module.php | 188 +++-------- .../src/Service/Factory/FrontpageFactory.php | 44 +++ .../src/Service/Factory/NewsFactory.php | 32 ++ .../src/Service/Factory/PageFactory.php | 35 +++ .../src/Service/Factory/PollFactory.php | 40 +++ .../view/frontpage/frontpage/home.phtml | 6 +- .../view/frontpage/organ/committee-list.phtml | 3 +- .../view/frontpage/organ/organ.phtml | 5 +- .../view/frontpage/poll/history.phtml | 3 +- .../Frontpage/view/frontpage/poll/index.phtml | 9 +- .../Frontpage/view/partial/organ-card.phtml | 3 +- .../Frontpage/view/partial/poll-options.phtml | 2 +- .../Command/Factory/WeeklyPhotoFactory.php | 24 ++ module/Photo/src/Command/WeeklyPhoto.php | 10 +- .../Factory/AlbumAdminControllerFactory.php | 9 +- .../Factory/AlbumControllerFactory.php | 9 +- .../Factory/ApiControllerFactory.php | 12 +- .../Factory/PhotoAdminControllerFactory.php | 6 +- .../Factory/PhotoControllerFactory.php | 9 +- .../Factory/TagControllerFactory.php | 6 +- .../Photo/src/Form/Factory/AlbumFactory.php | 29 ++ .../src/Form/Factory/SearchAlbumFactory.php | 26 ++ module/Photo/src/Module.php | 172 ++-------- .../src/Service/Factory/AdminFactory.php | 36 +++ .../src/Service/Factory/AlbumCoverFactory.php | 30 ++ .../src/Service/Factory/AlbumFactory.php | 46 +++ .../src/Service/Factory/MetadataFactory.php | 23 ++ .../src/Service/Factory/PhotoFactory.php | 43 +++ module/Photo/view/partial/tags.phtml | 5 +- module/Photo/view/photo/album/index.phtml | 29 +- .../Adapter/Factory/ApiUserAdapterFactory.php | 26 ++ .../Factory/CompanyUserAdapterFactory.php | 33 ++ .../Adapter/Factory/UserAdapterFactory.php | 33 ++ .../Service/Factory/LoginAttemptFactory.php | 28 ++ .../Storage/Factory/UserSessionFactory.php | 27 ++ .../src/Authorization/AclServiceFactory.php | 17 +- .../Factory/DeleteOldLoginAttemptsFactory.php | 5 +- .../Factory/ApiAdminControllerFactory.php | 3 +- .../ApiAuthenticationControllerFactory.php | 9 +- .../Factory/UserAdminControllerFactory.php | 6 +- .../Factory/UserControllerFactory.php | 6 +- .../Factory/ApiAppAuthorisationFactory.php | 24 ++ .../User/src/Form/Factory/ApiTokenFactory.php | 29 ++ .../Form/Factory/CompanyUserLoginFactory.php | 27 ++ .../Form/Factory/CompanyUserResetFactory.php | 24 ++ .../User/src/Form/Factory/RegisterFactory.php | 24 ++ .../src/Form/Factory/UserLoginFactory.php | 27 ++ .../src/Form/Factory/UserResetFactory.php | 24 ++ module/User/src/Module.php | 297 +++++------------- .../src/Service/Factory/ApiAppFactory.php | 3 +- .../src/Service/Factory/ApiUserFactory.php | 32 ++ .../User/src/Service/Factory/EmailFactory.php | 27 ++ .../User/src/Service/Factory/UserFactory.php | 59 ++++ phpcs.xml.dist | 130 ++++++-- psalm/psalm-baseline.xml | 2 +- 168 files changed, 3366 insertions(+), 1666 deletions(-) create mode 100644 module/Activity/src/Command/Factory/CalendarNotifyFactory.php create mode 100644 module/Activity/src/Form/Factory/ActivityCalendarOptionFactory.php create mode 100644 module/Activity/src/Form/Factory/ActivityCalendarPeriodFactory.php create mode 100644 module/Activity/src/Form/Factory/ActivityCalendarProposalFactory.php create mode 100644 module/Activity/src/Form/Factory/ActivityCategoryFactory.php create mode 100644 module/Activity/src/Form/Factory/ActivityFactory.php rename module/{User/src/Mapper/Factory/ApiAppFactory.php => Activity/src/Form/Factory/SignupFactory.php} (58%) create mode 100644 module/Activity/src/Form/Factory/SignupListFactory.php create mode 100644 module/Activity/src/Form/Factory/SignupListFieldFactory.php rename module/Activity/src/Form/{ => Fieldset}/MaxActivities.php (95%) create mode 100644 module/Activity/src/Service/Factory/ActivityCalendarFactory.php create mode 100644 module/Activity/src/Service/Factory/ActivityCalendarFormFactory.php create mode 100644 module/Activity/src/Service/Factory/ActivityCategoryFactory.php create mode 100644 module/Activity/src/Service/Factory/ActivityFactory.php create mode 100644 module/Activity/src/Service/Factory/ActivityQueryFactory.php create mode 100644 module/Activity/src/Service/Factory/SignupFactory.php create mode 100644 module/Activity/src/Service/Factory/SignupListQueryFactory.php create mode 100644 module/Application/src/Mapper/Factory/BaseMapperFactory.php create mode 100644 module/Application/src/Service/Factory/EmailFactory.php create mode 100644 module/Application/src/Service/Factory/FileStorageFactory.php create mode 100644 module/Application/src/Service/Factory/InfimumFactory.php create mode 100644 module/Application/src/Service/Factory/WatermarkFactory.php rename module/Application/src/Service/{WatermarkService.php => Watermark.php} (99%) create mode 100644 module/Company/src/Form/Factory/CompanyFactory.php create mode 100644 module/Company/src/Form/Factory/JobCategoryFactory.php create mode 100644 module/Company/src/Form/Factory/JobFactory.php create mode 100644 module/Company/src/Form/Factory/JobLabelFactory.php create mode 100644 module/Company/src/Form/Factory/JobsTransferFactory.php create mode 100644 module/Company/src/Service/Factory/CompanyFactory.php create mode 100644 module/Company/src/Service/Factory/CompanyQueryFactory.php create mode 100644 module/Decision/src/Controller/FileBrowser/Factory/LocalFileReaderFactory.php create mode 100644 module/Decision/src/Form/Factory/AuthorizationFactory.php create mode 100644 module/Decision/src/Form/Factory/AuthorizationRevocationFactory.php create mode 100644 module/Decision/src/Form/Factory/DocumentFactory.php create mode 100644 module/Decision/src/Form/Factory/MinutesFactory.php create mode 100644 module/Decision/src/Form/Factory/OrganInformationFactory.php create mode 100644 module/Decision/src/Form/Factory/ReorderDocumentFactory.php create mode 100644 module/Decision/src/Form/Factory/SearchDecisionFactory.php create mode 100644 module/Decision/src/Service/Factory/DecisionFactory.php create mode 100644 module/Decision/src/Service/Factory/GdprFactory.php create mode 100644 module/Decision/src/Service/Factory/MemberFactory.php create mode 100644 module/Decision/src/Service/Factory/MemberInfoFactory.php create mode 100644 module/Decision/src/Service/Factory/OrganFactory.php create mode 100644 module/Education/src/Form/Factory/CourseFactory.php create mode 100644 module/Education/src/Form/Factory/SearchCourseFactory.php create mode 100644 module/Education/src/Form/Factory/TempUploadFactory.php create mode 100644 module/Education/src/Form/Fieldset/Factory/ExamFactory.php create mode 100644 module/Education/src/Form/Fieldset/Factory/SummaryFactory.php create mode 100644 module/Education/src/Service/Factory/CourseFactory.php create mode 100644 module/Frontpage/src/Form/Factory/NewsItemFactory.php create mode 100644 module/Frontpage/src/Form/Factory/PageFactory.php create mode 100644 module/Frontpage/src/Form/Factory/PollApprovalFactory.php create mode 100644 module/Frontpage/src/Form/Factory/PollCommentFactory.php create mode 100644 module/Frontpage/src/Form/Factory/PollFactory.php rename module/Frontpage/src/Form/{ => Fieldset}/PollOption.php (98%) create mode 100644 module/Frontpage/src/Service/Factory/FrontpageFactory.php create mode 100644 module/Frontpage/src/Service/Factory/NewsFactory.php create mode 100644 module/Frontpage/src/Service/Factory/PageFactory.php create mode 100644 module/Frontpage/src/Service/Factory/PollFactory.php create mode 100644 module/Photo/src/Command/Factory/WeeklyPhotoFactory.php create mode 100644 module/Photo/src/Form/Factory/AlbumFactory.php create mode 100644 module/Photo/src/Form/Factory/SearchAlbumFactory.php create mode 100644 module/Photo/src/Service/Factory/AdminFactory.php create mode 100644 module/Photo/src/Service/Factory/AlbumCoverFactory.php create mode 100644 module/Photo/src/Service/Factory/AlbumFactory.php create mode 100644 module/Photo/src/Service/Factory/MetadataFactory.php create mode 100644 module/Photo/src/Service/Factory/PhotoFactory.php create mode 100644 module/User/src/Authentication/Adapter/Factory/ApiUserAdapterFactory.php create mode 100644 module/User/src/Authentication/Adapter/Factory/CompanyUserAdapterFactory.php create mode 100644 module/User/src/Authentication/Adapter/Factory/UserAdapterFactory.php create mode 100644 module/User/src/Authentication/Service/Factory/LoginAttemptFactory.php create mode 100644 module/User/src/Authentication/Storage/Factory/UserSessionFactory.php create mode 100644 module/User/src/Form/Factory/ApiAppAuthorisationFactory.php create mode 100644 module/User/src/Form/Factory/ApiTokenFactory.php create mode 100644 module/User/src/Form/Factory/CompanyUserLoginFactory.php create mode 100644 module/User/src/Form/Factory/CompanyUserResetFactory.php create mode 100644 module/User/src/Form/Factory/RegisterFactory.php create mode 100644 module/User/src/Form/Factory/UserLoginFactory.php create mode 100644 module/User/src/Form/Factory/UserResetFactory.php create mode 100644 module/User/src/Service/Factory/ApiUserFactory.php create mode 100644 module/User/src/Service/Factory/EmailFactory.php create mode 100644 module/User/src/Service/Factory/UserFactory.php diff --git a/README.md b/README.md index 467ea8aa97..be9261d555 100644 --- a/README.md +++ b/README.md @@ -109,8 +109,9 @@ To make development easier (and due to how the Laminas MVC framework works) we a │ │ └── ... │ ├── Model # Doctrine ORM entities. │ │ └── ... -│ └── Service # Services contain the core logic related to specific entities (or sets of entities) and do most of the processing. +│ ├── Service # Services contain the core logic related to specific entities (or sets of entities) and do most of the processing. │ │ └── ... +│ └── Module.php # Entrypoint of the module, allows for bootstrapping and includes factory definitions. ├── test # Test files for this module, such as unit tests. │ ├── Seeder # Data fixtures to seed the database with data for this module. │ │ └── ... diff --git a/config/autoload/doctrine.local.development.php.dist b/config/autoload/doctrine.local.development.php.dist index dc6f9addf0..34c1a4294b 100644 --- a/config/autoload/doctrine.local.development.php.dist +++ b/config/autoload/doctrine.local.development.php.dist @@ -36,7 +36,7 @@ return [ 'dbname' => getenv('DOCKER_DB_DATABASE'), 'charset' => 'utf8mb4', 'collate' => 'utf8mb4_unicode_ci', - 'driverOptions' => filter_var(getenv('DOCKER_DB_SSL') ?? false, FILTER_VALIDATE_BOOLEAN) ? [ + 'driverOptions' => filter_var(getenv('DOCKER_DB_SSL', false), FILTER_VALIDATE_BOOLEAN) ? [ PDO::MYSQL_ATTR_SSL_CAPATH => '/etc/ssl/certs/', PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => true, ] : [], diff --git a/config/autoload/local.development.php.dist b/config/autoload/local.development.php.dist index c2f32346b2..0dcb1c2f6b 100644 --- a/config/autoload/local.development.php.dist +++ b/config/autoload/local.development.php.dist @@ -94,7 +94,10 @@ return [ /* * Path to folder in local filesystem available for browsing */ - 'filebrowser_folder' => getcwd() . '/', + 'filebrowser' => [ + 'folder' => getcwd() . '/', + 'valid_file' => '[^?*:;{}\\\]*', + ], 'glide' => [ 'base_url' => getenv('GLIDE_HOST'), diff --git a/config/autoload/local.production.php.dist b/config/autoload/local.production.php.dist index 6b69526793..4e62c670a3 100644 --- a/config/autoload/local.production.php.dist +++ b/config/autoload/local.production.php.dist @@ -94,7 +94,10 @@ return [ /* * Path to folder in local filesystem available for browsing */ - 'filebrowser_folder' => getcwd() . '/public/publicarchive/', + 'filebrowser' => [ + 'folder' => getcwd() . '/public/publicarchive/', + 'valid_file' => '[^?*:;{}\\\]*', + ], 'glide' => [ 'base_url' => getenv('GLIDE_HOST'), diff --git a/module/Activity/src/Command/CalendarNotify.php b/module/Activity/src/Command/CalendarNotify.php index 71d216612f..4dd6ef54a3 100644 --- a/module/Activity/src/Command/CalendarNotify.php +++ b/module/Activity/src/Command/CalendarNotify.php @@ -11,7 +11,10 @@ class CalendarNotify extends Command { - private ActivityCalendar $calendarService; + public function __construct(private readonly ActivityCalendar $calendarService) + { + parent::__construct(); + } public function execute( InputInterface $input, @@ -21,9 +24,4 @@ public function execute( return 1; } - - public function setCalendarService(ActivityCalendar $calendarService): void - { - $this->calendarService = $calendarService; - } } diff --git a/module/Activity/src/Command/Factory/CalendarNotifyFactory.php b/module/Activity/src/Command/Factory/CalendarNotifyFactory.php new file mode 100644 index 0000000000..c96bc09081 --- /dev/null +++ b/module/Activity/src/Command/Factory/CalendarNotifyFactory.php @@ -0,0 +1,24 @@ +get(ActivityCalendarService::class)); + } +} diff --git a/module/Activity/src/Command/Factory/DeleteOldSignupsFactory.php b/module/Activity/src/Command/Factory/DeleteOldSignupsFactory.php index 474f3a22d2..2f2d5b2a64 100644 --- a/module/Activity/src/Command/Factory/DeleteOldSignupsFactory.php +++ b/module/Activity/src/Command/Factory/DeleteOldSignupsFactory.php @@ -19,9 +19,6 @@ public function __invoke( $requestedName, ?array $options = null, ): DeleteOldSignups { - /** @var SignupService $signupService */ - $signupService = $container->get('activity_service_signup'); - - return new DeleteOldSignups($signupService); + return new DeleteOldSignups($container->get(SignupService::class)); } } diff --git a/module/Activity/src/Controller/Factory/ActivityCalendarControllerFactory.php b/module/Activity/src/Controller/Factory/ActivityCalendarControllerFactory.php index e21c8899b3..0990915a6b 100644 --- a/module/Activity/src/Controller/Factory/ActivityCalendarControllerFactory.php +++ b/module/Activity/src/Controller/Factory/ActivityCalendarControllerFactory.php @@ -5,6 +5,10 @@ namespace Activity\Controller\Factory; use Activity\Controller\ActivityCalendarController; +use Activity\Form\ActivityCalendarProposal as ActivityCalendarProposalForm; +use Activity\Service\AclService; +use Activity\Service\ActivityCalendar as ActivityCalendarService; +use Activity\Service\ActivityCalendarForm as ActivityCalendarFormService; use Laminas\Mvc\I18n\Translator as MvcTranslator; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; @@ -20,11 +24,11 @@ public function __invoke( ?array $options = null, ): ActivityCalendarController { return new ActivityCalendarController( - $container->get('activity_service_acl'), + $container->get(AclService::class), $container->get(MvcTranslator::class), - $container->get('activity_service_calendar'), - $container->get('activity_service_calendar_form'), - $container->get('activity_form_calendar_proposal'), + $container->get(ActivityCalendarService::class), + $container->get(ActivityCalendarFormService::class), + $container->get(ActivityCalendarProposalForm::class), $container->get('config')['calendar'], ); } diff --git a/module/Activity/src/Controller/Factory/ActivityControllerFactory.php b/module/Activity/src/Controller/Factory/ActivityControllerFactory.php index 4038a90d77..b1fd47ce65 100644 --- a/module/Activity/src/Controller/Factory/ActivityControllerFactory.php +++ b/module/Activity/src/Controller/Factory/ActivityControllerFactory.php @@ -5,6 +5,11 @@ namespace Activity\Controller\Factory; use Activity\Controller\ActivityController; +use Activity\Mapper\Signup as SignupMapper; +use Activity\Service\AclService; +use Activity\Service\ActivityQuery as ActivityQueryService; +use Activity\Service\Signup as SignupService; +use Activity\Service\SignupListQuery as SignupListQueryService; use Laminas\Mvc\I18n\Translator as MvcTranslator; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; @@ -20,12 +25,12 @@ public function __invoke( ?array $options = null, ): ActivityController { return new ActivityController( - $container->get('activity_service_acl'), + $container->get(AclService::class), $container->get(MvcTranslator::class), - $container->get('activity_mapper_signup'), - $container->get('activity_service_activityQuery'), - $container->get('activity_service_signup'), - $container->get('activity_service_signupListQuery'), + $container->get(SignupMapper::class), + $container->get(ActivityQueryService::class), + $container->get(SignupService::class), + $container->get(SignupListQueryService::class), ); } } diff --git a/module/Activity/src/Controller/Factory/AdminApprovalControllerFactory.php b/module/Activity/src/Controller/Factory/AdminApprovalControllerFactory.php index c0f2b15aab..8c1e0dfa0d 100644 --- a/module/Activity/src/Controller/Factory/AdminApprovalControllerFactory.php +++ b/module/Activity/src/Controller/Factory/AdminApprovalControllerFactory.php @@ -5,6 +5,9 @@ namespace Activity\Controller\Factory; use Activity\Controller\AdminApprovalController; +use Activity\Service\AclService; +use Activity\Service\Activity as ActivityService; +use Activity\Service\ActivityQuery as ActivityQueryService; use Laminas\Mvc\I18n\Translator as MvcTranslator; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; @@ -20,10 +23,10 @@ public function __invoke( ?array $options = null, ): AdminApprovalController { return new AdminApprovalController( - $container->get('activity_service_acl'), + $container->get(AclService::class), $container->get(MvcTranslator::class), - $container->get('activity_service_activity'), - $container->get('activity_service_activityQuery'), + $container->get(ActivityService::class), + $container->get(ActivityQueryService::class), ); } } diff --git a/module/Activity/src/Controller/Factory/AdminCategoryControllerFactory.php b/module/Activity/src/Controller/Factory/AdminCategoryControllerFactory.php index 1f47560706..ec09023937 100644 --- a/module/Activity/src/Controller/Factory/AdminCategoryControllerFactory.php +++ b/module/Activity/src/Controller/Factory/AdminCategoryControllerFactory.php @@ -5,6 +5,8 @@ namespace Activity\Controller\Factory; use Activity\Controller\AdminCategoryController; +use Activity\Service\AclService; +use Activity\Service\ActivityCategory as ActivityCategoryService; use Laminas\Mvc\I18n\Translator as MvcTranslator; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; @@ -20,9 +22,9 @@ public function __invoke( ?array $options = null, ): AdminCategoryController { return new AdminCategoryController( - $container->get('activity_service_acl'), + $container->get(AclService::class), $container->get(MvcTranslator::class), - $container->get('activity_service_category'), + $container->get(ActivityCategoryService::class), ); } } diff --git a/module/Activity/src/Controller/Factory/AdminControllerFactory.php b/module/Activity/src/Controller/Factory/AdminControllerFactory.php index c41e11279b..eb9252084e 100644 --- a/module/Activity/src/Controller/Factory/AdminControllerFactory.php +++ b/module/Activity/src/Controller/Factory/AdminControllerFactory.php @@ -5,6 +5,12 @@ namespace Activity\Controller\Factory; use Activity\Controller\AdminController; +use Activity\Mapper\Signup as SignupMapper; +use Activity\Service\AclService; +use Activity\Service\Activity as ActivityService; +use Activity\Service\ActivityQuery as ActivityQueryService; +use Activity\Service\Signup as SignupService; +use Activity\Service\SignupListQuery as SignupListQueryService; use Laminas\Mvc\I18n\Translator as MvcTranslator; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; @@ -20,13 +26,13 @@ public function __invoke( ?array $options = null, ): AdminController { return new AdminController( - $container->get('activity_service_acl'), + $container->get(AclService::class), $container->get(MvcTranslator::class), - $container->get('activity_service_activity'), - $container->get('activity_service_activityQuery'), - $container->get('activity_service_signup'), - $container->get('activity_service_signupListQuery'), - $container->get('activity_mapper_signup'), + $container->get(ActivityService::class), + $container->get(ActivityQueryService::class), + $container->get(SignupService::class), + $container->get(SignupListQueryService::class), + $container->get(SignupMapper::class), ); } } diff --git a/module/Activity/src/Controller/Factory/AdminOptionControllerFactory.php b/module/Activity/src/Controller/Factory/AdminOptionControllerFactory.php index acf582d620..b42b0b80b9 100644 --- a/module/Activity/src/Controller/Factory/AdminOptionControllerFactory.php +++ b/module/Activity/src/Controller/Factory/AdminOptionControllerFactory.php @@ -5,6 +5,10 @@ namespace Activity\Controller\Factory; use Activity\Controller\AdminOptionController; +use Activity\Mapper\ActivityOptionCreationPeriod as ActivityOptionCreationPeriodMapper; +use Activity\Service\AclService; +use Activity\Service\ActivityCalendar as ActivityCalendarService; +use Decision\Service\Organ as OrganService; use Laminas\Mvc\I18n\Translator as MvcTranslator; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; @@ -20,11 +24,11 @@ public function __invoke( ?array $options = null, ): AdminOptionController { return new AdminOptionController( - $container->get('activity_service_acl'), + $container->get(AclService::class), $container->get(MvcTranslator::class), - $container->get('activity_service_calendar'), - $container->get('decision_service_organ'), - $container->get('activity_mapper_period'), + $container->get(ActivityCalendarService::class), + $container->get(OrganService::class), + $container->get(ActivityOptionCreationPeriodMapper::class), ); } } diff --git a/module/Activity/src/Controller/Factory/ApiControllerFactory.php b/module/Activity/src/Controller/Factory/ApiControllerFactory.php index e29486f84e..7594227350 100644 --- a/module/Activity/src/Controller/Factory/ApiControllerFactory.php +++ b/module/Activity/src/Controller/Factory/ApiControllerFactory.php @@ -5,6 +5,8 @@ namespace Activity\Controller\Factory; use Activity\Controller\ApiController; +use Activity\Service\AclService; +use Activity\Service\ActivityQuery; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; @@ -19,8 +21,8 @@ public function __invoke( ?array $options = null, ): ApiController { return new ApiController( - $container->get('activity_service_acl'), - $container->get('activity_service_activityQuery'), + $container->get(AclService::class), + $container->get(ActivityQuery::class), ); } } diff --git a/module/Activity/src/Form/ActivityCalendarPeriod.php b/module/Activity/src/Form/ActivityCalendarPeriod.php index 7a2a39fc10..647b81656c 100644 --- a/module/Activity/src/Form/ActivityCalendarPeriod.php +++ b/module/Activity/src/Form/ActivityCalendarPeriod.php @@ -4,6 +4,7 @@ namespace Activity\Form; +use Activity\Form\Fieldset\MaxActivities; use DateTime; use Laminas\Form\Element\Collection; use Laminas\Form\Element\DateTimeLocal; diff --git a/module/Activity/src/Form/Factory/ActivityCalendarOptionFactory.php b/module/Activity/src/Form/Factory/ActivityCalendarOptionFactory.php new file mode 100644 index 0000000000..886cc72ee2 --- /dev/null +++ b/module/Activity/src/Form/Factory/ActivityCalendarOptionFactory.php @@ -0,0 +1,28 @@ +get(MvcTranslator::class), + $container->get(ActivityCalendarFormService::class), + ); + } +} diff --git a/module/Activity/src/Form/Factory/ActivityCalendarPeriodFactory.php b/module/Activity/src/Form/Factory/ActivityCalendarPeriodFactory.php new file mode 100644 index 0000000000..22055740a9 --- /dev/null +++ b/module/Activity/src/Form/Factory/ActivityCalendarPeriodFactory.php @@ -0,0 +1,24 @@ +get(MvcTranslator::class)); + } +} diff --git a/module/Activity/src/Form/Factory/ActivityCalendarProposalFactory.php b/module/Activity/src/Form/Factory/ActivityCalendarProposalFactory.php new file mode 100644 index 0000000000..d18b4e003f --- /dev/null +++ b/module/Activity/src/Form/Factory/ActivityCalendarProposalFactory.php @@ -0,0 +1,30 @@ +get(MvcTranslator::class), + $container->get(ActivityCalendarFormService::class), + $container->get(AclService::class)->isAllowed('create_always', 'activity'), + ); + } +} diff --git a/module/Activity/src/Form/Factory/ActivityCategoryFactory.php b/module/Activity/src/Form/Factory/ActivityCategoryFactory.php new file mode 100644 index 0000000000..2758b7fb9f --- /dev/null +++ b/module/Activity/src/Form/Factory/ActivityCategoryFactory.php @@ -0,0 +1,24 @@ +get(MvcTranslator::class)); + } +} diff --git a/module/Activity/src/Form/Factory/ActivityFactory.php b/module/Activity/src/Form/Factory/ActivityFactory.php new file mode 100644 index 0000000000..2615985ab9 --- /dev/null +++ b/module/Activity/src/Form/Factory/ActivityFactory.php @@ -0,0 +1,27 @@ +get(MvcTranslator::class)); + $form->setHydrator($container->get('activity_hydrator')); + + return $form; + } +} diff --git a/module/User/src/Mapper/Factory/ApiAppFactory.php b/module/Activity/src/Form/Factory/SignupFactory.php similarity index 58% rename from module/User/src/Mapper/Factory/ApiAppFactory.php rename to module/Activity/src/Form/Factory/SignupFactory.php index f6402e3271..6b0dec163c 100644 --- a/module/User/src/Mapper/Factory/ApiAppFactory.php +++ b/module/Activity/src/Form/Factory/SignupFactory.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace User\Mapper\Factory; +namespace Activity\Form\Factory; +use Activity\Form\Signup as SignupForm; use Laminas\ServiceManager\Factory\FactoryInterface; use Psr\Container\ContainerInterface; -use User\Mapper\ApiApp; -class ApiAppFactory implements FactoryInterface +class SignupFactory implements FactoryInterface { /** * @param string $requestedName @@ -17,9 +17,7 @@ public function __invoke( ContainerInterface $container, $requestedName, ?array $options = null, - ): ApiApp { - return new ApiApp( - $container->get('doctrine.entitymanager.orm_default'), - ); + ): SignupForm { + return new SignupForm(); } } diff --git a/module/Activity/src/Form/Factory/SignupListFactory.php b/module/Activity/src/Form/Factory/SignupListFactory.php new file mode 100644 index 0000000000..1eca9d5141 --- /dev/null +++ b/module/Activity/src/Form/Factory/SignupListFactory.php @@ -0,0 +1,27 @@ +get(MvcTranslator::class)); + $form->setHydrator($container->get('activity_hydrator')); + + return $form; + } +} diff --git a/module/Activity/src/Form/Factory/SignupListFieldFactory.php b/module/Activity/src/Form/Factory/SignupListFieldFactory.php new file mode 100644 index 0000000000..f9f40fcd2d --- /dev/null +++ b/module/Activity/src/Form/Factory/SignupListFieldFactory.php @@ -0,0 +1,27 @@ +get(MvcTranslator::class)); + $form->setHydrator($container->get('activity_hydrator')); + + return $form; + } +} diff --git a/module/Activity/src/Form/MaxActivities.php b/module/Activity/src/Form/Fieldset/MaxActivities.php similarity index 95% rename from module/Activity/src/Form/MaxActivities.php rename to module/Activity/src/Form/Fieldset/MaxActivities.php index 19edaeab70..290f47d2f2 100644 --- a/module/Activity/src/Form/MaxActivities.php +++ b/module/Activity/src/Form/Fieldset/MaxActivities.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Activity\Form; +namespace Activity\Form\Fieldset; use Laminas\Form\Element\Hidden; use Laminas\Form\Element\Number; diff --git a/module/Activity/src/Module.php b/module/Activity/src/Module.php index cf99b80e59..9d2e5104d0 100644 --- a/module/Activity/src/Module.php +++ b/module/Activity/src/Module.php @@ -6,12 +6,21 @@ use Activity\Command\CalendarNotify as CalendarNotifyCommand; use Activity\Command\DeleteOldSignups as DeleteOldSignupsCommand; +use Activity\Command\Factory\CalendarNotifyFactory as CalendarNotifyCommandFactory; use Activity\Command\Factory\DeleteOldSignupsFactory as DeleteOldSignupsCommandFactory; use Activity\Form\Activity as ActivityForm; use Activity\Form\ActivityCalendarOption as ActivityCalendarOptionForm; use Activity\Form\ActivityCalendarPeriod as ActivityCalendarPeriodForm; use Activity\Form\ActivityCalendarProposal as ActivityCalendarProposalForm; use Activity\Form\ActivityCategory as CategoryForm; +use Activity\Form\Factory\ActivityCalendarOptionFactory as ActivityCalendarOptionFormFactory; +use Activity\Form\Factory\ActivityCalendarPeriodFactory as ActivityCalendarPeriodFormFactory; +use Activity\Form\Factory\ActivityCalendarProposalFactory as ActivityCalendarProposalFormFactory; +use Activity\Form\Factory\ActivityCategoryFactory as ActivityCategoryFormFactory; +use Activity\Form\Factory\ActivityFactory as ActivityFormFactory; +use Activity\Form\Factory\SignupFactory as SignupFormFactory; +use Activity\Form\Factory\SignupListFactory as SignupListFormFactory; +use Activity\Form\Factory\SignupListFieldFactory as SignupListFieldFormFactory; use Activity\Form\Signup as SignupForm; use Activity\Form\SignupList as SignupListForm; use Activity\Form\SignupListField as SignupListFieldForm; @@ -26,15 +35,23 @@ use Activity\Mapper\SignupFieldValue as SignupFieldValueMapper; use Activity\Mapper\SignupList as SignupListMapper; use Activity\Mapper\SignupOption as SignupOptionMapper; +use Activity\Service\AclService; use Activity\Service\Activity as ActivityService; use Activity\Service\ActivityCalendar as ActivityCalendarService; use Activity\Service\ActivityCalendarForm as ActivityCalendarFormService; use Activity\Service\ActivityCategory as ActivityCategoryService; use Activity\Service\ActivityQuery as ActivityQueryService; +use Activity\Service\Factory\ActivityCalendarFactory as ActivityCalendarServiceFactory; +use Activity\Service\Factory\ActivityCalendarFormFactory as ActivityCalendarFormServiceFactory; +use Activity\Service\Factory\ActivityCategoryFactory as ActivityCategoryServiceFactory; +use Activity\Service\Factory\ActivityFactory as ActivityServiceFactory; +use Activity\Service\Factory\ActivityQueryFactory as ActivityQueryServiceFactory; +use Activity\Service\Factory\SignupFactory as SignupServiceFactory; +use Activity\Service\Factory\SignupListQueryFactory as SignupListQueryServiceFactory; use Activity\Service\Signup as SignupService; use Activity\Service\SignupListQuery as SignupListQueryService; +use Application\Mapper\Factory\BaseMapperFactory; use Doctrine\Laminas\Hydrator\DoctrineObject; -use Laminas\Mvc\I18n\Translator as MvcTranslator; use Psr\Container\ContainerInterface; use User\Authorization\AclServiceFactory; @@ -59,239 +76,43 @@ public function getServiceConfig(): array { return [ 'factories' => [ - 'activity_service_activity' => static function (ContainerInterface $container) { - $aclService = $container->get('activity_service_acl'); - $translator = $container->get(MvcTranslator::class); - $entityManager = $container->get('doctrine.entitymanager.orm_default'); - $categoryService = $container->get('activity_service_category'); - $organService = $container->get('decision_service_organ'); - $companyService = $container->get('company_service_company'); - $emailService = $container->get('application_service_email'); - $activityForm = $container->get('activity_form_activity'); - - return new ActivityService( - $aclService, - $translator, - $entityManager, - $categoryService, - $organService, - $companyService, - $emailService, - $activityForm, - ); - }, - 'activity_service_calendar' => static function (ContainerInterface $container) { - $aclService = $container->get('activity_service_acl'); - $translator = $container->get(MvcTranslator::class); - $entityManager = $container->get('doctrine.entitymanager.orm_default'); - $organService = $container->get('decision_service_organ'); - $emailService = $container->get('application_service_email'); - $calendarOptionMapper = $container->get('activity_mapper_calendar_option'); - $maxActivitiesMapper = $container->get('activity_mapper_max_activities'); - $memberMapper = $container->get('decision_mapper_member'); - $calendarPeriodForm = $container->get('activity_form_calendar_period'); - $calendarPeriodMapper = $container->get('activity_mapper_period'); - $calendarFormService = $container->get('activity_service_calendar_form'); - - return new ActivityCalendarService( - $aclService, - $translator, - $entityManager, - $organService, - $emailService, - $calendarOptionMapper, - $maxActivitiesMapper, - $memberMapper, - $calendarPeriodForm, - $calendarPeriodMapper, - $calendarFormService, - ); - }, - 'activity_service_calendar_form' => static function (ContainerInterface $container) { - $aclService = $container->get('activity_service_acl'); - $organService = $container->get('decision_service_organ'); - $periodMapper = $container->get('activity_mapper_period'); - $maxActivitiesMapper = $container->get('activity_mapper_max_activities'); - $optionProposalMapper = $container->get('activity_mapper_option_proposal'); - - return new ActivityCalendarFormService( - $aclService, - $organService, - $periodMapper, - $maxActivitiesMapper, - $optionProposalMapper, - ); - }, - 'activity_service_category' => static function (ContainerInterface $container) { - $aclService = $container->get('activity_service_acl'); - $translator = $container->get(MvcTranslator::class); - $categoryMapper = $container->get('activity_mapper_category'); - $categoryForm = $container->get('activity_form_category'); - - return new ActivityCategoryService( - $aclService, - $translator, - $categoryMapper, - $categoryForm, - ); - }, - 'activity_service_activityQuery' => static function (ContainerInterface $container) { - $aclService = $container->get('activity_service_acl'); - $translator = $container->get(MvcTranslator::class); - $organService = $container->get('decision_service_organ'); - $activityMapper = $container->get('activity_mapper_activity'); - $proposalMapper = $container->get('activity_mapper_proposal'); - - return new ActivityQueryService( - $aclService, - $translator, - $organService, - $activityMapper, - $proposalMapper, - ); - }, - 'activity_service_signup' => static function (ContainerInterface $container) { - $aclService = $container->get('activity_service_acl'); - $translator = $container->get(MvcTranslator::class); - $entityManager = $container->get('doctrine.entitymanager.orm_default'); - $signupMapper = $container->get('activity_mapper_signup'); - $signupOptionMapper = $container->get('activity_mapper_signup_option'); - $signupFieldValueMapper = $container->get('activity_mapper_signup_field_value'); - - return new SignupService( - $aclService, - $translator, - $entityManager, - $signupMapper, - $signupFieldValueMapper, - $signupOptionMapper, - ); - }, - 'activity_service_signupListQuery' => static function (ContainerInterface $container) { - $aclService = $container->get('activity_service_acl'); - $translator = $container->get(MvcTranslator::class); - $signupListMapper = $container->get('activity_mapper_signuplist'); - - return new SignupListQueryService( - $aclService, - $translator, - $signupListMapper, - ); - }, - 'activity_form_activity_signup' => static function () { - return new SignupForm(); - }, - 'activity_form_signuplist' => static function (ContainerInterface $container) { - $translator = $container->get(MvcTranslator::class); - $form = new SignupListForm($translator); - $form->setHydrator($container->get('activity_hydrator')); - - return $form; - }, - 'activity_form_signuplist_fields' => static function (ContainerInterface $container) { - $translator = $container->get(MvcTranslator::class); - $form = new SignupListFieldForm($translator); - $form->setHydrator($container->get('activity_hydrator')); - - return $form; - }, - 'activity_form_activity' => static function (ContainerInterface $container) { - $translator = $container->get(MvcTranslator::class); - $form = new ActivityForm($translator); - $form->setHydrator($container->get('activity_hydrator')); - - return $form; - }, - 'activity_form_calendar_proposal' => static function (ContainerInterface $container) { - $translator = $container->get(MvcTranslator::class); - $calendarFormService = $container->get('activity_service_calendar_form'); - $aclService = $container->get('activity_service_acl'); - $createAlways = $aclService->isAllowed('create_always', 'activity'); - - return new ActivityCalendarProposalForm($translator, $calendarFormService, $createAlways); - }, - 'activity_form_calendar_option' => static function (ContainerInterface $container) { - $translator = $container->get(MvcTranslator::class); - $calendarFormService = $container->get('activity_service_calendar_form'); - - return new ActivityCalendarOptionForm($translator, $calendarFormService); - }, - 'activity_form_calendar_period' => static function (ContainerInterface $container) { - return new ActivityCalendarPeriodForm($container->get(MvcTranslator::class)); - }, - 'activity_form_category' => static function (ContainerInterface $container) { - $translator = $container->get(MvcTranslator::class); - - return new CategoryForm($translator); - }, + // Services + AclService::class => AclServiceFactory::class, + ActivityService::class => ActivityServiceFactory::class, + ActivityCalendarService::class => ActivityCalendarServiceFactory::class, + ActivityCalendarFormService::class => ActivityCalendarFormServiceFactory::class, + ActivityCategoryService::class => ActivityCategoryServiceFactory::class, + ActivityQueryService::class => ActivityQueryServiceFactory::class, + SignupService::class => SignupServiceFactory::class, + SignupListQueryService::class => SignupListQueryServiceFactory::class, + // Mappers + ActivityMapper::class => BaseMapperFactory::class, + ActivityCategoryMapper::class => BaseMapperFactory::class, + ActivityOptionCreationPeriodMapper::class => BaseMapperFactory::class, + MaxActivitiesMapper::class => BaseMapperFactory::class, + SignupListMapper::class => BaseMapperFactory::class, + SignupFieldValueMapper::class => BaseMapperFactory::class, + SignupOptionMapper::class => BaseMapperFactory::class, + ProposalMapper::class => BaseMapperFactory::class, + ActivityOptionProposalMapper::class => BaseMapperFactory::class, + SignupMapper::class => BaseMapperFactory::class, + ActivityCalendarOptionMapper::class => BaseMapperFactory::class, + // Forms 'activity_hydrator' => static function (ContainerInterface $container) { return new DoctrineObject( $container->get('doctrine.entitymanager.orm_default'), ); }, - 'activity_mapper_activity' => static function (ContainerInterface $container) { - return new ActivityMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_category' => static function (ContainerInterface $container) { - return new ActivityCategoryMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_period' => static function (ContainerInterface $container) { - return new ActivityOptionCreationPeriodMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_max_activities' => static function (ContainerInterface $container) { - return new MaxActivitiesMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_signuplist' => static function (ContainerInterface $container) { - return new SignupListMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_signup_field_value' => static function (ContainerInterface $container) { - return new SignupFieldValueMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_signup_option' => static function (ContainerInterface $container) { - return new SignupOptionMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_proposal' => static function (ContainerInterface $container) { - return new ProposalMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_option_proposal' => static function (ContainerInterface $container) { - return new ActivityOptionProposalMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_signup' => static function (ContainerInterface $container) { - return new SignupMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_mapper_calendar_option' => static function (ContainerInterface $container) { - return new ActivityCalendarOptionMapper( - $container->get('doctrine.entitymanager.orm_default'), - ); - }, - 'activity_service_acl' => AclServiceFactory::class, - CalendarNotifyCommand::class => static function (ContainerInterface $container) { - $calendarNotify = new CalendarNotifyCommand(); - $calendarService = $container->get('activity_service_calendar'); - $calendarNotify->setCalendarService($calendarService); - - return $calendarNotify; - }, + SignupForm::class => SignupFormFactory::class, + SignupListForm::class => SignupListFormFactory::class, + SignupListFieldForm::class => SignupListFieldFormFactory::class, + ActivityForm::class => ActivityFormFactory::class, + ActivityCalendarProposalForm::class => ActivityCalendarProposalFormFactory::class, + ActivityCalendarOptionForm::class => ActivityCalendarOptionFormFactory::class, + ActivityCalendarPeriodForm::class => ActivityCalendarPeriodFormFactory::class, + CategoryForm::class => ActivityCategoryFormFactory::class, + // Commands + CalendarNotifyCommand::class => CalendarNotifyCommandFactory::class, DeleteOldSignupsCommand::class => DeleteOldSignupsCommandFactory::class, ], ]; diff --git a/module/Activity/src/Service/Factory/ActivityCalendarFactory.php b/module/Activity/src/Service/Factory/ActivityCalendarFactory.php new file mode 100644 index 0000000000..0e33391060 --- /dev/null +++ b/module/Activity/src/Service/Factory/ActivityCalendarFactory.php @@ -0,0 +1,45 @@ +get(AclService::class), + $container->get(MvcTranslator::class), + $container->get('doctrine.entitymanager.orm_default'), + $container->get(OrganService::class), + $container->get(EmailService::class), + $container->get(ActivityCalendarOptionMapper::class), + $container->get(MaxActivitiesMapper::class), + $container->get(MemberMapper::class), + $container->get(ActivityCalendarPeriodForm::class), + $container->get(ActivityOptionCreationPeriodMapper::class), + $container->get(ActivityCalendarFormService::class), + ); + } +} diff --git a/module/Activity/src/Service/Factory/ActivityCalendarFormFactory.php b/module/Activity/src/Service/Factory/ActivityCalendarFormFactory.php new file mode 100644 index 0000000000..0e36992aae --- /dev/null +++ b/module/Activity/src/Service/Factory/ActivityCalendarFormFactory.php @@ -0,0 +1,34 @@ +get(AclService::class), + $container->get(OrganService::class), + $container->get(ActivityOptionCreationPeriodMapper::class), + $container->get(MaxActivitiesMapper::class), + $container->get(ActivityOptionProposalMapper::class), + ); + } +} diff --git a/module/Activity/src/Service/Factory/ActivityCategoryFactory.php b/module/Activity/src/Service/Factory/ActivityCategoryFactory.php new file mode 100644 index 0000000000..51a061f277 --- /dev/null +++ b/module/Activity/src/Service/Factory/ActivityCategoryFactory.php @@ -0,0 +1,32 @@ +get(AclService::class), + $container->get(MvcTranslator::class), + $container->get(ActivityCategoryMapper::class), + $container->get(ActivityCategoryForm::class), + ); + } +} diff --git a/module/Activity/src/Service/Factory/ActivityFactory.php b/module/Activity/src/Service/Factory/ActivityFactory.php new file mode 100644 index 0000000000..135954fce8 --- /dev/null +++ b/module/Activity/src/Service/Factory/ActivityFactory.php @@ -0,0 +1,39 @@ +get(AclService::class), + $container->get(MvcTranslator::class), + $container->get('doctrine.entitymanager.orm_default'), + $container->get(ActivityCategoryService::class), + $container->get(OrganService::class), + $container->get(CompanyService::class), + $container->get(EmailService::class), + $container->get(ActivityForm::class), + ); + } +} diff --git a/module/Activity/src/Service/Factory/ActivityQueryFactory.php b/module/Activity/src/Service/Factory/ActivityQueryFactory.php new file mode 100644 index 0000000000..ef54a0580f --- /dev/null +++ b/module/Activity/src/Service/Factory/ActivityQueryFactory.php @@ -0,0 +1,34 @@ +get(AclService::class), + $container->get(MvcTranslator::class), + $container->get(OrganService::class), + $container->get(ActivityMapper::class), + $container->get(ProposalMapper::class), + ); + } +} diff --git a/module/Activity/src/Service/Factory/SignupFactory.php b/module/Activity/src/Service/Factory/SignupFactory.php new file mode 100644 index 0000000000..513e9567ed --- /dev/null +++ b/module/Activity/src/Service/Factory/SignupFactory.php @@ -0,0 +1,35 @@ +get(AclService::class), + $container->get(MvcTranslator::class), + $container->get('doctrine.entitymanager.orm_default'), + $container->get(SignupMapper::class), + $container->get(SignupFieldValueMapper::class), + $container->get(SignupOptionMapper::class), + ); + } +} diff --git a/module/Activity/src/Service/Factory/SignupListQueryFactory.php b/module/Activity/src/Service/Factory/SignupListQueryFactory.php new file mode 100644 index 0000000000..289ac3b367 --- /dev/null +++ b/module/Activity/src/Service/Factory/SignupListQueryFactory.php @@ -0,0 +1,30 @@ +get(AclService::class), + $container->get(MvcTranslator::class), + $container->get(SignupListMapper::class), + ); + } +} diff --git a/module/Activity/test/Mapper/ActivityMapperTest.php b/module/Activity/test/Mapper/ActivityMapperTest.php index 5f7f362c1e..76bda3fa14 100644 --- a/module/Activity/test/Mapper/ActivityMapperTest.php +++ b/module/Activity/test/Mapper/ActivityMapperTest.php @@ -27,7 +27,7 @@ public function setUp(): void { $this->setUpEntityManager(); - $this->mapper = $this->serviceManager->get('activity_mapper_activity'); + $this->mapper = $this->serviceManager->get(ActivityMapper::class); $this->setUpUser(); diff --git a/module/Activity/view/activity/activity/index.phtml b/module/Activity/view/activity/activity/index.phtml index 5cb867fca9..b7875e6142 100644 --- a/module/Activity/view/activity/activity/index.phtml +++ b/module/Activity/view/activity/activity/index.phtml @@ -3,6 +3,7 @@ declare(strict_types=1); use Activity\Model\Activity; +use Activity\Service\AclService as ActivityAclService; use Application\View\HelperTrait; use Laminas\View\Renderer\PhpRenderer; @@ -29,7 +30,7 @@ $this->headTitle($this->translate('Activities')); - acl('activity_service_acl')->isAllowed('myActivities', 'view')): ?> + acl(ActivityAclService::class)->isAllowed('myActivities', 'view')): ?> @@ -38,7 +39,7 @@ $this->headTitle($this->translate('Activities')); - acl('activity_service_acl')->isAllowed('activity', 'create')): ?> + acl(ActivityAclService::class)->isAllowed('activity', 'create')): ?>
diff --git a/module/Activity/view/activity/activity/view.phtml b/module/Activity/view/activity/activity/view.phtml index 8b6acbaa13..7e561899c1 100644 --- a/module/Activity/view/activity/activity/view.phtml +++ b/module/Activity/view/activity/activity/view.phtml @@ -8,6 +8,7 @@ use Activity\Model\{ SignupField as SignupFieldModel, SignupList as SignupListModel }; +use Activity\Service\AclService as ActivityAclService; use Application\Form\ModifyRequest as RequestForm; use Application\View\HelperTrait; use Doctrine\Common\Collections\Collection; @@ -345,7 +346,7 @@ $this->headTitle($this->translate('Activities')); - acl('activity_service_acl')->isAllowed('signupList', 'viewDetails')): ?> + acl(ActivityAclService::class)->isAllowed('signupList', 'viewDetails')): ?> getDisplaySubscribedNumber()): ?> @@ -366,12 +367,12 @@ $this->headTitle($this->translate('Activities')); - acl('activity_service_acl')->isAllowed('signupList', 'viewDetails')): ?> + acl(ActivityAclService::class)->isAllowed('signupList', 'viewDetails')): ?> identity()?->getMember()->getLidnr(); ?> getSignUps() as $signup): ?> - acl('activity_service_acl')->isAllowed('signupList', 'viewDetails')): ?> + acl(ActivityAclService::class)->isAllowed('signupList', 'viewDetails')): ?> - acl('activity_service_acl')->isAllowed('signupList', 'view') || $signupList->getDisplaySubscribedNumber() ? $i : '' ?> + acl(ActivityAclService::class)->isAllowed('signupList', 'view') || $signupList->getDisplaySubscribedNumber() ? $i : '' ?> escapeHtml($signup->getFullName()) ?> [ 'factories' => [ - 'featuredCompanyPackage' => static function (ContainerInterface $container) { - $companyService = $container->get('company_service_company'); + 'acl' => static function (ContainerInterface $container) { + $helper = new Acl(); + $helper->setServiceLocator($container); - return new FeaturedCompanyPackage($companyService); + return $helper; }, 'breadcrumbs' => static function () { return new Breadcrumbs(); @@ -130,15 +154,79 @@ $container->get('user_auth_companyUser_service'), ); }, + 'diff' => static function (ContainerInterface $container) { + return new Diff($container->get('config')['php-diff']); + }, + 'featuredCompanyPackage' => static function (ContainerInterface $container) { + return new FeaturedCompanyPackage($container->get(CompanyService::class)); + }, + 'fileUrl' => static function (ContainerInterface $container) { + $helper = new FileUrl(); + $helper->setServiceLocator($container); + + return $helper; + }, + 'glideUrl' => static function (ContainerInterface $container) { + $helper = new GlideUrl(); + $helper->setUrlBuilder($container->get('glide_url_builder')); + + return $helper; + }, + 'hashUrl' => static function (ContainerInterface $container) { + $viewHelperManager = $container->get('ViewHelperManager'); + $serverUrlHelper = $viewHelperManager->get(ServerUrl::class); + + return new HashUrl($serverUrlHelper); + }, + 'highlightSearch' => static function () { + return new HighlightSearch(); + }, 'hrefLang' => static function () { return new HrefLang(); }, - 'localisedTextElement' => static function () { - return new LocalisedTextElement(); + 'jobCategories' => static function (ContainerInterface $container) { + return new JobCategories($container->get(CompanyQueryService::class)); }, 'localiseText' => static function () { return new LocaliseText(); }, + 'localisedTextElement' => static function () { + return new LocalisedTextElement(); + }, + 'markdown' => static function (ContainerInterface $container) { + $environment = new Environment($container->get('config')['commonmark']); + $environment->addExtension(new CommonMarkCoreExtension()) + ->addExtension(new GithubFlavoredMarkdownExtension()) + ->addExtension(new ExternalLinkExtension()); + + // Create separate environment for companies. + $companyEnvironment = clone $environment; + $glide = new GlideUrl(); + $glide->setUrlBuilder($container->get('glide_url_builder')); + $companyEnvironment->addExtension(new CompanyImageExtension($glide)) + ->addExtension(new VideoIframeExtension()); + + // Do not render images in the default environment (activities, news items, etc.). + $environment->addExtension(new NoImageExtension()); + + return new Markdown( + $container->get(MvcTranslator::class), + new MarkdownConverter($environment), + new MarkdownConverter($companyEnvironment), + ); + }, + 'moduleIsActive' => static function (ContainerInterface $container) { + $helper = new ModuleIsActive(); + $helper->setServiceLocator($container); + + return $helper; + }, + 'scriptUrl' => static function () { + return new ScriptUrl(); + }, + 'timeDiff' => static function (ContainerInterface $container) { + return new TimeDiff($container->get(MvcTranslator::class)); + }, ], ], 'view_helper_config' => [ diff --git a/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/VimeoUrlParser.php b/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/VimeoUrlParser.php index 37a86b61e5..38dc96147d 100644 --- a/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/VimeoUrlParser.php +++ b/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/VimeoUrlParser.php @@ -13,7 +13,7 @@ class VimeoUrlParser implements VideoUrlParserInterface { - private const REGEX = '/(?:vimeo\.com\/(?:\d+|[^\/]+\/[^\/]+\/video\/|album\/[^\/]+\/video\/|channels\/[^\/]+\/|groups\/[^\/]+\/videos\/|ondemand\/[^\/]+\/)|player\.vimeo\.com\/video\/)(\d+)/'; + private const string REGEX = '/(?:vimeo\.com\/(?:\d+|[^\/]+\/[^\/]+\/video\/|album\/[^\/]+\/video\/|channels\/[^\/]+\/|groups\/[^\/]+\/videos\/|ondemand\/[^\/]+\/)|player\.vimeo\.com\/video\/)(\d+)/'; #[Override] public function parse(string $url): ?Video diff --git a/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/YouTubeUrlParser.php b/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/YouTubeUrlParser.php index 4a80b8c93e..0ae738ab9c 100644 --- a/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/YouTubeUrlParser.php +++ b/module/Application/src/Extensions/CommonMark/VideoIframe/Parsers/YouTubeUrlParser.php @@ -13,7 +13,7 @@ class YouTubeUrlParser implements VideoUrlParserInterface { - private const REGEX = '/(?:m\.)?(?:youtube\.com\/(?:watch\?v=|v\/|embed\/)|youtu\.be\/|youtube-nocookie\.com\/embed\/)([\w-]+)/'; + private const string REGEX = '/(?:m\.)?(?:youtube\.com\/(?:watch\?v=|v\/|embed\/)|youtu\.be\/|youtube-nocookie\.com\/embed\/)([\w-]+)/'; #[Override] public function parse(string $url): ?Video diff --git a/module/Application/src/Mapper/Factory/BaseMapperFactory.php b/module/Application/src/Mapper/Factory/BaseMapperFactory.php new file mode 100644 index 0000000000..ada44b70a6 --- /dev/null +++ b/module/Application/src/Mapper/Factory/BaseMapperFactory.php @@ -0,0 +1,27 @@ + $requestedName + * + * @return T + */ + public function __invoke( + ContainerInterface $container, + $requestedName, + ?array $options = null, + ) { + return new $requestedName($container->get('doctrine.entitymanager.orm_default')); + } +} diff --git a/module/Application/src/Module.php b/module/Application/src/Module.php index 805a6207cf..70131fcbcb 100644 --- a/module/Application/src/Module.php +++ b/module/Application/src/Module.php @@ -6,26 +6,16 @@ use Application\Command\Factory\LoadFixturesFactory as LoadFixturesCommandFactory; use Application\Command\LoadFixtures as LoadFixturesCommand; -use Application\Extensions\CommonMark\CompanyImage\CompanyImageExtension; -use Application\Extensions\CommonMark\NoImage\NoImageExtension; -use Application\Extensions\CommonMark\VideoIframe\VideoIframeExtension; use Application\Router\Factory\LanguageAwareTreeRouteStackFactory; use Application\Router\LanguageAwareTreeRouteStack; use Application\Service\Email as EmailService; +use Application\Service\Factory\EmailFactory as EmailServiceFactory; +use Application\Service\Factory\FileStorageFactory as FileStorageServiceFactory; +use Application\Service\Factory\InfimumFactory as InfimumServiceFactory; +use Application\Service\Factory\WatermarkFactory; use Application\Service\FileStorage as FileStorageService; use Application\Service\Infimum as InfimumService; -use Application\Service\WatermarkService; -use Application\View\Helper\Acl; -use Application\View\Helper\Diff; -use Application\View\Helper\FileUrl; -use Application\View\Helper\GlideUrl; -use Application\View\Helper\HashUrl; -use Application\View\Helper\HighlightSearch; -use Application\View\Helper\JobCategories; -use Application\View\Helper\Markdown; -use Application\View\Helper\ModuleIsActive; -use Application\View\Helper\ScriptUrl; -use Application\View\Helper\TimeDiff; +use Application\Service\Watermark; use Exception; use Laminas\Cache\Storage\Adapter\Memcached; use Laminas\Cache\Storage\Adapter\MemcachedOptions; @@ -36,12 +26,6 @@ use Laminas\Router\Http\TreeRouteStack; use Laminas\Router\RouteStackInterface; use Laminas\Validator\AbstractValidator; -use Laminas\View\Helper\ServerUrl; -use League\CommonMark\Environment\Environment; -use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension; -use League\CommonMark\Extension\ExternalLink\ExternalLinkExtension; -use League\CommonMark\Extension\GithubFlavoredMarkdownExtension; -use League\CommonMark\MarkdownConverter; use League\Glide\Signatures\Signature; use League\Glide\Urls\UrlBuilder; use Locale; @@ -50,9 +34,6 @@ use Override; use Psr\Container\ContainerInterface; use RuntimeException; -use User\Authentication\Adapter\UserAdapter; -use User\Authentication\AuthenticationService; -use User\Authentication\Storage\UserSession; use User\Permissions\NotAllowedException; use function array_merge; @@ -158,38 +139,10 @@ public function getServiceConfig(): array TreeRouteStack::class => [LanguageAwareTreeRouteStackFactory::class], ], 'factories' => [ - 'application_service_email' => static function (ContainerInterface $container) { - $renderer = $container->get('ViewRenderer'); - $transport = $container->get('user_mail_transport'); - $emailConfig = $container->get('config')['email']; - - return new EmailService($renderer, $transport, $emailConfig); - }, - 'application_service_infimum' => static function (ContainerInterface $container) { - $infimumCache = $container->get('application_cache_infimum'); - $translator = $container->get(MvcTranslator::class); - $infimumConfig = $container->get('config')['infimum']; - - return new InfimumService($infimumCache, $translator, $infimumConfig); - }, - 'application_service_storage' => static function (ContainerInterface $container) { - $translator = $container->get(MvcTranslator::class); - $storageConfig = $container->get('config')['storage']; - $watermarkService = $container->get('application_service_watermark'); - - return new FileStorageService($translator, $storageConfig, $watermarkService); - }, - 'application_service_watermark' => static function (ContainerInterface $container) { - /** @var AuthenticationService $authService */ - $authService = $container->get('user_auth_user_service'); - $remoteAddress = $container->get('user_remoteaddress'); - $watermarkConfig = $container->get('config')['watermark']; - - return new WatermarkService($authService, $remoteAddress, $watermarkConfig); - }, - 'application_get_languages' => static function () { - return ['nl', 'en']; - }, + EmailService::class => EmailServiceFactory::class, + InfimumService::class => InfimumServiceFactory::class, + FileStorageService::class => FileStorageServiceFactory::class, + Watermark::class => WatermarkFactory::class, 'application_cache_infimum' => static function () { $cache = new Memcached(); $options = $cache->getOptions(); @@ -198,7 +151,7 @@ public function getServiceConfig(): array throw new RuntimeException('Unable to retrieve and set options for Memcached'); } - // The TTL is 5 minutes (60 seconds * 5), as Supremum has a 5 minute cache on their end too. There + // The TTL is 5 minutes (60 seconds * 5), as Supremum has a 5-minute cache on their end too. There // is no need to keep requesting an infimum if we get the same one back for 5 minutes. $options->setTtl(60 * 5); $options->setServers([ @@ -274,84 +227,4 @@ public function generateSignature( ], ]; } - - /** - * Get view helper configuration. - */ - public function getViewHelperConfig(): array - { - return [ - 'factories' => [ - 'acl' => static function (ContainerInterface $container) { - $helper = new Acl(); - $helper->setServiceLocator($container); - - return $helper; - }, - 'scriptUrl' => static function () { - return new ScriptUrl(); - }, - 'moduleIsActive' => static function (ContainerInterface $container) { - $helper = new ModuleIsActive(); - $helper->setServiceLocator($container); - - return $helper; - }, - 'jobCategories' => static function (ContainerInterface $container) { - $companyQueryService = $container->get('company_service_companyquery'); - - return new JobCategories($companyQueryService); - }, - 'fileUrl' => static function (ContainerInterface $container) { - $helper = new FileUrl(); - $helper->setServiceLocator($container); - - return $helper; - }, - 'diff' => static function (ContainerInterface $container) { - return new Diff($container->get('config')['php-diff']); - }, - 'markdown' => static function (ContainerInterface $container) { - $environment = new Environment($container->get('config')['commonmark']); - $environment->addExtension(new CommonMarkCoreExtension()) - ->addExtension(new GithubFlavoredMarkdownExtension()) - ->addExtension(new ExternalLinkExtension()); - - // Create separate environment for companies. - $companyEnvironment = clone $environment; - $glide = new GlideUrl(); - $glide->setUrlBuilder($container->get('glide_url_builder')); - $companyEnvironment->addExtension(new CompanyImageExtension($glide)) - ->addExtension(new VideoIframeExtension()); - - // Do not render images in the default environment (activities, news items, etc.). - $environment->addExtension(new NoImageExtension()); - - return new Markdown( - $container->get(MvcTranslator::class), - new MarkdownConverter($environment), - new MarkdownConverter($companyEnvironment), - ); - }, - 'glideUrl' => static function (ContainerInterface $container) { - $helper = new GlideUrl(); - $helper->setUrlBuilder($container->get('glide_url_builder')); - - return $helper; - }, - 'hashUrl' => static function (ContainerInterface $container) { - $viewHelperManager = $container->get('ViewHelperManager'); - $serverUrlHelper = $viewHelperManager->get(ServerUrl::class); - - return new HashUrl($serverUrlHelper); - }, - 'highlightSearch' => static function () { - return new HighlightSearch(); - }, - 'timeDiff' => static function (ContainerInterface $container) { - return new TimeDiff($container->get(MvcTranslator::class)); - }, - ], - ]; - } } diff --git a/module/Application/src/Service/Factory/EmailFactory.php b/module/Application/src/Service/Factory/EmailFactory.php new file mode 100644 index 0000000000..ce1ae818e2 --- /dev/null +++ b/module/Application/src/Service/Factory/EmailFactory.php @@ -0,0 +1,27 @@ +get('ViewRenderer'), + $container->get('user_mail_transport'), + $container->get('config')['email'], + ); + } +} diff --git a/module/Application/src/Service/Factory/FileStorageFactory.php b/module/Application/src/Service/Factory/FileStorageFactory.php new file mode 100644 index 0000000000..09f48e0912 --- /dev/null +++ b/module/Application/src/Service/Factory/FileStorageFactory.php @@ -0,0 +1,29 @@ +get(MvcTranslator::class), + $container->get('config')['storage'], + $container->get(Watermark::class), + ); + } +} diff --git a/module/Application/src/Service/Factory/InfimumFactory.php b/module/Application/src/Service/Factory/InfimumFactory.php new file mode 100644 index 0000000000..e4077b4a9f --- /dev/null +++ b/module/Application/src/Service/Factory/InfimumFactory.php @@ -0,0 +1,28 @@ +get('application_cache_infimum'), + $container->get(MvcTranslator::class), + $container->get('config')['infimum'], + ); + } +} diff --git a/module/Application/src/Service/Factory/WatermarkFactory.php b/module/Application/src/Service/Factory/WatermarkFactory.php new file mode 100644 index 0000000000..27f9800c0e --- /dev/null +++ b/module/Application/src/Service/Factory/WatermarkFactory.php @@ -0,0 +1,33 @@ + $authService */ + $authService = $container->get('user_auth_user_service'); + + return new Watermark( + $authService, + $container->get('user_remoteaddress'), + $container->get('config')['watermark'], + ); + } +} diff --git a/module/Application/src/Service/FileStorage.php b/module/Application/src/Service/FileStorage.php index 97ab0ccde3..1ffe579aff 100644 --- a/module/Application/src/Service/FileStorage.php +++ b/module/Application/src/Service/FileStorage.php @@ -42,7 +42,7 @@ class FileStorage public function __construct( private readonly Translator $translator, private readonly array $storageConfig, - private readonly WatermarkService $watermarkService, + private readonly Watermark $watermarkService, ) { } diff --git a/module/Application/src/Service/WatermarkService.php b/module/Application/src/Service/Watermark.php similarity index 99% rename from module/Application/src/Service/WatermarkService.php rename to module/Application/src/Service/Watermark.php index a71271ca45..25a1d0e77b 100644 --- a/module/Application/src/Service/WatermarkService.php +++ b/module/Application/src/Service/Watermark.php @@ -23,7 +23,7 @@ /** * @psalm-template TUserAuth of AuthenticationService */ -class WatermarkService +class Watermark { // The font size of the watermark private const FONT_SIZE_DIAGONAL = 32; diff --git a/module/Application/test/BaseControllerTrait.php b/module/Application/test/BaseControllerTrait.php index ded733c2f8..115c5be787 100644 --- a/module/Application/test/BaseControllerTrait.php +++ b/module/Application/test/BaseControllerTrait.php @@ -4,10 +4,12 @@ namespace ApplicationTest; +use Company\Mapper\Company as CompanyMapper; use Company\Model\Company; use Company\Model\CompanyLocalisedText; use DateInterval; use DateTime; +use Decision\Mapper\Member as MemberMapper; use Decision\Model\Enums\MembershipTypes; use Decision\Model\Member; use Doctrine\Common\Collections\ArrayCollection; @@ -16,7 +18,13 @@ use Laminas\Mvc\Service\ServiceManagerConfig; use Laminas\ServiceManager\ServiceManager; use PHPUnit\Framework\MockObject\MockObject; +use User\Authentication\Adapter\CompanyUserAdapter; +use User\Authentication\Adapter\UserAdapter; use User\Authentication\AuthenticationService; +use User\Authentication\Storage\CompanyUserSession; +use User\Authentication\Storage\UserSession; +use User\Mapper\CompanyUser as CompanyUserMapper; +use User\Mapper\User as UserMapper; use User\Model\CompanyUser; use User\Model\Enums\UserRoles; use User\Model\NewCompanyUser; @@ -131,8 +139,8 @@ private function bootstrapApplication( private function setUpMockCompanyUserAuthService(): void { - $storage = $this->serviceManager->get('user_auth_companyUser_storage'); - $adapter = $this->serviceManager->get('user_auth_companyUser_adapter'); + $storage = $this->serviceManager->get(CompanyUserSession::class); + $adapter = $this->serviceManager->get(CompanyUserAdapter::class); $this->companyUserAuthService = $this->getMockBuilder(AuthenticationService::class) ->setConstructorArgs([$storage, $adapter]) @@ -145,30 +153,30 @@ private function setUpMockCompanyMapper(): void { $entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); - $this->companyMapper = $this->getMockBuilder(\Company\Mapper\Company::class) + $this->companyMapper = $this->getMockBuilder(CompanyMapper::class) ->setConstructorArgs([$entityManager]) ->enableProxyingToOriginalMethods() ->getMock(); - $this->serviceManager->setService('company_mapper_company', $this->companyMapper); + $this->serviceManager->setService(CompanyMapper::class, $this->companyMapper); } private function setUpMockCompanyUserMapper(): void { $entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); - $this->companyUserMapper = $this->getMockBuilder(\User\Mapper\CompanyUser::class) + $this->companyUserMapper = $this->getMockBuilder(CompanyUserMapper::class) ->setConstructorArgs([$entityManager]) ->enableProxyingToOriginalMethods() ->getMock(); - $this->serviceManager->setService('user_mapper_companyUser', $this->companyUserMapper); + $this->serviceManager->setService(CompanyUserMapper::class, $this->companyUserMapper); } private function setUpMockUserAuthService(): void { - $storage = $this->serviceManager->get('user_auth_user_storage'); - $adapter = $this->serviceManager->get('user_auth_user_adapter'); + $storage = $this->serviceManager->get(UserSession::class); + $adapter = $this->serviceManager->get(UserAdapter::class); $this->userAuthService = $this->getMockBuilder(AuthenticationService::class) ->setConstructorArgs([$storage, $adapter]) @@ -181,24 +189,24 @@ private function setUpMockUserMapper(): void { $entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); - $this->userMapper = $this->getMockBuilder(\User\Mapper\User::class) + $this->userMapper = $this->getMockBuilder(UserMapper::class) ->setConstructorArgs([$entityManager]) ->enableProxyingToOriginalMethods() ->getMock(); - $this->serviceManager->setService('user_mapper_user', $this->userMapper); + $this->serviceManager->setService(UserMapper::class, $this->userMapper); } private function setUpMockMemberMapper(): void { $entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); - $this->memberMapper = $this->getMockBuilder(\Decision\Mapper\Member::class) + $this->memberMapper = $this->getMockBuilder(MemberMapper::class) ->setConstructorArgs([$entityManager]) ->enableProxyingToOriginalMethods() ->getMock(); - $this->serviceManager->setService('decision_mapper_member', $this->memberMapper); + $this->serviceManager->setService(MemberMapper::class, $this->memberMapper); } protected function setUpWithRole(string $role = 'user'): void diff --git a/module/Application/view/partial/admin.phtml b/module/Application/view/partial/admin.phtml index 4023a30623..c3330f15fd 100644 --- a/module/Application/view/partial/admin.phtml +++ b/module/Application/view/partial/admin.phtml @@ -2,8 +2,15 @@ declare(strict_types=1); +use Activity\Service\AclService as ActivityAclService; use Application\View\HelperTrait; +use Company\Service\AclService as CompanyAclService; +use Decision\Service\AclService as DecisionAclService; +use Education\Service\AclService as EducationAclService; +use Frontpage\Service\AclService as FrontpageAclService; use Laminas\View\Renderer\PhpRenderer; +use Photo\Service\AclService as PhotoAclService; +use User\Service\AclService as UserAclService; /** @var PhpRenderer|HelperTrait $this */ ?> @@ -32,7 +39,7 @@ use Laminas\View\Renderer\PhpRenderer; - acl('activity_service_acl')->isAllowed('activity_admin', 'view')): ?> + acl(ActivityAclService::class)->isAllowed('activity_admin', 'view')): ?> acl('activity_service_acl')->isAllowed('activity', 'listCategories')): ?> + if ($this->acl(ActivityAclService::class)->isAllowed('activity', 'listCategories')): ?>
  • translate( 'Categories' @@ -54,7 +61,7 @@ use Laminas\View\Renderer\PhpRenderer; acl('activity_service_acl')->isAllowed( + if ($this->acl(ActivityAclService::class)->isAllowed( 'activity_calendar_period', 'view' )): ?> @@ -68,7 +75,7 @@ use Laminas\View\Renderer\PhpRenderer;
  • - acl('company_service_acl')->isAllowed('company_admin', 'view')): ?> + acl(CompanyAclService::class)->isAllowed('company_admin', 'view')): ?> - acl('education_service_acl')->isAllowed('education_admin', 'view')): ?> + acl(EducationAclService::class)->isAllowed('education_admin', 'view')): ?>
  • translate('Organs') ?>
  • - acl('frontpage_service_acl')->isAllowed('news_item', 'create')): ?> + acl(FrontpageAclService::class)->isAllowed('news_item', 'create')): ?>
  • translate('News') ?>
  • - acl('frontpage_service_acl')->isAllowed('page', 'create')): ?> + acl(FrontpageAclService::class)->isAllowed('page', 'create')): ?>
  • translate('Pages') ?>
  • - acl('photo_service_acl')->isAllowed('photo_admin', 'view')): ?> + acl(PhotoAclService::class)->isAllowed('photo_admin', 'view')): ?>
  • translate('Photos') ?>
  • - acl('frontpage_service_acl')->isAllowed('poll', 'approve')): ?> + acl(FrontpageAclService::class)->isAllowed('poll', 'approve')): ?>
  • translate('Polls') ?>
  • - acl('user_service_acl')->isAllowed('user_admin', 'view')): ?> + acl(UserAclService::class)->isAllowed('user_admin', 'view')): ?>