Reputation: 43507
I have some functionality, that I want to add to yii\console\controllers\MessageController::actionExtract()
.
So normally what I have done - extended yii controller with my own controller and placed it to app\commands
directory.
<?php
namespace app\commands;
class MessageController extends \yii\console\controllers\MessageController{ /* .. */ }
For test purposes I added method named actionTest
.
When I do > yii
command, all I get is
Now I copy-pasted exactly same controller and just renamed it to MsgController
. Previous controller left intact.
So now > yii
gives me
yii message/test - 'Unknown command message/test'
yii msg/test - 'OK'
My app\config\console.php has 'controllerNamespace' => 'app\commands'
How should I properly extend MessageController and continue use standard yii command (means not changing controller name to have new command)?
Upvotes: 1
Views: 325
Reputation: 18021
Extend the controller like you did and in console configuration add:
'controllerMap' => [
'message' => 'app\commands\MessageController',
],
Upvotes: 2