1 2/** 3 * This file is part of the Phalcon Framework. 4 * 5 * (c) Phalcon Team <team@phalcon.io> 6 * 7 * For the full copyright and license information, please view the LICENSE.txt 8 * file that was distributed with this source code. 9 */ 10 11namespace Phalcon\Cli; 12 13use Phalcon\Di\Injectable; 14use Phalcon\Events\EventsAwareInterface; 15use Phalcon\Events\ManagerInterface; 16/** 17 * Every command-line task should extend this class that encapsulates all the 18 * task functionality 19 * 20 * A task can be used to run "tasks" such as migrations, cronjobs, unit-tests, 21 * or anything that you want. The Task class should at least have a "mainAction" 22 * method. 23 * 24 *```php 25 * class HelloTask extends \Phalcon\Cli\Task 26 * { 27 * // This action will be executed by default 28 * public function mainAction() 29 * { 30 * 31 * } 32 * 33 * public function findAction() 34 * { 35 * 36 * } 37 * } 38 *``` 39 */ 40class Task extends Injectable implements TaskInterface, EventsAwareInterface 41{ 42 protected eventsManager; 43 44 /** 45 * Phalcon\Cli\Task constructor 46 */ 47 final public function __construct() 48 { 49 if method_exists(this, "onConstruct") { 50 this->{"onConstruct"}(); 51 } 52 } 53 54 /** 55 * Returns the internal event manager 56 */ 57 public function getEventsManager() -> <ManagerInterface> | null 58 { 59 return this->eventsManager; 60 } 61 62 /** 63 * Sets the events manager 64 */ 65 public function setEventsManager(<ManagerInterface> eventsManager) -> void 66 { 67 let this->eventsManager = eventsManager; 68 } 69} 70