This repository has been archived by the owner on Dec 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor #7 Refactor the integration bundle (sstok)
This PR was merged into the master branch. Discussion ---------- |Q |A | |--- |---| |Bug Fix? |no | |New Feature? |yes| |BC Breaks? |yes| |Deprecations?|no | |Fixed Tickets| | Commits ------- b2e86e1 Refactor the integration bundle 0db7376 Fix PHPUnit breaks on dep=low
- Loading branch information
Showing
40 changed files
with
917 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/phpunit.xml | ||
/composer.lock | ||
.php_cs.cache | ||
*.phar | ||
/vendor/ | ||
/bin/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
preset: symfony | ||
|
||
risky: true | ||
|
||
enabled: | ||
- strict_param | ||
- ordered_use | ||
- short_array_syntax | ||
#- ordered_class_elements | ||
- ordered_imports | ||
- phpdoc_order | ||
|
||
- short_array_syntax | ||
- strict_param | ||
#- declare_strict_types | ||
|
||
disabled: | ||
- psr0 | ||
- strict | ||
|
||
- simplified_null_return # PHP 7.1 compatiblity (void !== null) | ||
|
||
finder: | ||
in: | ||
path: | ||
- 'src/' | ||
- 'tests/' | ||
exclude: | ||
- 'bin' | ||
- 'doc' | ||
not-path: | ||
- 'Fixtures' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/DependencyInjection/Compiler/DatagridConfiguratorPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the RollerworksDatagrid package. | ||
* | ||
* (c) Sebastiaan Stok <s.stok@rollerscapes.net> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Rollerworks\Bundle\DatagridBundle\DependencyInjection\Compiler; | ||
|
||
use Rollerworks\Component\Datagrid\DatagridConfiguratorInterface; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; | ||
|
||
/** | ||
* Registers Datagrid Configurators for loading. | ||
* | ||
* @author Sebastiaan Stok <s.stok@rollerscapes.net> | ||
*/ | ||
class DatagridConfiguratorPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasDefinition('rollerworks_datagrid.datagrid_registry')) { | ||
return; | ||
} | ||
|
||
$definition = $container->getDefinition('rollerworks_datagrid.datagrid_registry'); | ||
$mapping = []; | ||
|
||
foreach ($container->findTaggedServiceIds('rollerworks_datagrid.datagrid_configurator') as $id => $tag) { | ||
$def = $container->getDefinition($id); | ||
|
||
if (!$def->isPublic()) { | ||
throw new InvalidArgumentException(sprintf('The service "%s" must be public as it can be lazy-loaded.', $id)); | ||
} | ||
|
||
if ($def->isAbstract()) { | ||
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as it can be lazy-loaded.', $id)); | ||
} | ||
|
||
if (!in_array(DatagridConfiguratorInterface::class, class_implements($def->getClass()), true)) { | ||
throw new InvalidArgumentException(sprintf('The class of service "%s" must implement "%s".', $id, DatagridConfiguratorInterface::class)); | ||
} | ||
|
||
$mapping[$def->getClass()] = $id; | ||
} | ||
|
||
$definition->replaceArgument(1, $mapping); | ||
} | ||
} |
Oops, something went wrong.