• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Annotations\Reader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Doctrine\Common\Annotations\Reader的典型用法代码示例。如果您正苦于以下问题:PHP Reader类的具体用法?PHP Reader怎么用?PHP Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Reader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: readFormType

 private static function readFormType(\Doctrine\Common\Annotations\Reader $reader, \ReflectionClass $rc, array &$out, array &$non_deep_fields)
 {
     $as = $reader->getClassAnnotations($rc);
     $annot = null;
     if ($as) {
         foreach ($as as $_annot) {
             if ($_annot instanceof \Symforce\AdminBundle\Compiler\Annotation\FormType) {
                 if (null !== $annot) {
                     throw new \Exception(sprintf("sf_admin.form.type ( class: %s ) has multi form annotation", $rc->getName()));
                 }
                 $annot = $_annot;
             }
         }
     }
     if ($annot) {
         foreach ($annot as $key => $value) {
             if (!isset($out[$key]) || null === $out[$key]) {
                 if (!$out['deep'] || !in_array($key, $non_deep_fields)) {
                     $out[$key] = $value;
                 }
             }
         }
     }
     $parent = $rc->getParentClass();
     if ($parent && !$parent->isAbstract()) {
         $out['deep']++;
         self::readFormType($reader, $parent, $out, $non_deep_fields);
     }
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:29,代码来源:MetaFormFactory.php


示例2: setUp

 protected function setUp()
 {
     AnnotationRegistry::registerLoader('class_exists');
     $this->reader = new SimpleAnnotationReader();
     $this->reader->addNamespace('Bazinga\\Bundle\\GeocoderBundle\\Mapping\\Annotations');
     $this->driver = new AnnotationDriver($this->reader);
 }
开发者ID:nicolassing,项目名称:BazingaGeocoderBundle,代码行数:7,代码来源:AnnotationDriverTest.php


示例3: getForm

 public function getForm(ResourceInterface $resource)
 {
     $resourceClassName = \Doctrine\Common\Util\ClassUtils::getClass($resource);
     $resourceParts = explode("\\", $resourceClassName);
     $resourceParts[count($resourceParts) - 2] = 'Form';
     $resourceParts[count($resourceParts) - 1] .= 'Type';
     $formType = implode("\\", $resourceParts);
     if (class_exists($formType)) {
         return $this->formFactory->create(new $formType(), $resource);
     }
     $options = array('data_class' => $resourceClassName);
     $builder = $this->formFactory->createBuilder('form', $resource, $options);
     $reflectionClass = new \ReflectionClass($resourceClassName);
     $annotationClass = 'uebb\\HateoasBundle\\Annotation\\FormField';
     foreach ($reflectionClass->getProperties() as $propertyReflection) {
         /**
          * @var \uebb\HateoasBundle\Annotation\FormField $annotation
          */
         $annotation = $this->annotationReader->getPropertyAnnotation($propertyReflection, $annotationClass);
         if ($annotation) {
             $builder->add($propertyReflection->getName(), $annotation->type, is_array($annotation->options) ? $annotation->options : array());
         }
     }
     $form = $builder->getForm();
     return $form;
 }
开发者ID:uebb,项目名称:hateoas-bundle,代码行数:26,代码来源:FormResolver.php


示例4: fillFromArray

 /**
  * @param $object
  * @param $classRefl
  * @param $segmentData
  * @throws MandatorySegmentPieceMissing
  */
 protected function fillFromArray($object, $classRefl, $segmentData)
 {
     foreach ($classRefl->getProperties() as $propRefl) {
         $isSegmentPiece = $this->annotationReader->getPropertyAnnotation($propRefl, SegmentPiece::class);
         if ($isSegmentPiece) {
             $piece = isset($segmentData[$isSegmentPiece->position]) ? $segmentData[$isSegmentPiece->position] : null;
             $propRefl->setAccessible(true);
             if ($isSegmentPiece->parts) {
                 $value = array();
                 $i = 0;
                 foreach ($isSegmentPiece->parts as $k => $part) {
                     if (!is_numeric($k) && is_array($part)) {
                         $partName = $k;
                         if (!empty($piece) && in_array("@mandatory", $part) && $this->isEmpty($piece[$i])) {
                             throw new MandatorySegmentPieceMissing(sprintf("Segment %s part %s missing value at offset %d", $segmentData[0], $partName, $i));
                         }
                     } else {
                         $partName = $part;
                     }
                     $value[$partName] = isset($piece[$i]) ? $piece[$i] : null;
                     ++$i;
                 }
                 $propRefl->setValue($object, $value);
             } else {
                 $propRefl->setValue($object, $piece);
             }
         }
     }
 }
开发者ID:progrupa,项目名称:edifact,代码行数:35,代码来源:Populator.php


示例5: getEntityClassName

 /**
  * @internal
  * @param Reader $annotationReader
  * @return string
  * @throws InvalidAnnotationException
  */
 static function getEntityClassName(Reader $annotationReader)
 {
     $reflect = new ReflectionClass(get_called_class());
     $annotation = $annotationReader->getClassAnnotation($reflect, Entity::class);
     InvalidAnnotationException::assert($annotation, Entity::class);
     return $annotation->className;
 }
开发者ID:jkrecek,项目名称:nette-database-model,代码行数:13,代码来源:StoredCollection.php


示例6: onConfigureRoute

 /**
  * Reads the "@Access" annotations from the controller stores them in the "access" route option.
  */
 public function onConfigureRoute($event, $route)
 {
     if (!$this->reader) {
         $this->reader = new SimpleAnnotationReader();
         $this->reader->addNamespace('Pagekit\\User\\Annotation');
     }
     if (!$route->getControllerClass()) {
         return;
     }
     $access = [];
     foreach (array_merge($this->reader->getClassAnnotations($route->getControllerClass()), $this->reader->getMethodAnnotations($route->getControllerMethod())) as $annot) {
         if (!$annot instanceof Access) {
             continue;
         }
         if ($expression = $annot->getExpression()) {
             $access[] = $expression;
         }
         if ($admin = $annot->getAdmin() !== null) {
             $route->setPath('admin' . rtrim($route->getPath(), '/'));
             $permission = 'system: access admin area';
             if ($admin) {
                 $access[] = $permission;
             } else {
                 if ($key = array_search($permission, $access)) {
                     unset($access[$key]);
                 }
             }
         }
     }
     if ($access) {
         $route->setDefault('_access', array_unique($access));
     }
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:36,代码来源:AccessListener.php


示例7: loadClass

 public static function loadClass(ReflectionClass $refl, Reader $reader, Router $router)
 {
     $annotation = $reader->getClassAnnotation($refl, 'Destiny\\Common\\Annotation\\Controller');
     if (empty($annotation)) {
         return;
     }
     $methods = $refl->getMethods(ReflectionMethod::IS_PUBLIC);
     foreach ($methods as $method) {
         /** @var Route[] $routes */
         $routes = array();
         $annotations = $reader->getMethodAnnotations($method);
         for ($i = 0; $i < count($annotations); ++$i) {
             /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
             if ($annotations[$i] instanceof \Destiny\Common\Annotation\Route) {
                 $routes[] = $annotations[$i];
             }
         }
         if (count($routes) <= 0) {
             continue;
         }
         /** @var \Destiny\Common\Annotation\HttpMethod $feature */
         $httpMethod = $reader->getMethodAnnotation($method, 'Destiny\\Common\\Annotation\\HttpMethod');
         /** @var \Destiny\Common\Annotation\Secure $feature */
         $secure = $reader->getMethodAnnotation($method, 'Destiny\\Common\\Annotation\\Secure');
         for ($i = 0; $i < count($routes); ++$i) {
             $router->addRoute(new Route(array('path' => $routes[$i]->path, 'classMethod' => $method->name, 'class' => $refl->name, 'httpMethod' => $httpMethod ? $httpMethod->allow : null, 'secure' => $secure ? $secure->roles : null)));
         }
     }
 }
开发者ID:TonyWoo,项目名称:website,代码行数:29,代码来源:ControllerAnnotationLoader.php


示例8: setUp

 public function setUp()
 {
     $this->reflectionService = $this->getAccessibleMock(\TYPO3\Flow\Reflection\ReflectionService::class, null);
     $this->mockAnnotationReader = $this->getMockBuilder(\Doctrine\Common\Annotations\Reader::class)->disableOriginalConstructor()->getMock();
     $this->mockAnnotationReader->expects($this->any())->method('getClassAnnotations')->will($this->returnValue(array()));
     $this->inject($this->reflectionService, 'annotationReader', $this->mockAnnotationReader);
 }
开发者ID:kszyma,项目名称:flow-development-collection,代码行数:7,代码来源:ReflectionServiceTest.php


示例9: fromClass

 /**
  * @param AnnotationReader $reader
  * @param string $className
  * @return Entity
  * @throws \HireVoice\Neo4j\Exception
  */
 public static function fromClass(AnnotationReader $reader, $className)
 {
     $class = new \ReflectionClass($className);
     if ($class->implementsInterface('HireVoice\\Neo4j\\Proxy\\Entity')) {
         $class = $class->getParentClass();
         $className = $class->getName();
     }
     if (!($entity = $reader->getClassAnnotation($class, 'HireVoice\\Neo4j\\Annotation\\Entity'))) {
         throw new Exception("Class {$className} is not declared as an entity.");
     }
     $object = new self($class->getName());
     if ($entity->repositoryClass) {
         $object->repositoryClass = $entity->repositoryClass;
     }
     if ($entity->labels) {
         $object->labels = explode(",", $entity->labels);
     }
     foreach (self::getClassProperties($class->getName()) as $prop) {
         $prop = new Property($reader, $prop);
         if ($prop->isPrimaryKey()) {
             $object->setPrimaryKey($prop);
         } elseif ($prop->isProperty($prop)) {
             $object->properties[] = $prop;
             if ($prop->isIndexed()) {
                 $object->indexedProperties[] = $prop;
             }
         } elseif ($prop->isRelationList()) {
             $object->manyToManyRelations[] = $prop;
         } elseif ($prop->isRelation()) {
             $object->manyToOneRelations[] = $prop;
         }
     }
     $object->validate();
     return $object;
 }
开发者ID:rohankadam,项目名称:Neo4j-PHP-OGM,代码行数:41,代码来源:Entity.php


示例10: onPostSerialize

 public function onPostSerialize(ObjectEvent $event)
 {
     /**
      * @var JsonSerializationVisitor $visitor
      */
     $visitor = $event->getVisitor();
     $object = $event->getObject();
     $annotations = $this->annotationReader->getClassAnnotations(new \ReflectionObject($object));
     $links = array();
     foreach ($annotations as $annotation) {
         if ($annotation instanceof Link) {
             if ($annotation->url) {
                 $uri = $this->evaluate($annotation->url, $object);
             } else {
                 $uri = $this->router->generate($annotation->route, $this->resolveParams($annotation->params, $object));
             }
             // allow a blank URI to be an optional link
             if ($uri) {
                 $links[$annotation->name] = $uri;
             }
         }
     }
     if ($links) {
         $visitor->addData('_links', $links);
     }
 }
开发者ID:C3-TKO,项目名称:smash-api,代码行数:26,代码来源:LinkSerializationSubscriber.php


示例11: loadClassMetadata

 /**
  * {@inheritdoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     $reflClass = $metadata->getReflectionClass();
     $className = $reflClass->name;
     $loaded = false;
     foreach ($reflClass->getProperties() as $property) {
         if ($property->getDeclaringClass()->name == $className) {
             foreach ($this->reader->getPropertyAnnotations($property) as $groups) {
                 if ($groups instanceof Groups) {
                     foreach ($groups->getGroups() as $group) {
                         $metadata->addAttributeGroup($property->name, $group);
                     }
                 }
                 $loaded = true;
             }
         }
     }
     foreach ($reflClass->getMethods() as $method) {
         if ($method->getDeclaringClass()->name == $className) {
             foreach ($this->reader->getMethodAnnotations($method) as $groups) {
                 if ($groups instanceof Groups) {
                     if (preg_match('/^(get|is)(.+)$/i', $method->name, $matches)) {
                         foreach ($groups->getGroups() as $group) {
                             $metadata->addAttributeGroup(lcfirst($matches[2]), $group);
                         }
                     } else {
                         throw new \BadMethodCallException(sprintf('Groups on "%s::%s" cannot be added. Groups can only be added on methods beginning with "get" or "is".', $className, $method->name));
                     }
                 }
                 $loaded = true;
             }
         }
     }
     return $loaded;
 }
开发者ID:vadim2404,项目名称:symfony,代码行数:38,代码来源:AnnotationLoader.php


示例12: loadMetadata

 /**
  * {@inheritDoc}
  */
 public function loadMetadata($class)
 {
     // Try get object annotation from class
     $objectAnnotation = null;
     $classAnnotations = Reflection::loadClassAnnotations($this->reader, $class, true);
     foreach ($classAnnotations as $classAnnotation) {
         if ($classAnnotation instanceof ObjectAnnotation) {
             if ($objectAnnotation) {
                 throw new \RuntimeException(sprintf('Many @Transformer\\Object annotation in class "%s".', $class));
             }
             $objectAnnotation = $classAnnotation;
         }
     }
     if (!$objectAnnotation) {
         throw new TransformAnnotationNotFoundException(sprintf('Not found @Object annotations in class "%s".', $class));
     }
     // Try get properties annotations
     $properties = [];
     $classProperties = Reflection::getClassProperties($class, true);
     foreach ($classProperties as $classProperty) {
         $propertyAnnotations = $this->reader->getPropertyAnnotations($classProperty);
         foreach ($propertyAnnotations as $propertyAnnotation) {
             if ($propertyAnnotation instanceof PropertyAnnotation) {
                 $property = new PropertyMetadata($propertyAnnotation->propertyName ?: $classProperty->getName(), $propertyAnnotation->groups, $propertyAnnotation->shouldTransform, $propertyAnnotation->expressionValue);
                 $properties[$classProperty->getName()] = $property;
             }
         }
     }
     return new ObjectMetadata($objectAnnotation->transformedClass, $properties);
 }
开发者ID:Gtvar,项目名称:FivePercent-ModelTransformer,代码行数:33,代码来源:MetadataFactory.php


示例13: loadMetadataForMethod

 /**
  * @param \ReflectionClass  $class
  * @param \ReflectionMethod $method
  * @return null|MethodMetadata
  */
 private function loadMetadataForMethod(\ReflectionClass $class, \ReflectionMethod $method)
 {
     $methodAnnotation = $this->reader->getMethodAnnotation($method, Method::class);
     if ($methodAnnotation === null) {
         return null;
     }
     /** @var Method $methodAnnotation */
     $methodMetadata = new MethodMetadata($class->name, $method->name);
     $methodMetadata->isMethod = true;
     $methodMetadata->isFormHandler = $methodAnnotation->formHandler;
     $methodMetadata->hasNamedParams = $methodAnnotation->namedParams;
     $methodMetadata->isStrict = $methodAnnotation->strict;
     $methodMetadata->hasSession = $methodAnnotation->session;
     $methodMetadata->addParameters($method->getParameters());
     foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
         if ($annotation instanceof Parameter) {
             if (!empty($annotation->constraints)) {
                 $methodMetadata->addParameterMetadata($annotation->name, $annotation->constraints, $annotation->validationGroups, $annotation->strict, $annotation->serializationGroups, $annotation->serializationAttributes, $annotation->serializationVersion);
             }
         }
     }
     /** @var Result $resultAnnotation */
     $resultAnnotation = $this->reader->getMethodAnnotation($method, Result::class);
     if ($resultAnnotation) {
         $methodMetadata->setResult($resultAnnotation->groups, $resultAnnotation->attributes, $resultAnnotation->version);
     }
     /** @var Security $securityAnnotation */
     $securityAnnotation = $this->reader->getMethodAnnotation($method, Security::class);
     if ($securityAnnotation) {
         $methodMetadata->authorizationExpression = $securityAnnotation->expression;
     }
     return $methodMetadata;
 }
开发者ID:teqneers,项目名称:ext-direct,代码行数:38,代码来源:AnnotationDriver.php


示例14: processClass

 /**
  * @param string $className
  *
  * @return array
  */
 public function processClass($className, $path)
 {
     $reflection = new \ReflectionClass($className);
     if (null === $this->reader->getClassAnnotation($reflection, $this->annotationClass)) {
         return array();
     }
     $mappings = array();
     $this->output->writeln("Found class: {$className}");
     foreach ($reflection->getMethods() as $method) {
         /** @var Method[] $annotations */
         $annotations = $this->reader->getMethodAnnotations($method);
         if (0 == count($annotations)) {
             continue;
         }
         $this->output->writeln(sprintf("Found annotations for method %s::%s.", $method->class, $method->getName()));
         foreach ($annotations as $annotation) {
             if (!$annotation instanceof Method) {
                 continue;
             }
             $this->output->writeln(sprintf("Found mapping: %s::%s --> %s::%s", $method->class, $method->getName(), $annotation->getClass(), $annotation->getMethod()));
             $mapping = new Mapping();
             $moduleFile = $reflection->getFileName();
             $moduleFile = substr($moduleFile, strpos($moduleFile, $path));
             $mapping->setOxidClass($annotation->getClass())->setOxidMethod($annotation->getMethod())->setModuleClass($className)->setModuleMethod($method->getName())->setReturn($annotation->hasReturnValue())->setParentExecution($annotation->getParentExecution())->setModuleFile($moduleFile);
             $mappings[] = $mapping;
         }
     }
     return $mappings;
 }
开发者ID:d4rk4ng3l,项目名称:advanced-oxid-modules,代码行数:34,代码来源:Compiler.php


示例15: loadMetadataForClass

 /**
  * @param \ReflectionClass $class
  *
  * @return \Metadata\ClassMetadata
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $metadata = $this->driver->loadMetadataForClass($class);
     foreach ($metadata->propertyMetadata as $key => $propertyMetadata) {
         $type = $propertyMetadata->type['name'];
         if (!$propertyMetadata->reflection) {
             continue;
         }
         /** @var PropertyMetadata $propertyMetadata */
         /** @var HandledType $annot */
         $annot = $this->reader->getPropertyAnnotation($propertyMetadata->reflection, HandledType::class);
         if (!$annot) {
             continue;
         }
         $isCollection = false;
         $collectionType = null;
         if (in_array($type, ['array', 'ArrayCollection'], true)) {
             $isCollection = true;
             $collectionType = $type;
             $type = $propertyMetadata->type['params'][0]['name'];
         }
         $handler = $annot->handler ?: 'Relation';
         $newType = sprintf('%s<%s>', $handler, $type);
         if ($isCollection) {
             $newType = sprintf('%s<%s<%s>>', $collectionType, $handler, $type);
         }
         $propertyMetadata->setType($newType);
     }
     return $metadata;
 }
开发者ID:bankiru,项目名称:jsonrpc-server-bundle,代码行数:35,代码来源:HandledTypeDriver.php


示例16: invoke

 public function invoke(MethodInvocation $invocation)
 {
     $resource = $invocation->getThis();
     $result = $invocation->proceed();
     $annotation = $this->reader->getMethodAnnotation($invocation->getMethod(), Annotation\ResourceDelegate::class);
     if (isset($annotation)) {
         $class = $this->getDelegateClassName($annotation, $resource);
         if (!class_exists($class)) {
             throw new InvalidAnnotationException('Resource Delegate class is not found.');
         }
         $method = isset($resource->uri->query['_override']) ? $resource->uri->query['_override'] : $resource->uri->method;
         if (stripos($method, $resource->uri->method) !== 0) {
             throw new InvalidMatcherException('Overriden method must match to original method');
         }
         $call = $this->resolveDelegateMethod($method);
         if (!method_exists($class, $call)) {
             throw new InvalidMatcherException('Resource Delegate method is not found');
         }
         $delegate = new $class($resource);
         $params = $this->paramHandler->getParameters([$delegate, $call], $resource->uri->query);
         return call_user_func_array([$delegate, $call], $params);
     } else {
         $result;
     }
 }
开发者ID:ritalin,项目名称:bear-resource-delegate,代码行数:25,代码来源:ResourceDelegateIntercepter.php


示例17: onKernelController

 /**
  * This event will fire during any controller call.
  *
  * @param FilterControllerEvent $event
  *
  * @return type
  *
  * @throws AccessDeniedHttpException
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     if (!is_array($controller = $event->getController())) {
         //return if no controller
         return;
     }
     $object = new \ReflectionObject($controller[0]);
     // get controller
     $method = $object->getMethod($controller[1]);
     // get method
     $configurations = $this->reader->getMethodAnnotations($method);
     foreach ($configurations as $configuration) {
         //Start of annotations reading
         if (isset($configuration->grantType) && $controller[0] instanceof BaseProjectController) {
             //Found our annotation
             $controller[0]->setProjectGrantType($configuration->grantType);
             $request = $controller[0]->get('request_stack')->getCurrentRequest();
             $id = $request->get('id', false);
             if ($id !== false) {
                 $redirectUrl = $controller[0]->initAction($id, $configuration->grantType);
                 if ($redirectUrl) {
                     $event->setController(function () use($redirectUrl) {
                         return new RedirectResponse($redirectUrl);
                     });
                 }
             }
         }
     }
 }
开发者ID:sshversioncontrol,项目名称:git-web-client,代码行数:38,代码来源:ProjectAccessAnnotationDriver.php


示例18: onKernelController

 /**
  * Load JSON API configuration from controller annotations
  *
  * @param FilterControllerEvent $event
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $controller = $event->getController();
     if (!is_array($controller)) {
         return;
     }
     $config = null;
     $refClass = new \ReflectionClass($controller[0]);
     if (null !== ($annotation = $this->reader->getClassAnnotation($refClass, ApiRequest::class))) {
         /* @var $annotation ApiRequest */
         $config = $annotation->toArray();
     }
     $refMethod = $refClass->getMethod($controller[1]);
     if (null !== ($annotation = $this->reader->getMethodAnnotation($refMethod, ApiRequest::class))) {
         if (null !== $config) {
             $config = array_replace($config, $annotation->toArray());
         } else {
             $config = $annotation->toArray();
         }
     }
     if (null !== $config) {
         if (!array_key_exists('matcher', $config)) {
             $config['matcher'] = $this->defMatcher;
         }
         $event->getRequest()->attributes->set('_jsonapi', $this->factory->createEnvironment($config));
     }
 }
开发者ID:reva2,项目名称:jsonapi,代码行数:32,代码来源:ApiListener.php


示例19: testLoadMetadataForClassAddValuesToMetadata

 /**
  * @expectedException \Doctrine\Search\Exception\Driver\PropertyDoesNotExistsInMetadataException
  */
 public function testLoadMetadataForClassAddValuesToMetadata()
 {
     $this->reflectionClass->expects($this->once())->method('getProperties')->will($this->returnValue(array()));
     $this->reader->expects($this->once())->method('getClassAnnotations')->will($this->returnValue(array(0, new TestSearchable(array()))));
     $this->classMetadata->expects($this->once())->method('getReflectionClass')->will($this->returnValue($this->reflectionClass));
     $this->annotationDriver->loadMetadataForClass('Doctrine\\Tests\\Models\\Blog\\BlogPost', $this->classMetadata);
 }
开发者ID:akleiber,项目名称:search,代码行数:10,代码来源:AnnotationDriverTest.php


示例20: onKernelRequest

 /**
  * @param GetResponseEvent $event
  * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
  * @return bool
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (strpos($event->getRequest()->attributes->get('_controller'), 'Api\\Resource') !== false) {
         header('Access-Control-Allow-Origin: *');
         $controller = explode('::', $event->getRequest()->attributes->get('_controller'));
         $reflection = new \ReflectionMethod($controller[0], $controller[1]);
         $scopeAnnotation = $this->reader->getMethodAnnotation($reflection, 'Etu\\Core\\ApiBundle\\Framework\\Annotation\\Scope');
         if ($scopeAnnotation) {
             $requiredScope = $scopeAnnotation->value;
         } else {
             $requiredScope = null;
         }
         if (!$requiredScope) {
             $requiredScope = 'public';
         }
         $request = $event->getRequest();
         $token = $request->query->get('access_token');
         $access = $this->server->checkAccess($token, $requiredScope);
         if (!$access->isGranted()) {
             $event->setResponse($this->formatter->format($event->getRequest(), ['error' => $access->getError(), 'error_message' => $access->getErrorMessage()], 403));
         } else {
             $event->getRequest()->attributes->set('_oauth_token', $access->getToken());
         }
     }
 }
开发者ID:ChrisdAutume,项目名称:EtuUTT,代码行数:30,代码来源:SecurityListener.php



注:本文中的Doctrine\Common\Annotations\Reader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Cache\Cache类代码示例发布时间:2022-05-23
下一篇:
PHP Annotations\DocParser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap