| Total Complexity | 6 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | abstract class CliController extends Controller |
||
| 18 | { |
||
| 19 | |||
| 20 | private static $allowed_actions = array( |
||
|
|
|||
| 21 | 'index' |
||
| 22 | ); |
||
| 23 | |||
| 24 | protected function init() |
||
| 25 | { |
||
| 26 | parent::init(); |
||
| 27 | // Unless called from the command line, all CliControllers need ADMIN privileges |
||
| 28 | if (!Director::is_cli() && !Permission::check("ADMIN")) { |
||
| 29 | Security::permissionFailure(); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | public function index() |
||
| 34 | { |
||
| 35 | foreach (ClassInfo::subclassesFor(static::class) as $subclass) { |
||
| 36 | echo $subclass . "\n"; |
||
| 37 | /** @var CliController $task */ |
||
| 38 | $task = Injector::inst()->create($subclass); |
||
| 39 | $task->doInit(); |
||
| 40 | $task->process(); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Overload this method to contain the task logic. |
||
| 46 | */ |
||
| 47 | public function process() |
||
| 49 | } |
||
| 50 | } |
||
| 51 |