adding zend project folders into old campcaster.

This commit is contained in:
naomiaro 2010-12-07 14:19:27 -05:00
parent 56abfaf28e
commit 7ef0c18b26
4045 changed files with 1054952 additions and 0 deletions

View file

@ -0,0 +1,106 @@
<?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: Engine.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Content_Engine_CodeGenerator
*/
require_once 'Zend/Tool/Project/Context/Content/Engine/CodeGenerator.php';
/**
* @see Zend_Tool_Project_Context_Content_Engine_Phtml
*/
require_once 'Zend/Tool/Project/Context/Content/Engine/Phtml.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Content_Engine
{
/**
* @var Zend_Tool_Framework_Client_Storage
*/
protected $_storage = null;
/**
* @var string
*/
protected $_keyInStorage = 'project/content';
/**
* @var array
*/
protected $_engines = array();
/**
* __construct()
*
* @param Zend_Tool_Framework_Client_Storage $storage
*/
public function __construct(Zend_Tool_Framework_Client_Storage $storage)
{
$this->_storage = $storage;
$this->_engines = array(
new Zend_Tool_Project_Context_Content_Engine_CodeGenerator($storage, $this->_keyInStorage),
new Zend_Tool_Project_Context_Content_Engine_Phtml($storage, $this->_keyInStorage),
);
}
/**
* getContent()
*
* @param Zend_Tool_Project_Context_Interface $context
* @param string $methodName
* @param mixed $parameters
* @return string
*/
public function getContent(Zend_Tool_Project_Context_Interface $context, $methodName, $parameters)
{
$content = null;
foreach ($this->_engines as $engine) {
if ($engine->hasContent($context, $methodName, $parameters)) {
$content = $engine->getContent($context, $methodName, $parameters);
if ($content != null) {
break;
}
}
}
if ($content == null) {
return false;
}
return $content;
}
}

View file

@ -0,0 +1,98 @@
<?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: CodeGenerator.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Content_Engine_CodeGenerator
{
/**
* @var Zend_Tool_Framework_Client_Storage
*/
protected $_storage = null;
/**
* @var string
*/
protected $_contentPrefix = null;
/**
* __construct()
*
* @param Zend_Tool_Framework_Client_Storage $storage
* @param string $contentPrefix
*/
public function __construct(Zend_Tool_Framework_Client_Storage $storage, $contentPrefix)
{
$this->_storage = $storage;
$this->_contentPrefix = $contentPrefix;
}
/**
* hasContent()
*
* @param Zend_Tool_Project_Context_Interface $context
* @param string $method
* @return string
*/
public function hasContent(Zend_Tool_Project_Context_Interface $context, $method)
{
return $this->_storage->has($this->_contentPrefix . '/' . $context->getName() . '/' . $method . '.php');
}
/**
* getContent()
*
* @param Zend_Tool_Project_Context_Interface $context
* @param string $method
* @param mixed $parameters
* @return string
*/
public function getContent(Zend_Tool_Project_Context_Interface $context, $method, $parameters)
{
$streamUri = $this->_storage->getStreamUri($this->_contentPrefix . '/' . $context->getName() . '/' . $method . '.php');
if (method_exists($context, 'getCodeGenerator')) {
$codeGenerator = $context->getCodeGenerator();
} else {
$codeGenerator = new Zend_CodeGenerator_Php_File();
}
$codeGenerator = include $streamUri;
if (!$codeGenerator instanceof Zend_CodeGenerator_Abstract) {
throw new Zend_Tool_Project_Exception('Custom file at ' . $streamUri . ' did not return the $codeGenerator object.');
}
return $codeGenerator->generate();
}
}

View file

@ -0,0 +1,89 @@
<?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: Phtml.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Content_Engine_Phtml
{
/**
* @var Zend_Tool_Framework_Client_Storage
*/
protected $_storage = null;
/**
* @var string
*/
protected $_contentPrefix = null;
/**
* __construct()
*
* @param Zend_Tool_Framework_Client_Storage $storage
* @param string $contentPrefix
*/
public function __construct(Zend_Tool_Framework_Client_Storage $storage, $contentPrefix)
{
$this->_storage = $storage;
$this->_contentPrefix = $contentPrefix;
}
/**
* hasContext()
*
* @param Zend_Tool_Project_Context_Interface $context
* @param string $method
* @return string
*/
public function hasContent(Zend_Tool_Project_Context_Interface $context, $method)
{
return $this->_storage->has($this->_contentPrefix . '/' . $context . '/' . $method . '.phtml');
}
/**
* getContent()
*
* @param Zend_Tool_Project_Context_Interface $context
* @param string $method
* @param mixed $parameters
*/
public function getContent(Zend_Tool_Project_Context_Interface $context, $method, $parameters)
{
$streamUri = $this->_storage->getStreamUri($this->_contentPrefix . '/' . $context->getName() . '/' . $method . '.phtml');
ob_start();
include $streamUri;
$content = ob_get_clean();
return $content;
}
}

View file

@ -0,0 +1,33 @@
<?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: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
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_Context_Exception extends Zend_Tool_Project_Exception
{
}

View file

@ -0,0 +1,165 @@
<?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_Context_Interface
*/
require_once 'Zend/Tool/Project/Context/Interface.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Filesystem_Abstract implements Zend_Tool_Project_Context_Interface
{
/**
* @var Zend_Tool_Project_Profile_Resource
*/
protected $_resource = null;
/**
* @var string
*/
protected $_baseDirectory = null;
/**
* @var string
*/
protected $_filesystemName = null;
/**
* init()
*
* @return Zend_Tool_Project_Context_Filesystem_Abstract
*/
public function init()
{
$parentBaseDirectory = $this->_resource->getParentResource()->getContext()->getPath();
$this->_baseDirectory = $parentBaseDirectory;
return $this;
}
/**
* setResource()
*
* @param Zend_Tool_Project_Profile_Resource $resource
* @return Zend_Tool_Project_Context_Filesystem_Abstract
*/
public function setResource(Zend_Tool_Project_Profile_Resource $resource)
{
$this->_resource = $resource;
return $this;
}
/**
* setBaseDirectory()
*
* @param string $baseDirectory
* @return Zend_Tool_Project_Context_Filesystem_Abstract
*/
public function setBaseDirectory($baseDirectory)
{
$this->_baseDirectory = rtrim(str_replace('\\', '/', $baseDirectory), '/');
return $this;
}
/**
* getBaseDirectory()
*
* @return string
*/
public function getBaseDirectory()
{
return $this->_baseDirectory;
}
/**
* setFilesystemName()
*
* @param string $filesystemName
* @return Zend_Tool_Project_Context_Filesystem_Abstract
*/
public function setFilesystemName($filesystemName)
{
$this->_filesystemName = $filesystemName;
return $this;
}
/**
* getFilesystemName()
*
* @return string
*/
public function getFilesystemName()
{
return $this->_filesystemName;
}
/**
* getPath()
*
* @return string
*/
public function getPath()
{
$path = $this->_baseDirectory;
if ($this->_filesystemName) {
$path .= '/' . $this->_filesystemName;
}
return $path;
}
/**
* exists()
*
* @return bool
*/
public function exists()
{
return file_exists($this->getPath());
}
/**
* create()
*
* Create this resource/context
*
*/
abstract public function create();
/**
* delete()
*
* Delete this resouce/context
*
*/
abstract public function delete();
}

View file

@ -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: Directory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Abstract
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Abstract.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Filesystem_Directory extends Zend_Tool_Project_Context_Filesystem_Abstract
{
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'directory';
}
/**
* create()
*
* @return Zend_Tool_Project_Context_Filesystem_Directory;
*/
public function create()
{
// check to ensure the parent exists, if not, call it and create it
if (($parentResource = $this->_resource->getParentResource()) instanceof Zend_Tool_Project_Profile_Resource) {
if ((($parentContext = $parentResource->getContext()) instanceof Zend_Tool_Project_Context_Filesystem_Abstract)
&& (!$parentContext->exists())) {
$parentResource->create();
}
}
if (!file_exists($this->getPath())) {
mkdir($this->getPath());
}
return $this;
}
/**
* delete()
*
* @return Zend_Tool_Project_Context_Filesystem_Directory
*/
public function delete()
{
$this->_resource->setDeleted(true);
rmdir($this->getPath());
return $this;
}
}

View 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: File.php 20971 2010-02-07 18:22:38Z ralph $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Abstract
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Abstract.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Filesystem_File extends Zend_Tool_Project_Context_Filesystem_Abstract
{
protected $_fileOnlyContext = null;
protected $_filesystemName = null;
protected $_content = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'file';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_Filesystem_File
*/
public function init()
{
if ($this->_resource->hasAttribute('filesystemName')) {
$this->_filesystemName = $this->_resource->getAttribute('filesystemName');
}
// check to see if this file is
if ($this->getName() == 'file') {
$this->_initFileOnlyContext();
}
// @potential-todo check to ensure that this 'file' resource has no children
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return array
*/
public function getPersistentAttributes()
{
$returnAttrs = array();
if ($this->_filesystemName !== null) {
$returnAttrs['filesystemName'] = $this->_filesystemName;
}
return $returnAttrs;
}
/**
* setResource()
*
* @param unknown_type $resource
*/
public function setResource(Zend_Tool_Project_Profile_Resource $resource)
{
$this->_resource = $resource;
$this->_resource->setAppendable(false);
return $this;
}
/**
* getResource()
*
* @return Zend_Tool_Project_Profile_Resource
*/
public function getResource()
{
return $this->_resource;
}
/**
* create()
*
* @return Zend_Tool_Project_Context_Filesystem_File
*/
public function create()
{
// check to ensure the parent exists, if not, call it and create it
if (($parentResource = $this->_resource->getParentResource()) instanceof Zend_Tool_Project_Profile_Resource) {
if ((($parentContext = $parentResource->getContext()) instanceof Zend_Tool_Project_Context_Filesystem_Abstract)
&& (!$parentContext->exists())) {
$parentResource->create();
}
}
if (file_exists($this->getPath())) {
// @todo propt user to determine if its ok to overwrite file
}
file_put_contents($this->getPath(), $this->getContents());
return $this;
}
/**
* delete()
*
* @return Zend_Tool_Project_Context_Filesystem_File
*/
public function delete()
{
unlink($this->getPath());
$this->_resource->setDeleted(true);
return $this;
}
/**
* getContents()
*
* @return null
*/
public function getContents()
{
return $this->_content;
}
protected function _initFileOnlyContext()
{
if ($this->_resource->hasAttribute('defaultContentCallback')) {
$contentFunc = $this->_resource->getAttribute('defaultContentCallback');
if (is_callable($contentFunc)) {
$this->_content = call_user_func_array($contentFunc, array($this));
}
}
if ($this->_filesystemName == null) {
$this->_filesystemName = 'file.txt';
}
}
}

View file

@ -0,0 +1,38 @@
<?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: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* Interface for contexts
*
* setResource() is an optional method that if the context supports
* will be set with the resource at construction time
*
* @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
*/
interface Zend_Tool_Project_Context_Interface
{
public function getName();
}

View file

@ -0,0 +1,189 @@
<?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: Repository.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
require_once 'Zend/Tool/Project/Context/System/Interface.php';
require_once 'Zend/Tool/Project/Context/System/TopLevelRestrictable.php';
require_once 'Zend/Tool/Project/Context/System/NotOverwritable.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_Context_Repository implements Countable
{
protected static $_instance = null;
protected static $_isInitialized = false;
protected $_shortContextNames = array();
protected $_contexts = array();
/**
* Enter description here...
*
* @return Zend_Tool_Project_Context_Repository
*/
public static function getInstance()
{
if (self::$_instance == null) {
self::$_instance = new self();
}
return self::$_instance;
}
public static function resetInstance()
{
self::$_instance = null;
self::$_isInitialized = false;
}
protected function __construct()
{
if (self::$_isInitialized == false) {
$this->addContextClass('Zend_Tool_Project_Context_System_ProjectDirectory')
->addContextClass('Zend_Tool_Project_Context_System_ProjectProfileFile')
->addContextClass('Zend_Tool_Project_Context_System_ProjectProvidersDirectory');
self::$_isInitialized = true;
}
}
public function addContextsFromDirectory($directory, $prefix)
{
$prefix = trim($prefix, '_') . '_';
foreach (new DirectoryIterator($directory) as $directoryItem) {
if ($directoryItem->isDot() || (substr($directoryItem->getFilename(), -4) !== '.php')) {
continue;
}
$class = $prefix . substr($directoryItem->getFilename(), 0, -4);
$this->addContextClass($class);
}
}
public function addContextClass($contextClass)
{
if (!class_exists($contextClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($contextClass);
}
$reflectionContextClass = new ReflectionClass($contextClass);
if ($reflectionContextClass->isInstantiable()) {
$context = new $contextClass();
return $this->addContext($context);
}
return $this;
}
/**
* Enter description here...
*
* @param Zend_Tool_Project_Context_Interface $context
* @return Zend_Tool_Project_Context_Repository
*/
public function addContext(Zend_Tool_Project_Context_Interface $context)
{
$isSystem = ($context instanceof Zend_Tool_Project_Context_System_Interface);
$isTopLevel = ($context instanceof Zend_Tool_Project_Context_System_TopLevelRestrictable);
$isOverwritable = !($context instanceof Zend_Tool_Project_Context_System_NotOverwritable);
$index = (count($this->_contexts)) ? max(array_keys($this->_contexts)) + 1 : 1;
$normalName = $this->_normalizeName($context->getName());
if (isset($this->_shortContextNames[$normalName]) && ($this->_contexts[$this->_shortContextNames[$normalName]]['isOverwritable'] === false) ) {
require_once 'Zend/Tool/Project/Context/Exception.php';
throw new Zend_Tool_Project_Context_Exception('Context ' . $context->getName() . ' is not overwriteable.');
}
$this->_shortContextNames[$normalName] = $index;
$this->_contexts[$index] = array(
'isTopLevel' => $isTopLevel,
'isSystem' => $isSystem,
'isOverwritable' => $isOverwritable,
'normalName' => $normalName,
'context' => $context
);
return $this;
}
public function getContext($name)
{
if (!$this->hasContext($name)) {
require_once 'Zend/Tool/Project/Context/Exception.php';
throw new Zend_Tool_Project_Context_Exception('Context by name ' . $name . ' does not exist in the registry.');
}
$name = $this->_normalizeName($name);
return clone $this->_contexts[$this->_shortContextNames[$name]]['context'];
}
public function hasContext($name)
{
$name = $this->_normalizeName($name);
return (isset($this->_shortContextNames[$name]) ? true : false);
}
public function isSystemContext($name)
{
if (!$this->hasContext($name)) {
return false;
}
$name = $this->_normalizeName($name);
$index = $this->_shortContextNames[$name];
return $this->_contexts[$index]['isSystemContext'];
}
public function isTopLevelContext($name)
{
if (!$this->hasContext($name)) {
return false;
}
$name = $this->_normalizeName($name);
$index = $this->_shortContextNames[$name];
return $this->_contexts[$index]['isTopLevel'];
}
public function isOverwritableContext($name)
{
if (!$this->hasContext($name)) {
return false;
}
$name = $this->_normalizeName($name);
$index = $this->_shortContextNames[$name];
return $this->_contexts[$index]['isOverwritable'];
}
public function count()
{
return count($this->_contexts);
}
protected function _normalizeName($name)
{
return strtolower($name);
}
}

View 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: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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
*/
interface Zend_Tool_Project_Context_System_Interface
{
}

View 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: NotOverwritable.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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
*/
interface Zend_Tool_Project_Context_System_NotOverwritable
{
}

View file

@ -0,0 +1,128 @@
<?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: ProjectDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* @see Zend_Tool_Project_Context_System_Interface
*/
require_once 'Zend/Tool/Project/Context/System/Interface.php';
/**
* @see Zend_Tool_Project_Context_System_TopLevelRestrictable
*/
require_once 'Zend/Tool/Project/Context/System/TopLevelRestrictable.php';
/**
* @see Zend_Tool_Project_Context_System_NotOverwritable
*/
require_once 'Zend/Tool/Project/Context/System/NotOverwritable.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_System_ProjectDirectory
extends Zend_Tool_Project_Context_Filesystem_Directory
implements Zend_Tool_Project_Context_System_Interface,
Zend_Tool_Project_Context_System_NotOverwritable,
Zend_Tool_Project_Context_System_TopLevelRestrictable
{
/**
* @var string
*/
protected $_filesystemName = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ProjectDirectory';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_System_ProjectDirectory
*/
public function init()
{
// get base path from attributes (would be in path attribute)
$projectDirectory = $this->_resource->getAttribute('path');
// if not, get from profile
if ($projectDirectory == null) {
$projectDirectory = $this->_resource->getProfile()->getAttribute('projectDirectory');
}
// if not, exception.
if ($projectDirectory == null) {
require_once 'Zend/Tool/Project/Exception.php';
throw new Zend_Tool_Project_Exception('projectDirectory cannot find the directory for this project.');
}
$this->_baseDirectory = rtrim($projectDirectory, '\\/');
return $this;
}
/**
* create()
*
* @return Zend_Tool_Project_Context_System_ProjectDirectory
*/
public function create()
{
if (file_exists($this->getPath())) {
/*
foreach (new DirectoryIterator($this->getPath()) as $item) {
if (!$item->isDot()) {
if ($registry->getClient()->isInteractive()) {
// @todo prompt for override
} else {
require_once 'Zend/Tool/Project/Context/Exception.php';
throw new Zend_Tool_Project_Context_Exception('This directory is not empty, project creation aborted.');
}
break;
}
}
*/
}
parent::create();
return $this;
}
}

View 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: ProjectProfileFile.php 20967 2010-02-07 18:17:49Z ralph $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* @see Zend_Tool_Project_Context_System_Interface
*/
require_once 'Zend/Tool/Project/Context/System/Interface.php';
/**
* @see Zend_Tool_Project_Context_System_NotOverwritable
*/
require_once 'Zend/Tool/Project/Context/System/NotOverwritable.php';
/**
* @see Zend_Tool_Project_Profile_FileParser_Xml
*/
require_once 'Zend/Tool/Project/Profile/FileParser/Xml.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_System_ProjectProfileFile
extends Zend_Tool_Project_Context_Filesystem_File
implements Zend_Tool_Project_Context_System_Interface,
Zend_Tool_Project_Context_System_NotOverwritable
{
/**
* @var string
*/
protected $_filesystemName = '.zfproject.xml';
/**
* @var Zend_Tool_Project_Profile
*/
protected $_profile = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ProjectProfileFile';
}
/**
* setProfile()
*
* @param Zend_Tool_Project_Profile $profile
* @return Zend_Tool_Project_Context_System_ProjectProfileFile
*/
public function setProfile($profile)
{
$this->_profile = $profile;
return $this;
}
/**
* save()
*
* Proxy to create
*
* @return Zend_Tool_Project_Context_System_ProjectProfileFile
*/
public function save()
{
parent::create();
return $this;
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$parser = new Zend_Tool_Project_Profile_FileParser_Xml();
$profile = $this->_resource->getProfile();
$xml = $parser->serialize($profile);
return $xml;
}
}

View file

@ -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
* @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: ProjectProvidersDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* @see Zend_Tool_Project_Context_System_Interface
*/
require_once 'Zend/Tool/Project/Context/System/Interface.php';
/**
* @see Zend_Tool_Project_Context_System_NotOverwritable
*/
require_once 'Zend/Tool/Project/Context/System/NotOverwritable.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_System_ProjectProvidersDirectory
extends Zend_Tool_Project_Context_Filesystem_Directory
implements Zend_Tool_Project_Context_System_Interface,
Zend_Tool_Project_Context_System_NotOverwritable
{
/**
* @var string
*/
protected $_filesystemName = 'providers';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ProjectProvidersDirectory';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_System_ProjectProvidersDirectory
*/
public function init()
{
parent::init();
if (file_exists($this->getPath())) {
foreach (new DirectoryIterator($this->getPath()) as $item) {
if ($item->isFile()) {
$loadableFiles[] = $item->getPathname();
}
}
if ($loadableFiles) {
// @todo process and add the files to the system for usage.
}
}
return $this;
}
}

View 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: TopLevelRestrictable.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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
*/
interface Zend_Tool_Project_Context_System_TopLevelRestrictable
{
}

View file

@ -0,0 +1,78 @@
<?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: BootstrapFile.php 19643 2009-12-14 14:57:07Z ralph $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_AbstractClassFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* getFullClassName()
*
* @param $localClassName
* @param $classContextName
*/
public function getFullClassName($localClassName, $classContextName = null)
{
// find the ApplicationDirectory OR ModuleDirectory
$currentResource = $this->_resource;
do {
$resourceName = $currentResource->getName();
if ($resourceName == 'ApplicationDirectory' || $resourceName == 'ModuleDirectory') {
$containingResource = $currentResource;
break;
}
} while ($currentResource instanceof Zend_Tool_Project_Profile_Resource
&& $currentResource = $currentResource->getParentResource());
$fullClassName = '';
// go find the proper prefix
if (isset($containingResource)) {
if ($containingResource->getName() == 'ApplicationDirectory') {
$prefix = $containingResource->getAttribute('classNamePrefix');
$fullClassName = $prefix;
} elseif ($containingResource->getName() == 'ModuleDirectory') {
$prefix = $containingResource->getAttribute('moduleName') . '_';
$fullClassName = $prefix;
}
}
if ($classContextName) {
$fullClassName .= rtrim($classContextName, '_') . '_';
}
$fullClassName .= $localClassName;
return $fullClassName;
}
}

View file

@ -0,0 +1,224 @@
<?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: ActionMethod.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Interface
*/
require_once 'Zend/Tool/Project/Context/Interface.php';
/**
* @see Zend_Reflection_File
*/
require_once 'Zend/Reflection/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ActionMethod implements Zend_Tool_Project_Context_Interface
{
/**
* @var Zend_Tool_Project_Profile_Resource
*/
protected $_resource = null;
/**
* @var Zend_Tool_Project_Profile_Resource
*/
protected $_controllerResource = null;
/**
* @var string
*/
protected $_controllerPath = '';
/**
* @var string
*/
protected $_actionName = null;
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ActionMethod
*/
public function init()
{
$this->_actionName = $this->_resource->getAttribute('actionName');
$this->_resource->setAppendable(false);
$this->_controllerResource = $this->_resource->getParentResource();
if (!$this->_controllerResource->getContext() instanceof Zend_Tool_Project_Context_Zf_ControllerFile) {
require_once 'Zend/Tool/Project/Context/Exception.php';
throw new Zend_Tool_Project_Context_Exception('ActionMethod must be a sub resource of a ControllerFile');
}
// make the ControllerFile node appendable so we can tack on the actionMethod.
$this->_resource->getParentResource()->setAppendable(true);
$this->_controllerPath = $this->_controllerResource->getContext()->getPath();
/*
* This code block is now commented, its doing to much for init()
*
if ($this->_controllerPath != '' && self::hasActionMethod($this->_controllerPath, $this->_actionName)) {
require_once 'Zend/Tool/Project/Context/Exception.php';
throw new Zend_Tool_Project_Context_Exception('An action named ' . $this->_actionName . 'Action already exists in this controller');
}
*/
return $this;
}
/**
* getPersistentAttributes
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'actionName' => $this->getActionName()
);
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ActionMethod';
}
/**
* setResource()
*
* @param Zend_Tool_Project_Profile_Resource $resource
* @return Zend_Tool_Project_Context_Zf_ActionMethod
*/
public function setResource(Zend_Tool_Project_Profile_Resource $resource)
{
$this->_resource = $resource;
return $this;
}
/**
* setActionName()
*
* @param string $actionName
* @return Zend_Tool_Project_Context_Zf_ActionMethod
*/
public function setActionName($actionName)
{
$this->_actionName = $actionName;
return $this;
}
/**
* getActionName()
*
* @return string
*/
public function getActionName()
{
return $this->_actionName;
}
/**
* create()
*
* @return Zend_Tool_Project_Context_Zf_ActionMethod
*/
public function create()
{
if (self::createActionMethod($this->_controllerPath, $this->_actionName) === false) {
require_once 'Zend/Tool/Project/Context/Exception.php';
throw new Zend_Tool_Project_Context_Exception(
'Could not create action within controller ' . $this->_controllerPath
. ' with action name ' . $this->_actionName
);
}
return $this;
}
/**
* delete()
*
* @return Zend_Tool_Project_Context_Zf_ActionMethod
*/
public function delete()
{
// @todo do this
return $this;
}
/**
* createAcionMethod()
*
* @param string $controllerPath
* @param string $actionName
* @param string $body
* @return true
*/
public static function createActionMethod($controllerPath, $actionName, $body = ' // action body')
{
if (!file_exists($controllerPath)) {
return false;
}
$controllerCodeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($controllerPath, true, true);
$controllerCodeGenFile->getClass()->setMethod(array(
'name' => $actionName . 'Action',
'body' => $body
));
file_put_contents($controllerPath, $controllerCodeGenFile->generate());
return true;
}
/**
* hasActionMethod()
*
* @param string $controllerPath
* @param string $actionName
* @return bool
*/
public static function hasActionMethod($controllerPath, $actionName)
{
if (!file_exists($controllerPath)) {
return false;
}
$controllerCodeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($controllerPath, true, true);
return $controllerCodeGenFile->getClass()->hasMethod($actionName . 'Action');
}
}

View file

@ -0,0 +1,57 @@
<?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: ApisDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ApisDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'apis';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ApisDirectory';
}
}

View file

@ -0,0 +1,283 @@
<?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: ApplicationConfigFile.php 20967 2010-02-07 18:17:49Z ralph $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ApplicationConfigFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'application.ini';
/**
* @var string
*/
protected $_content = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ApplicationConfigFile';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ApplicationConfigFile
*/
public function init()
{
$this->_type = $this->_resource->getAttribute('type');
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return array
*/
public function getPersistentAttributes()
{
return array('type' => $this->_type);
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
if ($this->_content === null) {
if (file_exists($this->getPath())) {
$this->_content = file_get_contents($this->getPath());
} else {
$this->_content = $this->_getDefaultContents();
}
}
return $this->_content;
}
public function getAsZendConfig($section = 'production')
{
return new Zend_Config_Ini($this->getPath(), $section);
}
/**
* addStringItem()
*
* @param string $key
* @param string $value
* @param string $section
* @param bool $quoteValue
* @return Zend_Tool_Project_Context_Zf_ApplicationConfigFile
*/
public function addStringItem($key, $value, $section = 'production', $quoteValue = true)
{
// null quote value means to auto-detect
if ($quoteValue === null) {
$quoteValue = preg_match('#[\"\']#', $value) ? false : true;
}
if ($quoteValue == true) {
$value = '"' . $value . '"';
}
$contentLines = preg_split('#[\n\r]#', $this->getContents());
$newLines = array();
$insideSection = false;
foreach ($contentLines as $contentLineIndex => $contentLine) {
if ($insideSection === false && preg_match('#^\[' . $section . '#', $contentLine)) {
$insideSection = true;
}
if ($insideSection) {
// if its blank, or a section heading
if ((trim($contentLine) == null) || (isset($contentLines[$contentLineIndex + 1]{0}) && $contentLines[$contentLineIndex + 1]{0} == '[')) {
$newLines[] = $key . ' = ' . $value;
$insideSection = null;
}
}
$newLines[] = $contentLine;
}
$this->_content = implode("\n", $newLines);
return $this;
}
/**
*
* @param array $item
* @param string $section
* @param bool $quoteValue
* @return Zend_Tool_Project_Context_Zf_ApplicationConfigFile
*/
public function addItem($item, $section = 'production', $quoteValue = true)
{
$stringItems = array();
$stringValues = array();
$configKeyNames = array();
$rii = new RecursiveIteratorIterator(
new RecursiveArrayIterator($item),
RecursiveIteratorIterator::SELF_FIRST
);
$lastDepth = 0;
// loop through array structure recursively to create proper keys
foreach ($rii as $name => $value) {
$lastDepth = $rii->getDepth();
if (is_array($value)) {
array_push($configKeyNames, $name);
} else {
$stringItems[] = implode('.', $configKeyNames) . '.' . $name;
$stringValues[] = $value;
}
}
foreach ($stringItems as $stringItemIndex => $stringItem) {
$this->addStringItem($stringItem, $stringValues[$stringItemIndex], $section, $quoteValue);
}
return $this;
}
public function removeStringItem($key, $section = 'production')
{
$contentLines = file($this->getPath());
$newLines = array();
$insideSection = false;
foreach ($contentLines as $contentLineIndex => $contentLine) {
if ($insideSection === false && preg_match('#^\[' . $section . '#', $contentLine)) {
$insideSection = true;
}
if ($insideSection) {
// if its blank, or a section heading
if ((trim($contentLine) == null) || ($contentLines[$contentLineIndex + 1][0] == '[')) {
$insideSection = null;
}
}
if (!preg_match('#' . $key . '\s?=.*#', $contentLine)) {
$newLines[] = $contentLine;
}
}
$this->_content = implode('', $newLines);
}
public function removeItem($item, $section = 'production')
{
$stringItems = array();
$stringValues = array();
$configKeyNames = array();
$rii = new RecursiveIteratorIterator(
new RecursiveArrayIterator($item),
RecursiveIteratorIterator::SELF_FIRST
);
$lastDepth = 0;
// loop through array structure recursively to create proper keys
foreach ($rii as $name => $value) {
$lastDepth = $rii->getDepth();
if (is_array($value)) {
array_push($configKeyNames, $name);
} else {
$stringItems[] = implode('.', $configKeyNames) . '.' . $name;
$stringValues[] = $value;
}
}
foreach ($stringItems as $stringItemIndex => $stringItem) {
$this->removeStringItem($stringItem, $section);
}
return $this;
}
protected function _getDefaultContents()
{
$contents =<<<EOS
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
EOS;
return $contents;
}
}

View file

@ -0,0 +1,81 @@
<?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: ApplicationDirectory.php 20967 2010-02-07 18:17:49Z ralph $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ApplicationDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
protected $_filesystemName = 'application';
protected $_classNamePrefix = 'Application_';
public function init()
{
if ($this->_resource->hasAttribute('classNamePrefix')) {
$this->_classNamePrefix = $this->_resource->getAttribute('classNamePrefix');
}
parent::init();
}
/**
* getPersistentAttributes
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'classNamePrefix' => $this->getClassNamePrefix()
);
}
public function getName()
{
return 'ApplicationDirectory';
}
public function setClassNamePrefix($classNamePrefix)
{
$this->_classNamePrefix = $classNamePrefix;
}
public function getClassNamePrefix()
{
return $this->_classNamePrefix;
}
}

View file

@ -0,0 +1,119 @@
<?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: BootstrapFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_BootstrapFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'Bootstrap.php';
/**
* @var Zend_Tool_Project_Profile_Resource
*/
protected $_applicationConfigFile = null;
/**
* @var Zend_Tool_Project_Profile_Resource
*/
protected $_applicationDirectory = null;
/**
* @var Zend_Application
*/
protected $_applicationInstance = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'BootstrapFile';
}
public function init()
{
parent::init();
$this->_applicationConfigFile = $this->_resource->getProfile()->search('ApplicationConfigFile');
$this->_applicationDirectory = $this->_resource->getProfile()->search('ApplicationDirectory');
if (($this->_applicationConfigFile === false) || ($this->_applicationDirectory === false)) {
throw new Exception('To use the BootstrapFile context, your project requires the use of both the "ApplicationConfigFile" and "ApplicationDirectory" contexts.');
}
}
/**
* getContents()
*
* @return array
*/
public function getContents()
{
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => 'Bootstrap',
'extendedClass' => 'Zend_Application_Bootstrap_Bootstrap',
)),
)
));
return $codeGenFile->generate();
}
public function getApplicationInstance()
{
if ($this->_applicationInstance == null) {
if ($this->_applicationConfigFile->getContext()->exists()) {
define('APPLICATION_PATH', $this->_applicationDirectory->getPath());
$applicationOptions = array();
$applicationOptions['config'] = $this->_applicationConfigFile->getPath();
$this->_applicationInstance = new Zend_Application(
'development',
$applicationOptions
);
}
}
return $this->_applicationInstance;
}
}

View file

@ -0,0 +1,57 @@
<?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: CacheDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_CacheDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'cache';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'CacheDirectory';
}
}

View file

@ -0,0 +1,67 @@
<?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: ConfigFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ConfigFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'bootstrap.php';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ConfigFile';
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
return '';
}
}

View file

@ -0,0 +1,57 @@
<?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: ConfigsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ConfigsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'configs';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ConfigsDirectory';
}
}

View 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: ControllerFile.php 20247 2010-01-12 21:38:15Z dasprid $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ControllerFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_controllerName = 'index';
/**
* @var string
*/
protected $_moduleName = null;
/**
* @var string
*/
protected $_filesystemName = 'controllerName';
/**
* init()
*
*/
public function init()
{
$this->_controllerName = $this->_resource->getAttribute('controllerName');
$this->_moduleName = $this->_resource->getAttribute('moduleName');
$this->_filesystemName = ucfirst($this->_controllerName) . 'Controller.php';
parent::init();
}
/**
* getPersistentAttributes
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'controllerName' => $this->getControllerName()
);
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ControllerFile';
}
/**
* getControllerName()
*
* @return string
*/
public function getControllerName()
{
return $this->_controllerName;
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$className = ($this->_moduleName) ? ucfirst($this->_moduleName) . '_' : '';
$className .= ucfirst($this->_controllerName) . 'Controller';
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'fileName' => $this->getPath(),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
'extendedClass' => 'Zend_Controller_Action',
'methods' => array(
new Zend_CodeGenerator_Php_Method(array(
'name' => 'init',
'body' => '/* Initialize action controller here */',
))
)
))
)
));
if ($className == 'ErrorController') {
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'fileName' => $this->getPath(),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
'extendedClass' => 'Zend_Controller_Action',
'methods' => array(
new Zend_CodeGenerator_Php_Method(array(
'name' => 'errorAction',
'body' => <<<EOS
\$errors = \$this->_getParam('error_handler');
switch (\$errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
\$this->getResponse()->setHttpResponseCode(404);
\$this->view->message = 'Page not found';
break;
default:
// application error
\$this->getResponse()->setHttpResponseCode(500);
\$this->view->message = 'Application error';
break;
}
// Log exception, if logger available
if (\$log = \$this->getLog()) {
\$log->crit(\$this->view->message, \$errors->exception);
}
// conditionally display exceptions
if (\$this->getInvokeArg('displayExceptions') == true) {
\$this->view->exception = \$errors->exception;
}
\$this->view->request = \$errors->request;
EOS
)),
new Zend_CodeGenerator_Php_Method(array(
'name' => 'getLog',
'body' => <<<EOS
\$bootstrap = \$this->getInvokeArg('bootstrap');
if (!\$bootstrap->hasPluginResource('Log')) {
return false;
}
\$log = \$bootstrap->getResource('Log');
return \$log;
EOS
)),
)
))
)
));
}
// store the generator into the registry so that the addAction command can use the same object later
Zend_CodeGenerator_Php_File::registerFileCodeGenerator($codeGenFile); // REQUIRES filename to be set
return $codeGenFile->generate();
}
/**
* addAction()
*
* @param string $actionName
*/
public function addAction($actionName)
{
$classCodeGen = $this->getCodeGenerator();
$classCodeGen->setMethod(array('name' => $actionName . 'Action', 'body' => ' // action body here'));
file_put_contents($this->getPath(), $classCodeGen->generate());
}
/**
* getCodeGenerator()
*
* @return Zend_CodeGenerator_Php_Class
*/
public function getCodeGenerator()
{
$codeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($this->getPath());
$codeGenFileClasses = $codeGenFile->getClasses();
$class = array_shift($codeGenFileClasses);
return $class;
}
}

View file

@ -0,0 +1,57 @@
<?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: ControllersDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ControllersDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'controllers';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ControllersDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: DataDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_DataDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'data';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'DataDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: DbTableDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_DbTableDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'DbTable';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'DbTableDirectory';
}
}

View file

@ -0,0 +1,92 @@
<?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: DbTableFile.php 20967 2010-02-07 18:17:49Z ralph $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_DbTableFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
{
protected $_dbTableName = null;
protected $_actualTableName = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'DbTableFile';
}
/**
* init()
*
*/
public function init()
{
$this->_dbTableName = $this->_resource->getAttribute('dbTableName');
$this->_actualTableName = $this->_resource->getAttribute('actualTableName');
$this->_filesystemName = ucfirst($this->_dbTableName) . '.php';
parent::init();
}
public function getPersistentAttributes()
{
return array('dbTableName' => $this->_dbTableName);
}
public function getContents()
{
$className = $this->getFullClassName($this->_dbTableName, 'Model_DbTable');
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'fileName' => $this->getPath(),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
'extendedClass' => 'Zend_Db_Table_Abstract',
'properties' => array(
new Zend_CodeGenerator_Php_Property(array(
'name' => '_name',
'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED,
'defaultValue' => $this->_actualTableName
))
),
))
)
));
return $codeGenFile->generate();
}
}

View file

@ -0,0 +1,61 @@
<?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: DataDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_DocsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'docs';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'DocsDirectory';
}
public function create(){
parent::create();
}
}

View file

@ -0,0 +1,108 @@
<?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: FormFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_FormFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
{
/**
* @var string
*/
protected $_formName = 'Base';
/**
* @var string
*/
protected $_filesystemName = 'formName';
/**
* init()
*
*/
public function init()
{
$this->_formName = $this->_resource->getAttribute('formName');
$this->_filesystemName = ucfirst($this->_formName) . '.php';
parent::init();
}
/**
* getPersistentAttributes
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'formName' => $this->getFormName()
);
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'FormFile';
}
public function getFormName()
{
return $this->_formName;
}
public function getContents()
{
$className = $this->getFullClassName($this->_formName, 'Form');
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'fileName' => $this->getPath(),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
'extendedClass' => 'Zend_Form',
'methods' => array(
new Zend_CodeGenerator_Php_Method(array(
'name' => 'init',
'body' => '/* Form Elements & Other Definitions Here ... */',
))
)
))
)
));
return $codeGenFile->generate();
}
}

View file

@ -0,0 +1,57 @@
<?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: FormsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_FormsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'forms';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'FormsDirectory';
}
}

View file

@ -0,0 +1,77 @@
<?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: HtaccessFile.php 20969 2010-02-07 18:20:02Z ralph $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_HtaccessFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = '.htaccess';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'HtaccessFile';
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$output = <<<EOS
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
EOS;
return $output;
}
}

View 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: ViewScriptFile.php 18386 2009-09-23 20:44:43Z ralph $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_LayoutScriptFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'layout.phtml';
/**
* @var string
*/
protected $_layoutName = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'LayoutScriptFile';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ViewScriptFile
*/
public function init()
{
if ($layoutName = $this->_resource->getAttribute('layoutName')) {
$this->_layoutName = $layoutName;
} else {
throw new Exception('Either a forActionName or scriptName is required.');
}
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return unknown
*/
public function getPersistentAttributes()
{
$attributes = array();
if ($this->_layoutName) {
$attributes['layoutName'] = $this->_layoutName;
}
return $attributes;
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$contents = <<<EOS
<?php echo \$this->layout()->content; ?>
EOS;
return $contents;
}
}

View file

@ -0,0 +1,57 @@
<?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: ViewScriptsDirectory.php 18386 2009-09-23 20:44:43Z ralph $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_LayoutScriptsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'scripts';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'LayoutScriptsDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: LayoutsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_LayoutsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'layouts';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'LayoutsDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: LibraryDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_LibraryDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'library';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'LibraryDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: LocalesDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_LocalesDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'locales';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'LocalesDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: LogsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_LogsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'logs';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'LogsDirectory';
}
}

View file

@ -0,0 +1,102 @@
<?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: ModelFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ModelFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
{
/**
* @var string
*/
protected $_modelName = 'Base';
/**
* @var string
*/
protected $_filesystemName = 'modelName';
/**
* init()
*
*/
public function init()
{
$this->_modelName = $this->_resource->getAttribute('modelName');
$this->_filesystemName = ucfirst($this->_modelName) . '.php';
parent::init();
}
/**
* getPersistentAttributes
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'modelName' => $this->getModelName()
);
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ModelFile';
}
public function getModelName()
{
return $this->_modelName;
}
public function getContents()
{
$className = $this->getFullClassName($this->_modelName, 'Model');
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'fileName' => $this->getPath(),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
))
)
));
return $codeGenFile->generate();
}
}

View file

@ -0,0 +1,57 @@
<?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: ModelsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ModelsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'models';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ModelsDirectory';
}
}

View file

@ -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
* @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: ModuleDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ModuleDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_moduleName = null;
/**
* @var string
*/
protected $_filesystemName = 'moduleDirectory';
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ControllerFile
*/
public function init()
{
$this->_filesystemName = $this->_moduleName = $this->_resource->getAttribute('moduleName');
parent::init();
return $this;
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ModuleDirectory';
}
/**
* getPersistentAttributes
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'moduleName' => $this->getModuleName()
);
}
/**
* getModuleName()
*
* @return string
*/
public function getModuleName()
{
return $this->_moduleName;
}
}

View file

@ -0,0 +1,57 @@
<?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: ModulesDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ModulesDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'modules';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'modulesDirectory';
}
}

View file

@ -0,0 +1,152 @@
<?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: ProjectProviderFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* @see Zend_CodeGenerator_Php_File
*/
require_once 'Zend/CodeGenerator/Php/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ProjectProviderFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_projectProviderName = null;
/**
* @var array
*/
protected $_actionNames = array();
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ProjectProviderFile
*/
public function init()
{
$this->_projectProviderName = $this->_resource->getAttribute('projectProviderName');
$this->_actionNames = $this->_resource->getAttribute('actionNames');
$this->_filesystemName = ucfirst($this->_projectProviderName) . 'Provider.php';
if (strpos($this->_actionNames, ',')) {
$this->_actionNames = explode(',', $this->_actionNames);
} else {
$this->_actionNames = ($this->_actionNames) ? array($this->_actionNames) : array();
}
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'projectProviderName' => $this->getProjectProviderName(),
'actionNames' => implode(',', $this->_actionNames)
);
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ProjectProviderFile';
}
/**
* getProjectProviderName()
*
* @return string
*/
public function getProjectProviderName()
{
return $this->_projectProviderName;
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$filter = new Zend_Filter_Word_DashToCamelCase();
$className = $filter->filter($this->_projectProviderName) . 'Provider';
$class = new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
'extendedClass' => 'Zend_Tool_Project_Provider_Abstract'
));
$methods = array();
foreach ($this->_actionNames as $actionName) {
$methods[] = new Zend_CodeGenerator_Php_Method(array(
'name' => $actionName,
'body' => ' /** @todo Implementation */'
));
}
if ($methods) {
$class->setMethods($methods);
}
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'requiredFiles' => array(
'Zend/Tool/Project/Provider/Abstract.php',
'Zend/Tool/Project/Provider/Exception.php'
),
'classes' => array($class)
));
return $codeGenFile->generate();
}
}

View file

@ -0,0 +1,57 @@
<?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: PublicDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_PublicDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'public';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'PublicDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: PublicImagesDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_PublicImagesDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'images';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'PublicImagesDirectory';
}
}

View file

@ -0,0 +1,95 @@
<?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: PublicIndexFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_PublicIndexFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'index.php';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'PublicIndexFile';
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$codeGenerator = new Zend_CodeGenerator_Php_File(array(
'body' => <<<EOS
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
\$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
\$application->bootstrap()
->run();
EOS
));
return $codeGenerator->generate();
}
}

View file

@ -0,0 +1,57 @@
<?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: PublicScriptsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_PublicScriptsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'js';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'PublicScriptsDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: PublicStylesheetsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_PublicStylesheetsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'styles';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'PublicStylesheetsDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: SearchIndexesDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_SearchIndexesDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'search-indexes';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'SearchIndexesDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: SessionsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_SessionsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'sessions';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'SessionsDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: TemporaryDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TemporaryDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'temp';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TemporaryDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: TestApplicationBootstrapFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestApplicationBootstrapFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'bootstrap.php';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestApplicationBootstrapFile';
}
}

View file

@ -0,0 +1,57 @@
<?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: TestApplicationControllerDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestApplicationControllerDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'controllers';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestApplicationControllerDirectory';
}
}

View file

@ -0,0 +1,107 @@
<?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: TestApplicationControllerFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestApplicationControllerFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_forControllerName = '';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestApplicationControllerFile';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_TestApplicationControllerFile
*/
public function init()
{
$this->_forControllerName = $this->_resource->getAttribute('forControllerName');
$this->_filesystemName = ucfirst($this->_forControllerName) . 'ControllerTest.php';
parent::init();
return $this;
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$filter = new Zend_Filter_Word_DashToCamelCase();
$className = $filter->filter($this->_forControllerName) . 'ControllerTest';
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'requiredFiles' => array(
'PHPUnit/Framework/TestCase.php'
),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
'extendedClass' => 'PHPUnit_Framework_TestCase',
'methods' => array(
new Zend_CodeGenerator_Php_Method(array(
'name' => 'setUp',
'body' => ' /* Setup Routine */'
)),
new Zend_CodeGenerator_Php_Method(array(
'name' => 'tearDown',
'body' => ' /* Tear Down Routine */'
))
)
))
)
));
return $codeGenFile->generate();
}
}

View file

@ -0,0 +1,57 @@
<?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: TestApplicationDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestApplicationDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'application';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestApplicationDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: TestLibraryBootstrapFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestLibraryBootstrapFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'bootstrap.php';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestLibraryBootstrapFile';
}
}

View file

@ -0,0 +1,57 @@
<?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: TestLibraryDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestLibraryDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'library';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestLibraryDirectory';
}
}

View file

@ -0,0 +1,107 @@
<?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: TestLibraryFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestLibraryFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_forClassName = '';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestLibraryFile';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_TestLibraryFile
*/
public function init()
{
$this->_forClassName = $this->_resource->getAttribute('forClassName');
$this->_filesystemName = ucfirst(ltrim(strrchr($this->_forClassName, '_'), '_')) . 'Test.php';
parent::init();
return $this;
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$filter = new Zend_Filter_Word_DashToCamelCase();
$className = $filter->filter($this->_forClassName) . 'Test';
$codeGenFile = new Zend_CodeGenerator_Php_File(array(
'requiredFiles' => array(
'PHPUnit/Framework/TestCase.php'
),
'classes' => array(
new Zend_CodeGenerator_Php_Class(array(
'name' => $className,
'extendedClass' => 'PHPUnit_Framework_TestCase',
'methods' => array(
new Zend_CodeGenerator_Php_Method(array(
'name' => 'setUp',
'body' => ' /* Setup Routine */'
)),
new Zend_CodeGenerator_Php_Method(array(
'name' => 'tearDown',
'body' => ' /* Tear Down Routine */'
))
)
))
)
));
return $codeGenFile->generate();
}
}

View file

@ -0,0 +1,88 @@
<?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: TestLibraryNamespaceDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestLibraryNamespaceDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_namespaceName = '';
/**
* @var string
*/
protected $_filesystemName = 'library';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestLibraryNamespaceDirectory';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_TestLibraryNamespaceDirectory
*/
public function init()
{
$this->_namespaceName = $this->_resource->getAttribute('namespaceName');
$this->_filesystemName = $this->_namespaceName;
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return array
*/
public function getPersistentAttributes()
{
$attributes = array();
$attributes['namespaceName'] = $this->_namespaceName;
return $attributes;
}
}

View file

@ -0,0 +1,57 @@
<?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: TestPHPUnitConfigFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestPHPUnitConfigFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'phpunit.xml';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestPHPUnitConfigFile';
}
}

View file

@ -0,0 +1,57 @@
<?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: TestsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_TestsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'tests';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'TestsDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: UploadsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_UploadsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'uploads';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'UploadsDirectory';
}
}

View file

@ -0,0 +1,95 @@
<?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: ViewControllerScriptsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ViewControllerScriptsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'controllerName';
/**
* @var name
*/
protected $_forControllerName = null;
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ViewControllerScriptsDirectory
*/
public function init()
{
$this->_forControllerName = $this->_resource->getAttribute('forControllerName');
$this->_filesystemName = $this->_convertControllerNameToFilesystemName($this->_forControllerName);
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'forControllerName' => $this->_forControllerName
);
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ViewControllerScriptsDirectory';
}
protected function _convertControllerNameToFilesystemName($controllerName)
{
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_Word_CamelCaseToDash())
->addFilter(new Zend_Filter_StringToLower());
return $filter->filter($controllerName);
}
}

View file

@ -0,0 +1,57 @@
<?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: ViewFiltersDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ViewFiltersDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'filters';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ViewFiltersDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: ViewHelpersDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ViewHelpersDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'helpers';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ViewHelpersDirectory';
}
}

View file

@ -0,0 +1,212 @@
<?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: ViewScriptFile.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ViewScriptFile extends Zend_Tool_Project_Context_Filesystem_File
{
/**
* @var string
*/
protected $_filesystemName = 'view.phtml';
/**
* @var string
*/
protected $_forActionName = null;
/**
* @var string
*/
protected $_scriptName = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ViewScriptFile';
}
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ViewScriptFile
*/
public function init()
{
if ($forActionName = $this->_resource->getAttribute('forActionName')) {
$this->_forActionName = $forActionName;
$this->_filesystemName = $this->_convertActionNameToFilesystemName($forActionName) . '.phtml';
} elseif ($scriptName = $this->_resource->getAttribute('scriptName')) {
$this->_scriptName = $scriptName;
$this->_filesystemName = $scriptName . '.phtml';
} else {
throw new Exception('Either a forActionName or scriptName is required.');
}
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return unknown
*/
public function getPersistentAttributes()
{
$attributes = array();
if ($this->_forActionName) {
$attributes['forActionName'] = $this->_forActionName;
}
if ($this->_scriptName) {
$attributes['scriptName'] = $this->_scriptName;
}
return $attributes;
}
/**
* getContents()
*
* @return string
*/
public function getContents()
{
$contents = '';
if ($this->_filesystemName == 'error.phtml') { // should also check that the above directory is forController=error
$contents .= <<<EOS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zend Framework Default Application</title>
</head>
<body>
<h1>An error occurred</h1>
<h2><?php echo \$this->message ?></h2>
<?php if (isset(\$this->exception)): ?>
<h3>Exception information:</h3>
<p>
<b>Message:</b> <?php echo \$this->exception->getMessage() ?>
</p>
<h3>Stack trace:</h3>
<pre><?php echo \$this->exception->getTraceAsString() ?>
</pre>
<h3>Request Parameters:</h3>
<pre><?php echo var_export(\$this->request->getParams(), true) ?>
</pre>
<?php endif ?>
</body>
</html>
EOS;
} elseif ($this->_forActionName == 'index' && $this->_resource->getParentResource()->getAttribute('forControllerName') == 'Index') {
$contents =<<<EOS
<style>
a:link,
a:visited
{
color: #0398CA;
}
span#zf-name
{
color: #91BE3F;
}
div#welcome
{
color: #FFFFFF;
background-image: url(http://framework.zend.com/images/bkg_header.jpg);
width: 600px;
height: 400px;
border: 2px solid #444444;
overflow: hidden;
text-align: center;
}
div#more-information
{
background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);
height: 100%;
}
</style>
<div id="welcome">
<h1>Welcome to the <span id="zf-name">Zend Framework!</span></h1>
<h3>This is your project's main page</h3>
<div id="more-information">
<p><img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" /></p>
<p>
Helpful Links: <br />
<a href="http://framework.zend.com/">Zend Framework Website</a> |
<a href="http://framework.zend.com/manual/en/">Zend Framework Manual</a>
</p>
</div>
</div>
EOS;
} else {
$contents = '<br /><br /><center>View script for controller <b>' . $this->_resource->getParentResource()->getAttribute('forControllerName') . '</b>'
. ' and script/action name <b>' . $this->_forActionName . '</b></center>';
}
return $contents;
}
protected function _convertActionNameToFilesystemName($actionName)
{
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_Word_CamelCaseToDash())
->addFilter(new Zend_Filter_StringToLower());
return $filter->filter($actionName);
}
}

View file

@ -0,0 +1,57 @@
<?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: ViewScriptsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ViewScriptsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'scripts';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ViewScriptsDirectory';
}
}

View file

@ -0,0 +1,57 @@
<?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: ViewsDirectory.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ViewsDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'views';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ViewsDirectory';
}
}

View file

@ -0,0 +1,104 @@
<?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: ZfStandardLibraryDirectory.php 20903 2010-02-04 16:16:47Z matthew $
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_Directory
*/
require_once 'Zend/Tool/Project/Context/Filesystem/Directory.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Context_Zf_ZfStandardLibraryDirectory extends Zend_Tool_Project_Context_Filesystem_Directory
{
/**
* @var string
*/
protected $_filesystemName = 'Zend';
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ZfStandardLibraryDirectory';
}
/**
* create()
*
*/
public function create()
{
parent::create();
$zfPath = $this->_getZfPath();
if ($zfPath != false) {
$zfIterator = new RecursiveDirectoryIterator($zfPath);
foreach ($rii = new RecursiveIteratorIterator($zfIterator, RecursiveIteratorIterator::SELF_FIRST) as $file) {
$relativePath = preg_replace('#^'.preg_quote(realpath($zfPath), '#').'#', '', realpath($file->getPath())) . DIRECTORY_SEPARATOR . $file->getFilename();
if (strpos($relativePath, DIRECTORY_SEPARATOR . '.') !== false) {
continue;
}
if ($file->isDir()) {
mkdir($this->getBaseDirectory() . DIRECTORY_SEPARATOR . $this->getFilesystemName() . $relativePath);
} else {
copy($file->getPathname(), $this->getBaseDirectory() . DIRECTORY_SEPARATOR . $this->getFilesystemName() . $relativePath);
}
}
}
}
/**
* _getZfPath()
*
* @return string|false
*/
protected function _getZfPath()
{
require_once 'Zend/Loader.php';
foreach (Zend_Loader::explodeIncludePath() as $includePath) {
if (!file_exists($includePath) || $includePath[0] == '.') {
continue;
}
if (realpath($checkedPath = rtrim($includePath, '\\/') . '/Zend/Loader.php') !== false && file_exists($checkedPath)) {
return dirname($checkedPath);
}
}
return false;
}
}

View 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_Exception
*/
require_once 'Zend/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_Exception extends Zend_Exception
{
}

View file

@ -0,0 +1,237 @@
<?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 20967 2010-02-07 18:17:49Z ralph $
*/
/**
* @see Zend_Tool_Project_Profile_FileParser_Xml
*/
require_once 'Zend/Tool/Project/Profile/FileParser/Xml.php';
/**
* @see Zend_Tool_Project_Profile_Resource_Container
*/
require_once 'Zend/Tool/Project/Profile/Resource/Container.php';
/**
* This class is the front most class for utilizing Zend_Tool_Project
*
* A profile is a hierarchical set of resources that keep track of
* items within a specific project.
*
* @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_Profile extends Zend_Tool_Project_Profile_Resource_Container
{
/**
* @var bool
*/
protected static $_traverseEnabled = false;
/**
* Constructor, standard usage would allow the setting of options
*
* @param array $options
* @return bool
*/
public function __construct($options = null)
{
if ($options) {
$this->setOptions($options);
}
$this->_topResources = new Zend_Tool_Project_Profile_Resource_Container();
}
/**
* Process options and either set a profile property or
* set a profile 'attribute'
*
* @param array $options
*/
public function setOptions(Array $options)
{
$this->setAttributes($options);
}
/**
* getIterator() - reqruied by the RecursiveIterator interface
*
* @return RecursiveIteratorIterator
*/
public function getIterator()
{
require_once 'Zend/Tool/Project/Profile/Iterator/EnabledResourceFilter.php';
return new RecursiveIteratorIterator(
new Zend_Tool_Project_Profile_Iterator_EnabledResourceFilter($this),
RecursiveIteratorIterator::SELF_FIRST
);
}
/**
* loadFromData() - Load a profile from data provided by the
* 'profilData' attribute
*
*/
public function loadFromData()
{
if (!isset($this->_attributes['profileData'])) {
require_once 'Zend/Tool/Project/Exception.php';
throw new Zend_Tool_Project_Exception('loadFromData() must have "profileData" set.');
}
$profileFileParser = new Zend_Tool_Project_Profile_FileParser_Xml();
$profileFileParser->unserialize($this->_attributes['profileData'], $this);
$this->rewind();
}
/**
* isLoadableFromFile() - can a profile be loaded from a file
*
* wether or not a profile can be loaded from the
* file in attribute 'projectProfileFile', or from a file named
* '.zfproject.xml' inside a directory in key 'projectDirectory'
*
* @return bool
*/
public function isLoadableFromFile()
{
if (!isset($this->_attributes['projectProfileFile']) && !isset($this->_attributes['projectDirectory'])) {
return false;
}
if (isset($this->_attributes['projectProfileFile'])) {
$projectProfileFilePath = $this->_attributes['projectProfileFile'];
if (!file_exists($projectProfileFilePath)) {
return false;
}
} else {
$projectProfileFilePath = rtrim($this->_attributes['projectDirectory'], '/\\') . '/.zfproject.xml';
if (!file_exists($projectProfileFilePath)) {
return false;
}
}
return true;
}
/**
* loadFromFile() - Load data from file
*
* this attempts to load a project profile file from a variety of locations depending
* on what information the user provided vie $options or attributes, specifically the
* 'projectDirectory' or 'projectProfileFile'
*
*/
public function loadFromFile()
{
// if no data is supplied, need either a projectProfileFile or a projectDirectory
if (!isset($this->_attributes['projectProfileFile']) && !isset($this->_attributes['projectDirectory'])) {
require_once 'Zend/Tool/Project/Exception.php';
throw new Zend_Tool_Project_Exception('loadFromFile() must have at least "projectProfileFile" or "projectDirectory" set.');
}
if (isset($this->_attributes['projectProfileFile'])) {
$projectProfileFilePath = $this->_attributes['projectProfileFile'];
if (!file_exists($projectProfileFilePath)) {
require_once 'Zend/Tool/Project/Exception.php';
throw new Zend_Tool_Project_Exception('"projectProfileFile" was supplied but file was not found at location ' . $projectProfileFilePath);
}
$this->_attributes['projectDirectory'] = dirname($projectProfileFilePath);
} else {
$projectProfileFilePath = rtrim($this->_attributes['projectDirectory'], '/\\') . '/.zfproject.xml';
if (!file_exists($projectProfileFilePath)) {
require_once 'Zend/Tool/Project/Exception.php';
throw new Zend_Tool_Project_Exception('"projectDirectory" was supplied but no profile file file was not found at location ' . $projectProfileFilePath);
}
$this->_attributes['projectProfileFile'] = $projectProfileFilePath;
}
$profileData = file_get_contents($projectProfileFilePath);
$profileFileParser = new Zend_Tool_Project_Profile_FileParser_Xml();
$profileFileParser->unserialize($profileData, $this);
$this->rewind();
}
/**
* storeToFile() - store the current profile to file
*
* This will store the profile in memory to a place on disk determined by the attributes
* available, specifically if the key 'projectProfileFile' is available
*
*/
public function storeToFile()
{
$file = null;
if (isset($this->_attributes['projectProfileFile'])) {
$file = $this->_attributes['projectProfileFile'];
}
if ($file == null) {
require_once 'Zend/Tool/Project/Exception.php';
throw new Zend_Tool_Project_Exception('storeToFile() must have a "projectProfileFile" attribute set.');
}
$parser = new Zend_Tool_Project_Profile_FileParser_Xml();
$xml = $parser->serialize($this);
file_put_contents($file, $xml);
}
/**
* storeToData() - create a string representation of the profile in memory
*
* @return string
*/
public function storeToData()
{
$parser = new Zend_Tool_Project_Profile_FileParser_Xml();
$xml = $parser->serialize($this);
return $xml;
}
/**
* __toString() - cast this profile to string to be able to view it.
*
* @return string
*/
public function __toString()
{
$string = '';
foreach ($this as $resource) {
$string .= $resource->getName() . PHP_EOL;
$rii = new RecursiveIteratorIterator($resource, RecursiveIteratorIterator::SELF_FIRST);
foreach ($rii as $item) {
$string .= str_repeat(' ', $rii->getDepth()+1) . $item->getName()
. ((count($attributes = $item->getAttributes()) > 0) ? ' [' . http_build_query($attributes) . ']' : '')
. PHP_EOL;
}
}
return $string;
}
}

View 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_Profile_Exception extends Zend_Tool_Project_Exception
{
}

View 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: Interface.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
*/
interface Zend_Tool_Project_Profile_FileParser_Interface
{
/**
* serialize()
*
* This method should take a profile and return a string
* representation of it.
*
* @param Zend_Tool_Project_Profile $profile
* @return string
*/
public function serialize(Zend_Tool_Project_Profile $profile);
/**
* unserialize()
*
* This method should be able to take string data an create a
* struture in the provided $profile
*
* @param string $data
* @param Zend_Tool_Project_Profile $profile
*/
public function unserialize($data, Zend_Tool_Project_Profile $profile);
}

View file

@ -0,0 +1,240 @@
<?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: Xml.php 20967 2010-02-07 18:17:49Z ralph $
*/
require_once 'Zend/Tool/Project/Profile/FileParser/Interface.php';
require_once 'Zend/Tool/Project/Context/Repository.php';
require_once 'Zend/Tool/Project/Profile.php';
require_once 'Zend/Tool/Project/Profile/Resource.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_Profile_FileParser_Xml implements Zend_Tool_Project_Profile_FileParser_Interface
{
/**
* @var Zend_Tool_Project_Profile
*/
protected $_profile = null;
/**
* @var Zend_Tool_Project_Context_Repository
*/
protected $_contextRepository = null;
/**
* __construct()
*
*/
public function __construct()
{
$this->_contextRepository = Zend_Tool_Project_Context_Repository::getInstance();
}
/**
* serialize()
*
* create an xml string from the provided profile
*
* @param Zend_Tool_Project_Profile $profile
* @return string
*/
public function serialize(Zend_Tool_Project_Profile $profile)
{
$profile = clone $profile;
$this->_profile = $profile;
$xmlElement = new SimpleXMLElement('<projectProfile />');
if ($profile->hasAttribute('type')) {
$xmlElement->addAttribute('type', $profile->getAttribute('type'));
}
if ($profile->hasAttribute('version')) {
$xmlElement->addAttribute('version', $profile->getAttribute('version'));
}
self::_serializeRecurser($profile, $xmlElement);
$doc = new DOMDocument('1.0');
$doc->formatOutput = true;
$domnode = dom_import_simplexml($xmlElement);
$domnode = $doc->importNode($domnode, true);
$domnode = $doc->appendChild($domnode);
return $doc->saveXML();
}
/**
* unserialize()
*
* Create a structure in the object $profile from the structure specficied
* in the xml string provided
*
* @param string xml data
* @param Zend_Tool_Project_Profile The profile to use as the top node
* @return Zend_Tool_Project_Profile
*/
public function unserialize($data, Zend_Tool_Project_Profile $profile)
{
if ($data == null) {
throw new Exception('contents not available to unserialize.');
}
$this->_profile = $profile;
$xmlDataIterator = new SimpleXMLIterator($data);
if ($xmlDataIterator->getName() != 'projectProfile') {
throw new Exception('Profiles must start with a projectProfile node');
}
if (isset($xmlDataIterator['type'])) {
$this->_profile->setAttribute('type', (string) $xmlDataIterator['type']);
}
if (isset($xmlDataIterator['version'])) {
$this->_profile->setAttribute('version', (string) $xmlDataIterator['version']);
}
// start un-serialization of the xml doc
$this->_unserializeRecurser($xmlDataIterator);
// contexts should be initialized after the unwinding of the profile structure
$this->_lazyLoadContexts();
return $this->_profile;
}
/**
* _serializeRecurser()
*
* This method will be used to traverse the depths of the structure
* when *serializing* an xml structure into a string
*
* @param array $resources
* @param SimpleXmlElement $xmlNode
*/
protected function _serializeRecurser($resources, SimpleXmlElement $xmlNode)
{
// @todo find a better way to handle concurrency.. if no clone, _position in node gets messed up
//if ($resources instanceof Zend_Tool_Project_Profile_Resource) {
// $resources = clone $resources;
//}
foreach ($resources as $resource) {
if ($resource->isDeleted()) {
continue;
}
$resourceName = $resource->getContext()->getName();
$resourceName[0] = strtolower($resourceName[0]);
$newNode = $xmlNode->addChild($resourceName);
//$reflectionClass = new ReflectionClass($resource->getContext());
if ($resource->isEnabled() == false) {
$newNode->addAttribute('enabled', 'false');
}
foreach ($resource->getPersistentAttributes() as $paramName => $paramValue) {
$newNode->addAttribute($paramName, $paramValue);
}
if ($resource->hasChildren()) {
self::_serializeRecurser($resource, $newNode);
}
}
}
/**
* _unserializeRecurser()
*
* This method will be used to traverse the depths of the structure
* as needed to *unserialize* the profile from an xmlIterator
*
* @param SimpleXMLIterator $xmlIterator
* @param Zend_Tool_Project_Profile_Resource $resource
*/
protected function _unserializeRecurser(SimpleXMLIterator $xmlIterator, Zend_Tool_Project_Profile_Resource $resource = null)
{
foreach ($xmlIterator as $resourceName => $resourceData) {
$contextName = $resourceName;
$subResource = new Zend_Tool_Project_Profile_Resource($contextName);
$subResource->setProfile($this->_profile);
if ($resourceAttributes = $resourceData->attributes()) {
$attributes = array();
foreach ($resourceAttributes as $attrName => $attrValue) {
$attributes[$attrName] = (string) $attrValue;
}
$subResource->setAttributes($attributes);
}
if ($resource) {
$resource->append($subResource, false);
} else {
$this->_profile->append($subResource);
}
if ($this->_contextRepository->isOverwritableContext($contextName) == false) {
$subResource->initializeContext();
}
if ($xmlIterator->hasChildren()) {
self::_unserializeRecurser($xmlIterator->getChildren(), $subResource);
}
}
}
/**
* _lazyLoadContexts()
*
* This method will call initializeContext on the resources in a profile
* @todo determine if this method belongs inside the profile
*
*/
protected function _lazyLoadContexts()
{
foreach ($this->_profile as $topResource) {
$rii = new RecursiveIteratorIterator($topResource, RecursiveIteratorIterator::SELF_FIRST);
foreach ($rii as $resource) {
$resource->initializeContext();
}
}
}
}

View file

@ -0,0 +1,211 @@
<?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: ContextFilter.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is an iterator that will iterate only over enabled resources
*
* @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_Profile_Iterator_ContextFilter extends RecursiveFilterIterator
{
/**
* @var array
*/
protected $_acceptTypes = array();
/**
* @var array
*/
protected $_denyTypes = array();
/**
* @var array
*/
protected $_acceptNames = array();
/**
* @var array
*/
protected $_denyNames = array();
/**
* @var array
*/
protected $_rawOptions = array();
/**
* __construct()
*
* @param RecursiveIterator $iterator
* @param array $options
*/
public function __construct(RecursiveIterator $iterator, $options = array())
{
parent::__construct($iterator);
$this->_rawOptions = $options;
if ($options) {
$this->setOptions($options);
}
}
/**
* setOptions()
*
* @param array $options
*/
public function setOptions(Array $options)
{
foreach ($options as $optionName => $optionValue) {
if (substr($optionName, -1, 1) != 's') {
$optionName .= 's';
}
if (method_exists($this, 'set' . $optionName)) {
$this->{'set' . $optionName}($optionValue);
}
}
}
/**
* setAcceptTypes()
*
* @param array|string $acceptTypes
* @return Zend_Tool_Project_Profile_Iterator_ContextFilter
*/
public function setAcceptTypes($acceptTypes)
{
if (!is_array($acceptTypes)) {
$acceptTypes = array($acceptTypes);
}
$this->_acceptTypes = $acceptTypes;
return $this;
}
/**
* setDenyTypes()
*
* @param array|string $denyTypes
* @return Zend_Tool_Project_Profile_Iterator_ContextFilter
*/
public function setDenyTypes($denyTypes)
{
if (!is_array($denyTypes)) {
$denyTypes = array($denyTypes);
}
$this->_denyTypes = $denyTypes;
return $this;
}
/**
* setAcceptNames()
*
* @param array|string $acceptNames
* @return Zend_Tool_Project_Profile_Iterator_ContextFilter
*/
public function setAcceptNames($acceptNames)
{
if (!is_array($acceptNames)) {
$acceptNames = array($acceptNames);
}
foreach ($acceptNames as $n => $v) {
$acceptNames[$n] = strtolower($v);
}
$this->_acceptNames = $acceptNames;
return $this;
}
/**
* setDenyNames()
*
* @param array|string $denyNames
* @return Zend_Tool_Project_Profile_Iterator_ContextFilter
*/
public function setDenyNames($denyNames)
{
if (!is_array($denyNames)) {
$denyNames = array($denyNames);
}
foreach ($denyNames as $n => $v) {
$denyNames[$n] = strtolower($v);
}
$this->_denyNames = $denyNames;
return $this;
}
/**
* accept() is required by teh RecursiveFilterIterator
*
* @return bool
*/
public function accept()
{
$currentItem = $this->current();
if (in_array(strtolower($currentItem->getName()), $this->_acceptNames)) {
return true;
} elseif (in_array(strtolower($currentItem->getName()), $this->_denyNames)) {
return false;
}
foreach ($this->_acceptTypes as $acceptType) {
if ($currentItem->getContent() instanceof $acceptType) {
return true;
}
}
foreach ($this->_denyTypes as $denyType) {
if ($currentItem->getContext() instanceof $denyType) {
return false;
}
}
return true;
}
/**
* getChildren()
*
* This is here due to a bug/design issue in PHP
* @link
*
* @return unknown
*/
function getChildren()
{
if (empty($this->ref)) {
$this->ref = new ReflectionClass($this);
}
return $this->ref->newInstance($this->getInnerIterator()->getChildren(), $this->_rawOptions);
}
}

View file

@ -0,0 +1,43 @@
<?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: EnabledResourceFilter.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is an iterator that will iterate only over enabled resources
*
* @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_Profile_Iterator_EnabledResourceFilter extends RecursiveFilterIterator
{
/**
* accept() is required by teh RecursiveFilterIterator
*
* @return bool
*/
public function accept()
{
return $this->current()->isEnabled();
}
}

View file

@ -0,0 +1,262 @@
<?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: Resource.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Tool_Project_Profile_Resource_Container
*/
require_once 'Zend/Tool/Project/Profile/Resource/Container.php';
/**
* @see Zend_Tool_Project_Context_Repository
*/
require_once 'Zend/Tool/Project/Context/Repository.php';
/**
* This class is an iterator that will iterate only over enabled resources
*
* @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_Profile_Resource extends Zend_Tool_Project_Profile_Resource_Container
{
/**
* @var Zend_Tool_Project_Profile
*/
protected $_profile = null;
/**
* @var Zend_Tool_Project_Profile_Resource
*/
protected $_parentResource = null;
/**#@+
* @var bool
*/
protected $_deleted = false;
protected $_enabled = true;
/**#@-*/
/**
* @var Zend_Tool_Project_Context|string
*/
protected $_context = null;
/**
* @var array
*/
protected $_attributes = array();
/**
* @var bool
*/
protected $_isContextInitialized = false;
/**
* __construct()
*
* @param string|Zend_Tool_Project_Context_Interface $context
*/
public function __construct($context)
{
$this->setContext($context);
}
/**
* setContext()
*
* @param string|Zend_Tool_Project_Context_Interface $context
* @return Zend_Tool_Project_Profile_Resource
*/
public function setContext($context)
{
$this->_context = $context;
return $this;
}
/**
* getContext()
*
* @return Zend_Tool_Project_Context_Interface
*/
public function getContext()
{
return $this->_context;
}
/**
* getName() - Get the resource name
*
* Name is derived from the context name
*
* @return string
*/
public function getName()
{
if (is_string($this->_context)) {
return $this->_context;
} elseif ($this->_context instanceof Zend_Tool_Project_Context_Interface) {
return $this->_context->getName();
} else {
throw new Zend_Tool_Project_Exception('Invalid context in resource');
}
}
/**
* setProfile()
*
* @param Zend_Tool_Project_Profile $profile
* @return Zend_Tool_Project_Profile_Resource
*/
public function setProfile(Zend_Tool_Project_Profile $profile)
{
$this->_profile = $profile;
return $this;
}
/**
* getProfile
*
* @return Zend_Tool_Project_Profile
*/
public function getProfile()
{
return $this->_profile;
}
/**
* getPersistentAttributes()
*
* @return array
*/
public function getPersistentAttributes()
{
if (method_exists($this->_context, 'getPersistentAttributes')) {
return $this->_context->getPersistentAttributes();
}
return array();
}
/**
* setEnabled()
*
* @param bool $enabled
* @return Zend_Tool_Project_Profile_Resource
*/
public function setEnabled($enabled = true)
{
// convert fuzzy types to bool
$this->_enabled = (!in_array($enabled, array('false', 'disabled', 0, -1, false), true)) ? true : false;
return $this;
}
/**
* isEnabled()
*
* @return bool
*/
public function isEnabled()
{
return $this->_enabled;
}
/**
* setDeleted()
*
* @param bool $deleted
* @return Zend_Tool_Project_Profile_Resource
*/
public function setDeleted($deleted = true)
{
$this->_deleted = (bool) $deleted;
return $this;
}
/**
* isDeleted()
*
* @return Zend_Tool_Project_Profile_Resource
*/
public function isDeleted()
{
return $this->_deleted;
}
/**
* initializeContext()
*
* @return Zend_Tool_Project_Profile_Resource
*/
public function initializeContext()
{
if ($this->_isContextInitialized) {
return;
}
if (is_string($this->_context)) {
$this->_context = Zend_Tool_Project_Context_Repository::getInstance()->getContext($this->_context);
}
if (method_exists($this->_context, 'setResource')) {
$this->_context->setResource($this);
}
if (method_exists($this->_context, 'init')) {
$this->_context->init();
}
$this->_isContextInitialized = true;
return $this;
}
/**
* __toString()
*
* @return string
*/
public function __toString()
{
return $this->_context->getName();
}
/**
* __call()
*
* @param string $method
* @param array $arguments
* @return Zend_Tool_Project_Profile_Resource
*/
public function __call($method, $arguments)
{
if (method_exists($this->_context, $method)) {
if (!$this->isEnabled()) {
$this->setEnabled(true);
}
return call_user_func_array(array($this->_context, $method), $arguments);
} else {
throw new Zend_Tool_Project_Profile_Exception('cannot call ' . $method);
}
}
}

View file

@ -0,0 +1,421 @@
<?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: Container.php 20967 2010-02-07 18:17:49Z ralph $
*/
/**
* @see Zend_Tool_Project_Profile_Resource_SearchConstraints
*/
require_once 'Zend/Tool/Project/Profile/Resource/SearchConstraints.php';
/**
* This class is an iterator that will iterate only over enabled resources
*
* @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_Profile_Resource_Container implements RecursiveIterator, Countable
{
/**
* @var array
*/
protected $_subResources = array();
/**
* @var int
*/
protected $_position = 0;
/**
* @var bool
*/
protected $_appendable = true;
/**
* @var array
*/
protected $_attributes = array();
/**
* Finder method to be able to find resources by context name
* and attributes. Example usage:
*
* <code>
*
* </code>
*
* @param Zend_Tool_Project_Profile_Resource_SearchConstraints|string|array $searchParameters
* @return Zend_Tool_Project_Profile_Resource
*/
public function search($matchSearchConstraints, $nonMatchSearchConstraints = null)
{
if (!$matchSearchConstraints instanceof Zend_Tool_Project_Profile_Resource_SearchConstraints) {
$matchSearchConstraints = new Zend_Tool_Project_Profile_Resource_SearchConstraints($matchSearchConstraints);
}
$this->rewind();
/**
* @todo This should be re-written with better support for a filter iterator, its the way to go
*/
if ($nonMatchSearchConstraints) {
$filterIterator = new Zend_Tool_Project_Profile_Iterator_ContextFilter($this, array('denyNames' => $nonMatchSearchConstraints));
$riIterator = new RecursiveIteratorIterator($filterIterator, RecursiveIteratorIterator::SELF_FIRST);
} else {
$riIterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
}
$foundResource = false;
$currentConstraint = $matchSearchConstraints->getConstraint();
$foundDepth = 0;
foreach ($riIterator as $currentResource) {
// if current depth is less than found depth, end
if ($riIterator->getDepth() < $foundDepth) {
break;
}
if (strtolower($currentResource->getName()) == strtolower($currentConstraint->name)) {
$paramsMatch = true;
// @todo check to ensure params match (perhaps)
if (count($currentConstraint->params) > 0) {
$currentResourceAttributes = $currentResource->getAttributes();
if (!is_array($currentConstraint->params)) {
require_once 'Zend/Tool/Project/Profile/Exception.php';
throw new Zend_Tool_Project_Profile_Exception('Search parameter specifics must be in the form of an array for key "'
. $currentConstraint->name .'"');
}
foreach ($currentConstraint->params as $paramName => $paramValue) {
if (!isset($currentResourceAttributes[$paramName]) || $currentResourceAttributes[$paramName] != $paramValue) {
$paramsMatch = false;
break;
}
}
}
if ($paramsMatch) {
$foundDepth = $riIterator->getDepth();
if (($currentConstraint = $matchSearchConstraints->getConstraint()) == null) {
$foundResource = $currentResource;
break;
}
}
}
}
return $foundResource;
}
/**
* createResourceAt()
*
* @param array|Zend_Tool_Project_Profile_Resource_SearchConstraints $appendResourceOrSearchConstraints
* @param string $context
* @param array $attributes
* @return Zend_Tool_Project_Profile_Resource
*/
public function createResourceAt($appendResourceOrSearchConstraints, $context, Array $attributes = array())
{
if (!$appendResourceOrSearchConstraints instanceof Zend_Tool_Project_Profile_Resource_Container) {
if (($parentResource = $this->search($appendResourceOrSearchConstraints)) == false) {
require_once 'Zend/Tool/Project/Profile/Exception.php';
throw new Zend_Tool_Project_Profile_Exception('No node was found to append to.');
}
} else {
$parentResource = $appendResourceOrSearchConstraints;
}
return $parentResource->createResource($context, $attributes);
}
/**
* createResource()
*
* Method to create a resource with a given context with specific attributes
*
* @param string $context
* @param array $attributes
* @return Zend_Tool_Project_Profile_Resource
*/
public function createResource($context, Array $attributes = array())
{
if (is_string($context)) {
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
if ($contextRegistry->hasContext($context)) {
$context = $contextRegistry->getContext($context);
} else {
require_once 'Zend/Tool/Project/Profile/Exception.php';
throw new Zend_Tool_Project_Profile_Exception('Context by name ' . $context . ' was not found in the context registry.');
}
} elseif (!$context instanceof Zend_Tool_Project_Context_Interface) {
require_once 'Zend/Tool/Project/Profile/Exception.php';
throw new Zend_Tool_Project_Profile_Exception('Context must be of type string or Zend_Tool_Project_Context_Interface.');
}
$newResource = new Zend_Tool_Project_Profile_Resource($context);
if ($attributes) {
$newResource->setAttributes($attributes);
}
/**
* Interesting logic here:
*
* First set the parentResource (this will also be done inside append). This will allow
* the initialization routine to change the appendability of the parent resource. This
* is important to allow specific resources to be appendable by very specific sub-resources.
*/
$newResource->setParentResource($this);
$newResource->initializeContext();
$this->append($newResource);
return $newResource;
}
/**
* setAttributes()
*
* persist the attributes if the resource will accept them
*
* @param array $attributes
* @return Zend_Tool_Project_Profile_Resource_Container
*/
public function setAttributes(Array $attributes)
{
foreach ($attributes as $attrName => $attrValue) {
$setMethod = 'set' . $attrName;
if (method_exists($this, $setMethod)) {
$this->{$setMethod}($attrValue);
} else {
$this->setAttribute($attrName, $attrValue);
}
}
return $this;
}
/**
* getAttributes()
*
* @return array
*/
public function getAttributes()
{
return $this->_attributes;
}
/**
* setAttribute()
*
* @param string $name
* @param mixed $value
* @return Zend_Tool_Project_Profile_Resource_Container
*/
public function setAttribute($name, $value)
{
$this->_attributes[$name] = $value;
return $this;
}
/**
* getAttribute()
*
* @param string $name
* @return Zend_Tool_Project_Profile_Resource_Container
*/
public function getAttribute($name)
{
return (array_key_exists($name, $this->_attributes)) ? $this->_attributes[$name] : null;
}
/**
* hasAttribute()
*
* @param string $name
* @return bool
*/
public function hasAttribute($name)
{
return array_key_exists($name, $this->_attributes);
}
/**
* setAppendable()
*
* @param bool $appendable
* @return Zend_Tool_Project_Profile_Resource_Container
*/
public function setAppendable($appendable)
{
$this->_appendable = (bool) $appendable;
return $this;
}
/**
* isAppendable()
*
* @return bool
*/
public function isAppendable()
{
return $this->_appendable;
}
/**
* setParentResource()
*
* @param Zend_Tool_Project_Profile_Resource_Container $parentResource
* @return Zend_Tool_Project_Profile_Resource_Container
*/
public function setParentResource(Zend_Tool_Project_Profile_Resource_Container $parentResource)
{
$this->_parentResource = $parentResource;
return $this;
}
/**
* getParentResource()
*
* @return Zend_Tool_Project_Profile_Resource_Container
*/
public function getParentResource()
{
return $this->_parentResource;
}
/**
* append()
*
* @param Zend_Tool_Project_Profile_Resource_Container $resource
* @return Zend_Tool_Project_Profile_Resource_Container
*/
public function append(Zend_Tool_Project_Profile_Resource_Container $resource)
{
if (!$this->isAppendable()) {
throw new Exception('Resource by name ' . (string) $this . ' is not appendable');
}
array_push($this->_subResources, $resource);
$resource->setParentResource($this);
return $this;
}
/**
* current() - required by RecursiveIterator
*
* @return Zend_Tool_Project_Profile_Resource
*/
public function current()
{
return current($this->_subResources);
}
/**
* key() - required by RecursiveIterator
*
* @return int
*/
public function key()
{
return key($this->_subResources);
}
/**
* next() - required by RecursiveIterator
*
* @return bool
*/
public function next()
{
return next($this->_subResources);
}
/**
* rewind() - required by RecursiveIterator
*
* @return bool
*/
public function rewind()
{
return reset($this->_subResources);
}
/**
* valid() - - required by RecursiveIterator
*
* @return bool
*/
public function valid()
{
return (bool) $this->current();
}
/**
* hasChildren()
*
* @return bool
*/
public function hasChildren()
{
return (count($this->_subResources > 0)) ? true : false;
}
/**
* getChildren()
*
* @return array
*/
public function getChildren()
{
return $this->current();
}
/**
* count()
*
* @return int
*/
public function count()
{
return count($this->_subResources);
}
/**
* __clone()
*
*/
public function __clone()
{
$this->rewind();
foreach ($this->_subResources as $index => $resource) {
$this->_subResources[$index] = clone $resource;
}
}
}

View file

@ -0,0 +1,117 @@
<?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: SearchConstraints.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* This class is an iterator that will iterate only over enabled resources
*
* @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_Profile_Resource_SearchConstraints
{
/**
* @var array
*/
protected $_constraints = array();
/**
* __construct()
*
* @param array|string $options
*/
public function __construct($options = null)
{
if (is_string($options)) {
$this->addConstraint($options);
} elseif (is_array($options)) {
$this->setOptions($options);
}
}
/**
* setOptions()
*
* @param array $option
* @return Zend_Tool_Project_Profile_Resource_SearchConstraints
*/
public function setOptions(Array $option)
{
foreach ($option as $optionName => $optionValue) {
if (is_int($optionName)) {
$this->addConstraint($optionValue);
} elseif (is_string($optionName)) {
$this->addConstraint(array('name' => $optionName, 'params' => $optionValue));
}
}
return $this;
}
/**
* addConstraint()
*
* @param string|array $constraint
* @return Zend_Tool_Project_Profile_Resource_SearchConstraints
*/
public function addConstraint($constraint)
{
if (is_string($constraint)) {
$name = $constraint;
$params = array();
} elseif (is_array($constraint)) {
$name = $constraint['name'];
$params = $constraint['params'];
}
$constraint = $this->_makeConstraint($name, $params);
array_push($this->_constraints, $constraint);
return $this;
}
/**
* getConstraint()
*
* @return ArrayObject
*/
public function getConstraint()
{
return array_shift($this->_constraints);
}
/**
* _makeConstraint
*
* @param string $name
* @param mixed $params
* @return ArrayObject
*/
protected function _makeConstraint($name, $params)
{
$value = array('name' => $name, 'params' => $params);
return new ArrayObject($value, ArrayObject::ARRAY_AS_PROPS);
}
}

View 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);
}
}
}

View 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();
}
}
}
}

View file

@ -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();
}
}

View 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();
}
}
}

View 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);
}
}

View 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);
}
}

View 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
{
}

View 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();
}
}
}

View 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
}
}

View 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',
);
}
}

View 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();
}
}
}

View 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();
}
}
}

View 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
);
}
}
}

View 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;
}
}

View file

@ -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();
}
}
}

View 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();
}
}
}

View 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();
}
}
}