Skip to content

Commit

Permalink
Merge pull request fsi-open#317 from chives/dev
Browse files Browse the repository at this point in the history
Symfony >= 3.4 compatibility
  • Loading branch information
rn0 authored Jan 9, 2018
2 parents 08e849f + a5234ea commit 8100d0c
Show file tree
Hide file tree
Showing 21 changed files with 76 additions and 52 deletions.
8 changes: 8 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---
build:
nodes:
analysis:
project_setup:
override: true
tests:
override: [php-scrutinizer-run]

filter:
excluded_paths: [vendor/*, app/*, web/*, Behat/*, spec/*, features/*]

Expand Down
2 changes: 1 addition & 1 deletion Behat/Context/AdminContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions Behat/Context/ResourceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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']))
);
}
}
}
Expand All @@ -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
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions Doctrine/Admin/ElementImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ trait ElementImpl
*/
protected $registry;

abstract public function getClassName(): string;

public function setManagerRegistry(ManagerRegistry $registry): void
{
$this->registry = $registry;
Expand Down
9 changes: 8 additions & 1 deletion EventListener/MainMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ public function __construct(ManagerInterface $manager, string $configFilePath)

public function createMainMenu(MenuEvent $event): Item
{
$config = $this->yaml->parse(file_get_contents($this->configFilePath), true, true);
if (defined('Symfony\Component\Yaml\Yaml::PARSE_OBJECT')) {
$config = $this->yaml->parse(
file_get_contents($this->configFilePath),
Yaml::PARSE_OBJECT | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE
);
} else {
$config = $this->yaml->parse(file_get_contents($this->configFilePath), true, true);
}

if (!isset($config['menu'])) {
throw new InvalidYamlStructureException(
Expand Down
2 changes: 1 addition & 1 deletion FSiAdminBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</service>

<!-- Controllers -->
<service id="admin.controller.abstract" class="%admin.controller.abstract.class%" abstract="true">
<service id="admin.controller.abstract" class="%admin.controller.abstract.class%" abstract="true" public="true">
<argument type="service" id="templating"/>
<argument type="service" id="admin.context.manager"/>
<argument type="service" id="event_dispatcher"/>
Expand All @@ -101,7 +101,7 @@
<argument>%admin.templates.resource%</argument>
</service>

<service id="admin.controller.admin" class="%admin.controller.admin.class%">
<service id="admin.controller.admin" class="%admin.controller.admin.class%" public="true">
<argument type="service" id="templating"/>
<argument type="service" id="router"/>
<argument>%admin.templates.index_page%</argument>
Expand Down
40 changes: 20 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
],
"require": {
"php": ">=7.1",
"symfony/framework-bundle" : "^2.4|^3.0",
"symfony/form" : "^2.3|^3.0",
"symfony/intl" : "^2.6|^3.0",
"symfony/asset": "^2.7|^3.0",
"symfony/options-resolver": "^2.6|^3.0",
"symfony/expression-language": "^2.6|^3.0",
"symfony/http-foundation": "^2.6|^3.0",
"symfony/dependency-injection": "^2.6.2|^3.0",
"symfony/validator": "^2.3|^3.0",
"symfony/proxy-manager-bridge": "^2.3|^3.0",
"symfony/doctrine-bridge": "^2.3|^3.0",
"symfony/twig-bridge": "^2.6|^3.0",
"symfony/translation": "^2.4|^3.0",
"symfony/templating": "^2.4|^3.0",
"sensio/framework-extra-bundle": "^3.0",
"symfony/twig-bundle": "^2.3|^3.0",
"symfony/framework-bundle" : "^2.4|^3.0|^4.0",
"symfony/form" : "^2.3|^3.0|^4.0",
"symfony/intl" : "^2.6|^3.0|^4.0",
"symfony/asset": "^2.7|^3.0|^4.0",
"symfony/options-resolver": "^2.6|^3.0|^4.0",
"symfony/expression-language": "^2.6|^3.0|^4.0",
"symfony/http-foundation": "^2.6|^3.0|^4.0",
"symfony/dependency-injection": "^2.6.2|^3.0|^4.0",
"symfony/validator": "^2.3|^3.0|^4.0",
"symfony/proxy-manager-bridge": "^2.3|^3.0|^4.0",
"symfony/doctrine-bridge": "^2.3|^3.0|^4.0",
"symfony/twig-bridge": "^2.6|^3.0|^4.0",
"symfony/translation": "^2.4|^3.0|^4.0",
"symfony/templating": "^2.4|^3.0|^4.0",
"sensio/framework-extra-bundle": "^3.0|^4.0",
"symfony/twig-bundle": "^2.3|^3.0|^4.0",
"fsi/datagrid-bundle" : "^1.2|^2.0@dev",
"fsi/datasource-bundle": "^2.0@dev",
"knplabs/knp-menu-bundle": "^2.0",
Expand All @@ -44,10 +44,10 @@
"ocramius/proxy-manager": "^2.1"
},
"require-dev": {
"symfony/class-loader": "^2.3|^3.0",
"symfony/monolog-bundle": "^2.3|^3.0",
"symfony/yaml": "^2.7.1|^3.0",
"symfony/var-dumper": "^2.6|^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",
"ext-pdo_sqlite": "*",
"fsi/resource-repository-bundle": "^1.1.5|^2.0@dev",
"fsi/datagrid": "^1.3|^2.0@dev",
Expand Down
6 changes: 3 additions & 3 deletions features/fixtures/project/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Up @@ -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
Expand Up @@ -76,7 +76,7 @@ function it_return_response_from_handler(
->shouldReturnAnInstanceOf(Response::class);
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveKeyInArray' => function($subject, $key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function it_throws_exception_when_adding_is_not_allowed(
$this->shouldThrow(NotFoundHttpException::class)->during('handleRequest', [$request]);
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveKeyInArray' => function($subject, $key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -82,7 +85,7 @@ function it_return_response_from_handler(
->shouldReturnAnInstanceOf(Response::class);
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveKeyInArray' => function($subject, $key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function it_returns_response_from_handler(HandlerInterface $handler, Request $re
->shouldReturnAnInstanceOf(Response::class);
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveKeyInArray' => function($subject, $key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function it_return_response_from_handler(
->shouldReturnAnInstanceOf(Response::class);
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveKeyInArray' => function($subject, $key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function it_creates_display_view_with_decorated_values()
$this->getData()->shouldHaveProperty($now->format('Y-m-d'), 'Date');
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveProperty' => function($subject, $value, $label) {
Expand Down
2 changes: 1 addition & 1 deletion spec/FSi/Bundle/AdminBundle/Display/SimpleDisplaySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function it_creates_data_for_object()
$this->getData()->shouldHaveProperty('Piotr', 'First Name');
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveProperty' => function($subject, $value, $label) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function it_build_menu()
$offerItem->getOption('elements')[1]->getId()->shouldReturn('product');
}

public function getMatchers()
public function getMatchers(): array
{
return [
'haveItem' => function(Item $menu, $itemName, $elementId = false) {
Expand Down
6 changes: 2 additions & 4 deletions spec/FSi/Bundle/AdminBundle/FSiAdminBundleSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8100d0c

Please sign in to comment.