Merge branch '3.4' into 4.1
* 3.4: fix authorization checker variable name [Routing] Remove duplicate schemes and methods for invokable controllers [Bridge/PhpUnit] fix the fix
This commit is contained in:
commit
b178266bcd
@ -89,6 +89,9 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
|
|||||||
|
|
||||||
@mkdir($PHPUNIT_DIR, 0777, true);
|
@mkdir($PHPUNIT_DIR, 0777, true);
|
||||||
chdir($PHPUNIT_DIR);
|
chdir($PHPUNIT_DIR);
|
||||||
|
if (file_exists("phpunit-$PHPUNIT_VERSION")) {
|
||||||
|
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
|
||||||
|
}
|
||||||
passthru("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\"");
|
passthru("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit phpunit-$PHPUNIT_VERSION \"$PHPUNIT_VERSION.*\"");
|
||||||
chdir("phpunit-$PHPUNIT_VERSION");
|
chdir("phpunit-$PHPUNIT_VERSION");
|
||||||
if ($SYMFONY_PHPUNIT_REMOVE) {
|
if ($SYMFONY_PHPUNIT_REMOVE) {
|
||||||
|
@ -120,12 +120,9 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (0 === $collection->count() && $class->hasMethod('__invoke')) {
|
if (0 === $collection->count() && $class->hasMethod('__invoke')) {
|
||||||
|
$globals = $this->resetGlobals();
|
||||||
foreach ($this->reader->getClassAnnotations($class) as $annot) {
|
foreach ($this->reader->getClassAnnotations($class) as $annot) {
|
||||||
if ($annot instanceof $this->routeAnnotationClass) {
|
if ($annot instanceof $this->routeAnnotationClass) {
|
||||||
$globals['path'] = '';
|
|
||||||
$globals['name'] = '';
|
|
||||||
$globals['localized_paths'] = array();
|
|
||||||
|
|
||||||
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
|
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,18 +251,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
|
|
||||||
protected function getGlobals(\ReflectionClass $class)
|
protected function getGlobals(\ReflectionClass $class)
|
||||||
{
|
{
|
||||||
$globals = array(
|
$globals = $this->resetGlobals();
|
||||||
'path' => null,
|
|
||||||
'localized_paths' => array(),
|
|
||||||
'requirements' => array(),
|
|
||||||
'options' => array(),
|
|
||||||
'defaults' => array(),
|
|
||||||
'schemes' => array(),
|
|
||||||
'methods' => array(),
|
|
||||||
'host' => '',
|
|
||||||
'condition' => '',
|
|
||||||
'name' => '',
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) {
|
if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) {
|
||||||
if (null !== $annot->getName()) {
|
if (null !== $annot->getName()) {
|
||||||
@ -310,6 +296,22 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
return $globals;
|
return $globals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function resetGlobals()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'path' => null,
|
||||||
|
'localized_paths' => array(),
|
||||||
|
'requirements' => array(),
|
||||||
|
'options' => array(),
|
||||||
|
'defaults' => array(),
|
||||||
|
'schemes' => array(),
|
||||||
|
'methods' => array(),
|
||||||
|
'host' => '',
|
||||||
|
'condition' => '',
|
||||||
|
'name' => '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition)
|
protected function createRoute($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition)
|
||||||
{
|
{
|
||||||
return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
|
return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
|
||||||
|
@ -5,7 +5,7 @@ namespace Symfony\Component\Routing\Tests\Fixtures\AnnotationFixtures;
|
|||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/here", name="lol")
|
* @Route("/here", name="lol", methods={"GET", "POST"}, schemes={"https"})
|
||||||
*/
|
*/
|
||||||
class InvokableController
|
class InvokableController
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,8 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||||||
$routes = $this->loader->load(InvokableController::class);
|
$routes = $this->loader->load(InvokableController::class);
|
||||||
$this->assertCount(1, $routes);
|
$this->assertCount(1, $routes);
|
||||||
$this->assertEquals('/here', $routes->get('lol')->getPath());
|
$this->assertEquals('/here', $routes->get('lol')->getPath());
|
||||||
|
$this->assertEquals(array('GET', 'POST'), $routes->get('lol')->getMethods());
|
||||||
|
$this->assertEquals(array('https'), $routes->get('lol')->getSchemes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvokableLocalizedControllerLoading()
|
public function testInvokableLocalizedControllerLoading()
|
||||||
@ -134,7 +136,7 @@ class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
|||||||
$this->assertEquals('/the/path', $routes->get('post')->getPath());
|
$this->assertEquals('/the/path', $routes->get('post')->getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLocalizedMethodActionControllers()
|
public function testInvokableClassRouteLoadWithMethodAnnotation()
|
||||||
{
|
{
|
||||||
$routes = $this->loader->load(LocalizedMethodActionControllers::class);
|
$routes = $this->loader->load(LocalizedMethodActionControllers::class);
|
||||||
$this->assertCount(4, $routes);
|
$this->assertCount(4, $routes);
|
||||||
|
@ -28,17 +28,17 @@ class GuardListener
|
|||||||
private $configuration;
|
private $configuration;
|
||||||
private $expressionLanguage;
|
private $expressionLanguage;
|
||||||
private $tokenStorage;
|
private $tokenStorage;
|
||||||
private $authenticationChecker;
|
private $authorizationChecker;
|
||||||
private $trustResolver;
|
private $trustResolver;
|
||||||
private $roleHierarchy;
|
private $roleHierarchy;
|
||||||
private $validator;
|
private $validator;
|
||||||
|
|
||||||
public function __construct(array $configuration, ExpressionLanguage $expressionLanguage, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authenticationChecker, AuthenticationTrustResolverInterface $trustResolver, RoleHierarchyInterface $roleHierarchy = null, ValidatorInterface $validator = null)
|
public function __construct(array $configuration, ExpressionLanguage $expressionLanguage, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authorizationChecker, AuthenticationTrustResolverInterface $trustResolver, RoleHierarchyInterface $roleHierarchy = null, ValidatorInterface $validator = null)
|
||||||
{
|
{
|
||||||
$this->configuration = $configuration;
|
$this->configuration = $configuration;
|
||||||
$this->expressionLanguage = $expressionLanguage;
|
$this->expressionLanguage = $expressionLanguage;
|
||||||
$this->tokenStorage = $tokenStorage;
|
$this->tokenStorage = $tokenStorage;
|
||||||
$this->authenticationChecker = $authenticationChecker;
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
$this->trustResolver = $trustResolver;
|
$this->trustResolver = $trustResolver;
|
||||||
$this->roleHierarchy = $roleHierarchy;
|
$this->roleHierarchy = $roleHierarchy;
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
@ -94,7 +94,7 @@ class GuardListener
|
|||||||
return $role->getRole();
|
return $role->getRole();
|
||||||
}, $roles),
|
}, $roles),
|
||||||
// needed for the is_granted expression function
|
// needed for the is_granted expression function
|
||||||
'auth_checker' => $this->authenticationChecker,
|
'auth_checker' => $this->authorizationChecker,
|
||||||
// needed for the is_* expression function
|
// needed for the is_* expression function
|
||||||
'trust_resolver' => $this->trustResolver,
|
'trust_resolver' => $this->trustResolver,
|
||||||
// needed for the is_valid expression function
|
// needed for the is_valid expression function
|
||||||
|
Reference in New Issue
Block a user