Skip to content

[FrameworkBundle] Remove support for the bundle:controller:action notation #31702

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

Merged
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
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ FrameworkBundle
* Support for the legacy directory structure in `translation:update` and `debug:translation` commands has been removed.
* Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
* Removed support for `templating` engine in `TemplateController`, use Twig instead
* Removed `ResolveControllerNameSubscriber`.

HttpClient
----------
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ CHANGELOG
-----

* Removed support to load translation resources from the legacy directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`
* Removed `ControllerNameParser`.
* Removed `ResolveControllerNameSubscriber`
* Removed support for `bundle:controller:action` to reference controllers. Use `serviceOrFqcn::method` instead
* Removed support for PHP templating, use Twig instead

4.4.0
Expand Down
146 changes: 0 additions & 146 deletions src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Controller;

use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;

/**
Expand All @@ -23,45 +21,6 @@
*/
class ControllerResolver extends ContainerControllerResolver
{
/**
* @deprecated since Symfony 4.4
*/
protected $parser;

/**
* @param LoggerInterface|null $logger
*/
public function __construct(ContainerInterface $container, $logger = null)
{
if ($logger instanceof ControllerNameParser) {
@trigger_error(sprintf('Passing a "%s" instance as 2nd argument to "%s()" is deprecated since Symfony 4.4, pass a "%s" instance or null instead.', ControllerNameParser::class, __METHOD__, LoggerInterface::class), E_USER_DEPRECATED);
$this->parser = $logger;
$logger = 2 < \func_num_args() ? func_get_arg(2) : null;
} elseif (2 < \func_num_args() && func_get_arg(2) instanceof ControllerNameParser) {
$this->parser = func_get_arg(2);
} elseif ($logger && !$logger instanceof LoggerInterface) {
throw new \TypeError(sprintf('Argument 2 of "%s()" must be an instance of "%s" or null, "%s" given.', __METHOD__, LoggerInterface::class, \is_object($logger) ? \get_class($logger) : \gettype($logger)), E_USER_DEPRECATED);
}

parent::__construct($container, $logger);
}

/**
* {@inheritdoc}
*/
protected function createController($controller)
{
if ($this->parser && false === strpos($controller, '::') && 2 === substr_count($controller, ':')) {
// controller in the a:b:c notation then
$deprecatedNotation = $controller;
$controller = $this->parser->parse($deprecatedNotation, false);

@trigger_error(sprintf('Referencing controllers with %s is deprecated since Symfony 4.1. Use %s instead.', $deprecatedNotation, $controller), E_USER_DEPRECATED);
}

return parent::createController($controller);
}

/**
* {@inheritdoc}
*/
Expand All @@ -77,9 +36,7 @@ private function configureController($controller, string $class)
}
if ($controller instanceof AbstractController) {
if (null === $previousContainer = $controller->setContainer($this->container)) {
@trigger_error(sprintf('Auto-injection of the container for "%s" is deprecated since Symfony 4.2. Configure it as a service instead.', $class), E_USER_DEPRECATED);
// To be uncommented on Symfony 5:
//throw new \LogicException(sprintf('"%s" has no container set, did you forget to define it as a service subscriber?', $class));
throw new \LogicException(sprintf('"%s" has no container set, did you forget to define it as a service subscriber?', $class));
} else {
$controller->setContainer($previousContainer);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<service id="routing.loader" class="Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader" public="true">
<argument type="service" id="routing.resolver" />
<argument type="collection" />
<argument type="service" id=".legacy_controller_name_converter" /> <!-- deprecated since Symfony 4.4 -->
</service>

<service id="router.default" class="Symfony\Bundle\FrameworkBundle\Routing\Router">
Expand Down
20 changes: 0 additions & 20 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@
<services>
<defaults public="false" />

<service id=".legacy_controller_name_converter" class="Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser">
<tag name="monolog.logger" channel="request" />
<argument type="service" id="kernel" />
<argument>false</argument>
</service>

<service id="controller_name_converter" alias=".legacy_controller_name_converter">
<deprecated>The "%alias_id%" service is deprecated since Symfony 4.3.</deprecated>
</service>

<service id="controller_resolver" class="Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver">
<tag name="monolog.logger" channel="request" />
<argument type="service" id="service_container" />
<argument type="service" id="logger" on-invalid="ignore" />
<argument type="service" id=".legacy_controller_name_converter" />
</service>

<service id="argument_metadata_factory" class="Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadataFactory" />
Expand Down Expand Up @@ -86,15 +75,6 @@
<tag name="kernel.event_subscriber" />
</service>

<service id=".legacy_resolve_controller_name_subscriber" class="Symfony\Bundle\FrameworkBundle\EventListener\ResolveControllerNameSubscriber">
<argument type="service" id=".legacy_controller_name_converter" />
<argument>false</argument>
<tag name="kernel.event_subscriber" />
</service>
<service id="resolve_controller_name_subscriber" alias=".legacy_resolve_controller_name_subscriber">
<deprecated>The "%alias_id%" service is deprecated since Symfony 4.3.</deprecated>
</service>

<service id="disallow_search_engine_index_response_listener" class="Symfony\Component\HttpKernel\EventListener\DisallowRobotsIndexingListener">
<tag name="kernel.event_subscriber" />
</service>
Expand Down
32 changes: 1 addition & 31 deletions src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Bundle\FrameworkBundle\Routing;

use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Component\Config\Exception\LoaderLoadException;
use Symfony\Component\Config\Loader\DelegatingLoader as BaseDelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolverInterface;
Expand All @@ -28,28 +27,11 @@
*/
class DelegatingLoader extends BaseDelegatingLoader
{
/**
* @deprecated since Symfony 4.4
*/
protected $parser;
private $loading = false;
private $defaultOptions;

/**
* @param LoaderResolverInterface $resolver
* @param array $defaultOptions
*/
public function __construct($resolver, $defaultOptions = [])
public function __construct(LoaderResolverInterface $resolver, array $defaultOptions = [])
{
if ($resolver instanceof ControllerNameParser) {
@trigger_error(sprintf('Passing a "%s" instance as first argument to "%s()" is deprecated since Symfony 4.4, pass a "%s" instance instead.', ControllerNameParser::class, __METHOD__, LoaderResolverInterface::class), E_USER_DEPRECATED);
$this->parser = $resolver;
$resolver = $defaultOptions;
$defaultOptions = 2 < \func_num_args() ? func_get_arg(2) : [];
} elseif (2 < \func_num_args() && func_get_arg(2) instanceof ControllerNameParser) {
$this->parser = func_get_arg(2);
}

$this->defaultOptions = $defaultOptions;

parent::__construct($resolver);
Expand Down Expand Up @@ -99,18 +81,6 @@ public function load($resource, $type = null)
continue;
}

if ($this->parser && 2 === substr_count($controller, ':')) {
$deprecatedNotation = $controller;

try {
$controller = $this->parser->parse($controller, false);

@trigger_error(sprintf('Referencing controllers with %s is deprecated since Symfony 4.1, use "%s" instead.', $deprecatedNotation, $controller), E_USER_DEPRECATED);
} catch (\InvalidArgumentException $e) {
// unable to optimize unknown notation
}
}

if (1 === substr_count($controller, ':')) {
$nonDeprecatedNotation = str_replace(':', '::', $controller);
// TODO deprecate this in 5.1
Expand Down
Loading