Remove custom service definition, use auto-discovery feature.

This commit is contained in:
Pol Dellaiera 2021-05-06 17:33:12 +02:00
parent ac9d0242ad
commit 7f602ffa47
11 changed files with 52 additions and 144 deletions

View File

@ -1,27 +1,45 @@
services:
chill.person.form.type.select2maritalstatus:
class: Chill\PersonBundle\Form\Type\Select2MaritalStatusType
arguments:
- "@request_stack"
- "@doctrine.orm.entity_manager"
tags:
- { name: form.type, alias: select2_chill_marital_status }
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
chill.person.timeline.accompanying_period_opening:
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodOpening
arguments:
- "@doctrine.orm.entity_manager"
public: true
tags:
- { name: chill.timeline, context: 'person' }
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
Chill\PersonBundle\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
- '../src/Tests/'
chill.person.timeline.accompanying_period_closing:
class: Chill\PersonBundle\Timeline\TimelineAccompanyingPeriodClosing
arguments:
- "@doctrine.orm.entity_manager"
public: true
Chill\PersonBundle\Form\Type\:
resource: '../src/Form/Type/'
tags:
- { name: chill.timeline, context: 'person' }
- { name: form.type }
Chill\PersonBundle\Timeline\:
resource: '../src/Timeline/'
tags:
- { name: chill.timeline, context: person }
Chill\PersonBundle\Controller\:
resource: '../src/Controller/'
tags: ['controller.service_arguments']
Chill\PersonBundle\Repository\:
resource: '../src/Repository/'
tags: ['doctrine.repository_service']
Chill\PersonBundle\Command\:
resource: '../src/Command/'
tags:
- { name: console.command }
Chill\PersonBundle\Menu\:
resource: '../src/Menu/'
tags:
- { name: 'chill.menu_builder' }
chill.person.security.authorization.person:
class: Chill\PersonBundle\Security\Authorization\PersonVoter
@ -38,10 +56,3 @@ services:
tags:
- { name: validator.constraint_validator, alias: birthdate_not_before }
Chill\PersonBundle\Controller\:
resource: '../src/Controller/'
tags: ['controller.service_arguments']
Chill\PersonBundle\Repository\:
resource: '../src/Repository/'
tags: ['doctrine.repository_service']

View File

@ -1,5 +0,0 @@
services:
Chill\PersonBundle\Actions\Remove\PersonMove:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'

View File

@ -6,14 +6,3 @@ services:
$chillLogger: '@chill.main.logger'
tags:
- { name: console.command }
Chill\PersonBundle\Command\ImportPeopleFromCSVCommand:
arguments:
$logger: '@logger'
$helper: '@Chill\MainBundle\Templating\TranslatableStringHelper'
$em: '@Doctrine\ORM\EntityManagerInterface'
$customFieldProvider: '@Chill\CustomFieldsBundle\Service\CustomFieldProvider'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$formFactory: '@form.factory'
tags:
- { name: console.command }

View File

@ -1,36 +0,0 @@
services:
Chill\PersonBundle\Controller\TimelinePersonController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$timelineBuilder: '@chill_main.timeline_builder'
$paginatorFactory: '@chill_main.paginator_factory'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingPeriodController:
arguments:
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\PersonAddressController:
arguments:
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AdminController: ~
Chill\PersonBundle\Controller\PersonDuplicateController:
arguments:
$similarPersonMatcher: '@Chill\PersonBundle\Search\SimilarPersonMatcher'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
$personRepository: '@Chill\PersonBundle\Repository\PersonRepository'
$personMove: '@Chill\PersonBundle\Actions\Remove\PersonMove'
$eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
tags: ['controller.service_arguments']
Chill\PersonBundle\Controller\AccompanyingCourseController:
arguments:
$serializer: '@Symfony\Component\Serializer\SerializerInterface'
$dispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
tags: ['controller.service_arguments']

View File

@ -32,7 +32,7 @@ services:
chill.person.form.type.pick_person:
class: Chill\PersonBundle\Form\Type\PickPersonType
arguments:
- "@chill.person.repository.person"
- Chill\PersonBundle\Repository\PersonRepository"
- "@security.token_storage"
- "@chill.main.security.authorization.helper"
- '@Symfony\Component\Routing\Generator\UrlGeneratorInterface'
@ -46,10 +46,3 @@ services:
$translatableStringHelper: '@chill.main.helper.translatable_string'
tags:
- { name: form.type }
Chill\PersonBundle\Form\Type\PersonPhoneType:
arguments:
$phonenumberHelper: '@Chill\MainBundle\Phonenumber\PhonenumberHelper'
$em: '@Doctrine\ORM\EntityManagerInterface'
tags:
- { name: form.type }

View File

@ -1,26 +0,0 @@
services:
Chill\PersonBundle\Menu\SectionMenuBuilder:
arguments:
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
tags:
- { name: 'chill.menu_builder' }
Chill\PersonBundle\Menu\AdminMenuBuilder:
arguments:
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
tags:
- { name: 'chill.menu_builder' }
Chill\PersonBundle\Menu\PersonMenuBuilder:
arguments:
$showAccompanyingPeriod: '%chill_person.accompanying_period%'
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
tags:
- { name: 'chill.menu_builder' }
Chill\PersonBundle\Menu\AccompanyingCourseMenuBuilder:
arguments:
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
tags:
- { name: 'chill.menu_builder' }

View File

@ -1,7 +0,0 @@
services:
chill.person.repository.person:
class: Chill\PersonBundle\Repository\PersonRepository
autowire: true
autoconfigure: true
Chill\PersonBundle\Repository\PersonRepository: '@chill.person.repository.person'

View File

@ -10,7 +10,7 @@ services:
- ['setContainer', ["@service_container"]]
tags:
- { name: chill.search, alias: 'person_regular' }
Chill\PersonBundle\Search\SimilarityPersonSearch:
arguments:
- "@doctrine.orm.entity_manager"
@ -22,9 +22,3 @@ services:
- ['setContainer', ["@service_container"]]
tags:
- { name: chill.search, alias: 'person_similarity' }
Chill\PersonBundle\Search\SimilarPersonMatcher:
arguments:
$em: '@Doctrine\ORM\EntityManagerInterface'
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'

View File

@ -2,13 +2,13 @@ services:
chill_person.widget.person_list:
class: Chill\PersonBundle\Widget\PersonListWidget
arguments:
- "@chill.person.repository.person"
- Chill\PersonBundle\Repository\PersonRepository
- "@doctrine.orm.entity_manager"
- "@chill.main.security.authorization.helper"
- "@security.token_storage"
# this widget is defined by the PersonListWidgetFactory
chill_person.widget.add_person:
class: Chill\PersonBundle\Widget\AddAPersonWidget
tags:
- { name: chill_widget, alias: add_person, place: homepage }
- { name: chill_widget, alias: add_person, place: homepage }

View File

@ -65,14 +65,10 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
$loader->load('services/widgets.yaml');
$loader->load('services/exports.yaml');
$loader->load('services/fixtures.yaml');
$loader->load('services/controller.yaml');
$loader->load('services/search.yaml');
$loader->load('services/menu.yaml');
$loader->load('services/privacyEvent.yaml');
$loader->load('services/command.yaml');
$loader->load('services/actions.yaml');
$loader->load('services/form.yaml');
$loader->load('services/repository.yaml');
$loader->load('services/templating.yaml');
$loader->load('services/alt_names.yaml');
$loader->load('services/serializer.yaml');

View File

@ -19,13 +19,14 @@ namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Add menu entrie to person menu.
*
*
* Menu entries added :
*
*
* - person details ;
* - accompanying period (if `visible`)
*
@ -33,25 +34,23 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class PersonMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var string 'visible' or 'hidden'
*/
protected $showAccompanyingPeriod;
/**
*
* @var TranslatorInterface
*/
protected $translator;
public function __construct(
$showAccompanyingPeriod,
ParameterBagInterface $parameterBag,
TranslatorInterface $translator
) {
$this->showAccompanyingPeriod = $showAccompanyingPeriod;
$this->showAccompanyingPeriod = $parameterBag->get('chill_person.accompanying_period');
$this->translator = $translator;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
$menu->addChild($this->translator->trans('Person details'), [
@ -73,7 +72,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
->setExtras([
'order' => 51
]);
if ($this->showAccompanyingPeriod === 'visible') {
$menu->addChild($this->translator->trans('Accompanying period list'), [
'route' => 'chill_person_accompanying_period_list',