Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit901535c

Browse files
committed
Deprecate the get() and has() shortcuts of AbstractController
1 parent8c54c21 commit901535c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

‎best_practices.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ Use Dependency Injection to Get Services
244244

245245
If you extend the base ``AbstractController``, you can only access to the most
246246
common services (e.g ``twig``, ``router``, ``doctrine``, etc.), directly from the
247-
container via ``$this->container->get()`` or ``$this->get()``.
247+
container via ``$this->container->get()``.
248248
Instead, you must use dependency injection to fetch services by
249249
:ref:`type-hinting action method arguments<controller-accessing-services>` or
250250
constructor arguments.

‎forms.rst‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,14 +857,15 @@ method::
857857

858858
use App\Form\TaskType;
859859
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
860+
use Symfony\Component\Form\FormFactoryInterface;
860861
// ...
861862

862863
class TaskController extends AbstractController
863864
{
864-
public function new(): Response
865+
public function new(FormFactoryInterface $formFactory): Response
865866
{
866867
$task = ...;
867-
$form = $this->get('form.factory')->createNamed('my_name', TaskType::class, $task);
868+
$form = $formFactory->createNamed('my_name', TaskType::class, $task);
868869

869870
// ...
870871
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp