Skip to content

Commit

Permalink
chore: move everything to factories
Browse files Browse the repository at this point in the history
Moves _everything_ to factories (except some things that require duplication in
the `Education` and `User` module).
  • Loading branch information
tomudding committed Dec 27, 2024
1 parent f15647e commit 8bd4c62
Show file tree
Hide file tree
Showing 215 changed files with 4,526 additions and 1,658 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
│ │ └── ...
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/doctrine.local.development.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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,
] : [],
Expand Down
5 changes: 4 additions & 1 deletion config/autoload/local.development.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
5 changes: 4 additions & 1 deletion config/autoload/local.production.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
10 changes: 4 additions & 6 deletions module/Activity/src/Command/CalendarNotify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,9 +24,4 @@ public function execute(

return 1;
}

public function setCalendarService(ActivityCalendar $calendarService): void
{
$this->calendarService = $calendarService;
}
}
24 changes: 24 additions & 0 deletions module/Activity/src/Command/Factory/CalendarNotifyFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Activity\Command\Factory;

use Activity\Command\CalendarNotify;
use Activity\Service\ActivityCalendar as ActivityCalendarService;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;

class CalendarNotifyFactory implements FactoryInterface
{
/**
* @param string $requestedName
*/
public function __invoke(
ContainerInterface $container,
$requestedName,
?array $options = null,
): CalendarNotify {
return new CalendarNotify($container->get(ActivityCalendarService::class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
);
}
}
18 changes: 12 additions & 6 deletions module/Activity/src/Controller/Factory/AdminControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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),
);
}
}
1 change: 1 addition & 0 deletions module/Activity/src/Form/ActivityCalendarPeriod.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Activity\Form;

use Activity\Form\Fieldset\MaxActivities;
use DateTime;
use Laminas\Form\Element\Collection;
use Laminas\Form\Element\DateTimeLocal;
Expand Down
28 changes: 28 additions & 0 deletions module/Activity/src/Form/Factory/ActivityCalendarOptionFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Activity\Form\Factory;

use Activity\Form\ActivityCalendarOption as ActivityCalendarOptionForm;
use Activity\Service\ActivityCalendarForm as ActivityCalendarFormService;
use Laminas\Mvc\I18n\Translator as MvcTranslator;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;

class ActivityCalendarOptionFactory implements FactoryInterface
{
/**
* @param string $requestedName
*/
public function __invoke(
ContainerInterface $container,
$requestedName,
?array $options = null,
): ActivityCalendarOptionForm {
return new ActivityCalendarOptionForm(
$container->get(MvcTranslator::class),
$container->get(ActivityCalendarFormService::class),
);
}
}
24 changes: 24 additions & 0 deletions module/Activity/src/Form/Factory/ActivityCalendarPeriodFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Activity\Form\Factory;

use Activity\Form\ActivityCalendarPeriod as ActivityCalendarPeriodForm;
use Laminas\Mvc\I18n\Translator as MvcTranslator;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;

class ActivityCalendarPeriodFactory implements FactoryInterface
{
/**
* @param string $requestedName
*/
public function __invoke(
ContainerInterface $container,
$requestedName,
?array $options = null,
): ActivityCalendarPeriodForm {
return new ActivityCalendarPeriodForm($container->get(MvcTranslator::class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Activity\Form\Factory;

use Activity\Form\ActivityCalendarProposal as ActivityCalendarProposalForm;
use Activity\Service\AclService;
use Activity\Service\ActivityCalendarForm as ActivityCalendarFormService;
use Laminas\Mvc\I18n\Translator as MvcTranslator;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;

class ActivityCalendarProposalFactory implements FactoryInterface
{
/**
* @param string $requestedName
*/
public function __invoke(
ContainerInterface $container,
$requestedName,
?array $options = null,
): ActivityCalendarProposalForm {
return new ActivityCalendarProposalForm(
$container->get(MvcTranslator::class),
$container->get(ActivityCalendarFormService::class),
$container->get(AclService::class)->isAllowed('create_always', 'activity'),
);
}
}
Loading

0 comments on commit 8bd4c62

Please sign in to comment.