Beispiel #1
0
 public function init(array $argv = array(), $verbosity = 0)
 {
     $this->_verbosity = $verbosity;
     /* First element is the php script name. Store it for debugging. */
     $this->_php_exec = array_shift($argv);
     /* Second element is just the executable we called to run ZF commands. Store it for printing errors/usage. */
     $this->_native_exec = array_shift($argv);
     $opts = $this->getOptions()->addArguments($argv);
     $opts->parse();
     // Shortcut to verbosity option so that we can display more earlier
     if (isset($opts->verbosity)) {
         $this->_verbosity = $opts->verbosity;
     }
     // Shortcut to help option so that no arguments have to be specified
     if (isset($opts->help)) {
         $this->printHelp();
         return null;
     }
     try {
         $actionName = array_shift($argv);
         $context = Zend_Build_Manifest::getInstance()->getContext(self::MF_ACTION_TYPE, $actionName);
         $config = $this->_parseParams($context, $argv);
         $action = new $context->class();
         $action . setConfig($config);
         $action . configure();
     } catch (Zend_Console_Exception $e) {
         throw $e->prependUsage($this->getUsage());
     }
     return $this;
 }
Beispiel #2
0
 /**
  * getInstance
  *
  * @return Zend_Build_Manifest
  */
 public function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #3
0
 public function __construct()
 {
     $buildManifest = Zend_Build_Manifest::getInstance();
     $buildManifest->scanIncludePath();
     $this->_globalContext = new Zend_Tool_Cli_Context_Global();
     $this->_globalContext->setBuildManifest($buildManifest);
     $this->_actionContext = new Zend_Tool_Cli_Context_Action();
     $this->_actionContext->setBuildManifest($buildManifest);
     $this->_resourceContext = new Zend_Tool_Cli_Context_Resource();
     $this->_resourceContext->setBuildManifest($buildManifest);
 }
Beispiel #4
0
 /**
  * _make
  *
  * @param  string $type
  * @param  string $name
  * @throws Zend_Build_Exception
  * @return Zend_Config
  */
 private static function _make($type, $name)
 {
     /**
      * @see Zend_Build_Manifest
      */
     require_once 'Zend/Build/Manifest.php';
     $config = Zend_Build_Manifest::getInstance()->getContext($type, $name);
     if (!is_set($config)) {
         /**
          * @see Zend_Build_Exception
          */
         require_once 'Zend/Build/Exception.php';
         throw new Zend_Build_Exception("Action '{$name}' not found.");
     }
     return Zend_Build_AbstractConfigurable::getConfigurable($config);
 }
 public function setup()
 {
     $this->_cdToTestProject();
     $this->_manifest = Zend_Build_Manifest::getInstance();
 }
Beispiel #6
0
 public function resetInstance()
 {
     self::$_instance = null;
     return self::getInstance();
 }
Beispiel #7
0
 public function create()
 {
     parent::create();
     $basePath = $this->getDirname();
     $actionName = 'create';
     $pathArray = array();
     $projectFile = new Zend_Build_Resource_ProjectFile();
     $lastDepth = 0;
     $profileIterator = new RecursiveIteratorIterator($projectFile->getProfile(), RecursiveIteratorIterator::SELF_FIRST);
     foreach ($profileIterator as $name => $item) {
         if ($skipToDepth !== null && $profileIterator->getDepth() > $skipToDepth) {
             continue;
         } elseif ($skipToDepth !== null && $profileIterator->getDepth() == $skipToDepth) {
             $skipToDepth = null;
         }
         $currentDepth = $profileIterator->getDepth();
         if ($currentDepth <= $lastDepth) {
             array_pop($pathArray);
         }
         if ($currentDepth < $lastDepth) {
             for ($x = 0; $x < $lastDepth - $currentDepth; $x++) {
                 array_pop($pathArray);
             }
         }
         $fullPath = $basePath;
         if ($pathArray) {
             $fullPath .= implode('/', $pathArray);
         }
         if ($item['enabled'] == 'false') {
             $skipToDepth = $profileIterator->getDepth();
             continue;
         }
         $resource = $this->_buildManifest->getContext('resource', $name);
         if ($resource === null) {
             throw new Zend_Build_Exception('Context not available.');
         }
         $className = $resource->getClassName();
         Zend_Loader::loadClass($className);
         $resourceObject = new $className();
         if (!$resourceObject instanceof Zend_Build_Resource_Filesystem) {
             throw new Zend_Build_Exception('Projects can only deal with file and directory resources.');
         }
         $resourceObject->setParameter('basePath', $fullPath);
         if (count($attrs = $item->attributes()) > 0) {
             foreach ($attrs as $attrName => $attrValue) {
                 if ($attrName != 'enabled') {
                     $resourceObject->setParameter($attrName, $attrValue);
                 }
             }
         }
         $resourceObject->validate();
         if (!isset($item->enabled) || isset($item->enabled) && $item->enabled != false) {
             $resourceObject->execute($actionName);
         }
         $dirRemainder = preg_replace('#^' . preg_quote($fullPath, '#') . '#', '', $resourceObject->getDirname());
         if ($dirRemainder) {
             array_push($pathArray, trim($dirRemainder, '/'));
         }
         $lastDepth = $profileIterator->getDepth();
     }
 }