本文整理汇总了PHP中Zend_Reflection_Class类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Reflection_Class类的具体用法?PHP Zend_Reflection_Class怎么用?PHP Zend_Reflection_Class使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Reflection_Class类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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) {
}
}
}
}
开发者ID:ankuradhey,项目名称:laundry,代码行数:26,代码来源:AdminMenu.php
示例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);
}
开发者ID:travisj,项目名称:zf,代码行数:7,代码来源:TagTest.php
示例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;
}
开发者ID:theolymp,项目名称:diem,代码行数:39,代码来源:Class.php
示例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;
}
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:8,代码来源:Exception.php
示例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');
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:8,代码来源:ClassTest.php
示例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());
}
开发者ID:jsnshrmn,项目名称:Suma,代码行数:11,代码来源:ParamTest.php
示例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');
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:8,代码来源:DocblockTest.php
示例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;
}
}
开发者ID:BGCX262,项目名称:zsoc-svn-to-git,代码行数:8,代码来源:Object.php
示例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;
}
开发者ID:dragonprojects,项目名称:dragonjsonserver,代码行数:15,代码来源:Account.php
示例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);
}
开发者ID:laiello,项目名称:wanderson,代码行数:16,代码来源:ActionAbstract.php
示例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;
}
开发者ID:ankuradhey,项目名称:laundry,代码行数:12,代码来源:Abstract.php
示例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;
}
开发者ID:omusico,项目名称:logica,代码行数:21,代码来源:DisplayClass.php
示例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());
}
开发者ID:laiello,项目名称:wanderson,代码行数:19,代码来源:ReferenciaController.php
示例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);
}
开发者ID:jo-m,项目名称:ecamp3,代码行数:19,代码来源:Injecter.php
示例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()));
}
}
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:25,代码来源:Plugin.php
示例16: setUp
/**
* Check for dependencies and inject them if needed.
*/
protected function setUp()
{
parent::setUp();
if (Zend_Registry::isRegistered(LoSo_Zend_Application_Bootstrap_SymfonyContainerBootstrap::getRegistryIndex()) && ($container = Zend_Registry::get(LoSo_Zend_Application_Bootstrap_SymfonyContainerBootstrap::getRegistryIndex())) instanceof \Symfony\Component\DependencyInjection\ContainerInterface) {
$r = new Zend_Reflection_Class($this);
$properties = $r->getProperties();
foreach ($properties as $property) {
if ($property->getDocComment() && $property->getDocComment()->hasTag('Inject')) {
$injectTag = $property->getDocComment()->getTag('Inject');
$serviceName = $injectTag->getDescription();
if (empty($serviceName)) {
$serviceName = $this->_formatServiceName($property->getName());
}
if ($container->has($serviceName)) {
$property->setAccessible(true);
$property->setValue($this, $container->get($serviceName));
}
}
}
}
}
开发者ID:nuxwin,项目名称:losolib,代码行数:24,代码来源:SymfonyContainerAwareTestCase.php
示例17: preDispatch
/**
* Takes care of injecting controller dependencies
* into the controller at runtime.
*/
public function preDispatch()
{
$actionController = $this->getActionController();
$r = new Zend_Reflection_Class($actionController);
$properties = $r->getProperties();
foreach ($properties as $property) {
if ($property->getDeclaringClass()->getName() == get_class($actionController)) {
if ($property->getDocComment() && $property->getDocComment()->hasTag('InjectService')) {
$tag = $property->getDocComment()->getTag('InjectService');
if ($tag->getDescription()) {
$sc = Zend_Registry::get('sc');
$service = $sc->getService(trim(lcfirst($tag->getDescription())));
$property->setAccessible(true);
$property->setValue($actionController, $service);
} else {
throw new Exception("No service key given");
}
}
}
}
}
开发者ID:nnevala,项目名称:zf-boilerplate,代码行数:25,代码来源:DependencyInjector.php
示例18: objectToDictionary
/**
* Method scan given object for properties which has public getters
* and generate array of entities-replacements pairs from this method
* @param $object Object
* @param $namespace Custom namespace for replacements
* @return Tools_Content_EntityParser Return self for chaining
* @throws Exceptions_SeotoasterException
*/
public function objectToDictionary($object, $namespace = null)
{
if (!is_object($object)) {
throw new Exceptions_SeotoasterException('Given variable must be an object');
}
$reflection = new Zend_Reflection_Class($object);
$dictionary = array();
foreach ($reflection->getProperties() as $prop) {
$normalizedPropName = join('', array_map('ucfirst', explode('_', $prop->getName())));
$getter = 'get' . join('', array_map('ucfirst', explode('_', $prop->getName())));
if ($reflection->hasMethod($getter)) {
$replacement = $object->{$getter}();
$className = empty($namespace) ? preg_replace('/.*_([\\w\\d]*)$/', '$1', $reflection->getName()) : $namespace;
$entityName = strtolower($className . ':' . $normalizedPropName);
if (!is_array($replacement) && !is_object($replacement)) {
$dictionary[$entityName] = $replacement;
}
}
}
$this->addToDictionary($dictionary);
return $this;
}
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:30,代码来源:EntityParser.php
示例19: preDispatch
/**
* Prüft bei jedem Request ist die Authentifizierung
* @param Dragon_Json_Server_Request_Http $request
*/
public function preDispatch(Dragon_Json_Server_Request_Http $request)
{
try {
list($classname, $methodname) = $request->parseMethod();
$reflectionClass = new Zend_Reflection_Class($classname);
$tagResource = $reflectionClass->getMethod($methodname)->getDocblock()->getTag('dragonx_acl_resource');
if (!$tagResource) {
return;
}
$resource = $tagResource->getDescription();
} catch (Exception $exception) {
return;
}
$resources = array();
if (Zend_Registry::isRegistered('recordAccount')) {
$logicAcl = new DragonX_Acl_Logic_Acl();
$resources = $logicAcl->getResources(Zend_Registry::get('recordAccount'));
}
if (!in_array($resource, $resources)) {
throw new Dragon_Application_Exception_System('missing resource', array('resource' => $resource));
}
}
开发者ID:dragonprojects,项目名称:dragonjsonserver,代码行数:26,代码来源:Acl.php
示例20: testPropertyWillLoadFromReflection
/**
* @group ZF-6444
*/
public function testPropertyWillLoadFromReflection()
{
$reflectionClass = new Zend_Reflection_Class('Zend_CodeGenerator_Php_TestClassWithManyProperties');
// test property 1
$reflProp = $reflectionClass->getProperty('_bazProperty');
$cgProp = Zend_CodeGenerator_Php_Property::fromReflection($reflProp);
$this->assertEquals('_bazProperty', $cgProp->getName());
$this->assertEquals(array(true, false, true), $cgProp->getDefaultValue()->getValue());
$this->assertEquals('private', $cgProp->getVisibility());
$reflProp = $reflectionClass->getProperty('_bazStaticProperty');
// test property 2
$cgProp = Zend_CodeGenerator_Php_Property::fromReflection($reflProp);
$this->assertEquals('_bazStaticProperty', $cgProp->getName());
$this->assertEquals(Zend_CodeGenerator_Php_TestClassWithManyProperties::FOO, $cgProp->getDefaultValue()->getValue());
$this->assertTrue($cgProp->isStatic());
$this->assertEquals('private', $cgProp->getVisibility());
}
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:20,代码来源:PropertyTest.php
注:本文中的Zend_Reflection_Class类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论