/** * Generate command. * index.php generate action_name [action_name [action_name [...]]] * * @param array $arguments */ public static function generate($args, $opts, $console) { $checklist = new ConsoleKit\Widgets\Checklist($console); foreach ($args as $action) { $console->writeln("Generating '{$action}'"); $filename = ltrim($action, '/') . '.php'; $actionsDir = (array) Atomik::get('atomik.dirs.actions'); $actionsDir = array_shift($actionsDir); $checklist->step("Creating action file in {$actionsDir}", function () use($actionsDir, $filename) { return ConsoleKit\FileSystem::touch(ConsoleKit\FileSystem::join($actionsDir, $filename), "<?php\n\n// Logic goes here\n"); }); $viewsDir = (array) Atomik::get('atomik.dirs.views'); $viewsDir = array_shift($viewsDir); $checklist->step("Creating view file in {$viewsDir}", function () use($viewsDir, $filename) { return ConsoleKit\FileSystem::touch(ConsoleKit\FileSystem::join($viewsDir, $filename)); }); Atomik::fireEvent('Console::Generate', array($action)); } }