예제 #1
0
파일: Console.php 프로젝트: Edjek/LearnAll
 /**
  * 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));
     }
 }
예제 #2
0
파일: Assets.php 프로젝트: Edjek/LearnAll
 public static function write($args, $opts, $console)
 {
     $publicDir = Atomik::path(self::$config['public_assets_dir'], Atomik::get('atomik.dirs.public'), false);
     $checklist = new \ConsoleKit\Widgets\Checklist($console);
     $console->writeln("Writing packages to '{$publicDir}'");
     foreach (array_keys(self::$config['packages']) as $name) {
         $filename = Atomik::path($name, $publicDir, false);
         $checklist->step($filename, function () use($filename, $name) {
             return \ConsoleKit\FileSystem::touch($filename, self::dump($name));
         });
     }
     if (self::$config['allow_file_assets']) {
         $dir = Atomik::path(self::$config['assets_dir']);
         $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
         $console->writeln("Writing files to '{$publicDir}'");
         foreach ($it as $file) {
             if ($file->isDir() || substr($file->getFilename(), 0, 1) === '.') {
                 continue;
             }
             $filename = trim(substr($file->getPathname(), strlen($dir)), DIRECTORY_SEPARATOR);
             $pathname = Atomik::path(substr($filename, 0, strrpos($filename, '.')), $publicDir, false);
             if (in_array($file->getExtension(), (array) self::$config['css_extension'])) {
                 $pathname .= '.css';
             } else {
                 if (in_array($file->getExtension(), (array) self::$config['js_extension'])) {
                     $pathname .= '.js';
                 } else {
                     $pathname .= '.' . $file->getExtension();
                 }
             }
             \ConsoleKit\FileSystem::touch($pathname, self::dump($filename));
         }
     }
     Atomik::fireEvent('Assets::write');
 }