collection-crud/config/services.php

37 lines
1.3 KiB
PHP

<?php declare(strict_types=1);
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use App\Maker\MakeCollectionCrud;
return function (ContainerConfigurator $configurator): void {
$parameters = $configurator->parameters();
$parameters->set('locale', 'en');
// 'private' means you cannot fetch services directly from the container via $container->get()
// if you need to do this, you can override this setting on individual services
$services = $configurator->services()
->defaults()
->autowire()
->autoconfigure()
->private();
// makes classes in src/App available to be used as services
// this creates a service per class whose id is the fully-qualified class name
// you can exclude directories or files
// but if a service is unused, it's removed anyway
$services->load('App\\', '../src/*')
->exclude('../src/{Entity,Repository,Tests}');
// controllers are imported separately to make sure they're public
// and have a tag that allows actions to type-hint services
$services->load('App\\Controller\\', '../src/Controller')
->tag('controller.service_arguments');
// Fix wiring of custom CRUD maker class
$services->set(MakeCollectionCrud::class)
->arg('$doctrineHelper', service('maker.doctrine_helper'))
->arg('$formTypeRenderer', service('maker.renderer.form_type_renderer'));
};