-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add "setFormTheme" and "setFilterTheme" calls + change "initialize" p…
…riority
- Loading branch information
Showing
6 changed files
with
87 additions
and
2 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
32 changes: 32 additions & 0 deletions
32
src/DependencyInjection/Compiler/AdminAddInitializeCallCompilerPass.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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* this compiler pass is registered with low priority to make sure it runs after all the other passes | ||
* as we want the "initialize()" calls to come after all the other calls. | ||
*/ | ||
final class AdminAddInitializeCallCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
$admins = $container->findTaggedServiceIds('sonata.admin'); | ||
foreach (array_keys($admins) as $id) { | ||
$container->getDefinition($id)->addMethodCall('initialize'); | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
tests/DependencyInjection/Compiler/AdminAddInitializeCallCompilerPassTest.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,22 @@ | ||
<?php | ||
|
||
namespace Sonata\AdminBundle\Tests\DependencyInjection\Compiler; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Sonata\AdminBundle\DependencyInjection\Compiler\AdminAddInitializeCallCompilerPass; | ||
use Sonata\AdminBundle\Tests\App\Admin\FooAdmin; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
final class AdminAddInitializeCallCompilerPassTest extends TestCase | ||
{ | ||
public function testProcess(): void | ||
{ | ||
$builder = new ContainerBuilder(); | ||
$builder->register('foo', FooAdmin::class) | ||
->addTag('sonata.admin'); | ||
|
||
(new AdminAddInitializeCallCompilerPass())->process($builder); | ||
|
||
$this->assertSame([['initialize', []]], $builder->getDefinition('foo')->getMethodCalls()); | ||
} | ||
} |
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