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

Commitb89bbca

Browse files
committed
minor#10307 [Console] Remove mentions about the deprecated ContainerAwareCommand (chalasr, javiereguiluz)
This PR was merged into the master branch.Discussion----------[Console] Remove mentions about the deprecated ContainerAwareCommandRelated tosymfony/symfony#28415Commits-------4143835 Maintained a note about ContainerAwareCommand being deprecatedf3e8f0e [WCM][Console] Remove mentions about the deprecated ContainerAwareCommand class
2 parents0e8b06a +4143835 commitb89bbca

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

‎console/commands_as_services.rst‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ recommended setup.
1313
You can also manually register your command as a service by configuring the service
1414
and:doc:`tagging it</service_container/tags>` with ``console.command``.
1515

16-
In either case, if your class extends:class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand`,
17-
you can access public services via ``$this->getContainer()->get('SERVICE_ID')``.
18-
19-
But if your class is registered as a service, you can instead access services by
20-
using normal:ref:`dependency injection<services-constructor-injection>`.
21-
2216
For example, suppose you want to log something from within your command::
2317

2418
namespace App\Command;
@@ -66,6 +60,13 @@ works! You can call the ``app:sunshine`` command and start logging.
6660
work (e.g. making database queries), as that code will be run, even if you're using
6761
the console to execute a different command.
6862

63+
..note::
64+
65+
In previous Symfony versions, you could make the command class extend from
66+
:class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand` to
67+
get services via ``$this->getContainer()->get('SERVICE_ID')``. This is
68+
deprecated in Symfony 4.2 and it won't work in future Symfony versions.
69+
6970
.. _console-command-service-lazy-loading:
7071

7172
Lazy Loading

‎console/style.rst‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Consider for example the code used to display the title of the following command
1313
// src/Command/GreetCommand.php
1414
namespace App\Command;
1515

16-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16+
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Symfony\Component\Console\Output\OutputInterface;
1919

20-
class GreetCommand extendsContainerAwareCommand
20+
class GreetCommand extendsCommand
2121
{
2222
// ...
2323

@@ -53,12 +53,12 @@ title of the command::
5353
// src/Command/GreetCommand.php
5454
namespace App\Command;
5555

56-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
56+
use Symfony\Component\Console\Command\Command;
5757
use Symfony\Component\Console\Style\SymfonyStyle;
5858
use Symfony\Component\Console\Input\InputInterface;
5959
use Symfony\Component\Console\Output\OutputInterface;
6060

61-
class GreetCommand extendsContainerAwareCommand
61+
class GreetCommand extendsCommand
6262
{
6363
// ...
6464

@@ -355,10 +355,11 @@ of your commands to change their appearance::
355355
namespace App\Console;
356356

357357
use App\Console\CustomStyle;
358+
use Symfony\Component\Console\Command\Command;
358359
use Symfony\Component\Console\Input\InputInterface;
359360
use Symfony\Component\Console\Output\OutputInterface;
360361

361-
class GreetCommand extendsContainerAwareCommand
362+
class GreetCommand extendsCommand
362363
{
363364
// ...
364365

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp