Esempio n. 1
0
 /**
  * Main entry point into the application.
  *
  * @return void
  */
 public function main()
 {
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? false : $_SERVER['argv'][1], 'project:run');
     $task = $runner->getTask();
     $threshold = DocBlox_Core_Log::WARN;
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     } else {
         $threshold = DocBlox_Core_Log::QUIET;
     }
     if ($task->getVerbose()) {
         $threshold = DocBlox_Core_Log::DEBUG;
     }
     $dispatcher = new sfEventDispatcher();
     $logger = new DocBlox_Core_Log(DocBlox_Core_Log::FILE_STDOUT);
     $logger->setThreshold($threshold);
     $dispatcher->connect('system.log', array($logger, 'log'));
     DocBlox_Parser_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Transformer_Abstract::$event_dispatcher = $dispatcher;
     DocBlox_Reflection_Abstract::$event_dispatcher = $dispatcher;
     try {
         $task->execute();
     } catch (Exception $e) {
         if (!$task->getQuiet()) {
             echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
             echo $task->getUsageMessage();
         }
         die(1);
     }
 }
Esempio n. 2
0
 /**
  * Parses the configuration options and populates the data store.
  *
  * @param bool $force if true; forces parsing independently of the _parsed property.
  *
  * @return void
  */
 public function parse($force = false)
 {
     if ($this->_parsed === true && !$force) {
         return $this;
     }
     $this->_parsed = false;
     try {
         parent::parse();
     } catch (Zend_Exception $e) {
         $name = basename($_SERVER['SCRIPT_NAME'], '.php');
         echo $name . ': ' . $e->getMessage() . PHP_EOL;
         echo 'Try: \'' . $name . ' --help\' for more information.' . PHP_EOL;
         exit(22);
     }
     if ($this->getHelp()) {
         DocBlox_Core_Application::renderVersion();
         echo $this->getUsageMessage();
         exit(0);
     }
     // prevent the loading of configuration files by specifying 'none'.
     if (strtolower($this->getConfig()) == 'none') {
         return;
     }
     if ($this->getConfig()) {
         // when the configuration parameter is provided; merge that with the basic config
         DocBlox_Core_Abstract::config()->merge(new Zend_Config_Xml($this->getConfig()));
     } elseif (is_readable('docblox.xml')) {
         // when the configuration is not provided; check for the presence of a configuration file in the current directory
         // and merge that
         DocBlox_Core_Abstract::config()->merge(new Zend_Config_Xml('docblox.xml'));
     } elseif (is_readable('docblox.dist.xml')) {
         // when no docblox.xml is provided; check for a dist.xml file. Yes, compared to, for example, PHPUnit the xml
         // and dist is reversed; this is done on purpose so IDEs have an easier time on it.
         DocBlox_Core_Abstract::config()->merge(new Zend_Config_Xml('docblox.dist.xml'));
     }
     $this->prePopulate();
     // the parse method does not have a hook point to invoke the setter methods; thus we iterate through the options and
     // invoke the setters. If no setter exists the __call method will handle this.
     // We have explicitly kept this intact (as the __call's set does nothing special) to enable subclasses to override
     // the __call and receive the benefits.
     foreach ($this->getOptions() as $value) {
         $method_name = '';
         // loop through all aliases to check whether a real method was overridden
         foreach ($this->_rules[$value]['alias'] as $alias) {
             $method_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $alias)));
             if (method_exists($this, $method_name)) {
                 // found one! execute it and continue to the next
                 $this->{$method_name}($this->getOption($value));
                 continue 2;
             }
         }
         if ($method_name == '') {
             throw new Exception('Unable to find a name for the setter for argument ' . $value);
         }
         // no overridden methods found; just invoke the default name to trigger the __call method
         $this->{$method_name}($this->getOption($value));
     }
 }
Esempio n. 3
0
 /**
  * Main entry point into the application
  *
  * @return void
  */
 public function main()
 {
     require_once 'Image/GraphViz.php';
     require_once 'markdown.php';
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? 'project:run' : $_SERVER['argv'][1]);
     $task = $runner->getTask();
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     }
     try {
         $task->execute();
     } catch (Exception $e) {
         echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
         echo $task->getUsageMessage();
     }
 }
Esempio n. 4
0
 /**
  * Parses the configuration options and populates the data store.
  *
  * @param bool $force if true; forces parsing independently of the _parsed property.
  *
  * @return void
  */
 public function parse($force = false)
 {
     if ($this->_parsed === true && !$force) {
         return $this;
     }
     $this->_parsed = false;
     try {
         parent::parse();
     } catch (Zend_Exception $e) {
         $name = basename($_SERVER['SCRIPT_NAME'], '.php');
         echo $name . ': ' . $e->getMessage() . PHP_EOL;
         echo 'Try: \'' . $name . ' --help\' for more information.' . PHP_EOL;
         exit(22);
     }
     if ($this->getHelp()) {
         DocBlox_Core_Application::renderVersion();
         echo $this->getUsageMessage();
         exit(0);
     }
     $this->prePopulate();
     // the parse method does not have a hook point to invoke the setter methods; thus we iterate through the options and
     // invoke the setters. If no setter exists the __call method will handle this.
     // We have explicitly kept this intact (as the __call's set does nothing special) to enable subclasses to override
     // the __call and receive the benefits.
     foreach ($this->getOptions() as $value) {
         $method_name = '';
         // loop through all aliases to check whether a real method was overridden
         foreach ($this->_rules[$value]['alias'] as $alias) {
             $method_name = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $alias)));
             if (method_exists($this, $method_name)) {
                 // found one! execute it and continue to the next
                 $this->{$method_name}($this->getOption($value));
                 continue 2;
             }
         }
         if ($method_name == '') {
             throw new Exception('Unable to find a name for the setter for argument ' . $value);
         }
         // no overridden methods found; just invoke the default name to trigger the __call method
         $this->{$method_name}($this->getOption($value));
     }
 }
Esempio n. 5
0
 /**
  * Main entry point into the application.
  *
  * @return void
  */
 public function main()
 {
     require_once 'markdown.php';
     $runner = new DocBlox_Task_Runner($_SERVER['argc'] == 1 ? false : $_SERVER['argv'][1], 'project:run');
     $task = $runner->getTask();
     if (!$task->getQuiet()) {
         DocBlox_Core_Application::renderVersion();
     }
     try {
         $task->execute();
     } catch (Exception $e) {
         echo 'ERROR: ' . $e->getMessage() . PHP_EOL . PHP_EOL;
         echo $task->getUsageMessage();
         // exit with the exception's code or 1 if null/0
         $exit = $e->getCode();
         if (!$exit) {
             $exit = 1;
         }
         exit($exit);
     }
 }