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:
@ -16,7 +16,7 @@
|
||||
* @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
|
||||
* @version $Id: Repository.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Repository.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
require_once 'Zend/Tool/Project/Context/System/Interface.php';
|
||||
@ -31,13 +31,13 @@ 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...
|
||||
*
|
||||
@ -48,16 +48,16 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
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) {
|
||||
@ -67,7 +67,7 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
self::$_isInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addContextsFromDirectory($directory, $prefix)
|
||||
{
|
||||
$prefix = trim($prefix, '_') . '_';
|
||||
@ -79,8 +79,8 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
$this->addContextClass($class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function addContextClass($contextClass)
|
||||
{
|
||||
if (!class_exists($contextClass)) {
|
||||
@ -90,7 +90,7 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
$context = new $contextClass();
|
||||
return $this->addContext($context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
@ -102,16 +102,16 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
$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,
|
||||
@ -120,38 +120,38 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
'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)) {
|
||||
@ -161,7 +161,7 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
$index = $this->_shortContextNames[$name];
|
||||
return $this->_contexts[$index]['isTopLevel'];
|
||||
}
|
||||
|
||||
|
||||
public function isOverwritableContext($name)
|
||||
{
|
||||
if (!$this->hasContext($name)) {
|
||||
@ -171,15 +171,15 @@ class Zend_Tool_Project_Context_Repository implements Countable
|
||||
$index = $this->_shortContextNames[$name];
|
||||
return $this->_contexts[$index]['isOverwritable'];
|
||||
}
|
||||
|
||||
|
||||
public function count()
|
||||
{
|
||||
return count($this->_contexts);
|
||||
}
|
||||
|
||||
|
||||
protected function _normalizeName($name)
|
||||
{
|
||||
return strtolower($name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user