Skip to content

Commit

Permalink
Define services using FQCN
Browse files Browse the repository at this point in the history
This is in line with the standard suggested by new symfony versions.
  • Loading branch information
Webonaute authored and rdohms committed Jul 18, 2018
1 parent 84a9916 commit 2904795
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('services.yml');

$container->setParameter('dms_filter.auto_filter_forms', $config['auto_filter_forms']);

AnnotationRegistry::registerAutoloadNamespace('DMS\Bundle\FilterBundle\Rule', __DIR__ . '/../../../');
}
}
18 changes: 7 additions & 11 deletions src/DMS/Bundle/FilterBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,21 @@ parameters:
dms.filter.inner.filter.class: DMS\Filter\Filter

services:

dms.filter:
class: DMS\Bundle\FilterBundle\Service\Filter
# Class service.
DMS\Bundle\FilterBundle\Service\Filter:
public: true
arguments:
- '@dms.filter.inner.filter'

dms.filter.type_extension:
class: DMS\Bundle\FilterBundle\Form\Type\FormTypeFilterExtension
DMS\Bundle\FilterBundle\Form\Type\FormTypeFilterExtension:
public: true
arguments:
- '@dms.filter'
- '@DMS\Bundle\FilterBundle\Service\Filter'
- '%dms_filter.auto_filter_forms%'
tags:
- { name: form.type_extension, alias: Symfony\Component\Form\Extension\Core\Type\FormType, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType }

dms.filter.container_loader:
class: DMS\Bundle\FilterBundle\Loader\ContainerAwareLoader
DMS\Bundle\FilterBundle\Loader\ContainerAwareLoader:
calls:
- [ setContainer, ['@service_container'] ]

Expand All @@ -40,10 +37,9 @@ services:
class: '%dms.filter.inner.filter.class%'
arguments:
- '@dms.filter.mapping.factory'
- '@dms.filter.container_loader'
- '@DMS\Bundle\FilterBundle\Loader\ContainerAwareLoader'

dms.filter.container_filter:
class: DMS\Bundle\FilterBundle\Filter\ContainerFilter
DMS\Bundle\FilterBundle\Filter\ContainerFilter:
public: true
calls:
- [setContainer, ['@service_container']]
3 changes: 2 additions & 1 deletion src/DMS/Bundle/FilterBundle/Rule/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DMS\Bundle\FilterBundle\Rule;

use DMS\Bundle\FilterBundle\Filter\ContainerFilter;
use DMS\Filter\Rules\Rule;

/**
Expand Down Expand Up @@ -36,6 +37,6 @@ public function getRequiredOptions(): array
*/
public function getFilter(): string
{
return 'dms.filter.container_filter';
return ContainerFilter::class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DMS\DMS\Bundle\FilterBundle\Tests\Integration;

use DMS\Bundle\FilterBundle\DependencyInjection\DMSFilterExtension;
use DMS\Bundle\FilterBundle\Service\Filter;
use Doctrine\Common\Annotations\AnnotationReader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -33,7 +34,7 @@ public function buildContainer()

public function testContainerBoots()
{
$this->container->get('dms.filter');
$this->container->get(Filter::class);

if (method_exists($this->container, 'isCompiled')) {
self::assertTrue($this->container->isCompiled());
Expand Down

0 comments on commit 2904795

Please sign in to comment.