Skip to content

[FrameworkBundle] Add ControllerHelper; the helpers from AbstractController as a standalone service #60857

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
merged 1 commit into from
Jun 27, 2025
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 src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
7.4
---

* Add `ControllerHelper`; the helpers from AbstractController as a standalone service
* Allow using their name without added suffix when using `#[Target]` for custom services
* Deprecate `Symfony\Bundle\FrameworkBundle\Console\Application::add()` in favor of `Symfony\Bundle\FrameworkBundle\Console\Application::addCommand()`
* Add `assertEmailAddressNotContains()` to the `MailerAssertionsTrait`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,6 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
return $previous;
}

/**
* Gets a container parameter by its name.
*/
protected function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null
{
if (!$this->container->has('parameter_bag')) {
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));
}

return $this->container->get('parameter_bag')->get($name);
}

public static function getSubscribedServices(): array
{
return [
Expand All @@ -96,6 +84,18 @@ public static function getSubscribedServices(): array
];
}

/**
* Gets a container parameter by its name.
*/
protected function getParameter(string $name): array|bool|string|int|float|\UnitEnum|null
{
if (!$this->container->has('parameter_bag')) {
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));
}

return $this->container->get('parameter_bag')->get($name);
}

/**
* Generates a URL from the given parameters.
*
Expand Down
Loading
Loading