Re-add symfony 2.8 support

This commit is contained in:
Guilhem N 2016-12-29 15:31:10 +01:00
parent af3b77eb9f
commit 9b677f2ff3
No known key found for this signature in database
GPG Key ID: 9E5D2DB67BF054DD
4 changed files with 63 additions and 10 deletions

View File

@ -12,7 +12,6 @@
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class AddDescribersPass implements CompilerPassInterface

View File

@ -12,7 +12,6 @@
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class AddRouteDescribersPass implements CompilerPassInterface

View File

@ -0,0 +1,55 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Trait that allows a generic method to find and sort service by priority option in the tag.
*
* @author Iltar van der Berg <kjarli@gmail.com>
*
* @internal extracted from Symfony, to keep sf 2.8 support.
*/
trait PriorityTaggedServiceTrait
{
/**
* Finds all services with the given tag name and order them by their priority.
*
* The order of additions must be respected for services having the same priority,
* and knowing that the \SplPriorityQueue class does not respect the FIFO method,
* we should not use this class.
*
* @see https://bugs.php.net/bug.php?id=53710
* @see https://bugs.php.net/bug.php?id=60926
*
* @param string $tagName
* @param ContainerBuilder $container
*
* @return Reference[]
*/
private function findAndSortTaggedServices($tagName, ContainerBuilder $container)
{
$services = array();
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) {
foreach ($tags as $attributes) {
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
$services[$priority][] = new Reference($serviceId);
}
}
if ($services) {
krsort($services);
$services = call_user_func_array('array_merge', $services);
}
return $services;
}
}

View File

@ -16,17 +16,17 @@
],
"require": {
"php": "~7.0|~7.1",
"symfony/framework-bundle": "^3.2",
"symfony/framework-bundle": "^2.8|^3.0",
"exsyst/swagger": "~0.2.2"
},
"require-dev": {
"symfony/twig-bundle": "^3.2",
"symfony/console": "^3.2",
"symfony/config": "^3.2",
"symfony/validator": "^3.2",
"symfony/property-access": "^3.2",
"symfony/browser-kit": "^3.2",
"symfony/cache": "^3.2",
"symfony/twig-bundle": "^2.8|^3.0",
"symfony/console": "^2.8|^3.0",
"symfony/config": "^2.8|^3.0",
"symfony/validator": "^2.8|^3.0",
"symfony/property-access": "^2.8|^3.0",
"symfony/browser-kit": "^2.8|^3.0",
"symfony/cache": "^3.1",
"symfony/phpunit-bridge": "^3.2",
"sensio/framework-extra-bundle": "^3.0",
"phpunit/phpunit": "^5.4",