/** * Initializes the output handlers. * * @see lithium\console\command\Test::$_handlers * @return void */ protected function _init() { parent::_init(); $self = $this; $this->_handlers += array('txt' => function ($runner, $path) use($self) { $message = sprintf('Running test(s) in `%s`... ', ltrim($path, '\\')); $self->header('Test'); $self->out($message, array('nl' => false)); $report = $runner(); $self->out('done.', 2); $self->out('{:heading}Results{:end}', 0); $self->out($report->render('stats', $report->stats())); foreach ($report->filters() as $filter => $options) { $data = $report->results['filters'][$filter]; $self->out($report->render($options['name'], compact('data'))); } $self->hr(); $self->nl(); return $report; }, 'json' => function ($runner, $path) use($self) { $report = $runner(); if ($results = $report->filters()) { $filters = array(); foreach ($results as $filter => $options) { $filters[$options['name']] = $report->results['filters'][$filter]; } } $self->out($report->render('stats', $report->stats() + compact('filters'))); return $report; }); }
/** * Exercise initialization. * * @return void */ public function _init() { parent::_init(); Libraries::paths(array('exercises' => '{:library}\\extensions\\exercises\\{:name}')); $exercises = Libraries::locate('exercises'); foreach ($exercises as $exercise) { $this->_exercises[$this->exerciseName($exercise)] = $exercise; } }
protected function _init() { parent::_init(); Environment::set($this->env); if (file_exists($this->_config['routes'])) { return require $this->_config['routes']; } $this->error("The routes file for this library doesn't exist or can't be found."); }
protected function _init() { parent::_init(); $this->_library = isset($this->request->library) ? $this->request->library : true; $this->_library = Libraries::get($this->_library); $this->_path = $this->_library['path'] . '/resources/migration'; $this->_migrations = $this->_getMigrations($this->_path); if (isset($this->request->params['connection'])) { $this->_options['connection'] = $this->request->params['connection']; } }
protected function _init() { $gitExec = array(); exec('which git', $gitExec); $this->_gitCommand = isset($gitExec[0]) && is_executable($gitExec[0]) ? $gitExec[0] : 'git'; $this->_appConfig = Libraries::get(true); $this->_appConfig['webroot'] = $this->_appConfig['path'] . '/webroot'; $appRoot = $this->_appConfig['path']; // system("/usr/bin/env -i HOME={$appRoot} > /dev/null 2>&1 &"); parent::_init(); }
public function _init() { parent::_init(); $this->socket = $this->_instance('socket', array('host' => $this->_config['host'], 'port' => $this->_config['port'])); foreach (Libraries::locate('command.bot.plugins') as $class) { if (method_exists($class, 'poll')) { Logger::debug("Registering `poll` method from plugin `{$class}`."); $this->_plugins['poll'][] = new $class($this->_config); } if (method_exists($class, 'process')) { Logger::debug("Registering `process` method from plugin `{$class}`."); $this->_plugins['process'][] = new $class($this->_config); } } }
public function __construct(array $config = array()) { $this->setUp(); parent::__construct($config); }
/** * Initializes the output handlers. * * @see lithium\console\command\Test::$_handlers * @return void */ protected function _init() { parent::_init(); $command = $this; $this->_handlers += array('txt' => function ($runner, $path) use($command) { if (!$command->plain) { $command->header('Test'); $command->out(null, 1); } $colorize = function ($result) { switch (trim($result)) { case '.': return $result; case 'pass': return "{:green}{$result}{:end}"; case 'F': case 'fail': return "{:red}{$result}{:end}"; case 'E': case 'exception': return "{:purple}{$result}{:end}"; case 'S': case 'skip': return "{:cyan}{$result}{:end}"; default: return "{:yellow}{$result}{:end}"; } }; if ($command->verbose) { $reporter = function ($result) use($command, $colorize) { $command->out(sprintf('[%s] on line %4s in %s::%s()', $colorize(sprintf('%9s', $result['result'])), isset($result['line']) ? $result['line'] : '??', isset($result['class']) ? $result['class'] : '??', isset($result['method']) ? $result['method'] : '??')); }; } else { $i = 0; $columns = 60; $reporter = function ($result) use($command, &$i, $columns, $colorize) { $shorten = array('fail', 'skip', 'exception'); if ($result['result'] === 'pass') { $symbol = '.'; } elseif (in_array($result['result'], $shorten)) { $symbol = strtoupper($result['result'][0]); } else { $symbol = '?'; } $command->out($colorize($symbol), false); $i++; if ($i % $columns === 0) { $command->out(); } }; } $report = $runner(compact('reporter')); if (!$command->plain) { $stats = $report->stats(); $command->out(null, 2); $command->out($report->render('result', $stats)); $command->out($report->render('errors', $stats)); if ($command->verbose) { $command->out($report->render('skips', $stats)); } foreach ($report->filters() as $filter => $options) { $data = $report->results['filters'][$filter]; $command->out($report->render($options['name'], compact('data'))); } } return $report; }, 'json' => function ($runner, $path) use($command) { $report = $runner(); if ($results = $report->filters()) { $filters = array(); foreach ($results as $filter => $options) { $filters[$options['name']] = $report->results['filters'][$filter]; } } $command->out($report->render('stats', $report->stats() + compact('filters'))); return $report; }); }
/** * Get an instance of a sub-command * * @param string $name the name of the sub-command to instantiate * @param array $config * @return object; */ protected function _instance($name, array $config = array()) { if ($class = Libraries::locate('command.create', Inflector::camelize($name))) { $this->request->params['template'] = $this->template; return new $class(array('request' => $this->request, 'classes' => $this->_classes)); } return parent::_instance($name, $config); }
/** * Initialize _settings from `--conf`. * * Throws an exception if the command is initialized without a request object * which is needed by `_toPath()` in order to determine the current working directory. * This most often happens if the command is inspected using the `ReflectionClass`. * * @return void */ protected function _init() { parent::_init(); if (!isset($this->request)) { throw new RuntimeException("Command has been initialized without a request object"); } $this->_settings['servers'][$this->server] = true; if (file_exists($this->conf)) { $this->_settings += json_decode($this->conf, true); } $this->path = $this->_toPath($this->path ?: 'libraries/plugins'); $this->force = $this->f ? $this->f : $this->force; }
/** * Class Constrcutor. * * @param string $config */ public function __construct($config = array()) { $this->template = strtolower(join('', array_slice(explode("\\", get_class($this)), -1))); parent::__construct($config); }
public function _init() { parent::_init(); $this->source = $this->source ?: LITHIUM_APP_PATH; $this->destination = $this->destination ?: Libraries::get(true, 'resources') . '/g11n'; }
public function __construct($config) { parent::__construct($config); $this->_library = Libraries::get('li3_hierarchy'); return $this->_cacheDir = $this->_library['path'] . '/resources/tmp/cache'; }
protected function _init() { parent::_init(); $this->source = $this->source ?: Libraries::get(true, 'path'); $this->destination = $this->destination ?: Libraries::get(true, 'resources') . '/g11n'; }
/** * Exit immediately. Primarily used for overrides during testing. * * @param integer|string $status integer range 0 to 254, string printed on exit * @return void */ protected function _stop($status = 0) { if ($this->process['logOpened']) { closelog(); $this->process['logOpened'] = false; } return parent::stop($status); }
public function _init() { parent::_init(); $this->source = $this->source ?: LITHIUM_APP_PATH; $this->destination = $this->destination ?: LITHIUM_APP_PATH . '/resources/g11n'; }
protected function _init() { parent::_init(); Environment::set($this->env); }
/** * Initialize _settings from `--conf`. * * Throws an exception if the command is initialized without a request object * which is needed by `_toPath()` in order to determine the current working directory. * This most often happens if the command is inspected using the `ReflectionClass`. * * @return void */ protected function _init() { parent::_init(); if ($this->server) { $this->_settings['servers'][$this->server] = true; } if (file_exists($this->conf)) { $this->_settings += (array) json_decode($this->conf, true); } $this->path = $this->_toPath($this->path ?: 'libraries'); $this->force = $this->f ? $this->f : $this->force; }
protected function _init() { parent::_init(); $this->webroot = $this->webroot ?: LITHIUM_APP_PATH . '/webroot'; $this->router = $this->router ?: dirname(dirname(__DIR__)) . '/config/router.php'; }