Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Routing] Remove duplicate schemes and methods for invokable controllers #29225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions 34 src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,9 @@ public function load($class, $type = null)
}

if (0 === $collection->count() && $class->hasMethod('__invoke')) {
$globals = $this->resetGlobals();
foreach ($this->reader->getClassAnnotations($class) as $annot) {
if ($annot instanceof $this->routeAnnotationClass) {
$globals['path'] = '';
$globals['name'] = '';
$globals['localized_paths'] = array();

$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
}
}
Expand Down Expand Up @@ -254,18 +251,7 @@ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMetho

protected function getGlobals(\ReflectionClass $class)
{
$globals = array(
'path' => null,
'localized_paths' => array(),
'requirements' => array(),
'options' => array(),
'defaults' => array(),
'schemes' => array(),
'methods' => array(),
'host' => '',
'condition' => '',
'name' => '',
);
$globals = $this->resetGlobals();

if ($annot = $this->reader->getClassAnnotation($class, $this->routeAnnotationClass)) {
if (null !== $annot->getName()) {
Expand Down Expand Up @@ -310,6 +296,22 @@ protected function getGlobals(\ReflectionClass $class)
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)
{
return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route("/here", name="lol")
* @Route("/here", name="lol", methods={"GET", "POST"}, schemes={"https"})
*/
class InvokableController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public function testInvokableControllerLoader()
$routes = $this->loader->load(InvokableController::class);
$this->assertCount(1, $routes);
$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()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.