本文整理汇总了PHP中Zend_Reflection_Class类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Reflection_Class类的具体用法?PHP Zend_Reflection_Class怎么用?PHP Zend_Reflection_Class使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Reflection_Class类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: routeShutdown
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{
if (!in_array(Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName(), array('admin', 'admin_language'))) {
return;
}
$resource = new User_Model_Acl_Resource();
$resource->getAdminPrivileges();
if ($resource->admin_privileges) {
//$actionStack = Zend_Controller_Action_HelperBroker::getStaticHelper('ActionStack');
$actionStack = new Zend_Controller_Plugin_ActionStack();
foreach ($resource->admin_privileges as $module => $actions) {
$class = ucfirst($module) . '_AdminController';
if (!class_exists($class)) {
Zend_Loader::loadFile(APPLICATION_PATH . '/modules/' . $module . '/controllers/AdminController.php');
}
$reflection = new Zend_Reflection_Class($class);
$method = null;
try {
if ($method = $reflection->getMethod('menuAction')) {
$actionStack->pushStack(new Zend_Controller_Request_Simple('menu', 'admin', $module, array('admin_actions' => array_flip($actions))));
}
} catch (Exception $e) {
}
}
}
}
示例2: testToString
public function testToString()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass6');
$tag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('descriptionTag');
$expectedString = "Docblock Tag [ * @descriptionTag ]" . PHP_EOL;
$this->assertEquals($expectedString, (string) $tag);
}
示例3: fromReflection
/**
* fromReflection() - build a Code Generation PHP Object from a Class Reflection
*
* @param Zend_Reflection_Class $reflectionClass
* @return dmZendCodeGeneratorPhpClass
*/
public static function fromReflection(Zend_Reflection_Class $reflectionClass)
{
$class = new self();
$class->setSourceContent($class->getSourceContent());
$class->setSourceDirty(false);
if ($reflectionClass->getDocComment() != '') {
$class->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionClass->getDocblock()));
}
$class->setAbstract($reflectionClass->isAbstract());
$class->setName($reflectionClass->getName());
if ($parentClass = $reflectionClass->getParentClass()) {
$class->setExtendedClass($parentClass->getName());
$interfaces = array_diff($parentClass->getInterfaces(), $reflectionClass->getInterfaces());
} else {
$interfaces = $reflectionClass->getInterfaces();
}
$class->setImplementedInterfaces($interfaces);
$properties = array();
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
if ($reflectionProperty->getDeclaringClass()->getName() == $class->getName()) {
$properties[] = Zend_CodeGenerator_Php_Property::fromReflection($reflectionProperty);
}
}
$class->setProperties($properties);
$methods = array();
foreach ($reflectionClass->getMethods(-1, 'dmZendReflectionMethod') as $reflectionMethod) {
if ($reflectionMethod->getDeclaringClass()->getName() == $class->getName()) {
$methods[] = dmZendCodeGeneratorPhpMethod::fromReflection($reflectionMethod);
}
}
$class->setMethods($methods);
return $class;
}
示例4: getCodeKeys
public static function getCodeKeys()
{
if (null === self::$_codeKeys) {
$r = new Zend_Reflection_Class(__CLASS__);
self::$_codeKeys = array_flip($r->getConstants());
}
return self::$_codeKeys;
}
示例5: testInterfaceReturn
public function testInterfaceReturn()
{
$reflectionClass = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass4');
$interfaces = $reflectionClass->getInterfaces();
$this->assertEquals(count($interfaces), 1);
$interface = array_shift($interfaces);
$this->assertEquals($interface->getName(), 'Zend_Reflection_TestSampleClassInterface');
}
示例6: testNamespaceInParam
/**
* @group ZF-8307
*/
public function testNamespaceInParam()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_Docblock_Param_WithNamespace');
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
$this->assertEquals('Zend\\Foo\\Bar', $paramTag->getType());
$this->assertEquals('$var', $paramTag->getVariableName());
$this->assertEquals('desc', $paramTag->getDescription());
}
示例7: testDocblockTags
public function testDocblockTags()
{
$classReflection = new Zend_Reflection_Class('Zend_Reflection_TestSampleClass5');
$this->assertEquals($classReflection->getMethod('doSomething')->getDocblock()->hasTag('return'), true);
$returnTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
$this->assertEquals(get_class($returnTag), 'Zend_Reflection_Docblock_Tag_Return');
$this->assertEquals($returnTag->getType(), 'mixed');
}
示例8: __construct
public function __construct($object)
{
if ($object != null) {
$refl = new Zend_Reflection_Class(get_class($object));
$this->getReader()->setFile($refl->getFileName());
$this->_object = $object;
}
}
示例9: _authenticateRequired
/**
* Prüft ob der Service einen Account benötigt
* @param string $classname
* @param string $methodname
* @return boolean
*/
private function _authenticateRequired($classname, $methodname)
{
try {
$reflectionClass = new Zend_Reflection_Class($classname);
return $reflectionClass->getMethod($methodname)->getDocblock()->hasTag('dragonx_account_authenticate');
} catch (Exception $exception) {
}
return false;
}
示例10: _build
/**
* Construção de Objetos para Elementos Internas
* @param string $name Nome Completo da Classe
* @return mixed Instância da Classe Solicitada
* @throws Zend_Controller_Action_Exception Classe Inválida
*/
private function _build($name, array $params = array())
{
if (!(is_string($name) && class_exists($name))) {
throw new Zend_Controller_Action_Exception('Invalid Class Name');
}
// Construção
$reflect = new Zend_Reflection_Class($name);
// Retorno da Instância
return $reflect->newInstance($params);
}
示例11: _getProperties
protected function _getProperties()
{
$propertyArray = array();
$class = new Zend_Reflection_Class($this);
$properties = $class->getProperties();
foreach ($properties as $property) {
if ($property->isPublic()) {
$propertyArray[] = $property->getName();
}
}
return $propertyArray;
}
示例12: _getClassUrl
/**
* Returns the URL for the given class' API page
*
* @param mixed $class
* @access protected
* @return string
*/
protected function _getClassUrl($class)
{
$reflection = new Zend_Reflection_Class($class);
$docblock = $reflection->getDocblock();
$url = $this->_zendApiUrl;
if ($docblock->hasTag('package')) {
$url .= $docblock->getTag('package')->getDescription();
}
if ($docblock->hasTag('subpackage')) {
$url .= '/' . $docblock->getTag('subpackage')->getDescription();
}
$url .= '/' . $class . '.html';
return $url;
}
示例13: _getFormReferencia
/**
* Captura um Formulário de Determinado Tipo
* @param string Nome do Formulário
* @return Local_Form_FormAbstract Elemento Solicitado
*/
protected function _getFormReferencia($tipo)
{
// Filtro de Dados
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_StringToLower())->addFilter(new Zend_Filter_Callback('ucfirst'));
$tipo = $filter->filter($tipo);
// Verificação
if (!in_array($tipo, $this->_references)) {
throw new Zend_Controller_Action_Exception('Invalid Referencia');
}
$classname = 'Application_Form_Referencia_' . $tipo;
$reflect = new Zend_Reflection_Class($classname);
return $reflect->newInstance(array());
}
示例14: InjectDependencies
public function InjectDependencies($object)
{
$reflectionClass = new \Zend_Reflection_Class($object);
//$reflectionProperty = new \Zend_Reflection_Property(null, null);
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
/** @var \Zend_Reflection_Property $reflectionProperty */
$reflectionDocComment = $reflectionProperty->getDocComment();
if ($reflectionDocComment) {
if ($reflectionDocComment->hasTag("Inject")) {
$reflectionDocCommentTag = $reflectionDocComment->getTag("Inject");
$dependencyName = $reflectionDocCommentTag->getDescription();
$dependency = $this->kernel->Get($dependencyName);
$reflectionProperty->setAccessible(true);
$reflectionProperty->setValue($object, $dependency);
}
}
}
//print_r($reflectionClass);
}
示例15: _callPlugins
/**
* Trigger Seotoaster plugins hooks
*
* @param $method string Method to trigger
*/
private function _callPlugins($method)
{
$enabledPlugins = Tools_Plugins_Tools::getEnabledPlugins();
if (is_array($enabledPlugins) && !empty($enabledPlugins)) {
array_walk($enabledPlugins, function ($plugin, $key, $data) {
try {
$name = ucfirst($plugin->getName());
Tools_Factory_PluginFactory::validate($name);
$reflection = new Zend_Reflection_Class($name);
if ($reflection->hasMethod($data['method'])) {
$pluginInstance = Tools_Factory_PluginFactory::createPlugin($plugin->getName(), array(), array('websiteUrl' => $data['websiteUrl']));
$pluginInstance->{$data}['method']();
}
} catch (Exceptions_SeotoasterException $se) {
error_log($se->getMessage());
error_log($se->getTraceAsString());
}
}, array('method' => $method, 'websiteUrl' => Zend_Controller_Action_HelperBroker::getStaticHelper('Website')->getUrl()));
}
}