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

Commit

Permalink
refactor #7 Refactor the integration bundle (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|   |

Commits
-------

b2e86e1 Refactor the integration bundle
0db7376 Fix PHPUnit breaks on dep=low
  • Loading branch information
sstok committed Oct 14, 2016
2 parents 36cc9e4 + 0db7376 commit 39631ae
Show file tree
Hide file tree
Showing 40 changed files with 917 additions and 163 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/phpunit.xml
/composer.lock
.php_cs.cache
*.phar
/vendor/
/bin/
Expand Down
33 changes: 13 additions & 20 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';

$header = <<<EOF
This file is part of the RollerworksDatagrid package.
Expand All @@ -9,25 +11,16 @@ This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);
$config = SLLH\StyleCIBridge\ConfigBridge::create()
->setUsingCache(true)
->setRiskyAllowed(true)
;

return Symfony\CS\Config\Config::create()
->setUsingLinter(false)
// use SYMFONY_LEVEL:
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
// and extra fixers:
->fixers(array(
'ordered_use',
//'strict',
'strict_param',
'short_array_syntax',
'phpdoc_order',
'header_comment',
'-psr0',
))
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->exclude(array('bin', 'doc'))
->in(__DIR__)
$config->setRules(
array_merge(
$config->getRules(),
['header_comment' => ['header' => $header]]
)
;
);

return $config;
24 changes: 13 additions & 11 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
preset: symfony

risky: true

enabled:
- strict_param
- ordered_use
- short_array_syntax
#- ordered_class_elements
- ordered_imports
- phpdoc_order

- short_array_syntax
- strict_param
#- declare_strict_types

disabled:
- psr0
- strict

- simplified_null_return # PHP 7.1 compatiblity (void !== null)

finder:
in:
path:
- 'src/'
- 'tests/'
exclude:
- 'bin'
- 'doc'
not-path:
- 'Fixtures'
27 changes: 12 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- hhvm

matrix:
include:
- php: 5.5
- php: 7.0
# Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version
#- php: hhvm-3.12
# sudo: required
# dist: trusty
# group: edge
- php: 7.0
env: DEPENDENCIES='low'
- php: 5.6
- php: 7.1
env: DEPENDENCIES='dev'
- php: 5.6
env: SYMFONY_VERSION=3.0.*
allow_failures:
- env: DEPENDENCIES='dev'
fast_finish: true
Expand All @@ -22,17 +20,16 @@ sudo: false

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

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

install:
- export SYMFONY_DEPRECATIONS_HELPER=weak
- export SYMFONY_DEPRECATIONS_HELPER=strict
- if [ "$DEPENDENCIES" == "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [ "$DEPENDENCIES" != "low" ]; then travis_retry composer update; fi;
- if [ "$DEPENDENCIES" == "low" ]; then travis_retry composer update --prefer-lowest; fi;

script:
- phpunit --configuration phpunit.xml.dist --verbose
- vendor/bin/phpunit --configuration phpunit.xml.dist --verbose
33 changes: 33 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
UPGRADE
=======

## Upgrade FROM 0.5 to 0.6

This version is compatible with Rollerworks Datagrid >=0.11.

Please see the [component upgrade](https://github.com/rollerworks/datagrid/blob/master/UPGRADE.md)
instructions for more information.

* Support for Symfony 2.7 is dropped, you need at least Symfony 3.1 now.

* The `ActionTypeExtension` handling has changed:

* Option `parameters_field_mapping` is renamed to `parameters_mapping`

* Option `redirect_parameters_field_mapping` is renamed to `redirect_parameters_mapping`

* When no `parameters_field_mapping` is configured the values provided by the data-provider
are used as-is for the route parameters, use `null` to provide no route parameters.

The parameters for a redirect-route must still be set explicitly with
`redirect_parameters_mapping` and optionally `redirect_additional_parameters`.

* The `redirect_uri` can now be a bool value. When `true` is passed the current
uri is used (based on the RequestStack) else the `redirect_route` is used to
determine if a redirect must be included in the action's uri.

By default no redirect uri is used now.

**Note:** The twig block-naming convention has changed, see the [twig extension upgrade]
instructions for more information.

[component upgrade]: https://github.com/rollerworks/datagrid/blob/master/UPGRADE.md
[twig extension upgrade]: https://github.com/rollerworks/datagrid/blob/master/UPGRADE.md

## Upgrade FROM 0.4 to 0.5

This version is compatible with Rollerworks Datagrid 0.8, which contains
Expand Down
32 changes: 18 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollerworks/datagrid-bundle",
"description": "Symfony integration bundle for the RollerworksDatagrid component",
"description": "Symfony integration bundle for the Rollerworks Datagrid component",
"keywords": ["rollerworks", "datagrid", "bundle"],
"type": "symfony-bundle",
"license": "MIT",
Expand All @@ -11,22 +11,25 @@
},
{
"name": "Community contributions",
"homepage": "https://github.com/Rollerworks/rollerworks-datagrid-bundle/contributors"
"homepage": "https://github.com/Rollerworks/datagrid-bundle/contributors"
}
],
"require": {
"php": ">=5.5.0",
"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"
"php": "^7.0",
"rollerworks/datagrid": "~0.11",
"rollerworks/datagrid-twig": "^0.6.1",
"symfony/framework-bundle": "^3.1",
"symfony/twig-bundle": "^3.1"
},
"require-dev": {
"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"
"symfony/browser-kit": "^3.0",
"symfony/css-selector": "^3.0",
"matthiasnoback/symfony-dependency-injection-test": "^1.0.0",
"matthiasnoback/symfony-service-definition-validator": "^1.2.6",
"phpunit/phpunit": "^5.6.1",
"phpdocumentor/type-resolver": ">=0.2",

"sllh/php-cs-fixer-styleci-bridge": "^2.1"
},
"autoload": {
"psr-4": {
Expand All @@ -36,11 +39,12 @@
"autoload-dev": {
"psr-4": {
"Rollerworks\\Bundle\\DatagridBundle\\Tests\\": "tests/"
}
},
"files": ["tests/Redis.php"]
},
"extra": {
"branch-alias": {
"dev-master": "0.5-dev"
"dev-master": "0.6-dev"
}
},
"minimum-stability": "dev",
Expand Down
15 changes: 6 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
beStrictAboutTestsThatDoNotTestAnything="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"

convertWarningsToExceptions="false"
convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="date.timezone" value="UTC"/>
<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>
<testsuite name="RollerworksDatagrid Bundle Test Suite">
<testsuite name="RollerworksDatagrid Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
60 changes: 60 additions & 0 deletions src/DependencyInjection/Compiler/DatagridConfiguratorPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);

/*
* This file is part of the RollerworksDatagrid package.
*
* (c) Sebastiaan Stok <s.stok@rollerscapes.net>
*
* 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\DatagridConfiguratorInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;

/**
* Registers Datagrid Configurators for loading.
*
* @author Sebastiaan Stok <s.stok@rollerscapes.net>
*/
class DatagridConfiguratorPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('rollerworks_datagrid.datagrid_registry')) {
return;
}

$definition = $container->getDefinition('rollerworks_datagrid.datagrid_registry');
$mapping = [];

foreach ($container->findTaggedServiceIds('rollerworks_datagrid.datagrid_configurator') as $id => $tag) {
$def = $container->getDefinition($id);

if (!$def->isPublic()) {
throw new InvalidArgumentException(sprintf('The service "%s" must be public as it can be lazy-loaded.', $id));
}

if ($def->isAbstract()) {
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as it can be lazy-loaded.', $id));
}

if (!in_array(DatagridConfiguratorInterface::class, class_implements($def->getClass()), true)) {
throw new InvalidArgumentException(sprintf('The class of service "%s" must implement "%s".', $id, DatagridConfiguratorInterface::class));
}

$mapping[$def->getClass()] = $id;
}

$definition->replaceArgument(1, $mapping);
}
}
Loading

0 comments on commit 39631ae

Please sign in to comment.