import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @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: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Exception.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -33,5 +33,5 @@ require_once 'Zend/Tool/Project/Exception.php';
|
||||
*/
|
||||
class Zend_Tool_Project_Profile_Exception extends Zend_Tool_Project_Exception
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @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: Interface.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Interface.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,21 +28,21 @@
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -50,5 +50,5 @@ interface Zend_Tool_Project_Profile_FileParser_Interface
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
*/
|
||||
public function unserialize($data, Zend_Tool_Project_Profile $profile);
|
||||
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* @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: Xml.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Xml.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
require_once 'Zend/Tool/Project/Profile/FileParser/Interface.php';
|
||||
@ -33,12 +33,12 @@ require_once 'Zend/Tool/Project/Profile/Resource.php';
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -52,10 +52,10 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
{
|
||||
$this->_contextRepository = Zend_Tool_Project_Context_Repository::getInstance();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* serialize()
|
||||
*
|
||||
*
|
||||
* create an xml string from the provided profile
|
||||
*
|
||||
* @param Zend_Tool_Project_Profile $profile
|
||||
@ -65,27 +65,27 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
{
|
||||
|
||||
$profile = clone $profile;
|
||||
|
||||
|
||||
$this->_profile = $profile;
|
||||
$xmlElement = new SimpleXMLElement('<projectProfile />');
|
||||
|
||||
self::_serializeRecurser($profile, $xmlElement);
|
||||
|
||||
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()
|
||||
*
|
||||
* 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
|
||||
@ -97,25 +97,25 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
}
|
||||
|
||||
$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
|
||||
*
|
||||
@ -128,16 +128,16 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
//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());
|
||||
@ -145,7 +145,7 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
if ($resource->isEnabled() == false) {
|
||||
$newNode->addAttribute('enabled', 'false');
|
||||
}
|
||||
|
||||
|
||||
foreach ($resource->getPersistentAttributes() as $paramName => $paramValue) {
|
||||
$newNode->addAttribute($paramName, $paramValue);
|
||||
}
|
||||
@ -153,15 +153,15 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
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
|
||||
*
|
||||
@ -170,9 +170,9 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
*/
|
||||
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);
|
||||
@ -184,7 +184,7 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
}
|
||||
$subResource->setAttributes($attributes);
|
||||
}
|
||||
|
||||
|
||||
if ($resource) {
|
||||
$resource->append($subResource, false);
|
||||
} else {
|
||||
@ -194,23 +194,23 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
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) {
|
||||
@ -219,5 +219,5 @@ class Zend_Tool_Project_Profile_FileParser_Xml implements Zend_Tool_Project_Prof
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -17,12 +17,12 @@
|
||||
* @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: ContextFilter.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: ContextFilter.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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)
|
||||
@ -30,32 +30,32 @@
|
||||
*/
|
||||
class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIterator
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array
|
||||
*/
|
||||
protected $_acceptTypes = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array
|
||||
*/
|
||||
protected $_denyTypes = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array
|
||||
*/
|
||||
protected $_acceptNames = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array
|
||||
*/
|
||||
protected $_denyNames = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array
|
||||
*/
|
||||
protected $_rawOptions = array();
|
||||
|
||||
|
||||
/**
|
||||
* __construct()
|
||||
*
|
||||
@ -70,7 +70,7 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setOptions()
|
||||
*
|
||||
@ -87,7 +87,7 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setAcceptTypes()
|
||||
*
|
||||
@ -99,11 +99,11 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
if (!is_array($acceptTypes)) {
|
||||
$acceptTypes = array($acceptTypes);
|
||||
}
|
||||
|
||||
|
||||
$this->_acceptTypes = $acceptTypes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setDenyTypes()
|
||||
*
|
||||
@ -115,11 +115,11 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
if (!is_array($denyTypes)) {
|
||||
$denyTypes = array($denyTypes);
|
||||
}
|
||||
|
||||
|
||||
$this->_denyTypes = $denyTypes;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setAcceptNames()
|
||||
*
|
||||
@ -131,11 +131,11 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
if (!is_array($acceptNames)) {
|
||||
$acceptNames = array($acceptNames);
|
||||
}
|
||||
|
||||
|
||||
$this->_acceptNames = $acceptNames;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setDenyNames()
|
||||
*
|
||||
@ -147,11 +147,11 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
if (!is_array($denyNames)) {
|
||||
$denyNames = array($denyNames);
|
||||
}
|
||||
|
||||
|
||||
$this->_denyNames = $denyNames;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* accept() is required by teh RecursiveFilterIterator
|
||||
*
|
||||
@ -160,33 +160,33 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
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
|
||||
* @link
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
@ -199,5 +199,5 @@ class Zend_Tool_Project_Profile_Iterator_ContextFilter extends RecursiveFilterIt
|
||||
|
||||
return $this->ref->newInstance($this->getInnerIterator()->getChildren(), $this->_rawOptions);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,12 +17,12 @@
|
||||
* @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: EnabledResourceFilter.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: EnabledResourceFilter.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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)
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
class Zend_Tool_Project_Profile_Iterator_EnabledResourceFilter extends RecursiveFilterIterator
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* accept() is required by teh RecursiveFilterIterator
|
||||
*
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @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: Resource.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Resource.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ 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)
|
||||
@ -40,12 +40,12 @@ require_once 'Zend/Tool/Project/Context/Repository.php';
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -107,7 +107,7 @@ class Zend_Tool_Project_Profile_Resource extends Zend_Tool_Project_Profile_Resou
|
||||
|
||||
/**
|
||||
* getName() - Get the resource name
|
||||
*
|
||||
*
|
||||
* Name is derived from the context name
|
||||
*
|
||||
* @return string
|
||||
@ -164,7 +164,7 @@ class Zend_Tool_Project_Profile_Resource extends Zend_Tool_Project_Profile_Resou
|
||||
*
|
||||
* @param bool $enabled
|
||||
* @return Zend_Tool_Project_Profile_Resource
|
||||
*/
|
||||
*/
|
||||
public function setEnabled($enabled = true)
|
||||
{
|
||||
// convert fuzzy types to bool
|
||||
@ -203,7 +203,7 @@ class Zend_Tool_Project_Profile_Resource extends Zend_Tool_Project_Profile_Resou
|
||||
{
|
||||
return $this->_deleted;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initializeContext()
|
||||
*
|
||||
@ -217,15 +217,15 @@ class Zend_Tool_Project_Profile_Resource extends Zend_Tool_Project_Profile_Resou
|
||||
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;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @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: Container.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Container.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -27,7 +27,7 @@ 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)
|
||||
@ -35,12 +35,12 @@ require_once 'Zend/Tool/Project/Profile/Resource/SearchConstraints.php';
|
||||
*/
|
||||
class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator, Countable
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_subResources = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
@ -54,9 +54,9 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
/**
|
||||
* 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
|
||||
@ -67,42 +67,42 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
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 .'"');
|
||||
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) {
|
||||
@ -111,10 +111,10 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($paramsMatch) {
|
||||
$foundDepth = $riIterator->getDepth();
|
||||
|
||||
|
||||
if (($currentConstraint = $matchSearchConstraints->getConstraint()) == null) {
|
||||
$foundResource = $currentResource;
|
||||
break;
|
||||
@ -122,12 +122,12 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $foundResource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* createResourceAt()
|
||||
*
|
||||
@ -146,13 +146,13 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
} else {
|
||||
$parentResource = $appendResourceOrSearchConstraints;
|
||||
}
|
||||
|
||||
|
||||
return $parentResource->createResource($context, $attributes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* createResource()
|
||||
*
|
||||
*
|
||||
* Method to create a resource with a given context with specific attributes
|
||||
*
|
||||
* @param string $context
|
||||
@ -167,25 +167,25 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
$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.');
|
||||
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.');
|
||||
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.
|
||||
* is important to allow specific resources to be appendable by very specific sub-resources.
|
||||
*/
|
||||
$newResource->setParentResource($this);
|
||||
$newResource->initializeContext();
|
||||
@ -193,10 +193,10 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
|
||||
return $newResource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setAttributes()
|
||||
*
|
||||
*
|
||||
* persist the attributes if the resource will accept them
|
||||
*
|
||||
* @param array $attributes
|
||||
@ -224,7 +224,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return $this->_attributes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setAttribute()
|
||||
*
|
||||
@ -237,7 +237,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
$this->_attributes[$name] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getAttribute()
|
||||
*
|
||||
@ -260,7 +260,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
$this->_appendable = (bool) $appendable;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* isAppendable()
|
||||
*
|
||||
@ -270,7 +270,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return $this->_appendable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setParentResource()
|
||||
*
|
||||
@ -282,7 +282,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
$this->_parentResource = $parentResource;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getParentResource()
|
||||
*
|
||||
@ -292,7 +292,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return $this->_parentResource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* append()
|
||||
*
|
||||
@ -306,10 +306,10 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
}
|
||||
array_push($this->_subResources, $resource);
|
||||
$resource->setParentResource($this);
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* current() - required by RecursiveIterator
|
||||
*
|
||||
@ -319,7 +319,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return current($this->_subResources);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* key() - required by RecursiveIterator
|
||||
*
|
||||
@ -329,7 +329,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return key($this->_subResources);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* next() - required by RecursiveIterator
|
||||
*
|
||||
@ -339,7 +339,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return next($this->_subResources);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rewind() - required by RecursiveIterator
|
||||
*
|
||||
@ -349,7 +349,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return reset($this->_subResources);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* valid() - - required by RecursiveIterator
|
||||
*
|
||||
@ -359,7 +359,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return (bool) $this->current();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hasChildren()
|
||||
*
|
||||
@ -369,7 +369,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return (count($this->_subResources > 0)) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getChildren()
|
||||
*
|
||||
@ -379,7 +379,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return $this->current();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* count()
|
||||
*
|
||||
@ -389,7 +389,7 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
{
|
||||
return count($this->_subResources);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* __clone()
|
||||
*
|
||||
@ -401,5 +401,5 @@ class Zend_Tool_Project_Profile_Resource_Container implements RecursiveIterator,
|
||||
$this->_subResources[$index] = clone $resource;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -17,12 +17,12 @@
|
||||
* @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: SearchConstraints.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: SearchConstraints.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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)
|
||||
@ -30,12 +30,12 @@
|
||||
*/
|
||||
class Zend_Tool_Project_Profile_Resource_SearchConstraints
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_constraints = array();
|
||||
|
||||
|
||||
/**
|
||||
* __construct()
|
||||
*
|
||||
@ -49,7 +49,7 @@ class Zend_Tool_Project_Profile_Resource_SearchConstraints
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setOptions()
|
||||
*
|
||||
@ -68,7 +68,7 @@ class Zend_Tool_Project_Profile_Resource_SearchConstraints
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* addConstraint()
|
||||
*
|
||||
@ -84,13 +84,13 @@ class Zend_Tool_Project_Profile_Resource_SearchConstraints
|
||||
$name = $constraint['name'];
|
||||
$params = $constraint['params'];
|
||||
}
|
||||
|
||||
|
||||
$constraint = $this->_makeConstraint($name, $params);
|
||||
|
||||
|
||||
array_push($this->_constraints, $constraint);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getConstraint()
|
||||
*
|
||||
@ -113,5 +113,5 @@ class Zend_Tool_Project_Profile_Resource_SearchConstraints
|
||||
$value = array('name' => $name, 'params' => $params);
|
||||
return new ArrayObject($value, ArrayObject::ARRAY_AS_PROPS);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user