diff --git a/en/development/dependency-injection.rst b/en/development/dependency-injection.rst index bb307fb4c9..2e1c8306ce 100644 --- a/en/development/dependency-injection.rst +++ b/en/development/dependency-injection.rst @@ -55,10 +55,13 @@ Command Example :: // In src/Command/CheckUsersCommand.php + use Cake\Console\CommandFactoryInterface; + class CheckUsersCommand extends Command { - public function __construct(public UsersService $users) + public function __construct(protected UsersService $users, ?CommandFactoryInterface $factory = null) { + parent::__construct($factory); } public function execute(Arguments $args, ConsoleIo $io) @@ -73,7 +76,8 @@ Command Example { $container ->add(CheckUsersCommand::class) - ->addArgument(UsersService::class); + ->addArgument(UsersService::class) + ->addArgument(CommandFactoryInterface::class); $container->add(UsersService::class); }