|
|
@@ -51,7 +51,7 @@ require_once 'Zend/Tool/Framework/Provider/Pretendable.php';
|
|
|
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
*/
|
|
|
-class Zend_Tool_Project_Provider_Controller
|
|
|
+class Zend_Tool_Project_Provider_Controller
|
|
|
extends Zend_Tool_Project_Provider_Abstract
|
|
|
implements Zend_Tool_Framework_Provider_Pretendable
|
|
|
{
|
|
|
@@ -71,7 +71,7 @@ class Zend_Tool_Project_Provider_Controller
|
|
|
if (!is_string($controllerName)) {
|
|
|
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Controller::createResource() expects \"controllerName\" is the name of a controller resource to create.');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (!($controllersDirectory = self::_getControllersDirectoryResource($profile, $moduleName))) {
|
|
|
if ($moduleName) {
|
|
|
$exceptionMessage = 'A controller directory for module "' . $moduleName . '" was not found.';
|
|
|
@@ -80,12 +80,12 @@ class Zend_Tool_Project_Provider_Controller
|
|
|
}
|
|
|
throw new Zend_Tool_Project_Provider_Exception($exceptionMessage);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$newController = $controllersDirectory->createResource('controllerFile', array('controllerName' => $controllerName));
|
|
|
|
|
|
return $newController;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* hasResource()
|
|
|
*
|
|
|
@@ -99,11 +99,11 @@ class Zend_Tool_Project_Provider_Controller
|
|
|
if (!is_string($controllerName)) {
|
|
|
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Controller::createResource() expects \"controllerName\" is the name of a controller resource to create.');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$controllersDirectory = self::_getControllersDirectoryResource($profile, $moduleName);
|
|
|
return (($controllersDirectory->search(array('controllerFile' => array('controllerName' => $controllerName)))) instanceof Zend_Tool_Project_Profile_Resource);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* _getControllersDirectoryResource()
|
|
|
*
|
|
|
@@ -120,7 +120,7 @@ class Zend_Tool_Project_Provider_Controller
|
|
|
}
|
|
|
|
|
|
$profileSearchParams[] = 'controllersDirectory';
|
|
|
-
|
|
|
+
|
|
|
return $profile->search($profileSearchParams);
|
|
|
}
|
|
|
|
|
|
@@ -133,15 +133,15 @@ class Zend_Tool_Project_Provider_Controller
|
|
|
public function create($name, $indexActionIncluded = true, $module = null)
|
|
|
{
|
|
|
$this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
|
|
-
|
|
|
+
|
|
|
// determine if testing is enabled in the project
|
|
|
require_once 'Zend/Tool/Project/Provider/Test.php';
|
|
|
$testingEnabled = Zend_Tool_Project_Provider_Test::isTestingEnabled($this->_loadedProfile);
|
|
|
-
|
|
|
- if (self::hasResource($this->_loadedProfile, $name)) {
|
|
|
+
|
|
|
+ if (self::hasResource($this->_loadedProfile, $name, $module)) {
|
|
|
throw new Zend_Tool_Project_Provider_Exception('This project already has a controller named ' . $name);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
$controllerResource = self::createResource($this->_loadedProfile, $name, $module);
|
|
|
if ($indexActionIncluded) {
|
|
|
@@ -151,7 +151,7 @@ class Zend_Tool_Project_Provider_Controller
|
|
|
if ($testingEnabled) {
|
|
|
$testControllerResource = Zend_Tool_Project_Provider_Test::createApplicationResource($this->_loadedProfile, $name, 'index');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} catch (Exception $e) {
|
|
|
$response = $this->_registry->getResponse();
|
|
|
$response->setException($e);
|
|
|
@@ -160,35 +160,35 @@ class Zend_Tool_Project_Provider_Controller
|
|
|
|
|
|
// do the creation
|
|
|
if ($this->_registry->getRequest()->isPretend()) {
|
|
|
-
|
|
|
+
|
|
|
$this->_registry->getResponse()->appendContent('Would create a controller at ' . $controllerResource->getContext()->getPath());
|
|
|
-
|
|
|
+
|
|
|
if (isset($indexActionResource)) {
|
|
|
$this->_registry->getResponse()->appendContent('Would create an index action method in controller ' . $name);
|
|
|
$this->_registry->getResponse()->appendContent('Would create a view script for the index action method at ' . $indexActionViewResource->getContext()->getPath());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ($testControllerResource) {
|
|
|
$this->_registry->getResponse()->appendContent('Would create a controller test file at ' . $testControllerResource->getContext()->getPath());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else {
|
|
|
-
|
|
|
+
|
|
|
$this->_registry->getResponse()->appendContent('Creating a controller at ' . $controllerResource->getContext()->getPath());
|
|
|
$controllerResource->create();
|
|
|
-
|
|
|
+
|
|
|
if (isset($indexActionResource)) {
|
|
|
$this->_registry->getResponse()->appendContent('Creating an index action method in controller ' . $name);
|
|
|
$indexActionResource->create();
|
|
|
$this->_registry->getResponse()->appendContent('Creating a view script for the index action method at ' . $indexActionViewResource->getContext()->getPath());
|
|
|
$indexActionViewResource->create();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if ($testControllerResource) {
|
|
|
$this->_registry->getResponse()->appendContent('Creating a controller test file at ' . $testControllerResource->getContext()->getPath());
|
|
|
$testControllerResource->create();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$this->_storeProfile();
|
|
|
}
|
|
|
|