CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
241
airtime_mvc/library/Zend/Tool/Project/Provider/Abstract.php
Normal file
241
airtime_mvc/library/Zend/Tool/Project/Provider/Abstract.php
Normal file
|
@ -0,0 +1,241 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Profile
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Profile.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Context_Repository
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Context/Repository.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Profile_FileParser_Xml
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Profile/FileParser/Xml.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Registry
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Registry.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Tool_Project_Provider_Abstract extends Zend_Tool_Framework_Provider_Abstract
|
||||
{
|
||||
|
||||
const NO_PROFILE_THROW_EXCEPTION = true;
|
||||
const NO_PROFILE_RETURN_FALSE = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected static $_isInitialized = false;
|
||||
|
||||
protected $_projectPath = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Project_Profile
|
||||
*/
|
||||
protected $_loadedProfile = null;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* YOU SHOULD NOT OVERRIDE THIS, unless you know what you are doing
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// initialize the ZF Contexts (only once per php request)
|
||||
if (!self::$_isInitialized) {
|
||||
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
|
||||
$contextRegistry->addContextsFromDirectory(
|
||||
dirname(dirname(__FILE__)) . '/Context/Zf/', 'Zend_Tool_Project_Context_Zf_'
|
||||
);
|
||||
$contextRegistry->addContextsFromDirectory(
|
||||
dirname(dirname(__FILE__)) . '/Context/Filesystem/', 'Zend_Tool_Project_Context_Filesystem_'
|
||||
);
|
||||
self::$_isInitialized = true;
|
||||
}
|
||||
|
||||
// load up the extending providers required context classes
|
||||
if ($contextClasses = $this->getContextClasses()) {
|
||||
$this->_loadContextClassesIntoRegistry($contextClasses);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getContextClasses()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* _getProject is designed to find if there is project file in the context of where
|
||||
* the client 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 client registry - key=workingDirectory
|
||||
* - if an ENV variable with the key ZFPROJECT_PATH is found
|
||||
*
|
||||
* @param $loadProfileFlag bool Whether or not to throw an exception when no profile is found
|
||||
* @param $projectDirectory string The project directory to use to search
|
||||
* @param $searchParentDirectories bool Whether or not to search upper level direcotries
|
||||
* @return Zend_Tool_Project_Profile
|
||||
*/
|
||||
protected function _loadProfile($loadProfileFlag = self::NO_PROFILE_THROW_EXCEPTION, $projectDirectory = null, $searchParentDirectories = true)
|
||||
{
|
||||
// use the cwd if no directory was provided
|
||||
if ($projectDirectory == null) {
|
||||
$projectDirectory = getcwd();
|
||||
} elseif (realpath($projectDirectory) == false) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('The $projectDirectory supplied does not exist.');
|
||||
}
|
||||
|
||||
$profile = new Zend_Tool_Project_Profile();
|
||||
|
||||
$parentDirectoriesArray = explode(DIRECTORY_SEPARATOR, ltrim($projectDirectory, DIRECTORY_SEPARATOR));
|
||||
while ($parentDirectoriesArray) {
|
||||
$projectDirectoryAssembled = implode(DIRECTORY_SEPARATOR, $parentDirectoriesArray);
|
||||
|
||||
if (DIRECTORY_SEPARATOR !== "\\") {
|
||||
$projectDirectoryAssembled = DIRECTORY_SEPARATOR . $projectDirectoryAssembled;
|
||||
}
|
||||
|
||||
$profile->setAttribute('projectDirectory', $projectDirectoryAssembled);
|
||||
if ($profile->isLoadableFromFile()) {
|
||||
chdir($projectDirectoryAssembled);
|
||||
|
||||
$profile->loadFromFile();
|
||||
$this->_loadedProfile = $profile;
|
||||
break;
|
||||
}
|
||||
|
||||
// break after first run if we are not to check upper directories
|
||||
if ($searchParentDirectories == false) {
|
||||
break;
|
||||
}
|
||||
|
||||
array_pop($parentDirectoriesArray);
|
||||
}
|
||||
|
||||
if ($this->_loadedProfile == null) {
|
||||
if ($loadProfileFlag == self::NO_PROFILE_THROW_EXCEPTION) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('A project profile was not found.');
|
||||
} elseif ($loadProfileFlag == self::NO_PROFILE_RETURN_FALSE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the project profile from the current working directory, if not throw exception
|
||||
*
|
||||
* @return Zend_Tool_Project_Profile
|
||||
*/
|
||||
protected function _loadProfileRequired()
|
||||
{
|
||||
$profile = $this->_loadProfile();
|
||||
if ($profile === false) {
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
throw new Zend_Tool_Project_Provider_Exception('A project profile was not found in the current working directory.');
|
||||
}
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the currently loaded profile
|
||||
*
|
||||
* @return Zend_Tool_Project_Profile
|
||||
*/
|
||||
protected function _getProfile($loadProfileFlag = self::NO_PROFILE_THROW_EXCEPTION)
|
||||
{
|
||||
if (!$this->_loadedProfile) {
|
||||
if (($this->_loadProfile($loadProfileFlag) === false) && ($loadProfileFlag === self::NO_PROFILE_RETURN_FALSE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_loadedProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* _storeProfile()
|
||||
*
|
||||
* This method will store the profile into its proper location
|
||||
*
|
||||
*/
|
||||
protected function _storeProfile()
|
||||
{
|
||||
$projectProfileFile = $this->_loadedProfile->search('ProjectProfileFile');
|
||||
|
||||
$name = $projectProfileFile->getContext()->getPath();
|
||||
|
||||
$this->_registry->getResponse()->appendContent('Updating project profile \'' . $name . '\'');
|
||||
|
||||
$projectProfileFile->getContext()->save();
|
||||
}
|
||||
|
||||
protected function _getContentForContext(Zend_Tool_Project_Context_Interface $context, $methodName, $parameters)
|
||||
{
|
||||
$storage = $this->_registry->getStorage();
|
||||
if (!$storage->isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!class_exists('Zend_Tool_Project_Context_Content_Engine')) {
|
||||
require_once 'Zend/Tool/Project/Context/Content/Engine.php';
|
||||
}
|
||||
|
||||
$engine = new Zend_Tool_Project_Context_Content_Engine($storage);
|
||||
return $engine->getContent($context, $methodName, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* _loadContextClassesIntoRegistry() - This is called by the constructor
|
||||
* so that child providers can provide a list of contexts to load into the
|
||||
* context repository
|
||||
*
|
||||
* @param array $contextClasses
|
||||
*/
|
||||
private function _loadContextClassesIntoRegistry($contextClasses)
|
||||
{
|
||||
$registry = Zend_Tool_Project_Context_Repository::getInstance();
|
||||
|
||||
foreach ($contextClasses as $contextClass) {
|
||||
$registry->addContextClass($contextClass);
|
||||
}
|
||||
}
|
||||
}
|
214
airtime_mvc/library/Zend/Tool/Project/Provider/Action.php
Normal file
214
airtime_mvc/library/Zend/Tool/Project/Provider/Action.php
Normal file
|
@ -0,0 +1,214 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Action.php 20967 2010-02-07 18:17:49Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Provider_Pretendable
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Provider/Pretendable.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Action
|
||||
extends Zend_Tool_Project_Provider_Abstract
|
||||
implements Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
|
||||
/**
|
||||
* createResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $actionName
|
||||
* @param string $controllerName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $actionName, $controllerName, $moduleName = null)
|
||||
{
|
||||
|
||||
if (!is_string($actionName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Action::createResource() expects \"actionName\" is the name of a action resource to create.');
|
||||
}
|
||||
|
||||
if (!is_string($controllerName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Action::createResource() expects \"controllerName\" is the name of a controller resource to create.');
|
||||
}
|
||||
|
||||
$controllerFile = self::_getControllerFileResource($profile, $controllerName, $moduleName);
|
||||
|
||||
$actionMethod = $controllerFile->createResource('ActionMethod', array('actionName' => $actionName));
|
||||
|
||||
return $actionMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* hasResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $actionName
|
||||
* @param string $controllerName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function hasResource(Zend_Tool_Project_Profile $profile, $actionName, $controllerName, $moduleName = null)
|
||||
{
|
||||
if (!is_string($actionName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Action::createResource() expects \"actionName\" is the name of a action resource to create.');
|
||||
}
|
||||
|
||||
if (!is_string($controllerName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Action::createResource() expects \"controllerName\" is the name of a controller resource to create.');
|
||||
}
|
||||
|
||||
$controllerFile = self::_getControllerFileResource($profile, $controllerName, $moduleName);
|
||||
|
||||
if ($controllerFile == null) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Controller ' . $controllerName . ' was not found.');
|
||||
}
|
||||
|
||||
return (($controllerFile->search(array('actionMethod' => array('actionName' => $actionName)))) instanceof Zend_Tool_Project_Profile_Resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* _getControllerFileResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $controllerName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
protected static function _getControllerFileResource(Zend_Tool_Project_Profile $profile, $controllerName, $moduleName = null)
|
||||
{
|
||||
$profileSearchParams = array();
|
||||
|
||||
if ($moduleName != null && is_string($moduleName)) {
|
||||
$profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
|
||||
}
|
||||
|
||||
$profileSearchParams[] = 'controllersDirectory';
|
||||
$profileSearchParams['controllerFile'] = array('controllerName' => $controllerName);
|
||||
|
||||
return $profile->search($profileSearchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* create()
|
||||
*
|
||||
* @param string $name Action name for controller, in camelCase format.
|
||||
* @param string $controllerName Controller name action should be applied to.
|
||||
* @param bool $viewIncluded Whether the view should the view be included.
|
||||
* @param string $module Module name action should be applied to.
|
||||
*/
|
||||
public function create($name, $controllerName = 'Index', $viewIncluded = true, $module = null)
|
||||
{
|
||||
|
||||
$this->_loadProfile();
|
||||
|
||||
// Check that there is not a dash or underscore, return if doesnt match regex
|
||||
if (preg_match('#[_-]#', $name)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Action names should be camel cased.');
|
||||
}
|
||||
|
||||
$originalName = $name;
|
||||
$originalControllerName = $controllerName;
|
||||
|
||||
// ensure it is camelCase (lower first letter)
|
||||
$name = strtolower(substr($name, 0, 1)) . substr($name, 1);
|
||||
|
||||
// ensure controller is MixedCase
|
||||
$controllerName = ucfirst($controllerName);
|
||||
|
||||
if (self::hasResource($this->_loadedProfile, $name, $controllerName, $module)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('This controller (' . $controllerName . ') already has an action named (' . $name . ')');
|
||||
}
|
||||
|
||||
$actionMethod = self::createResource($this->_loadedProfile, $name, $controllerName, $module);
|
||||
|
||||
// get request/response object
|
||||
$request = $this->_registry->getRequest();
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
// alert the user about inline converted names
|
||||
$tense = (($request->isPretend()) ? 'would be' : 'is');
|
||||
|
||||
if ($name !== $originalName) {
|
||||
$response->appendContent(
|
||||
'Note: The canonical action name that ' . $tense
|
||||
. ' used with other providers is "' . $name . '";'
|
||||
. ' not "' . $originalName . '" as supplied',
|
||||
array('color' => array('yellow'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($controllerName !== $originalControllerName) {
|
||||
$response->appendContent(
|
||||
'Note: The canonical controller name that ' . $tense
|
||||
. ' used with other providers is "' . $controllerName . '";'
|
||||
. ' not "' . $originalControllerName . '" as supplied',
|
||||
array('color' => array('yellow'))
|
||||
);
|
||||
}
|
||||
|
||||
unset($tense);
|
||||
|
||||
if ($request->isPretend()) {
|
||||
$response->appendContent(
|
||||
'Would create an action named ' . $name .
|
||||
' inside controller at ' . $actionMethod->getParentResource()->getContext()->getPath()
|
||||
);
|
||||
} else {
|
||||
$response->appendContent(
|
||||
'Creating an action named ' . $name .
|
||||
' inside controller at ' . $actionMethod->getParentResource()->getContext()->getPath()
|
||||
);
|
||||
$actionMethod->create();
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
if ($viewIncluded) {
|
||||
$viewResource = Zend_Tool_Project_Provider_View::createResource($this->_loadedProfile, $name, $controllerName, $module);
|
||||
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
$response->appendContent(
|
||||
'Would create a view script for the ' . $name . ' action method at ' . $viewResource->getContext()->getPath()
|
||||
);
|
||||
} else {
|
||||
$response->appendContent(
|
||||
'Creating a view script for the ' . $name . ' action method at ' . $viewResource->getContext()->getPath()
|
||||
);
|
||||
$viewResource->create();
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Model.php 18386 2009-09-23 20:44:43Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Application
|
||||
extends Zend_Tool_Project_Provider_Abstract
|
||||
implements Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
|
||||
protected $_specialties = array('ClassNamePrefix');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $classNamePrefix Prefix of classes
|
||||
* @param $force
|
||||
*/
|
||||
public function changeClassNamePrefix($classNamePrefix /* , $force = false */)
|
||||
{
|
||||
$profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
$originalClassNamePrefix = $classNamePrefix;
|
||||
|
||||
if (substr($classNamePrefix, -1) != '_') {
|
||||
$classNamePrefix .= '_';
|
||||
}
|
||||
|
||||
$configFileResource = $profile->search('ApplicationConfigFile');
|
||||
$zc = $configFileResource->getAsZendConfig('production');
|
||||
if ($zc->appnamespace == $classNamePrefix) {
|
||||
throw new Zend_Tool_Project_Exception('The requested name ' . $classNamePrefix . ' is already the prefix.');
|
||||
}
|
||||
|
||||
// remove the old
|
||||
$configFileResource->removeStringItem('appnamespace', 'production');
|
||||
$configFileResource->create();
|
||||
|
||||
// add the new
|
||||
$configFileResource->addStringItem('appnamespace', $classNamePrefix, 'production', true);
|
||||
$configFileResource->create();
|
||||
|
||||
// update the project profile
|
||||
$applicationDirectory = $profile->search('ApplicationDirectory');
|
||||
$applicationDirectory->setClassNamePrefix($classNamePrefix);
|
||||
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
if ($originalClassNamePrefix !== $classNamePrefix) {
|
||||
$response->appendContent(
|
||||
'Note: the name provided "' . $originalClassNamePrefix . '" was'
|
||||
. ' altered to "' . $classNamePrefix . '" for correctness.',
|
||||
array('color' => 'yellow')
|
||||
);
|
||||
}
|
||||
|
||||
// note to the user
|
||||
$response->appendContent('Note: All existing models will need to be altered to this new namespace by hand', array('color' => 'yellow'));
|
||||
$response->appendContent('application.ini updated with new appnamespace ' . $classNamePrefix);
|
||||
|
||||
// store profile
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
200
airtime_mvc/library/Zend/Tool/Project/Provider/Controller.php
Normal file
200
airtime_mvc/library/Zend/Tool/Project/Provider/Controller.php
Normal file
|
@ -0,0 +1,200 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Controller.php 20967 2010-02-07 18:17:49Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 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
|
||||
extends Zend_Tool_Project_Provider_Abstract
|
||||
implements Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
|
||||
/**
|
||||
* createResource will create the controllerFile resource at the appropriate location in the
|
||||
* profile. NOTE: it is your job to execute the create() method on the resource, as well as
|
||||
* store the profile when done.
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $controllerName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $controllerName, $moduleName = null)
|
||||
{
|
||||
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.';
|
||||
} else {
|
||||
$exceptionMessage = 'A controller directory was not found.';
|
||||
}
|
||||
throw new Zend_Tool_Project_Provider_Exception($exceptionMessage);
|
||||
}
|
||||
|
||||
$newController = $controllersDirectory->createResource(
|
||||
'controllerFile',
|
||||
array('controllerName' => $controllerName, 'moduleName' => $moduleName)
|
||||
);
|
||||
|
||||
return $newController;
|
||||
}
|
||||
|
||||
/**
|
||||
* hasResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $controllerName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function hasResource(Zend_Tool_Project_Profile $profile, $controllerName, $moduleName = null)
|
||||
{
|
||||
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()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
protected static function _getControllersDirectoryResource(Zend_Tool_Project_Profile $profile, $moduleName = null)
|
||||
{
|
||||
$profileSearchParams = array();
|
||||
|
||||
if ($moduleName != null && is_string($moduleName)) {
|
||||
$profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
|
||||
}
|
||||
|
||||
$profileSearchParams[] = 'controllersDirectory';
|
||||
|
||||
return $profile->search($profileSearchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new controller
|
||||
*
|
||||
* @param string $name The name of the controller to create, in camelCase.
|
||||
* @param bool $indexActionIncluded Whether or not to create the index action.
|
||||
*/
|
||||
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, $module)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('This project already has a controller named ' . $name);
|
||||
}
|
||||
|
||||
// Check that there is not a dash or underscore, return if doesnt match regex
|
||||
if (preg_match('#[_-]#', $name)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Controller names should be camel cased.');
|
||||
}
|
||||
|
||||
$originalName = $name;
|
||||
$name = ucfirst($name);
|
||||
|
||||
// get request & response
|
||||
$request = $this->_registry->getRequest();
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
try {
|
||||
$controllerResource = self::createResource($this->_loadedProfile, $name, $module);
|
||||
if ($indexActionIncluded) {
|
||||
$indexActionResource = Zend_Tool_Project_Provider_Action::createResource($this->_loadedProfile, 'index', $name, $module);
|
||||
$indexActionViewResource = Zend_Tool_Project_Provider_View::createResource($this->_loadedProfile, 'index', $name, $module);
|
||||
}
|
||||
if ($testingEnabled) {
|
||||
$testControllerResource = Zend_Tool_Project_Provider_Test::createApplicationResource($this->_loadedProfile, $name, 'index', $module);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$response->setException($e);
|
||||
return;
|
||||
}
|
||||
|
||||
// determime if we need to note to the user about the name
|
||||
if (($name !== $originalName)) {
|
||||
$tense = (($request->isPretend()) ? 'would be' : 'is');
|
||||
$response->appendContent(
|
||||
'Note: The canonical controller name that ' . $tense
|
||||
. ' used with other providers is "' . $name . '";'
|
||||
. ' not "' . $originalName . '" as supplied',
|
||||
array('color' => array('yellow'))
|
||||
);
|
||||
unset($tense);
|
||||
}
|
||||
|
||||
// do the creation
|
||||
if ($request->isPretend()) {
|
||||
|
||||
$response->appendContent('Would create a controller at ' . $controllerResource->getContext()->getPath());
|
||||
|
||||
if (isset($indexActionResource)) {
|
||||
$response->appendContent('Would create an index action method in controller ' . $name);
|
||||
$response->appendContent('Would create a view script for the index action method at ' . $indexActionViewResource->getContext()->getPath());
|
||||
}
|
||||
|
||||
if ($testControllerResource) {
|
||||
$response->appendContent('Would create a controller test file at ' . $testControllerResource->getContext()->getPath());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$response->appendContent('Creating a controller at ' . $controllerResource->getContext()->getPath());
|
||||
$controllerResource->create();
|
||||
|
||||
if (isset($indexActionResource)) {
|
||||
$response->appendContent('Creating an index action method in controller ' . $name);
|
||||
$indexActionResource->create();
|
||||
$response->appendContent('Creating a view script for the index action method at ' . $indexActionViewResource->getContext()->getPath());
|
||||
$indexActionViewResource->create();
|
||||
}
|
||||
|
||||
if ($testControllerResource) {
|
||||
$response->appendContent('Creating a controller test file at ' . $testControllerResource->getContext()->getPath());
|
||||
$testControllerResource->create();
|
||||
}
|
||||
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
139
airtime_mvc/library/Zend/Tool/Project/Provider/DbAdapter.php
Normal file
139
airtime_mvc/library/Zend/Tool/Project/Provider/DbAdapter.php
Normal file
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: View.php 18386 2009-09-23 20:44:43Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Provider_Interactable
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Provider/Interactable.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_DbAdapter
|
||||
extends Zend_Tool_Project_Provider_Abstract
|
||||
implements Zend_Tool_Framework_Provider_Interactable, Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
|
||||
protected $_appConfigFilePath = null;
|
||||
|
||||
protected $_config = null;
|
||||
|
||||
protected $_sectionName = 'production';
|
||||
|
||||
public function configure($dsn = null, /* $interactivelyPrompt = false, */ $sectionName = 'production')
|
||||
{
|
||||
$profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
$appConfigFileResource = $profile->search('applicationConfigFile');
|
||||
|
||||
if ($appConfigFileResource == false) {
|
||||
throw new Zend_Tool_Project_Exception('A project with an application config file is required to use this provider.');
|
||||
}
|
||||
|
||||
$this->_appConfigFilePath = $appConfigFileResource->getPath();
|
||||
|
||||
$this->_config = new Zend_Config_Ini($this->_appConfigFilePath, null, array('skipExtends' => true, 'allowModifications' => true));
|
||||
|
||||
if ($sectionName != 'production') {
|
||||
$this->_sectionName = $sectionName;
|
||||
}
|
||||
|
||||
if (!isset($this->_config->{$this->_sectionName})) {
|
||||
throw new Zend_Tool_Project_Exception('The config does not have a ' . $this->_sectionName . ' section.');
|
||||
}
|
||||
|
||||
if (isset($this->_config->{$this->_sectionName}->resources->db)) {
|
||||
throw new Zend_Tool_Project_Exception('The config already has a db resource configured in section ' . $this->_sectionName . '.');
|
||||
}
|
||||
|
||||
if ($dsn) {
|
||||
$this->_configureViaDSN($dsn);
|
||||
//} elseif ($interactivelyPrompt) {
|
||||
// $this->_promptForConfig();
|
||||
} else {
|
||||
$this->_registry->getResponse()->appendContent('Nothing to do!');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function _configureViaDSN($dsn)
|
||||
{
|
||||
$dsnVars = array();
|
||||
|
||||
if (strpos($dsn, '=') === false) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('At least one name value pair is expected, typcially '
|
||||
. 'in the format of "adapter=Mysqli&username=uname&password=mypass&dbname=mydb"'
|
||||
);
|
||||
}
|
||||
|
||||
parse_str($dsn, $dsnVars);
|
||||
|
||||
// parse_str suffers when magic_quotes is enabled
|
||||
if (get_magic_quotes_gpc()) {
|
||||
array_walk_recursive($dsnVars, array($this, '_cleanMagicQuotesInValues'));
|
||||
}
|
||||
|
||||
$dbConfigValues = array('resources' => array('db' => null));
|
||||
|
||||
if (isset($dsnVars['adapter'])) {
|
||||
$dbConfigValues['resources']['db']['adapter'] = $dsnVars['adapter'];
|
||||
unset($dsnVars['adapter']);
|
||||
}
|
||||
|
||||
$dbConfigValues['resources']['db']['params'] = $dsnVars;
|
||||
|
||||
$isPretend = $this->_registry->getRequest()->isPretend();
|
||||
|
||||
// get the config resource
|
||||
$applicationConfig = $this->_loadedProfile->search('ApplicationConfigFile');
|
||||
$applicationConfig->addItem($dbConfigValues, $this->_sectionName, null);
|
||||
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
if ($isPretend) {
|
||||
$response->appendContent('A db configuration for the ' . $this->_sectionName
|
||||
. ' section would be written to the application config file with the following contents: '
|
||||
);
|
||||
$response->appendContent($applicationConfig->getContents());
|
||||
} else {
|
||||
$applicationConfig->create();
|
||||
$response->appendContent('A db configuration for the ' . $this->_sectionName
|
||||
. ' section has been written to the application config file.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _cleanMagicQuotesInValues(&$value, $key)
|
||||
{
|
||||
$value = stripslashes($value);
|
||||
}
|
||||
|
||||
}
|
220
airtime_mvc/library/Zend/Tool/Project/Provider/DbTable.php
Normal file
220
airtime_mvc/library/Zend/Tool/Project/Provider/DbTable.php
Normal file
|
@ -0,0 +1,220 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: View.php 18386 2009-09-23 20:44:43Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_DbTable
|
||||
extends Zend_Tool_Project_Provider_Abstract
|
||||
implements Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
|
||||
protected $_specialties = array('FromDatabase');
|
||||
|
||||
/**
|
||||
* @var Zend_Filter
|
||||
*/
|
||||
protected $_nameFilter = null;
|
||||
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $dbTableName, $actualTableName, $moduleName = null)
|
||||
{
|
||||
$profileSearchParams = array();
|
||||
|
||||
if ($moduleName != null && is_string($moduleName)) {
|
||||
$profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
|
||||
}
|
||||
|
||||
$profileSearchParams[] = 'modelsDirectory';
|
||||
|
||||
$modelsDirectory = $profile->search($profileSearchParams);
|
||||
|
||||
if (!($modelsDirectory instanceof Zend_Tool_Project_Profile_Resource)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception(
|
||||
'A models directory was not found' .
|
||||
(($moduleName) ? ' for module ' . $moduleName . '.' : '.')
|
||||
);
|
||||
}
|
||||
|
||||
if (!($dbTableDirectory = $modelsDirectory->search('DbTableDirectory'))) {
|
||||
$dbTableDirectory = $modelsDirectory->createResource('DbTableDirectory');
|
||||
}
|
||||
|
||||
$dbTableFile = $dbTableDirectory->createResource('DbTableFile', array('dbTableName' => $dbTableName, 'actualTableName' => $actualTableName));
|
||||
|
||||
return $dbTableFile;
|
||||
}
|
||||
|
||||
public static function hasResource(Zend_Tool_Project_Profile $profile, $dbTableName, $moduleName = null)
|
||||
{
|
||||
$profileSearchParams = array();
|
||||
|
||||
if ($moduleName != null && is_string($moduleName)) {
|
||||
$profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
|
||||
}
|
||||
|
||||
$profileSearchParams[] = 'modelsDirectory';
|
||||
|
||||
$modelsDirectory = $profile->search($profileSearchParams);
|
||||
|
||||
if (!($modelsDirectory instanceof Zend_Tool_Project_Profile_Resource)
|
||||
|| !($dbTableDirectory = $modelsDirectory->search('DbTableDirectory'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbTableFile = $dbTableDirectory->search(array('DbTableFile' => array('dbTableName' => $dbTableName)));
|
||||
|
||||
return ($dbTableFile instanceof Zend_Tool_Project_Profile_Resource) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
public function create($name, $actualTableName, $module = null, $forceOverwrite = false)
|
||||
{
|
||||
$this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
// Check that there is not a dash or underscore, return if doesnt match regex
|
||||
if (preg_match('#[_-]#', $name)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('DbTable names should be camel cased.');
|
||||
}
|
||||
|
||||
$originalName = $name;
|
||||
$name = ucfirst($name);
|
||||
|
||||
if ($actualTableName == '') {
|
||||
throw new Zend_Tool_Project_Provider_Exception('You must provide both the DbTable name as well as the actual db table\'s name.');
|
||||
}
|
||||
|
||||
if (self::hasResource($this->_loadedProfile, $name, $module)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('This project already has a DbTable named ' . $name);
|
||||
}
|
||||
|
||||
// get request/response object
|
||||
$request = $this->_registry->getRequest();
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
// alert the user about inline converted names
|
||||
$tense = (($request->isPretend()) ? 'would be' : 'is');
|
||||
|
||||
if ($name !== $originalName) {
|
||||
$response->appendContent(
|
||||
'Note: The canonical model name that ' . $tense
|
||||
. ' used with other providers is "' . $name . '";'
|
||||
. ' not "' . $originalName . '" as supplied',
|
||||
array('color' => array('yellow'))
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$tableResource = self::createResource($this->_loadedProfile, $name, $actualTableName, $module);
|
||||
} catch (Exception $e) {
|
||||
$response = $this->_registry->getResponse();
|
||||
$response->setException($e);
|
||||
return;
|
||||
}
|
||||
|
||||
// do the creation
|
||||
if ($request->isPretend()) {
|
||||
$response->appendContent('Would create a DbTable at ' . $tableResource->getContext()->getPath());
|
||||
} else {
|
||||
$response->appendContent('Creating a DbTable at ' . $tableResource->getContext()->getPath());
|
||||
$tableResource->create();
|
||||
$this->_storeProfile();
|
||||
}
|
||||
}
|
||||
|
||||
public function createFromDatabase($module = null, $forceOverwrite = false)
|
||||
{
|
||||
$this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
$bootstrapResource = $this->_loadedProfile->search('BootstrapFile');
|
||||
|
||||
/* @var $zendApp Zend_Application */
|
||||
$zendApp = $bootstrapResource->getApplicationInstance();
|
||||
|
||||
try {
|
||||
$zendApp->bootstrap('db');
|
||||
} catch (Zend_Application_Exception $e) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Db resource not available, you might need to configure a DbAdapter.');
|
||||
return;
|
||||
}
|
||||
|
||||
/* @var $db Zend_Db_Adapter_Abstract */
|
||||
$db = $zendApp->getBootstrap()->getResource('db');
|
||||
|
||||
$tableResources = array();
|
||||
foreach ($db->listTables() as $actualTableName) {
|
||||
|
||||
$dbTableName = $this->_convertTableNameToClassName($actualTableName);
|
||||
|
||||
if (!$forceOverwrite && self::hasResource($this->_loadedProfile, $dbTableName, $module)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception(
|
||||
'This DbTable resource already exists, if you wish to overwrite it, '
|
||||
. 'pass the "forceOverwrite" flag to this provider.'
|
||||
);
|
||||
}
|
||||
|
||||
$tableResources[] = self::createResource(
|
||||
$this->_loadedProfile,
|
||||
$dbTableName,
|
||||
$actualTableName,
|
||||
$module
|
||||
);
|
||||
}
|
||||
|
||||
if (count($tableResources) == 0) {
|
||||
$this->_registry->getResponse()->appendContent('There are no tables in the selected database to write.');
|
||||
}
|
||||
|
||||
// do the creation
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
|
||||
foreach ($tableResources as $tableResource) {
|
||||
$this->_registry->getResponse()->appendContent('Would create a DbTable at ' . $tableResource->getContext()->getPath());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
foreach ($tableResources as $tableResource) {
|
||||
$this->_registry->getResponse()->appendContent('Creating a DbTable at ' . $tableResource->getContext()->getPath());
|
||||
$tableResource->create();
|
||||
}
|
||||
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function _convertTableNameToClassName($tableName)
|
||||
{
|
||||
if ($this->_nameFilter == null) {
|
||||
$this->_nameFilter = new Zend_Filter();
|
||||
$this->_nameFilter
|
||||
->addFilter(new Zend_Filter_Word_UnderscoreToCamelCase());
|
||||
}
|
||||
|
||||
return $this->_nameFilter->filter($tableName);
|
||||
}
|
||||
|
||||
}
|
37
airtime_mvc/library/Zend/Tool/Project/Provider/Exception.php
Normal file
37
airtime_mvc/library/Zend/Tool/Project/Provider/Exception.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Exception
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Exception extends Zend_Tool_Project_Exception
|
||||
{
|
||||
|
||||
}
|
156
airtime_mvc/library/Zend/Tool/Project/Provider/Form.php
Normal file
156
airtime_mvc/library/Zend/Tool/Project/Provider/Form.php
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Form.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Form extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $formName, $moduleName = null)
|
||||
{
|
||||
if (!is_string($formName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Form::createResource() expects \"formName\" is the name of a form resource to create.');
|
||||
}
|
||||
|
||||
if (!($formsDirectory = self::_getFormsDirectoryResource($profile, $moduleName))) {
|
||||
if ($moduleName) {
|
||||
$exceptionMessage = 'A form directory for module "' . $moduleName . '" was not found.';
|
||||
} else {
|
||||
$exceptionMessage = 'A form directory was not found.';
|
||||
}
|
||||
throw new Zend_Tool_Project_Provider_Exception($exceptionMessage);
|
||||
}
|
||||
|
||||
$newForm = $formsDirectory->createResource(
|
||||
'formFile',
|
||||
array('formName' => $formName, 'moduleName' => $moduleName)
|
||||
);
|
||||
|
||||
return $newForm;
|
||||
}
|
||||
|
||||
/**
|
||||
* hasResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $formName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function hasResource(Zend_Tool_Project_Profile $profile, $formName, $moduleName = null)
|
||||
{
|
||||
if (!is_string($formName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Form::createResource() expects \"formName\" is the name of a form resource to check for existence.');
|
||||
}
|
||||
|
||||
$formsDirectory = self::_getFormsDirectoryResource($profile, $moduleName);
|
||||
return (($formsDirectory->search(array('formFile' => array('formName' => $formName)))) instanceof Zend_Tool_Project_Profile_Resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* _getFormsDirectoryResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
protected static function _getFormsDirectoryResource(Zend_Tool_Project_Profile $profile, $moduleName = null)
|
||||
{
|
||||
$profileSearchParams = array();
|
||||
|
||||
if ($moduleName != null && is_string($moduleName)) {
|
||||
$profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
|
||||
}
|
||||
|
||||
$profileSearchParams[] = 'formsDirectory';
|
||||
|
||||
return $profile->search($profileSearchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new form
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $module
|
||||
*/
|
||||
public function create($name, $module = null)
|
||||
{
|
||||
$this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
// determine if testing is enabled in the project
|
||||
$testingEnabled = Zend_Tool_Project_Provider_Test::isTestingEnabled($this->_loadedProfile);
|
||||
|
||||
if (self::hasResource($this->_loadedProfile, $name, $module)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('This project already has a form named ' . $name);
|
||||
}
|
||||
|
||||
// Check that there is not a dash or underscore, return if doesnt match regex
|
||||
if (preg_match('#[_-]#', $name)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Form names should be camel cased.');
|
||||
}
|
||||
|
||||
$name = ucwords($name);
|
||||
|
||||
try {
|
||||
$formResource = self::createResource($this->_loadedProfile, $name, $module);
|
||||
|
||||
if ($testingEnabled) {
|
||||
$testFormResource = null;
|
||||
// $testFormResource = Zend_Tool_Project_Provider_Test::createApplicationResource($this->_loadedProfile, $name, 'index', $module);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$response = $this->_registry->getResponse();
|
||||
$response->setException($e);
|
||||
return;
|
||||
}
|
||||
|
||||
// do the creation
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
|
||||
$this->_registry->getResponse()->appendContent('Would create a form at ' . $formResource->getContext()->getPath());
|
||||
|
||||
if ($testFormResource) {
|
||||
$this->_registry->getResponse()->appendContent('Would create a form test file at ' . $testFormResource->getContext()->getPath());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$this->_registry->getResponse()->appendContent('Creating a form at ' . $formResource->getContext()->getPath());
|
||||
$formResource->create();
|
||||
|
||||
if ($testFormResource) {
|
||||
$this->_registry->getResponse()->appendContent('Creating a form test file at ' . $testFormResource->getContext()->getPath());
|
||||
$testFormResource->create();
|
||||
}
|
||||
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
109
airtime_mvc/library/Zend/Tool/Project/Provider/Layout.php
Normal file
109
airtime_mvc/library/Zend/Tool/Project/Provider/Layout.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: View.php 18386 2009-09-23 20:44:43Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Layout extends Zend_Tool_Project_Provider_Abstract implements Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $layoutName = 'layout')
|
||||
{
|
||||
$applicationDirectory = $profile->search('applicationDirectory');
|
||||
$layoutDirectory = $applicationDirectory->search('layoutsDirectory');
|
||||
|
||||
if ($layoutDirectory == false) {
|
||||
$layoutDirectory = $applicationDirectory->createResource('layoutsDirectory');
|
||||
}
|
||||
|
||||
$layoutScriptsDirectory = $layoutDirectory->search('layoutScriptsDirectory');
|
||||
|
||||
if ($layoutScriptsDirectory == false) {
|
||||
$layoutScriptsDirectory = $layoutDirectory->createResource('layoutScriptsDirectory');
|
||||
}
|
||||
|
||||
$layoutScriptFile = $layoutScriptsDirectory->search('layoutScriptFile', array('layoutName' => 'layout'));
|
||||
|
||||
if ($layoutScriptFile == false) {
|
||||
$layoutScriptFile = $layoutScriptsDirectory->createResource('layoutScriptFile', array('layoutName' => 'layout'));
|
||||
}
|
||||
|
||||
return $layoutScriptFile;
|
||||
}
|
||||
|
||||
public function enable()
|
||||
{
|
||||
$profile = $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
$applicationConfigResource = $profile->search('ApplicationConfigFile');
|
||||
|
||||
if (!$applicationConfigResource) {
|
||||
throw new Zend_Tool_Project_Exception('A project with an application config file is required to use this provider.');
|
||||
}
|
||||
|
||||
$zc = $applicationConfigResource->getAsZendConfig();
|
||||
|
||||
if (isset($zc->resources) && isset($zf->resources->layout)) {
|
||||
$this->_registry->getResponse()->appendContent('A layout resource already exists in this project\'s application configuration file.');
|
||||
return;
|
||||
}
|
||||
|
||||
$layoutPath = 'APPLICATION_PATH "/layouts/scripts/"';
|
||||
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
$this->_registry->getResponse()->appendContent('Would add "resources.layout.layoutPath" key to the application config file.');
|
||||
} else {
|
||||
$applicationConfigResource->addStringItem('resources.layout.layoutPath', $layoutPath, 'production', false);
|
||||
$applicationConfigResource->create();
|
||||
|
||||
$layoutScriptFile = self::createResource($profile);
|
||||
|
||||
$layoutScriptFile->create();
|
||||
|
||||
$this->_registry->getResponse()->appendContent(
|
||||
'Layouts have been enabled, and a default layout created at '
|
||||
. $layoutScriptFile->getPath()
|
||||
);
|
||||
|
||||
$this->_registry->getResponse()->appendContent('A layout entry has been added to the application config file.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
// @todo
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
70
airtime_mvc/library/Zend/Tool/Project/Provider/Manifest.php
Normal file
70
airtime_mvc/library/Zend/Tool/Project/Provider/Manifest.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Manifest.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Manifest implements
|
||||
Zend_Tool_Framework_Manifest_ProviderManifestable
|
||||
{
|
||||
|
||||
/**
|
||||
* getProviders()
|
||||
*
|
||||
* @return array Array of Providers
|
||||
*/
|
||||
public function getProviders()
|
||||
{
|
||||
// the order here will represent what the output will look like when iterating a manifest
|
||||
|
||||
return array(
|
||||
// top level project & profile providers
|
||||
'Zend_Tool_Project_Provider_Profile',
|
||||
'Zend_Tool_Project_Provider_Project',
|
||||
|
||||
// app layer provider
|
||||
'Zend_Tool_Project_Provider_Application',
|
||||
|
||||
// MVC layer providers
|
||||
'Zend_Tool_Project_Provider_Model',
|
||||
'Zend_Tool_Project_Provider_View',
|
||||
'Zend_Tool_Project_Provider_Controller',
|
||||
'Zend_Tool_Project_Provider_Action',
|
||||
|
||||
// hMVC provider
|
||||
'Zend_Tool_Project_Provider_Module',
|
||||
|
||||
// application problem providers
|
||||
'Zend_Tool_Project_Provider_Form',
|
||||
'Zend_Tool_Project_Provider_Layout',
|
||||
'Zend_Tool_Project_Provider_DbAdapter',
|
||||
'Zend_Tool_Project_Provider_DbTable',
|
||||
|
||||
// provider within project provider
|
||||
'Zend_Tool_Project_Provider_ProjectProvider',
|
||||
|
||||
);
|
||||
}
|
||||
}
|
173
airtime_mvc/library/Zend/Tool/Project/Provider/Model.php
Normal file
173
airtime_mvc/library/Zend/Tool/Project/Provider/Model.php
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Model.php 20967 2010-02-07 18:17:49Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Model extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $modelName, $moduleName = null)
|
||||
{
|
||||
if (!is_string($modelName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Model::createResource() expects \"modelName\" is the name of a model resource to create.');
|
||||
}
|
||||
|
||||
if (!($modelsDirectory = self::_getModelsDirectoryResource($profile, $moduleName))) {
|
||||
if ($moduleName) {
|
||||
$exceptionMessage = 'A model directory for module "' . $moduleName . '" was not found.';
|
||||
} else {
|
||||
$exceptionMessage = 'A model directory was not found.';
|
||||
}
|
||||
throw new Zend_Tool_Project_Provider_Exception($exceptionMessage);
|
||||
}
|
||||
|
||||
$newModel = $modelsDirectory->createResource(
|
||||
'modelFile',
|
||||
array('modelName' => $modelName, 'moduleName' => $moduleName)
|
||||
);
|
||||
|
||||
return $newModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* hasResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $modelName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function hasResource(Zend_Tool_Project_Profile $profile, $modelName, $moduleName = null)
|
||||
{
|
||||
if (!is_string($modelName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Model::createResource() expects \"modelName\" is the name of a model resource to check for existence.');
|
||||
}
|
||||
|
||||
$modelsDirectory = self::_getModelsDirectoryResource($profile, $moduleName);
|
||||
return (($modelsDirectory->search(array('modelFile' => array('modelName' => $modelName)))) instanceof Zend_Tool_Project_Profile_Resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* _getModelsDirectoryResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
protected static function _getModelsDirectoryResource(Zend_Tool_Project_Profile $profile, $moduleName = null)
|
||||
{
|
||||
$profileSearchParams = array();
|
||||
|
||||
if ($moduleName != null && is_string($moduleName)) {
|
||||
$profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
|
||||
}
|
||||
|
||||
$profileSearchParams[] = 'modelsDirectory';
|
||||
|
||||
return $profile->search($profileSearchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new model
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $module
|
||||
*/
|
||||
public function create($name, $module = null)
|
||||
{
|
||||
$this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
$originalName = $name;
|
||||
|
||||
$name = ucwords($name);
|
||||
|
||||
// determine if testing is enabled in the project
|
||||
$testingEnabled = false; //Zend_Tool_Project_Provider_Test::isTestingEnabled($this->_loadedProfile);
|
||||
$testModelResource = null;
|
||||
|
||||
// Check that there is not a dash or underscore, return if doesnt match regex
|
||||
if (preg_match('#[_-]#', $name)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Model names should be camel cased.');
|
||||
}
|
||||
|
||||
if (self::hasResource($this->_loadedProfile, $name, $module)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('This project already has a model named ' . $name);
|
||||
}
|
||||
|
||||
// get request/response object
|
||||
$request = $this->_registry->getRequest();
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
// alert the user about inline converted names
|
||||
$tense = (($request->isPretend()) ? 'would be' : 'is');
|
||||
|
||||
if ($name !== $originalName) {
|
||||
$response->appendContent(
|
||||
'Note: The canonical model name that ' . $tense
|
||||
. ' used with other providers is "' . $name . '";'
|
||||
. ' not "' . $originalName . '" as supplied',
|
||||
array('color' => array('yellow'))
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$modelResource = self::createResource($this->_loadedProfile, $name, $module);
|
||||
|
||||
if ($testingEnabled) {
|
||||
// $testModelResource = Zend_Tool_Project_Provider_Test::createApplicationResource($this->_loadedProfile, $name, 'index', $module);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$response->setException($e);
|
||||
return;
|
||||
}
|
||||
|
||||
// do the creation
|
||||
if ($request->isPretend()) {
|
||||
|
||||
$response->appendContent('Would create a model at ' . $modelResource->getContext()->getPath());
|
||||
|
||||
if ($testModelResource) {
|
||||
$response->appendContent('Would create a model test file at ' . $testModelResource->getContext()->getPath());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$response->appendContent('Creating a model at ' . $modelResource->getContext()->getPath());
|
||||
$modelResource->create();
|
||||
|
||||
if ($testModelResource) {
|
||||
$response->appendContent('Creating a model test file at ' . $testModelResource->getContext()->getPath());
|
||||
$testModelResource->create();
|
||||
}
|
||||
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
172
airtime_mvc/library/Zend/Tool/Project/Provider/Module.php
Normal file
172
airtime_mvc/library/Zend/Tool/Project/Provider/Module.php
Normal file
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Module.php 20993 2010-02-08 18:41:22Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Provider_Pretendable
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Provider/Pretendable.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Profile_Iterator_ContextFilter
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Profile/Iterator/ContextFilter.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Profile_Iterator_EnabledResourceFilter
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Profile/Iterator/EnabledResourceFilter.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Module
|
||||
extends Zend_Tool_Project_Provider_Abstract
|
||||
implements Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
|
||||
public static function createResources(Zend_Tool_Project_Profile $profile, $moduleName, Zend_Tool_Project_Profile_Resource $targetModuleResource = null)
|
||||
{
|
||||
|
||||
// find the appliction directory, it will serve as our module skeleton
|
||||
if ($targetModuleResource == null) {
|
||||
$targetModuleResource = $profile->search('applicationDirectory');
|
||||
$targetModuleEnabledResources = array(
|
||||
'ControllersDirectory', 'ModelsDirectory', 'ViewsDirectory',
|
||||
'ViewScriptsDirectory', 'ViewHelpersDirectory', 'ViewFiltersDirectory'
|
||||
);
|
||||
}
|
||||
|
||||
// find the actual modules directory we will use to house our module
|
||||
$modulesDirectory = $profile->search('modulesDirectory');
|
||||
|
||||
// if there is a module directory already, except
|
||||
if ($modulesDirectory->search(array('moduleDirectory' => array('moduleName' => $moduleName)))) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('A module named "' . $moduleName . '" already exists.');
|
||||
}
|
||||
|
||||
// create the module directory
|
||||
$moduleDirectory = $modulesDirectory->createResource('moduleDirectory', array('moduleName' => $moduleName));
|
||||
|
||||
// create a context filter so that we can pull out only what we need from the module skeleton
|
||||
$moduleContextFilterIterator = new Zend_Tool_Project_Profile_Iterator_ContextFilter(
|
||||
$targetModuleResource,
|
||||
array(
|
||||
'denyNames' => array('ModulesDirectory', 'ViewControllerScriptsDirectory'),
|
||||
'denyType' => 'Zend_Tool_Project_Context_Filesystem_File'
|
||||
)
|
||||
);
|
||||
|
||||
// the iterator for the module skeleton
|
||||
$targetIterator = new RecursiveIteratorIterator($moduleContextFilterIterator, RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
// initialize some loop state information
|
||||
$currentDepth = 0;
|
||||
$parentResources = array();
|
||||
$currentResource = $moduleDirectory;
|
||||
|
||||
// loop through the target module skeleton
|
||||
foreach ($targetIterator as $targetSubResource) {
|
||||
|
||||
$depthDifference = $targetIterator->getDepth() - $currentDepth;
|
||||
$currentDepth = $targetIterator->getDepth();
|
||||
|
||||
if ($depthDifference === 1) {
|
||||
// if we went down into a child, make note
|
||||
array_push($parentResources, $currentResource);
|
||||
// this will have always been set previously by another loop
|
||||
$currentResource = $currentChildResource;
|
||||
} elseif ($depthDifference < 0) {
|
||||
// if we went up to a parent, make note
|
||||
$i = $depthDifference;
|
||||
do {
|
||||
// if we went out more than 1 parent, get to the correct parent
|
||||
$currentResource = array_pop($parentResources);
|
||||
} while ($i-- > 0);
|
||||
}
|
||||
|
||||
// get parameters for the newly created module resource
|
||||
$params = $targetSubResource->getAttributes();
|
||||
$currentChildResource = $currentResource->createResource($targetSubResource->getName(), $params);
|
||||
|
||||
// based of the provided list (Currently up top), enable specific resources
|
||||
if (isset($targetModuleEnabledResources)) {
|
||||
$currentChildResource->setEnabled(in_array($targetSubResource->getName(), $targetModuleEnabledResources));
|
||||
} else {
|
||||
$currentChildResource->setEnabled($targetSubResource->isEnabled());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $moduleDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* create()
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function create($name) //, $moduleProfile = null)
|
||||
{
|
||||
$this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
|
||||
|
||||
$resources = self::createResources($this->_loadedProfile, $name);
|
||||
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
$response->appendContent('I would create the following module and artifacts:');
|
||||
foreach (new RecursiveIteratorIterator($resources, RecursiveIteratorIterator::SELF_FIRST) as $resource) {
|
||||
if (is_callable(array($resource->getContext(), 'getPath'))) {
|
||||
$response->appendContent($resource->getContext()->getPath());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$response->appendContent('Creating the following module and artifacts:');
|
||||
$enabledFilter = new Zend_Tool_Project_Profile_Iterator_EnabledResourceFilter($resources);
|
||||
foreach (new RecursiveIteratorIterator($enabledFilter, RecursiveIteratorIterator::SELF_FIRST) as $resource) {
|
||||
$response->appendContent($resource->getContext()->getPath());
|
||||
$resource->create();
|
||||
}
|
||||
|
||||
if (strtolower($name) == 'default') {
|
||||
$response->appendContent('Added a key for the default module to the application.ini file');
|
||||
$appConfigFile = $this->_loadedProfile->search('ApplicationConfigFile');
|
||||
$appConfigFile->addStringItem('resources.frontController.params.prefixDefaultModule', '1', 'production');
|
||||
$appConfigFile->create();
|
||||
}
|
||||
|
||||
// store changes to the profile
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
54
airtime_mvc/library/Zend/Tool/Project/Provider/Profile.php
Normal file
54
airtime_mvc/library/Zend/Tool/Project/Provider/Profile.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Profile.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Profile extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* show()
|
||||
*
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
$this->_loadProfile();
|
||||
|
||||
$profileIterator = $this->_loadedProfile->getIterator();
|
||||
|
||||
foreach ($profileIterator as $profileItem) {
|
||||
$this->_registry->getResponse()->appendContent(
|
||||
str_repeat(' ', $profileIterator->getDepth()) . $profileItem
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
239
airtime_mvc/library/Zend/Tool/Project/Provider/Project.php
Normal file
239
airtime_mvc/library/Zend/Tool/Project/Provider/Project.php
Normal file
|
@ -0,0 +1,239 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Project.php 20970 2010-02-07 18:21:26Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Project
|
||||
extends Zend_Tool_Project_Provider_Abstract
|
||||
//implements Zend_Tool_Framework_Provider_DocblockManifestInterface
|
||||
{
|
||||
|
||||
protected $_specialties = array('Info');
|
||||
|
||||
/**
|
||||
* create()
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $nameOfProfile shortName=n
|
||||
* @param string $fileOfProfile shortName=f
|
||||
*/
|
||||
public function create($path, $nameOfProfile = null, $fileOfProfile = null)
|
||||
{
|
||||
if ($path == null) {
|
||||
$path = getcwd();
|
||||
} else {
|
||||
$path = trim($path);
|
||||
if (!file_exists($path)) {
|
||||
$created = mkdir($path);
|
||||
if (!$created) {
|
||||
require_once 'Zend/Tool/Framework/Client/Exception.php';
|
||||
throw new Zend_Tool_Framework_Client_Exception('Could not create requested project directory \'' . $path . '\'');
|
||||
}
|
||||
}
|
||||
$path = str_replace('\\', '/', realpath($path));
|
||||
}
|
||||
|
||||
$profile = $this->_loadProfile(self::NO_PROFILE_RETURN_FALSE, $path);
|
||||
|
||||
if ($profile !== false) {
|
||||
require_once 'Zend/Tool/Framework/Client/Exception.php';
|
||||
throw new Zend_Tool_Framework_Client_Exception('A project already exists here');
|
||||
}
|
||||
|
||||
$profileData = null;
|
||||
|
||||
if ($fileOfProfile != null && file_exists($fileOfProfile)) {
|
||||
$profileData = file_get_contents($fileOfProfile);
|
||||
}
|
||||
|
||||
$storage = $this->_registry->getStorage();
|
||||
if ($profileData == '' && $nameOfProfile != null && $storage->isEnabled()) {
|
||||
$profileData = $storage->get('project/profiles/' . $nameOfProfile . '.xml');
|
||||
}
|
||||
|
||||
if ($profileData == '') {
|
||||
$profileData = $this->_getDefaultProfile();
|
||||
}
|
||||
|
||||
$newProfile = new Zend_Tool_Project_Profile(array(
|
||||
'projectDirectory' => $path,
|
||||
'profileData' => $profileData
|
||||
));
|
||||
|
||||
$newProfile->loadFromData();
|
||||
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
$response->appendContent('Creating project at ' . $path);
|
||||
$response->appendContent('Note: ', array('separator' => false, 'color' => 'yellow'));
|
||||
$response->appendContent(
|
||||
'This command created a web project, '
|
||||
. 'for more information setting up your VHOST, please see docs/README');
|
||||
|
||||
foreach ($newProfile->getIterator() as $resource) {
|
||||
$resource->create();
|
||||
}
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
$this->_registry->getResponse()->appendContent('You probably meant to run "show project.info".', array('color' => 'yellow'));
|
||||
}
|
||||
|
||||
public function showInfo()
|
||||
{
|
||||
$profile = $this->_loadProfile(self::NO_PROFILE_RETURN_FALSE);
|
||||
if (!$profile) {
|
||||
$this->_registry->getResponse()->appendContent('No project found.');
|
||||
} else {
|
||||
$this->_registry->getResponse()->appendContent('Working with project located at: ' . $profile->getAttribute('projectDirectory'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getDefaultProfile()
|
||||
{
|
||||
$data = <<<EOS
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectProfile type="default" version="1.10">
|
||||
<projectDirectory>
|
||||
<projectProfileFile />
|
||||
<applicationDirectory>
|
||||
<apisDirectory enabled="false" />
|
||||
<configsDirectory>
|
||||
<applicationConfigFile type="ini" />
|
||||
</configsDirectory>
|
||||
<controllersDirectory>
|
||||
<controllerFile controllerName="Index">
|
||||
<actionMethod actionName="index" />
|
||||
</controllerFile>
|
||||
<controllerFile controllerName="Error" />
|
||||
</controllersDirectory>
|
||||
<formsDirectory enabled="false" />
|
||||
<layoutsDirectory enabled="false" />
|
||||
<modelsDirectory />
|
||||
<modulesDirectory enabled="false" />
|
||||
<viewsDirectory>
|
||||
<viewScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Index">
|
||||
<viewScriptFile forActionName="index" />
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Error">
|
||||
<viewScriptFile forActionName="error" />
|
||||
</viewControllerScriptsDirectory>
|
||||
</viewScriptsDirectory>
|
||||
<viewHelpersDirectory />
|
||||
<viewFiltersDirectory enabled="false" />
|
||||
</viewsDirectory>
|
||||
<bootstrapFile />
|
||||
</applicationDirectory>
|
||||
<dataDirectory enabled="false">
|
||||
<cacheDirectory enabled="false" />
|
||||
<searchIndexesDirectory enabled="false" />
|
||||
<localesDirectory enabled="false" />
|
||||
<logsDirectory enabled="false" />
|
||||
<sessionsDirectory enabled="false" />
|
||||
<uploadsDirectory enabled="false" />
|
||||
</dataDirectory>
|
||||
<docsDirectory>
|
||||
<file filesystemName="README.txt" defaultContentCallback="Zend_Tool_Project_Provider_Project::getDefaultReadmeContents"/>
|
||||
</docsDirectory>
|
||||
<libraryDirectory>
|
||||
<zfStandardLibraryDirectory enabled="false" />
|
||||
</libraryDirectory>
|
||||
<publicDirectory>
|
||||
<publicStylesheetsDirectory enabled="false" />
|
||||
<publicScriptsDirectory enabled="false" />
|
||||
<publicImagesDirectory enabled="false" />
|
||||
<publicIndexFile />
|
||||
<htaccessFile />
|
||||
</publicDirectory>
|
||||
<projectProvidersDirectory enabled="false" />
|
||||
<temporaryDirectory enabled="false" />
|
||||
<testsDirectory>
|
||||
<testPHPUnitConfigFile />
|
||||
<testApplicationDirectory>
|
||||
<testApplicationBootstrapFile />
|
||||
</testApplicationDirectory>
|
||||
<testLibraryDirectory>
|
||||
<testLibraryBootstrapFile />
|
||||
</testLibraryDirectory>
|
||||
</testsDirectory>
|
||||
</projectDirectory>
|
||||
</projectProfile>
|
||||
EOS;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getDefaultReadmeContents($caller = null)
|
||||
{
|
||||
$projectDirResource = $caller->getResource()->getProfile()->search('projectDirectory');
|
||||
if ($projectDirResource) {
|
||||
$name = ltrim(strrchr($projectDirResource->getPath(), DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
|
||||
$path = $projectDirResource->getPath() . '/public';
|
||||
} else {
|
||||
$path = '/path/to/public';
|
||||
}
|
||||
|
||||
return <<< EOS
|
||||
README
|
||||
======
|
||||
|
||||
This directory should be used to place project specfic documentation including
|
||||
but not limited to project notes, generated API/phpdoc documentation, or
|
||||
manual files generated or hand written. Ideally, this directory would remain
|
||||
in your development environment only and should not be deployed with your
|
||||
application to it's final production location.
|
||||
|
||||
|
||||
Setting Up Your VHOST
|
||||
=====================
|
||||
|
||||
The following is a sample VHOST you might want to consider for your project.
|
||||
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot "$path"
|
||||
ServerName $name.local
|
||||
|
||||
# This should be omitted in the production environment
|
||||
SetEnv APPLICATION_ENV development
|
||||
|
||||
<Directory "$path">
|
||||
Options Indexes MultiViews FollowSymLinks
|
||||
AllowOverride All
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
</VirtualHost>
|
||||
|
||||
EOS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ProjectProvider.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/** @see Zend_Tool_Project_Provider_Abstract */
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_ProjectProvider extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* createResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $projectProviderName
|
||||
* @param string $actionNames
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $projectProviderName, $actionNames = null)
|
||||
{
|
||||
|
||||
if (!is_string($projectProviderName)) {
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Exception
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_Controller::createResource() expects \"projectProviderName\" is the name of a project provider resource to create.');
|
||||
}
|
||||
|
||||
$profileSearchParams = array();
|
||||
$profileSearchParams[] = 'projectProvidersDirectory';
|
||||
|
||||
$projectProvider = $profile->createResourceAt($profileSearchParams, 'projectProviderFile', array('projectProviderName' => $projectProviderName, 'actionNames' => $actionNames));
|
||||
|
||||
return $projectProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* getName()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'ProjectProvider';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stub for Zend_Tool Project Provider
|
||||
*
|
||||
* @var string $name class name for new Zend_Tool Project Provider
|
||||
* @var array|string $actions list of provider methods
|
||||
* @throws Zend_Tool_Project_Provider_Exception
|
||||
*/
|
||||
public function create($name, $actions = null)
|
||||
{
|
||||
$profile = $this->_loadProfileRequired();
|
||||
|
||||
$projectProvider = self::createResource($profile, $name, $actions);
|
||||
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
$this->_registry->getResponse()->appendContent('Would create a project provider named ' . $name
|
||||
. ' in location ' . $projectProvider->getPath()
|
||||
);
|
||||
} else {
|
||||
$this->_registry->getResponse()->appendContent('Creating a project provider named ' . $name
|
||||
. ' in location ' . $projectProvider->getPath()
|
||||
);
|
||||
$projectProvider->create();
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
174
airtime_mvc/library/Zend/Tool/Project/Provider/Test.php
Normal file
174
airtime_mvc/library/Zend/Tool/Project/Provider/Test.php
Normal file
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Test.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Exception
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_Test extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
protected $_specialties = array('Application', 'Library');
|
||||
|
||||
/**
|
||||
* isTestingEnabled()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @return bool
|
||||
*/
|
||||
public static function isTestingEnabled(Zend_Tool_Project_Profile $profile)
|
||||
{
|
||||
$profileSearchParams = array('testsDirectory');
|
||||
$testsDirectory = $profile->search($profileSearchParams);
|
||||
|
||||
return $testsDirectory->isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* createApplicationResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $controllerName
|
||||
* @param string $actionName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createApplicationResource(Zend_Tool_Project_Profile $profile, $controllerName, $actionName, $moduleName = null)
|
||||
{
|
||||
if (!is_string($controllerName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createApplicationResource() expects \"controllerName\" is the name of a controller resource to create.');
|
||||
}
|
||||
|
||||
if (!is_string($actionName)) {
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createApplicationResource() expects \"actionName\" is the name of a controller resource to create.');
|
||||
}
|
||||
|
||||
$testsDirectoryResource = $profile->search('testsDirectory');
|
||||
|
||||
if (($testAppDirectoryResource = $testsDirectoryResource->search('testApplicationDirectory')) === false) {
|
||||
$testAppDirectoryResource = $testsDirectoryResource->createResource('testApplicationDirectory');
|
||||
}
|
||||
|
||||
if ($moduleName) {
|
||||
//@todo $moduleName
|
||||
$moduleName = '';
|
||||
}
|
||||
|
||||
if (($testAppControllerDirectoryResource = $testAppDirectoryResource->search('testApplicationControllerDirectory')) === false) {
|
||||
$testAppControllerDirectoryResource = $testAppDirectoryResource->createResource('testApplicationControllerDirectory');
|
||||
}
|
||||
|
||||
$testAppControllerFileResource = $testAppControllerDirectoryResource->createResource('testApplicationControllerFile', array('forControllerName' => $controllerName));
|
||||
|
||||
return $testAppControllerFileResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* createLibraryResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $libraryClassName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createLibraryResource(Zend_Tool_Project_Profile $profile, $libraryClassName)
|
||||
{
|
||||
$testLibraryDirectoryResource = $profile->search(array('TestsDirectory', 'TestLibraryDirectory'));
|
||||
|
||||
|
||||
$fsParts = explode('_', $libraryClassName);
|
||||
|
||||
$currentDirectoryResource = $testLibraryDirectoryResource;
|
||||
|
||||
while ($nameOrNamespacePart = array_shift($fsParts)) {
|
||||
|
||||
if (count($fsParts) > 0) {
|
||||
|
||||
if (($libraryDirectoryResource = $currentDirectoryResource->search(array('TestLibraryNamespaceDirectory' => array('namespaceName' => $nameOrNamespacePart)))) === false) {
|
||||
$currentDirectoryResource = $currentDirectoryResource->createResource('TestLibraryNamespaceDirectory', array('namespaceName' => $nameOrNamespacePart));
|
||||
} else {
|
||||
$currentDirectoryResource = $libraryDirectoryResource;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if (($libraryFileResource = $currentDirectoryResource->search(array('TestLibraryFile' => array('forClassName' => $libraryClassName)))) === false) {
|
||||
$libraryFileResource = $currentDirectoryResource->createResource('TestLibraryFile', array('forClassName' => $libraryClassName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $libraryFileResource;
|
||||
}
|
||||
|
||||
public function enable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* create()
|
||||
*
|
||||
* @param unknown_type $libraryClassName
|
||||
*/
|
||||
public function create($libraryClassName)
|
||||
{
|
||||
$profile = $this->_loadProfile();
|
||||
|
||||
if (!self::isTestingEnabled($profile)) {
|
||||
$this->_registry->getResponse()->appendContent('Testing is not enabled for this project.');
|
||||
}
|
||||
|
||||
$testLibraryResource = self::createLibraryResource($profile, $libraryClassName);
|
||||
|
||||
$response = $this->_registry->getResponse();
|
||||
|
||||
if ($this->_registry->getRequest()->isPretend()) {
|
||||
$response->appendContent('Would create a library stub in location ' . $testLibraryResource->getContext()->getPath());
|
||||
} else {
|
||||
$response->appendContent('Creating a library stub in location ' . $testLibraryResource->getContext()->getPath());
|
||||
$testLibraryResource->create();
|
||||
$this->_storeProfile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
118
airtime_mvc/library/Zend/Tool/Project/Provider/View.php
Normal file
118
airtime_mvc/library/Zend/Tool/Project/Provider/View.php
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: View.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Project_Provider_Abstract
|
||||
*/
|
||||
require_once 'Zend/Tool/Project/Provider/Abstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Project_Provider_View extends Zend_Tool_Project_Provider_Abstract
|
||||
{
|
||||
|
||||
/**
|
||||
* createResource()
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
* @param string $actionName
|
||||
* @param string $controllerName
|
||||
* @param string $moduleName
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
public static function createResource(Zend_Tool_Project_Profile $profile, $actionName, $controllerName, $moduleName = null)
|
||||
{
|
||||
if (!is_string($actionName)) {
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createResource() expects \"actionName\" is the name of a controller resource to create.');
|
||||
}
|
||||
|
||||
if (!is_string($controllerName)) {
|
||||
require_once 'Zend/Tool/Project/Provider/Exception.php';
|
||||
throw new Zend_Tool_Project_Provider_Exception('Zend_Tool_Project_Provider_View::createResource() expects \"controllerName\" is the name of a controller resource to create.');
|
||||
}
|
||||
|
||||
$profileSearchParams = array();
|
||||
|
||||
if ($moduleName) {
|
||||
$profileSearchParams = array('modulesDirectory', 'moduleDirectory' => 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue