Skip to content

Commit e254719

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Deprecate the get() and has() shortcuts of AbstractController
2 parents 976aa17 + 3fa34a9 commit e254719

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
@@ -853,14 +853,15 @@ method::
853853

854854
use App\Form\TaskType;
855855
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
856+
use Symfony\Component\Form\FormFactoryInterface;
856857
// ...
857858

858859
class TaskController extends AbstractController
859860
{
860-
public function new(): Response
861+
public function new(FormFactoryInterface $formFactory): Response
861862
{
862863
$task = ...;
863-
$form = $this->get('form.factory')->createNamed('my_name', TaskType::class, $task);
864+
$form = $formFactory->createNamed('my_name', TaskType::class, $task);
864865

865866
// ...
866867
}

0 commit comments

Comments
 (0)