diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Tool/Project/Provider/View.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Tool/Project/Provider/View.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,118 @@ + array('moduleName' => $moduleName)); + $noModuleSearch = null; + } else { + $noModuleSearch = array('modulesDirectory'); + } + + $profileSearchParams[] = 'viewsDirectory'; + $profileSearchParams[] = 'viewScriptsDirectory'; + + if (($viewScriptsDirectory = $profile->search($profileSearchParams, $noModuleSearch)) === false) { + require_once 'Zend/Tool/Project/Provider/Exception.php'; + throw new Zend_Tool_Project_Provider_Exception('This project does not have a viewScriptsDirectory resource.'); + } + + $profileSearchParams['viewControllerScriptsDirectory'] = array('forControllerName' => $controllerName); + + // @todo check if below is failing b/c of above search params + if (($viewControllerScriptsDirectory = $viewScriptsDirectory->search($profileSearchParams)) === false) { + $viewControllerScriptsDirectory = $viewScriptsDirectory->createResource('viewControllerScriptsDirectory', array('forControllerName' => $controllerName)); + } + + $newViewScriptFile = $viewControllerScriptsDirectory->createResource('ViewScriptFile', array('forActionName' => $actionName)); + + return $newViewScriptFile; + } + + /** + * create() + * + * @param string $controllerName + * @param string $actionNameOrSimpleName + */ + public function create($controllerName, $actionNameOrSimpleName) + { + + if ($controllerName == '' || $actionNameOrSimpleName == '') { + require_once 'Zend/Tool/Project/Provider/Exception.php'; + throw new Zend_Tool_Project_Provider_Exception('ControllerName and/or ActionName are empty.'); + } + + $profile = $this->_loadProfile(); + + $view = self::createResource($profile, $actionNameOrSimpleName, $controllerName); + + if ($this->_registry->getRequest()->isPretend()) { + $this->_registry->getResponse( + 'Would create a view script in location ' . $view->getContext()->getPath() + ); + } else { + $this->_registry->getResponse( + 'Creating a view script in location ' . $view->getContext()->getPath() + ); + $view->create(); + $this->_storeProfile(); + } + + } +}