Skip to content

Commit c2020bb

Browse files
[FrameworkBundle] Add ControllerHelper; the helpers from AbstractController as a standalone service
1 parent a3c1d1f commit c2020bb

File tree

6 files changed

+557
-13
lines changed

6 files changed

+557
-13
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.4
55
---
66

7+
* Add `ControllerHelper`; the helpers from AbstractController as a standalone service
78
* Allow using their name without added suffix when using `#[Target]` for custom services
89
* Deprecate `Symfony\Bundle\FrameworkBundle\Console\Application::add()` in favor of `Symfony\Bundle\FrameworkBundle\Console\Application::addCommand()`
910
* Add `assertEmailAddressNotContains()` to the `MailerAssertionsTrait`

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
6767
return $previous;
6868
}
6969

70-
/**
71-
* Gets a container parameter by its name.
72-
*/
73-
protected function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null
74-
{
75-
if (!$this->container->has('parameter_bag')) {
76-
throw new ServiceNotFoundException('parameter_bag.', null, null, [], \sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', static::class));
77-
}
78-
79-
return $this->container->get('parameter_bag')->get($name);
80-
}
81-
8270
public static function getSubscribedServices(): array
8371
{
8472
return [
@@ -96,6 +84,18 @@ public static function getSubscribedServices(): array
9684
];
9785
}
9886

87+
/**
88+
* Gets a container parameter by its name.
89+
*/
90+
protected function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null
91+
{
92+
if (!$this->container->has('parameter_bag')) {
93+
throw new ServiceNotFoundException('parameter_bag.', null, null, [], \sprintf('The "%s::getParameter()" method is missing a parameter bag to work properly. Did you forget to register your controller as a service subscriber? This can be fixed either by using autoconfiguration or by manually wiring a "parameter_bag" in the service locator passed to the controller.', static::class));
94+
}
95+
96+
return $this->container->get('parameter_bag')->get($name);
97+
}
98+
9999
/**
100100
* Generates a URL from the given parameters.
101101
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy