Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
Rely *explicitly* on FrameworkBundle's FormPass (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas authored and greg0ire committed Apr 27, 2017
1 parent bc3cc80 commit 6da6436
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
5 changes: 3 additions & 2 deletions DependencyInjection/Compiler/FormFactoryCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

namespace Sonata\CoreBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FormPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class FormFactoryCompilerPass implements CompilerPassInterface
class FormFactoryCompilerPass extends FormPass
{
/**
* {@inheritdoc}
Expand All @@ -41,6 +41,7 @@ public function process(ContainerBuilder $container)

// get factories
$original = $container->getDefinition('form.extension');
parent::process($container);

$factory = $container->getDefinition('sonata.core.form.extension.dependency');
$factory->replaceArgument(1, $original->getArgument(1));
Expand Down
25 changes: 10 additions & 15 deletions Tests/DependencyInjection/Compiler/FormFactoryCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,22 @@ public function testProcessWithContainerHasNoFormExtensionDefinition()

public function testProcessWithContainerHasFormExtensionDefinition()
{
$formExtension = new Definition();
$formExtension->addArgument('foo');
$formExtension->addArgument('bar');
$formExtension->addArgument('baz');
$formExtension->addArgument('caz');
$formExtension = new Definition(null, array(null, null, null, null));
$this->setDefinition('form.extension', $formExtension);

$sonataFormExtension = new Definition();
$sonataFormExtension->addArgument('extension-foo');
$sonataFormExtension->addArgument('extension-bar');
$sonataFormExtension->addArgument('extension-baz');
$sonataFormExtension->addArgument('extension-caz');
$formType = new Definition();
$formType->addTag('form.type');
$this->setDefinition('foo', $formType);

$sonataFormExtension = new Definition(null, array(null, null, null, null));
$this->setDefinition('sonata.core.form.extension.dependency', $sonataFormExtension);

$this->compile();

$expectedFormExtension = $this->container->getDefinition('form.extension');
$this->assertSame($sonataFormExtension, $this->container->getDefinition('form.extension'));

$this->assertSame('extension-foo', $expectedFormExtension->getArgument(0));
$this->assertSame('bar', $expectedFormExtension->getArgument(1));
$this->assertSame('baz', $expectedFormExtension->getArgument(2));
$this->assertSame('caz', $expectedFormExtension->getArgument(3));
$this->assertContains('foo', $sonataFormExtension->getArgument(1));
$this->assertSame(array(), $sonataFormExtension->getArgument(2));
$this->assertSame(array(), $sonataFormExtension->getArgument(3));
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"sonata-project/datagrid-bundle": "^2.0",
"symfony/config": "^2.3 || ^3.0",
"symfony/form": "^2.3.5 || ^3.0",
"symfony/framework-bundle": "^2.3 || ^3.0",
"symfony/http-foundation": "^2.3 || ^3.0",
"symfony/property-access": "^2.3 || ^3.0",
"symfony/security": "^2.3 || ^3.0",
Expand Down

0 comments on commit 6da6436

Please sign in to comment.