Example #1
0
 public function getContents()
 {
     $parser = new ZendL_Tool_Project_Structure_Parser_Xml();
     $isTraverseEnabled = ZendL_Tool_Project_Structure_Graph::isTraverseEnabled();
     ZendL_Tool_Project_Structure_Graph::setTraverseEnabled(true);
     $xml = $parser->serialize($this->_graph);
     ZendL_Tool_Project_Structure_Graph::setTraverseEnabled($isTraverseEnabled);
     return $xml;
 }
Example #2
0
 /**
  * _getProject is designed to find if there is project file in the context of where
  * the endpoint has been called from..   The search order is as follows..
  *    - traversing downwards from (PWD) - current working directory
  *    - if an enpoint variable has been registered in teh endpoint registry - key=workingDirectory
  *    - if an ENV variable with the key ZFPROJECT_PATH is found
  * 
  * @return ZendL_Tool_Project_Structure_Graph
  */
 protected function _loadExistingStructureGraph($path = null)
 {
     if ($path == null) {
         $path = $_SERVER['PWD'];
     }
     $structureDataFile = $path . '/.zfproject.xml';
     // @todo make this non-hard coded?
     if (file_exists($structureDataFile)) {
         $structureData = file_get_contents($structureDataFile);
     }
     $structureGraph = false;
     if (isset($structureData)) {
         $structureGraphParser = new ZendL_Tool_Project_Structure_Parser_Xml();
         $structureGraph = $structureGraphParser->unserialize($structureData);
         $structureGraph->recursivelySetBaseDirectory($path);
     }
     $this->_loadedStructureGraph = $structureGraph;
     return $structureGraph;
 }
Example #3
0
 public function create($path = null)
 {
     if ($path == null) {
         $path = $_SERVER['PWD'];
     } else {
         $path = str_replace('\\', '/', realpath($path));
     }
     /**
      * @todo make sure a project doesnt alredy exist here
      */
     $structureGraph = $this->_loadExistingStructureGraph($path);
     if ($structureGraph) {
         throw new Exception('A project already exists here');
     }
     try {
         $structureParser = new ZendL_Tool_Project_Structure_Parser_Xml();
         $structureGraph = $structureParser->unserialize($this->_getStructureData());
         $structureGraph->recursivelySetBaseDirectory($path);
         $structureGraph->recursivelyCreate();
     } catch (Exception $e) {
         die('Exception: ' . $e->getMessage());
     }
     echo 'creating project at ' . $path;
 }