CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.
This commit is contained in:
parent
514777e8d2
commit
b11cbd8159
4546 changed files with 138 additions and 51 deletions
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Provider_Interface
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Provider/Interface.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Registry_EnabledInterface
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php';
|
||||
|
||||
|
||||
/**
|
||||
* This is a convenience class.
|
||||
*
|
||||
* At current it will return the request and response from the client registry
|
||||
* as they are the more common things that will be needed by providers
|
||||
*
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Tool_Framework_Provider_Abstract
|
||||
implements Zend_Tool_Framework_Provider_Interface, Zend_Tool_Framework_Registry_EnabledInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Registry_Interface
|
||||
*/
|
||||
protected $_registry = null;
|
||||
|
||||
/**
|
||||
* setRegistry() - required by Zend_Tool_Framework_Registry_EnabledInterface
|
||||
*
|
||||
* @param Zend_Tool_Framework_Registry_Interface $registry
|
||||
* @return Zend_Tool_Framework_Provider_Abstract
|
||||
*/
|
||||
public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
|
||||
{
|
||||
$this->_registry = $registry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: DocblockManifestable.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Provider_DocblockManifestInterface
|
||||
{
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Exception
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Exception.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Provider_Exception extends Zend_Tool_Framework_Exception
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interactable.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Provider_Interactable
|
||||
{
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interface.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Provider_Interface
|
||||
{
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Pretendable.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Provider_Pretendable
|
||||
{
|
||||
}
|
265
airtime_mvc/library/Zend/Tool/Framework/Provider/Repository.php
Normal file
265
airtime_mvc/library/Zend/Tool/Framework/Provider/Repository.php
Normal file
|
@ -0,0 +1,265 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Repository.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Provider_Signature
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Provider/Signature.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Registry_EnabledInterface
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Provider_Repository
|
||||
implements Zend_Tool_Framework_Registry_EnabledInterface, IteratorAggregate, Countable
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Registry
|
||||
*/
|
||||
protected $_registry = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $_processOnAdd = false;
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Provider_Interface[]
|
||||
*/
|
||||
protected $_unprocessedProviders = array();
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Provider_Signature[]
|
||||
*/
|
||||
protected $_providerSignatures = array();
|
||||
|
||||
/**
|
||||
* @var array Array of Zend_Tool_Framework_Provider_Inteface
|
||||
*/
|
||||
protected $_providers = array();
|
||||
|
||||
/**
|
||||
* setRegistry()
|
||||
*
|
||||
* @param Zend_Tool_Framework_Registry_Interface $registry
|
||||
* @return unknown
|
||||
*/
|
||||
public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
|
||||
{
|
||||
$this->_registry = $registry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ProcessOnAdd flag
|
||||
*
|
||||
* @param unknown_type $processOnAdd
|
||||
* @return unknown
|
||||
*/
|
||||
public function setProcessOnAdd($processOnAdd = true)
|
||||
{
|
||||
$this->_processOnAdd = (bool) $processOnAdd;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a provider to the repository for processing
|
||||
*
|
||||
* @param Zend_Tool_Framework_Provider_Interface $provider
|
||||
* @return Zend_Tool_Framework_Provider_Repository
|
||||
*/
|
||||
public function addProvider(Zend_Tool_Framework_Provider_Interface $provider, $overwriteExistingProvider = false)
|
||||
{
|
||||
if ($provider instanceof Zend_Tool_Framework_Registry_EnabledInterface) {
|
||||
$provider->setRegistry($this->_registry);
|
||||
}
|
||||
|
||||
if (method_exists($provider, 'getName')) {
|
||||
$providerName = $provider->getName();
|
||||
} else {
|
||||
$providerName = $this->_parseName($provider);
|
||||
}
|
||||
|
||||
// if a provider by the given name already exist, and its not set as overwritable, throw exception
|
||||
if (!$overwriteExistingProvider &&
|
||||
(array_key_exists($providerName, $this->_unprocessedProviders)
|
||||
|| array_key_exists($providerName, $this->_providers)))
|
||||
{
|
||||
require_once 'Zend/Tool/Framework/Provider/Exception.php';
|
||||
throw new Zend_Tool_Framework_Provider_Exception('A provider by the name ' . $providerName
|
||||
. ' is already registered and $overrideExistingProvider is set to false.');
|
||||
}
|
||||
|
||||
$this->_unprocessedProviders[$providerName] = $provider;
|
||||
|
||||
// if process has already been called, process immediately.
|
||||
if ($this->_processOnAdd) {
|
||||
$this->process();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasProvider($providerOrClassName, $processedOnly = true)
|
||||
{
|
||||
if ($providerOrClassName instanceof Zend_Tool_Framework_Provider_Interface) {
|
||||
$targetProviderClassName = get_class($providerOrClassName);
|
||||
} else {
|
||||
$targetProviderClassName = (string) $providerOrClassName;
|
||||
}
|
||||
|
||||
if (!$processedOnly) {
|
||||
foreach ($this->_unprocessedProviders as $unprocessedProvider) {
|
||||
if (get_class($unprocessedProvider) == $targetProviderClassName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->_providers as $processedProvider) {
|
||||
if (get_class($processedProvider) == $targetProviderClassName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process all of the unprocessed providers
|
||||
*
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
|
||||
// process all providers in the unprocessedProviders array
|
||||
foreach ($this->_unprocessedProviders as $providerName => $provider) {
|
||||
|
||||
// create a signature for the provided provider
|
||||
$providerSignature = new Zend_Tool_Framework_Provider_Signature($provider);
|
||||
|
||||
if ($providerSignature instanceof Zend_Tool_Framework_Registry_EnabledInterface) {
|
||||
$providerSignature->setRegistry($this->_registry);
|
||||
}
|
||||
|
||||
$providerSignature->process();
|
||||
|
||||
// ensure the name is lowercased for easier searching
|
||||
$providerName = strtolower($providerName);
|
||||
|
||||
// add to the appropraite place
|
||||
$this->_providerSignatures[$providerName] = $providerSignature;
|
||||
$this->_providers[$providerName] = $providerSignature->getProvider();
|
||||
|
||||
// remove from unprocessed array
|
||||
unset($this->_unprocessedProviders[$providerName]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* getProviders() Get all the providers in the repository
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProviders()
|
||||
{
|
||||
return $this->_providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* getProviderSignatures() Get all the provider signatures
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProviderSignatures()
|
||||
{
|
||||
return $this->_providerSignatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* getProvider()
|
||||
*
|
||||
* @param string $providerName
|
||||
* @return Zend_Tool_Framework_Provider_Interface
|
||||
*/
|
||||
public function getProvider($providerName)
|
||||
{
|
||||
return $this->_providers[strtolower($providerName)];
|
||||
}
|
||||
|
||||
/**
|
||||
* getProviderSignature()
|
||||
*
|
||||
* @param string $providerName
|
||||
* @return Zend_Tool_Framework_Provider_Signature
|
||||
*/
|
||||
public function getProviderSignature($providerName)
|
||||
{
|
||||
return $this->_providerSignatures[strtolower($providerName)];
|
||||
}
|
||||
|
||||
/**
|
||||
* count() - return the number of providers
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->_providers);
|
||||
}
|
||||
|
||||
/**
|
||||
* getIterator() - Required by the IteratorAggregate Interface
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->getProviders());
|
||||
}
|
||||
|
||||
/**
|
||||
* _parseName - internal method to determine the name of an action when one is not explicity provided.
|
||||
*
|
||||
* @param Zend_Tool_Framework_Action_Interface $action
|
||||
* @return string
|
||||
*/
|
||||
protected function _parseName(Zend_Tool_Framework_Provider_Interface $provider)
|
||||
{
|
||||
$className = get_class($provider);
|
||||
$providerName = substr($className, strrpos($className, '_')+1);
|
||||
if (substr($providerName, -8) == 'Provider') {
|
||||
$providerName = substr($providerName, 0, strlen($providerName)-8);
|
||||
}
|
||||
return $providerName;
|
||||
}
|
||||
|
||||
}
|
391
airtime_mvc/library/Zend/Tool/Framework/Provider/Signature.php
Normal file
391
airtime_mvc/library/Zend/Tool/Framework/Provider/Signature.php
Normal file
|
@ -0,0 +1,391 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Signature.php 20096 2010-01-06 02:05:09Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Reflection_Class
|
||||
*/
|
||||
require_once 'Zend/Reflection/Class.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Registry
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Action_Base
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Action/Base.php';
|
||||
|
||||
/**
|
||||
* The purpose of Zend_Tool_Framework_Provider_Signature is to derive
|
||||
* callable signatures from the provided provider.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Provider_Signature implements Zend_Tool_Framework_Registry_EnabledInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Registry
|
||||
*/
|
||||
protected $_registry = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Provider_Interface
|
||||
*/
|
||||
protected $_provider = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_name = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_specialties = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_actionableMethods = array();
|
||||
|
||||
/**
|
||||
* @var unknown_type
|
||||
*/
|
||||
protected $_actions = array();
|
||||
|
||||
/**
|
||||
* @var Zend_Reflection_Class
|
||||
*/
|
||||
protected $_providerReflection = null;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $_isProcessed = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Tool_Framework_Provider_Interface $provider
|
||||
*/
|
||||
public function __construct(Zend_Tool_Framework_Provider_Interface $provider)
|
||||
{
|
||||
$this->_provider = $provider;
|
||||
$this->_providerReflection = new Zend_Reflection_Class($provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* setRegistry()
|
||||
*
|
||||
* @param Zend_Tool_Framework_Registry_Interface $registry
|
||||
* @return Zend_Tool_Framework_Provider_Signature
|
||||
*/
|
||||
public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
|
||||
{
|
||||
$this->_registry = $registry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
if ($this->_isProcessed) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_process();
|
||||
}
|
||||
|
||||
/**
|
||||
* getName() of the provider
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the provider for this signature
|
||||
*
|
||||
* @return Zend_Tool_Framework_Provider_Interface
|
||||
*/
|
||||
public function getProvider()
|
||||
{
|
||||
return $this->_provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* getProviderReflection()
|
||||
*
|
||||
* @return Zend_Reflection_Class
|
||||
*/
|
||||
public function getProviderReflection()
|
||||
{
|
||||
return $this->_providerReflection;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSpecialities()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSpecialties()
|
||||
{
|
||||
return $this->_specialties;
|
||||
}
|
||||
|
||||
/**
|
||||
* getActions()
|
||||
*
|
||||
* @return array Array of Actions
|
||||
*/
|
||||
public function getActions()
|
||||
{
|
||||
return $this->_actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* getActionableMethods()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getActionableMethods()
|
||||
{
|
||||
return $this->_actionableMethods;
|
||||
}
|
||||
|
||||
/**
|
||||
* getActionableMethod() - Get an actionable method by name, this will return an array of
|
||||
* useful information about what can be exectued on this provider
|
||||
*
|
||||
* @param string $methodName
|
||||
* @return array
|
||||
*/
|
||||
public function getActionableMethod($methodName)
|
||||
{
|
||||
if (isset($this->_actionableMethods[$methodName])) {
|
||||
return $this->_actionableMethods[$methodName];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* getActionableMethodByActionName() - Get an actionable method by its action name, this
|
||||
* will return an array of useful information about what can be exectued on this provider
|
||||
*
|
||||
* @param string $actionName
|
||||
* @return array
|
||||
*/
|
||||
public function getActionableMethodByActionName($actionName, $specialtyName = '_Global')
|
||||
{
|
||||
foreach ($this->_actionableMethods as $actionableMethod) {
|
||||
if ($actionName == $actionableMethod['actionName']
|
||||
&& $specialtyName == $actionableMethod['specialty']) {
|
||||
return $actionableMethod;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* _process() is called at construction time and is what will build the signature information
|
||||
* for determining what is actionable
|
||||
*
|
||||
*/
|
||||
protected function _process()
|
||||
{
|
||||
$this->_isProcessed = true;
|
||||
$this->_processName();
|
||||
$this->_processSpecialties();
|
||||
$this->_processActionableMethods();
|
||||
}
|
||||
|
||||
/**
|
||||
* _processName();
|
||||
*
|
||||
*/
|
||||
protected function _processName()
|
||||
{
|
||||
if (method_exists($this->_provider, 'getName')) {
|
||||
$this->_name = $this->_provider->getName();
|
||||
}
|
||||
|
||||
if ($this->_name == null) {
|
||||
$className = get_class($this->_provider);
|
||||
$name = substr($className, strrpos($className, '_')+1);
|
||||
$name = preg_replace('#(Provider|Manifest)$#', '', $name);
|
||||
$this->_name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* _processSpecialties() - Break out the specialty names for this provider
|
||||
*
|
||||
*/
|
||||
protected function _processSpecialties()
|
||||
{
|
||||
$specialties = array();
|
||||
|
||||
if ($this->_providerReflection->hasMethod('getSpecialties')) {
|
||||
$specialties = $this->_provider->getSpecialties();
|
||||
if (!is_array($specialties)) {
|
||||
require_once 'Zend/Tool/Framework/Provider/Exception.php';
|
||||
throw new Zend_Tool_Framework_Provider_Exception(
|
||||
'Provider ' . get_class($this->_provider) . ' must return an array for method getSpecialties().'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$defaultProperties = $this->_providerReflection->getDefaultProperties();
|
||||
$specialties = (isset($defaultProperties['_specialties'])) ? $defaultProperties['_specialties'] : array();
|
||||
if (!is_array($specialties)) {
|
||||
require_once 'Zend/Tool/Framework/Provider/Exception.php';
|
||||
throw new Zend_Tool_Framework_Provider_Exception(
|
||||
'Provider ' . get_class($this->_provider) . '\'s property $_specialties must be an array.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_specialties = array_merge(array('_Global'), $specialties);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* _processActionableMethods() - process all methods that can be called on this provider.
|
||||
*
|
||||
*/
|
||||
protected function _processActionableMethods()
|
||||
{
|
||||
|
||||
$specialtyRegex = '#(.*)(' . implode('|', $this->_specialties) . ')$#i';
|
||||
|
||||
|
||||
$methods = $this->_providerReflection->getMethods();
|
||||
|
||||
$actionableMethods = array();
|
||||
foreach ($methods as $method) {
|
||||
|
||||
$methodName = $method->getName();
|
||||
|
||||
/**
|
||||
* the following will determine what methods are actually actionable
|
||||
* public, non-static, non-underscore prefixed, classes that dont
|
||||
* contain the name "
|
||||
*/
|
||||
if (!$method->getDeclaringClass()->isInstantiable()
|
||||
|| !$method->isPublic()
|
||||
|| $methodName[0] == '_'
|
||||
|| $method->isStatic()
|
||||
|| in_array($methodName, array('getContextClasses', 'getName')) // other protected public methods will nee to go here
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* check to see if the method was a required method by a Zend_Tool_* interface
|
||||
*/
|
||||
foreach ($method->getDeclaringClass()->getInterfaces() as $methodDeclaringClassInterface) {
|
||||
if (strpos($methodDeclaringClassInterface->getName(), 'Zend_Tool_') === 0
|
||||
&& $methodDeclaringClassInterface->hasMethod($methodName)) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$actionableName = ucfirst($methodName);
|
||||
|
||||
if (substr($actionableName, -6) == 'Action') {
|
||||
$actionableName = substr($actionableName, 0, -6);
|
||||
}
|
||||
|
||||
$actionableMethods[$methodName]['methodName'] = $methodName;
|
||||
|
||||
$matches = null;
|
||||
if (preg_match($specialtyRegex, $actionableName, $matches)) {
|
||||
$actionableMethods[$methodName]['actionName'] = $matches[1];
|
||||
$actionableMethods[$methodName]['specialty'] = $matches[2];
|
||||
} else {
|
||||
$actionableMethods[$methodName]['actionName'] = $actionableName;
|
||||
$actionableMethods[$methodName]['specialty'] = '_Global';
|
||||
}
|
||||
|
||||
// get the action, and create non-existent actions when they dont exist (the true part below)
|
||||
$action = $this->_registry->getActionRepository()->getAction($actionableMethods[$methodName]['actionName']);
|
||||
if ($action == null) {
|
||||
$action = new Zend_Tool_Framework_Action_Base($actionableMethods[$methodName]['actionName']);
|
||||
$this->_registry->getActionRepository()->addAction($action);
|
||||
}
|
||||
$actionableMethods[$methodName]['action'] = $action;
|
||||
|
||||
if (!in_array($actionableMethods[$methodName]['action'], $this->_actions)) {
|
||||
$this->_actions[] = $actionableMethods[$methodName]['action'];
|
||||
}
|
||||
|
||||
$parameterInfo = array();
|
||||
$position = 1;
|
||||
foreach ($method->getParameters() as $parameter) {
|
||||
$currentParam = $parameter->getName();
|
||||
$parameterInfo[$currentParam]['position'] = $position++;
|
||||
$parameterInfo[$currentParam]['optional'] = $parameter->isOptional();
|
||||
$parameterInfo[$currentParam]['default'] = ($parameter->isOptional()) ? $parameter->getDefaultValue() : null;
|
||||
$parameterInfo[$currentParam]['name'] = $currentParam;
|
||||
$parameterInfo[$currentParam]['type'] = 'string';
|
||||
$parameterInfo[$currentParam]['description'] = null;
|
||||
}
|
||||
|
||||
$matches = null;
|
||||
if (($docComment = $method->getDocComment()) != '' &&
|
||||
(preg_match_all('/@param\s+(\w+)+\s+(\$\S+)\s+(.*?)(?=(?:\*\s*@)|(?:\*\/))/s', $docComment, $matches)))
|
||||
{
|
||||
for ($i=0; $i <= count($matches[0])-1; $i++) {
|
||||
$currentParam = ltrim($matches[2][$i], '$');
|
||||
|
||||
if ($currentParam != '' && isset($parameterInfo[$currentParam])) {
|
||||
|
||||
$parameterInfo[$currentParam]['type'] = $matches[1][$i];
|
||||
|
||||
$descriptionSource = $matches[3][$i];
|
||||
|
||||
if ($descriptionSource != '') {
|
||||
$parameterInfo[$currentParam]['description'] = trim($descriptionSource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$actionableMethods[$methodName]['parameterInfo'] = $parameterInfo;
|
||||
|
||||
}
|
||||
|
||||
$this->_actionableMethods = $actionableMethods;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue