public function getContents() { $parser = new Zend_Tool_Project_Structure_Parser_Xml(); $isTraverseEnabled = Zend_Tool_Project_Structure_Graph::isTraverseEnabled(); Zend_Tool_Project_Structure_Graph::setTraverseEnabled(true); $xml = $parser->serialize($this->_graph); Zend_Tool_Project_Structure_Graph::setTraverseEnabled($isTraverseEnabled); return $xml; }
/** * _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 Zend_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 Zend_Tool_Project_Structure_Parser_Xml(); $structureGraph = $structureGraphParser->unserialize($structureData); $structureGraph->recursivelySetBaseDirectory($path); } $this->_loadedStructureGraph = $structureGraph; return $structureGraph; }
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 Zend_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; }