示例#1
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     $this['app_name'] = 'UNKNOWN';
     $this['app_version'] = 'UNKNOWN';
     $this['config_file'] = '{base}/config.json';
     $this['config_defaults'] = array();
     $this['working_directory_sub_folder'] = '.console-kit';
     $this['working_directory'] = function ($c) {
         $working_directory = new WorkingDirectory($c['working_directory_sub_folder']);
         return $working_directory->get();
     };
     $this['config_editor'] = function ($c) {
         return new ConfigEditor(str_replace('{base}', $c['working_directory'], $c['config_file']), $c['config_defaults']);
     };
     $this['input'] = function () {
         return new ArgvInput();
     };
     $this['output'] = function () {
         return new ConsoleOutput();
     };
     $this['io'] = function ($c) {
         return new ConsoleIO($c['input'], $c['output'], $c['helper_set']);
     };
     // Would be replaced with actual HelperSet from extended Application class.
     $this['helper_set'] = function () {
         return new HelperSet();
     };
     $this['container_helper'] = function ($c) {
         return new ContainerHelper($c);
     };
 }
 /**
  * Returns working directory.
  *
  * @return string
  */
 protected function getWorkingDirectory()
 {
     $sub_folder = array_key_exists('working_directory', $_SERVER) ? $_SERVER['working_directory'] : '';
     if (!strlen($sub_folder)) {
         $this->fail('Please set "working_directory" environment variable before calling ' . __METHOD__ . '.');
     }
     $working_directory = new WorkingDirectory($sub_folder);
     return $working_directory->get();
 }