Skip to content

Commit

Permalink
Symfony 4 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chives committed Jan 8, 2018

Verified

This commit was signed with the committer’s verified signature.
chives Łukasz Cybula
1 parent 3bf7caa commit a2cfcbe
Showing 10 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Behat/Context/AdminContext.php
Original file line number Diff line number Diff line change
@@ -161,6 +161,6 @@ public function castWordToNumber(string $word): int

private function getAdminManager(): ManagerInterface
{
return $this->getContainer()->get('admin.manager');
return $this->getContainer()->get('test.admin.manager');
}
}
2 changes: 1 addition & 1 deletion Behat/Context/FiltersContext.php
Original file line number Diff line number Diff line change
@@ -246,7 +246,7 @@ private function getDataSource(AdminListElement $adminElement)

private function clearDataSource(AdminListElement $element): void
{
$this->getContainer()->get('datasource.factory')->clearDataSource($element->getId());
$this->getContainer()->get('test.datasource.factory')->clearDataSource($element->getId());
}

private function getFiltersElement(): Filters
18 changes: 10 additions & 8 deletions Behat/Context/ResourceContext.php
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@

use Behat\Gherkin\Node\TableNode;
use Behat\Symfony2Extension\Context\KernelAwareContext;
use FSi\Bundle\ResourceRepositoryBundle\Repository\MapBuilder;
use SensioLabs\Behat\PageObjectExtension\Context\PageObjectContext;
use Symfony\Component\HttpKernel\KernelInterface;

@@ -37,16 +38,12 @@ public function setKernel(KernelInterface $kernel): void
public function thereAreFollowingResourcesAddedToResourceMap(TableNode $resources)
{
foreach ($resources->getHash() as $resource) {
expect($this->kernel->getContainer()
->get('fsi_resource_repository.map_builder')
->hasResource($resource['Key']))->toBe(true);
expect($this->getResourceMapBuilder()->hasResource($resource['Key']))->toBe(true);

if (isset($resource['Type'])) {
expect($this->kernel->getContainer()
->get('fsi_resource_repository.map_builder')
->getResource($resource['Key']))->toBeAnInstanceOf(
sprintf('FSi\Bundle\ResourceRepositoryBundle\Repository\Resource\Type\%sType', ucfirst($resource['Type']))
);
expect($this->getResourceMapBuilder()->getResource($resource['Key']))->toBeAnInstanceOf(
sprintf('FSi\Bundle\ResourceRepositoryBundle\Repository\Resource\Type\%sType', ucfirst($resource['Type']))
);
}
}
}
@@ -66,4 +63,9 @@ public function iShouldSeeFormFieldWithValue($value)
{
expect($this->getElement('Form')->findField('Content')->getValue())->toBe($value);
}

private function getResourceMapBuilder(): MapBuilder
{
return $this->kernel->getContainer()->get('test.fsi_resource_repository.map_builder');
}
}
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/AdminElementPass.php
Original file line number Diff line number Diff line change
@@ -20,15 +20,15 @@ class AdminElementPass implements CompilerPassInterface
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('admin.manager')
|| !$container->has('admin.manager.visitor.element_collection')
|| !$container->hasDefinition('admin.manager.visitor.element_collection')
) {
return;
}

$elements = [];
$elementServices = $container->findTaggedServiceIds('admin.element');
foreach (array_keys($elementServices) as $id) {
$elements[] = new Reference($id);
$elements[] = new Reference((string) $id);
}

$container->findDefinition('admin.manager.visitor.element_collection')
2 changes: 1 addition & 1 deletion FSiAdminBundle.php
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public function build(ContainerBuilder $container): void
new AnnotationReader(),
new AdminClassFinder()
));
$container->addCompilerPass(new AdminElementPass(), PassConfig::TYPE_REMOVE);
$container->addCompilerPass(new AdminElementPass());
$container->addCompilerPass(new KnpMenuBuilderPass());
$container->addCompilerPass(new ResourceRepositoryPass());
$container->addCompilerPass(new ManagerVisitorPass());
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@
"ocramius/proxy-manager": "^2.1"
},
"require-dev": {
"symfony/class-loader": "^2.3|^3.0",
"symfony/class-loader": "^2.3|^3.0|^4.0",
"symfony/monolog-bundle": "^2.3|^3.0|^4.0",
"symfony/yaml": "^2.7.1|^3.0|^4.0",
"symfony/var-dumper": "^2.6|^3.0|^4.0",
6 changes: 3 additions & 3 deletions features/fixtures/project/app/config/config.yml
Original file line number Diff line number Diff line change
@@ -19,9 +19,9 @@ doctrine:
driver: pdo_sqlite
user: admin
charset: UTF8
path: %kernel.root_dir%/data.sqlite
path: "%kernel.root_dir%/data.sqlite"
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true

fsi_resource_repository:
@@ -41,4 +41,4 @@ monolog:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
channels: ["!event"]
Original file line number Diff line number Diff line change
@@ -75,11 +75,15 @@
<tag name="admin.element" />
</service>

<service id="datasource.factory" class="FSi\FixturesBundle\DataSource\DataSourceFactory">
<service id="test.datasource.factory" class="FSi\FixturesBundle\DataSource\DataSourceFactory" public="true">
<argument type="service" id="datasource.driver.factory.manager" />
<argument type="collection">
<argument type="service" id="datasource.extension" />
</argument>
</service>

<service id="test.admin.manager" alias="admin.manager" public="true" />

<service id="test.fsi_resource_repository.map_builder" alias="fsi_resource_repository.map_builder" public="true" />
</services>
</container>
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
use FSi\Bundle\AdminBundle\Admin\Context\Request\HandlerInterface;
use FSi\Bundle\AdminBundle\Admin\CRUD\ListElement;
use FSi\Component\DataGrid\DataGridInterface;
use FSi\Component\DataGrid\DataGridViewInterface;
use FSi\Component\DataSource\DataSourceInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
@@ -26,10 +27,12 @@ function let(
ListElement $element,
DataSourceInterface $datasource,
DataGridInterface $datagrid,
DataGridViewInterface $datagridView,
HandlerInterface $handler
) {
$this->beConstructedWith([$handler], 'default_list');
$element->createDataGrid()->willReturn($datagrid);
$datagrid->createView()->willReturn($datagridView);
$element->createDataSource()->willReturn($datasource);
$this->setElement($element);
}
6 changes: 2 additions & 4 deletions spec/FSi/Bundle/AdminBundle/FSiAdminBundleSpec.php
Original file line number Diff line number Diff line change
@@ -33,10 +33,8 @@ function it_add_compiler_pass(ContainerBuilder $builder)
{
$builder->addCompilerPass(Argument::type(AdminAnnotatedElementPass::class))
->shouldBeCalled();
$builder->addCompilerPass(
Argument::type(AdminElementPass::class),
PassConfig::TYPE_REMOVE
)->shouldBeCalled();
$builder->addCompilerPass(Argument::type(AdminElementPass::class))
->shouldBeCalled();
$builder->addCompilerPass(Argument::type(KnpMenuBuilderPass::class))
->shouldBeCalled();
$builder->addCompilerPass(Argument::type(ResourceRepositoryPass::class))

0 comments on commit a2cfcbe

Please sign in to comment.