public function create($controllerName, $actionName) { $structureGraph = $this->_getExistingStructureGraph(); $viewScriptsDirectoryNode = $structureGraph->findNodeByContext(array('viewsDirectory', 'viewScriptsDirectory')); $newViewControllerScriptsDirectoryContext = Zend_Tool_Project_Structure_Context_Registry::getInstance()->getContext('ViewControllerScriptsDirectory'); $newViewControllerScriptsDirectoryContext->setForControllerName($controllerName); $newViewScriptFileContext = Zend_Tool_Project_Structure_Context_Registry::getInstance()->getContext('ViewScriptFile'); $newViewScriptFileContext->setScriptName($actionName); $newViewControllerScriptsDirectoryNode = new Zend_Tool_Project_Structure_Node($newViewControllerScriptsDirectoryContext); $newViewScriptFileNode = new Zend_Tool_Project_Structure_Node($newViewScriptFileContext); $newViewControllerScriptsDirectoryNode->append($newViewScriptFileNode); $newViewControllerScriptsDirectoryNode->recursivelySetBaseDirectory($viewScriptsDirectoryNode->getPath()); $newViewControllerScriptsDirectoryNode->recursivelyCreate(); $viewScriptsDirectoryNode->append($newViewControllerScriptsDirectoryNode); echo 'Creating a view script.' . PHP_EOL; $this->_storeLoadedStructureGraph(); }
public function create($name, $viewincluded = true) { $structureGraph = $this->_getExistingStructureGraph(); $controllersDirectoryNode = $structureGraph->findNodeByContext('controllersDirectory'); $controllerFileContext = Zend_Tool_Project_Structure_Context_Registry::getInstance()->getContext('controllerFile'); $newNode = new Zend_Tool_Project_Structure_Node($controllerFileContext); $newNode->setBaseDirectory($controllersDirectoryNode->getContext()->getPath()); $newNode->setControllerName($name); echo 'Creating new controller named \'' . $name . '\'' . PHP_EOL; $newNode->create(); $controllersDirectoryNode->append($newNode); $this->_storeLoadedStructureGraph(); if ($viewincluded) { $viewProvider = Zend_Tool_Rpc_Provider_Registry::getInstance()->getProvider('View'); $viewProvider->create($name, 'index'); } }
public function append(Zend_Tool_Project_Structure_Node $node) { $this->_topNodes[$node->getName()] = $node; }
protected function _unserializeRecurser(SimpleXMLIterator $xmlIterator, Zend_Tool_Project_Structure_Node $node = null) { foreach ($xmlIterator as $nodeName => $nodeData) { $context = Zend_Tool_Project_Structure_Context_Registry::getInstance()->getContext($nodeName); $subNode = new Zend_Tool_Project_Structure_Node($context); if ($attributes = $nodeData->attributes()) { foreach ($attributes as $attrName => $attrValue) { $method = 'set' . $attrName; if (method_exists($subNode, $method)) { $subNode->{$method}((string) $attrValue); } elseif (method_exists($context, $method)) { $context->{$method}((string) $attrValue); } } } if (method_exists($context, 'setGraph')) { $context->setGraph($this->_graph); } if ($node) { $node->append($subNode); } else { $this->_graph->append($subNode); } if ($xmlIterator->hasChildren()) { self::_unserializeRecurser($xmlIterator->getChildren(), $subNode); } } }