public function create($name, $viewincluded = true) { $structureGraph = $this->_getExistingStructureGraph(); $controllersDirectoryNode = $structureGraph->findNodeByContext('controllersDirectory'); $controllerFileContext = ZendL_Tool_Project_Structure_Context_Registry::getInstance()->getContext('controllerFile'); $newNode = new ZendL_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 = ZendL_Tool_Rpc_Provider_Registry::getInstance()->getProvider('View'); $viewProvider->create($name, 'index'); } }
public function create($controllerName, $actionName) { $structureGraph = $this->_getExistingStructureGraph(); $viewScriptsDirectoryNode = $structureGraph->findNodeByContext(array('viewsDirectory', 'viewScriptsDirectory')); $newViewControllerScriptsDirectoryContext = ZendL_Tool_Project_Structure_Context_Registry::getInstance()->getContext('ViewControllerScriptsDirectory'); $newViewControllerScriptsDirectoryContext->setForControllerName($controllerName); $newViewScriptFileContext = ZendL_Tool_Project_Structure_Context_Registry::getInstance()->getContext('ViewScriptFile'); $newViewScriptFileContext->setScriptName($actionName); $newViewControllerScriptsDirectoryNode = new ZendL_Tool_Project_Structure_Node($newViewControllerScriptsDirectoryContext); $newViewScriptFileNode = new ZendL_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 append(ZendL_Tool_Project_Structure_Node $node) { $this->_topNodes[$node->getName()] = $node; }