Skip to content
This repository has been archived by the owner on Dec 9, 2017. It is now read-only.

Commit

Permalink
feature #5 Drop support for old versions (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

|Q            |A  |
|---          |---|
|Bug Fix?     |no |
|New Feature? |yes|
|BC Breaks?   |yes|
|Deprecations?|no |
|Fixed Tickets|   |

Support for the latest Datagrid component, support for Symfony 2.3 is dropped, at least Symfony 2.7 is required, and Symfony 3.0 is now possible.

Commits
-------

ac2d95c Drop support for old versions
b7ea17a Fix failing tests for DEPENDENCIES='low'
  • Loading branch information
sstok committed Feb 16, 2016
2 parents 0065ee9 + b7ea17a commit 0809dae
Show file tree
Hide file tree
Showing 31 changed files with 720 additions and 481 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ matrix:
env: DEPENDENCIES='low'
- php: 5.6
env: DEPENDENCIES='dev'
- php: 5.6
env: SYMFONY_VERSION=3.0.*
allow_failures:
- php: 7.0
- env: DEPENDENCIES='dev'
fast_finish: true

sudo: false

cache:
directories:
- $HOME/.composer/cache
- $HOME/.composer/cache/files

before_install:
- composer selfupdate
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;

install:
- export SYMFONY_DEPRECATIONS_HELPER=weak
Expand Down
23 changes: 23 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
UPGRADE
=======

## Upgrade FROM 0.4 to 0.5

This version is compatible with Rollerworks Datagrid 0.8, which contains
some major BC breaks! Please see the [component upgrade](https://github.com/rollerworks/datagrid/blob/v0.8.1/UPGRADE.md)
instructions for more information.

* Support for Symfony 2.3 is dropped, you need at least Symfony 2.7 LTS or Symfony 3

* The extension tags are renamed to follow the changes in the component.

* `rollerworks_datagrid.column_type` is renamed to `rollerworks_datagrid.type`
* `rollerworks_datagrid.column_extension` is renamed to `rollerworks_datagrid.type_extension`.

* The `alias` argument of `rollerworks_datagrid.column_extension` is renamed to `extended_type`.

* The `alias` argument of `rollerworks_datagrid.type` is no longer required, and should be removed.
The FQCN is used as the type name now.

* The `rollerworks_datagrid.extension` is no longer supported, you need to register your types
and types extensions directly as services with the correct tags.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
],
"require": {
"php": ">=5.5.0",
"rollerworks/datagrid": "~0.7",
"rollerworks/datagrid-twig": "~0.4",
"symfony/framework-bundle": "~2.3",
"symfony/twig-bundle": "~2.3"
"rollerworks/datagrid": "~0.8",
"rollerworks/datagrid-twig": "^0.5.1",
"symfony/framework-bundle": "^2.7.9|^3.0.1",
"symfony/dependency-injection": "^2.7.9|^3.0.1",
"symfony/twig-bundle": "~2.7|~3.0"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "^0.7.3",
"symfony/browser-kit": "^2.7.9|~3.0",
"symfony/css-selector": "^2.7.9|~3.0",
"matthiasnoback/symfony-dependency-injection-test": "^0.7.4",
"matthiasnoback/symfony-service-definition-validator": "^1.2.2"
},
"autoload": {
Expand All @@ -35,12 +38,9 @@
"Rollerworks\\Bundle\\DatagridBundle\\Tests\\": "tests/"
}
},
"config": {
"bin-dir": "bin"
},
"extra": {
"branch-alias": {
"dev-master": "0.4-dev"
"dev-master": "0.5-dev"
}
},
"minimum-stability": "dev",
Expand Down
7 changes: 7 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
<ini name="intl.default_locale" value="en"/>
<ini name="intl.error_level" value="0"/>
<ini name="memory_limit" value="-1"/>

<!--
Disable E_USER_DEPRECATED, else composer.json needs to be very verbose
when using `DEPENDENCIES='low'`. This can be removed when support for Symfony 2 is dropped.
-->
<!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
<ini name="error_reporting" value="-16385"/>
</php>

<testsuites>
Expand Down
82 changes: 33 additions & 49 deletions src/DependencyInjection/Compiler/ExtensionPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@

namespace Rollerworks\Bundle\DatagridBundle\DependencyInjection\Compiler;

use Rollerworks\Component\Datagrid\Twig\Extension\DatagridExtension as TwigDatagridExtension;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

/**
* Adds all services with the tags "rollerworks_datagrid.column_type" and "rollerworks_datagrid.column_extension" as
* Adds all services with the tags "rollerworks_datagrid.type" and "rollerworks_datagrid.type_extension" as
* arguments of the "rollerworks_datagrid.extension" service.
*
* @author Sebastiaan Stok <[email protected]>
Expand All @@ -36,59 +33,46 @@ public function process(ContainerBuilder $container)

$definition = $container->getDefinition('rollerworks_datagrid.extension');

$this->processTwig($container);
$this->processExtensions($container);
$this->processTypes($definition, $container);
$this->processTypeExtensions($definition, $container);
}

private function processTwig(ContainerBuilder $container)
{
$reflection = new \ReflectionClass(TwigDatagridExtension::class);
$extensionFolder = dirname(dirname(dirname($reflection->getFileName())));

$container->getDefinition('twig.loader.filesystem')->addMethodCall(
'addPath',
[$extensionFolder.'/Resources/theme']
);
}

private function processExtensions(ContainerBuilder $container)
{
if (!$container->hasDefinition('rollerworks_datagrid.registry')) {
return;
}

$definition = $container->getDefinition('rollerworks_datagrid.registry');
$extensions = $definition->getArgument(0);

foreach (array_keys($container->findTaggedServiceIds('rollerworks_datagrid.extension')) as $serviceId) {
$extensions[] = new Reference($serviceId);
}

$definition->replaceArgument(0, $extensions);
}

private function processTypes(Definition $definition, ContainerBuilder $container)
{
// Builds an array with fully-qualified type class names as keys and service IDs as values
$types = [];

foreach ($container->findTaggedServiceIds('rollerworks_datagrid.column_type') as $serviceId => $tag) {
$alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId;
// Flip, because we want tag aliases (= type identifiers) as keys
$types[$alias] = $serviceId;
foreach ($container->findTaggedServiceIds('rollerworks_datagrid.type') as $serviceId => $tag) {
$serviceDefinition = $container->getDefinition($serviceId);
if (!$serviceDefinition->isPublic()) {
throw new \InvalidArgumentException(
sprintf('The service "%s" must be public as datagrid types are lazy-loaded.', $serviceId)
);
}

// Support type access by FQCN
$types[$serviceDefinition->getClass()] = $serviceId;
}

$definition->replaceArgument(1, $types);
}

private function processTypeExtensions(Definition $definition, ContainerBuilder $container)
{
$typeExtensions = [];

foreach ($container->findTaggedServiceIds('rollerworks_datagrid.column_extension') as $serviceId => $tag) {
$alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId;
$typeExtensions[$alias][] = $serviceId;
foreach ($container->findTaggedServiceIds('rollerworks_datagrid.type_extension') as $serviceId => $tag) {
$serviceDefinition = $container->getDefinition($serviceId);
if (!$serviceDefinition->isPublic()) {
throw new \InvalidArgumentException(
sprintf('The service "%s" must be public as datagrid type extensions are lazy-loaded.', $serviceId)
);
}

if (isset($tag[0]['extended_type'])) {
$extendedType = $tag[0]['extended_type'];
} else {
throw new \InvalidArgumentException(
sprintf(
'Tagged datagrid type extension must have the extended type configured using the '.
'extended_type/extended-type attribute, none was configured for the "%s" service.',
$serviceId
)
);
}

$typeExtensions[$extendedType][] = $serviceId;
}

$definition->replaceArgument(2, $typeExtensions);
Expand Down
43 changes: 0 additions & 43 deletions src/DependencyInjection/Compiler/RequestUriProviderPass.php

This file was deleted.

38 changes: 38 additions & 0 deletions src/DependencyInjection/Compiler/TwigRenderEnginePass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* 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\Twig\Extension\DatagridExtension as TwigDatagridExtension;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Registers the Datagrid base themes for loading.
*
* @author Sebastiaan Stok <[email protected]>
*/
class TwigRenderEnginePass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$reflection = new \ReflectionClass(TwigDatagridExtension::class);
$extensionFolder = dirname(dirname(dirname($reflection->getFileName())));

$container->getDefinition('twig.loader.filesystem')->addMethodCall(
'addPath',
[$extensionFolder.'/Resources/theme']
);
}
}
Loading

0 comments on commit 0809dae

Please sign in to comment.