import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -0,0 +1,8 @@
<?php
require_once 'Zend/Tool/Project/Exception.php';
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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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_Directory extends Zend_Tool_Project_Context_Filesystem_Abstract
{
/**
* 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,112 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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_File extends Zend_Tool_Project_Context_Filesystem_Abstract
{
/**
* init()
*
* @return Zend_Tool_Project_Context_Filesystem_File
*/
public function init()
{
// @todo check to ensure that this 'file' resource has no children
parent::init();
return $this;
}
/**
* setResource()
*
* @param unknown_type $resource
*/
public function setResource(Zend_Tool_Project_Profile_Resource $resource)
{
$this->_resource = $resource;
$this->_resource->setAppendable(false);
return $this;
}
/**
* 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 null;
}
}

View File

@ -0,0 +1,15 @@
<?php
/**
* Interface for contexts
*
* setResource() is an optional method that if the context supports
* will be set with the resource at construction time
*
*/
interface Zend_Tool_Project_Context_Interface
{
public function getName();
}

View File

@ -0,0 +1,160 @@
<?php
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';
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);
}
$context = new $contextClass();
return $this->addContext($context);
}
/**
* 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* 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-2009 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,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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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';
/**
* 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()
{
$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"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
EOS;
return $contents;
}
}

View File

@ -0,0 +1,49 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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';
public function getName()
{
return 'ApplicationDirectory';
}
}

View File

@ -0,0 +1,103 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Project_Context_Filesystem_File
*/
require_once 'Zend/Tool/Project/Context/Filesystem/File.php';
require_once 'Zend/Application.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-2009 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';
protected $_applicationInstance = null;
protected $_bootstrapInstance = null;
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'BootstrapFile';
}
public function init()
{
parent::init();
$applicationConfigFile = $this->_resource->getProfile()->search('ApplicationConfigFile');
$applicationDirectory = $this->_resource->getProfile()->search('ApplicationDirectory');
if (($applicationConfigFile === false) || ($applicationDirectory === false)) {
throw new Exception('To use the BootstrapFile context, your project requires the use of both the "ApplicationConfigFile" and "ApplicationDirectory" contexts.');
}
if ($applicationConfigFile->getContext()->exists()) {
define('APPLICATION_PATH', $applicationDirectory->getPath());
$applicationOptions = array();
$applicationOptions['config'] = $applicationConfigFile->getPath();
$this->_applicationInstance = new Zend_Application(
'development',
$applicationOptions
);
}
}
/**
* 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();
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,197 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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';
/**
* @see Zend_Filter_Word_DashToCamelCase
*/
require_once 'Zend/Filter/Word/DashToCamelCase.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-2009 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 $_filesystemName = 'controllerName';
/**
* init()
*
* @return Zend_Tool_Project_Context_Zf_ControllerFile
*/
public function init()
{
$this->_controllerName = $this->_resource->getAttribute('controllerName');
$this->_filesystemName = ucfirst($this->_controllerName) . 'Controller.php';
parent::init();
return $this;
}
/**
* 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()
{
$filter = new Zend_Filter_Word_DashToCamelCase();
$className = $filter->filter($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_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;
}
\$this->view->exception = \$errors->exception;
\$this->view->request = \$errors->request;
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)
{
//require_once $this->getPath();
//$codeGenFile = Zend_CodeGenerator_Php_File::fromReflection(new Zend_Reflection_File($this->getPath()));
$codeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($this->getPath());
$codeGenFileClasses = $codeGenFile->getClasses();
$class = array_shift($codeGenFileClasses);
$class->setMethod(array('name' => $actionName . 'Action', 'body' => ' // action body here'));
file_put_contents($this->getPath(), $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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,72 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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_Filesystem_File
{
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'DbTableFile';
}
/*
protected $_dbTableName;
public function getPersistentAttributes()
{
return array('dbTableName' => $this->_dbTableName);
}
public function setDbTableName($dbTableName)
{
$this->_dbTableName = $dbTableName;
$this->_filesystemName = $dbTableName . '.php';
}
public function getDbTableName()
{
return $this->_dbTableName;
}
*/
}

View File

@ -0,0 +1,52 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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_Filesystem_File
{
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'FormFile';
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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
SetEnv APPLICATION_ENV development
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,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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,52 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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_Filesystem_File
{
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ModelFile';
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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->_forControllerName;
parent::init();
return $this;
}
/**
* getPersistentAttributes()
*
* @return array
*/
public function getPersistentAttributes()
{
return array(
'forControllerName' => $this->_forControllerName
);
}
/**
* getName()
*
* @return string
*/
public function getName()
{
return 'ViewControllerScriptsDirectory';
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,205 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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 = $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><?= \$this->message ?></h2>
<? if ('development' == APPLICATION_ENV): ?>
<h3>Exception information:</h3>
<p>
<b>Message:</b> <?= \$this->exception->getMessage() ?>
</p>
<h3>Stack trace:</h3>
<pre><?= \$this->exception->getTraceAsString() ?>
</pre>
<h3>Request Parameters:</h3>
<pre><? var_dump(\$this->request->getParams()) ?>
</pre>
<? 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;
}
div#more-information
{
background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);
height: 100%;
}
</style>
<center>
<div id="welcome">
<br />
<h1>Welcome to the <span id="zf-name">Zend Framework!</span></h1>
<h3>This is your project's main page</h3><br /><br />
<div id="more-information">
<br />
<img src="http://framework.zend.com/images/PoweredBy_ZF_4LightBG.png" /><br /><br />
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>
</div>
</div>
</center>
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;
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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()
{
foreach (explode(PATH_SEPARATOR, get_include_path()) 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Exception
*/
require_once 'Zend/Exception.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Exception extends Zend_Exception
{
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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;
/**
* @var array
*/
protected $_attributes = array();
/**
* 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);
}
} 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);
}
}
$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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Project_Exception
*/
require_once 'Zend/Tool/Project/Exception.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 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,223 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
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-2009 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 />');
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');
}
$this->_unserializeRecurser($xmlDataIterator);
$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,203 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* This class is an iterator that will iterate only over enabled resources
*
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_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);
}
$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);
}
$this->_denyNames = $denyNames;
return $this;
}
/**
* accept() is required by teh RecursiveFilterIterator
*
* @return bool
*/
public function accept()
{
$currentItem = $this->current();
if (in_array($currentItem->getName(), $this->_acceptNames)) {
return true;
} elseif (in_array($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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* This class is an iterator that will iterate only over enabled resources
*
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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,405 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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;
/**
* 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;
}
/**
* 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* This class is an iterator that will iterate only over enabled resources
*
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_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,201 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 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_'
);
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
*
* @
* @return Zend_Tool_Project_Profile
*/
protected function _loadProfile($loadProfileFlag = self::NO_PROFILE_THROW_EXCEPTION, $projectDirectory = null)
{
if ($projectDirectory == null) {
$projectDirectory = getcwd();
}
$profile = new Zend_Tool_Project_Profile();
$profile->setAttribute('projectDirectory', $projectDirectory);
if ($profile->isLoadableFromFile()) {
$profile->loadFromFile();
$this->_loadedProfile = $profile;
}
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();
}
/**
* _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,168 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_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);
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
* @param string $controllerName
* @param bool $viewIncluded
*/
public function create($name, $controllerName = 'index', $viewIncluded = true, $module = null)
{
$this->_loadProfile();
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);
if ($this->_registry->getRequest()->isPretend()) {
$this->_registry->getResponse()->appendContent(
'Would create an action named ' . $name .
' inside controller at ' . $actionMethod->getParentResource()->getContext()->getPath()
);
} else {
$this->_registry->getResponse()->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()) {
$this->_registry->getResponse()->appendContent(
'Would create a view script for the ' . $name . ' action method at ' . $viewResource->getContext()->getPath()
);
} else {
$this->_registry->getResponse()->appendContent(
'Creating a view script for the ' . $name . ' action method at ' . $viewResource->getContext()->getPath()
);
$viewResource->create();
$this->_storeProfile();
}
}
}
}

View File

@ -0,0 +1,199 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Project_Provider_Abstract
*/
require_once 'Zend/Tool/Project/Provider/Abstract.php';
/**
* @see Zend_Tool_Framework_Registry
*/
require_once 'Zend/Tool/Framework/Registry.php';
/**
* @see Zend_Tool_Project_Provider_View
*/
require_once 'Zend/Tool/Project/Provider/View.php';
/**
* @see Zend_Tool_Project_Provider_Exception
*/
require_once 'Zend/Tool/Project/Provider/Exception.php';
/**
* @see Zend_Tool_Framework_Provider_Pretendable
*/
require_once 'Zend/Tool/Framework/Provider/Pretendable.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_Controller
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));
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);
}
/**
* Enter description here...
*
* @param string $name The name of the controller to create.
* @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);
}
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 = $this->_registry->getResponse();
$response->setException($e);
return;
}
// do the creation
if ($this->_registry->getRequest()->isPretend()) {
$this->_registry->getResponse()->appendContent('Would create a controller at ' . $controllerResource->getContext()->getPath());
if (isset($indexActionResource)) {
$this->_registry->getResponse()->appendContent('Would create an index action method in controller ' . $name);
$this->_registry->getResponse()->appendContent('Would create a view script for the index action method at ' . $indexActionViewResource->getContext()->getPath());
}
if ($testControllerResource) {
$this->_registry->getResponse()->appendContent('Would create a controller test file at ' . $testControllerResource->getContext()->getPath());
}
} else {
$this->_registry->getResponse()->appendContent('Creating a controller at ' . $controllerResource->getContext()->getPath());
$controllerResource->create();
if (isset($indexActionResource)) {
$this->_registry->getResponse()->appendContent('Creating an index action method in controller ' . $name);
$indexActionResource->create();
$this->_registry->getResponse()->appendContent('Creating a view script for the index action method at ' . $indexActionViewResource->getContext()->getPath());
$indexActionViewResource->create();
}
if ($testControllerResource) {
$this->_registry->getResponse()->appendContent('Creating a controller test file at ' . $testControllerResource->getContext()->getPath());
$testControllerResource->create();
}
$this->_storeProfile();
}
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Project_Exception
*/
require_once 'Zend/Tool/Project/Exception.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_Exception extends Zend_Tool_Project_Exception
{
}

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
* @subpackage Framework
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_Form extends Zend_Tool_Project_Provider_Abstract
{
public function create($name)
{
echo '@todo - create form';
}
}

View File

@ -0,0 +1,90 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Framework_Manifest_ProviderManifestable
*/
require_once 'Zend/Tool/Framework/Manifest/ProviderManifestable.php';
/**
* @see Zend_Tool_Project_Provider_Profile
*/
require_once 'Zend/Tool/Project/Provider/Profile.php';
/**
* @see Zend_Tool_Project_Provider_Project
*/
require_once 'Zend/Tool/Project/Provider/Project.php';
/**
* @see Zend_Tool_Project_Provider_Controller
*/
require_once 'Zend/Tool/Project/Provider/Controller.php';
/**
* @see Zend_Tool_Project_Provider_Action
*/
require_once 'Zend/Tool/Project/Provider/Action.php';
/**
* @see Zend_Tool_Project_Provider_View
*/
require_once 'Zend/Tool/Project/Provider/View.php';
/**
* @see Zend_Tool_Project_Provider_Module
*/
require_once 'Zend/Tool/Project/Provider/Module.php';
/**
* @see Zend_Tool_Project_Provider_ProjectProvider
*/
require_once 'Zend/Tool/Project/Provider/ProjectProvider.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_Manifest implements
Zend_Tool_Framework_Manifest_ProviderManifestable
{
/**
* getProviders()
*
* @return array Array of Providers
*/
public function getProviders()
{
return array(
new Zend_Tool_Project_Provider_Profile(),
new Zend_Tool_Project_Provider_Project(),
new Zend_Tool_Project_Provider_Controller(),
new Zend_Tool_Project_Provider_Action(),
new Zend_Tool_Project_Provider_View(),
new Zend_Tool_Project_Provider_Module(),
new Zend_Tool_Project_Provider_ProjectProvider()
);
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_Model extends Zend_Tool_Project_Provider_Abstract
{
/**
* create()
*
* @param string $name
*/
public function create($name)
{
echo '@todo - create model';
}
}

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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_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();
}
// 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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Project_Provider_Abstract
*/
require_once 'Zend/Tool/Project/Provider/Abstract.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_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,148 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Project_Provider_Abstract
*/
require_once 'Zend/Tool/Project/Provider/Abstract.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_Project extends Zend_Tool_Project_Provider_Abstract
{
/**
* create()
*
* @param string $path
*/
public function create($path)
{
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');
}
$newProfile = new Zend_Tool_Project_Profile(array(
'projectDirectory' => $path,
'profileData' => $this->_getDefaultProfile()
));
$newProfile->loadFromData();
$this->_registry->getResponse()->appendContent('Creating project at ' . $path);
foreach ($newProfile->getIterator() as $resource) {
$resource->create();
}
}
protected function _getDefaultProfile()
{
$data = <<<EOS
<?xml version="1.0" encoding="UTF-8"?>
<projectProfile type="default">
<projectDirectory>
<projectProfileFile />
<applicationDirectory>
<apisDirectory enabled="false" />
<configsDirectory>
<applicationConfigFile type="ini" />
</configsDirectory>
<controllersDirectory>
<controllerFile controllerName="index">
<actionMethod actionName="index" />
</controllerFile>
<controllerFile controllerName="error" />
</controllersDirectory>
<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>
<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;
}
}

View File

@ -0,0 +1,99 @@
<?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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Tool_Project_Provider_Abstract */
require_once 'Zend/Tool/Project/Provider/Abstract.php';
/** Zend_Tool_Project_Provider_Exception */
require_once 'Zend/Tool/Project/Provider/Exception.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_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-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Tool_Project_Provider_Abstract
*/
require_once 'Zend/Tool/Project/Provider/Abstract.php';
/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Tool_Project_Provider_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);
// XXXXXXXXX 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();
}
}
}