当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassType::getName方法代码示例

本文整理汇总了PHP中Nette\Reflection\ClassType::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassType::getName方法的具体用法?PHP ClassType::getName怎么用?PHP ClassType::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Reflection\ClassType的用法示例。


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

示例1: isAllowed

 /**
  * {@inheritdoc}
  */
 public function isAllowed($role, $resource, $privilege)
 {
     if ($role instanceof IRole) {
         $role = $role->getRoleId();
     }
     if (!$resource instanceof PresenterResource) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('Resource must be instance of %s, %s given.', PresenterResource::class, gettype($resource)));
     }
     $request = $resource->getRequest();
     $presenterName = $request->getPresenterName();
     list($signal, $signalReceiver) = $this->getSignal($request);
     if (!$signal) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('No signal sent.'));
     }
     $refClass = new PresenterComponentReflection($class = $this->presenterFactory->getPresenterClass($presenterName));
     while ($name = array_shift($signalReceiver)) {
         $name = 'createComponent' . ucfirst($name);
         if (!$refClass->hasMethod($name)) {
             throw new \Nette\InvalidStateException(sprintf('Method %s::%s is not implemented.', $refClass->getName(), $name));
         }
         $refMethod = $refClass->getMethod($name);
         if (!$refMethod->hasAnnotation('return')) {
             throw new \Nette\InvalidStateException(sprintf('Method %s::%s must have fully qualified return annotation.', $refClass->getName(), $name));
         }
         $refClass = new ClassType($refMethod->getAnnotation('return'));
     }
     if (!$refClass->hasMethod($name = Presenter::formatSignalMethod($signal))) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('Method %s::%s is not implemented.', $refClass->getName(), $name));
     }
     $refMethod = $refClass->getMethod($name);
     if (!$refMethod->hasAnnotation($privilege)) {
         throw new \Ark8\Security\Exceptions\SkipException(sprintf('Method %s::%s does not have annotation %s.', $refClass->getName(), $name, $privilege));
     }
     return in_array($role, preg_split('#\\s+#', trim((string) $refMethod->getAnnotation($privilege))));
 }
开发者ID:ark8,项目名称:security,代码行数:38,代码来源:SignalAuthorizator.php

示例2: getTypesWithin

 /**
  * @return array
  */
 public function getTypesWithin()
 {
     if ($this->typesWithing !== NULL) {
         return $this->typesWithing;
     }
     return $this->typesWithing = class_parents($class = $this->originalType->getName()) + class_implements($class) + [$class => $class];
 }
开发者ID:kdyby,项目名称:aop,代码行数:10,代码来源:ServiceDefinition.php

示例3: getPresenterClass

 /**
  * Generates and checks presenter class name.
  *
  * @param  string presenter name
  * @return string  class name
  * @throws Application\InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new Application\InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $classes = $this->formatPresenterClasses($name);
     if (!$classes) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', no applicable mapping found.");
     }
     $class = $this->findValidClass($classes);
     if (!$class) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', none of following classes were found: " . implode(', ', $classes));
     }
     $reflection = new Nette\Reflection\ClassType($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     }
     if ($reflection->isAbstract()) {
         throw new Application\InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     return $this->cache[$name] = $class;
 }
开发者ID:librette,项目名称:presenter-factory,代码行数:33,代码来源:PresenterFactory.php

示例4: classToMD

 /**
  * Generates markdown output for a specified class
  * @param string $class e.g. `PDO` or a user class like `diversen\markdownDocs`
  * @return void the method adds to $output
  */
 public function classToMD($class, $options = [])
 {
     $r = new ClassType($class);
     $this->output .= $this->sectionHeader('Class: ' . $r->getName(), 3);
     // Class description
     $this->output .= $r->getDescription() . $this->getNL();
     // Get methods and props
     $methods = $r->getMethods();
     $props = $r->getDefaultProperties();
     // Parse properties
     $this->output .= $this->sectionHeader("Properties");
     $this->generatePropsMD($r, $props, $options);
     // Parse methods
     $this->output .= $this->sectionHeader("Methods");
     $this->generateMethodMD($methods, $options);
 }
开发者ID:diversen,项目名称:php-markdown-docs,代码行数:21,代码来源:markdownDocs.php

示例5: getPresenterClass

 /**
  * Generates and checks presenter class name.
  * @param  string  presenter name
  * @return string  class name
  * @throws InvalidPresenterException
  */
 public function getPresenterClass(&$name)
 {
     if (isset($this->cache[$name])) {
         list($class, $name) = $this->cache[$name];
         return $class;
     }
     if (!is_string($name) || !Nette\Utils\Strings::match($name, '#^[a-zA-Z\\x7f-\\xff][a-zA-Z0-9\\x7f-\\xff:]*\\z#')) {
         throw new InvalidPresenterException("Presenter name must be alphanumeric string, '{$name}' is invalid.");
     }
     $class = $this->formatPresenterClass($name);
     if (!class_exists($class)) {
         // internal autoloading
         $file = $this->formatPresenterFile($name);
         if (is_file($file) && is_readable($file)) {
             call_user_func(function () use($file) {
                 require $file;
             });
         }
         if (!class_exists($class)) {
             throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' was not found in '{$file}'.");
         }
     }
     $reflection = new Nette\Reflection\ClassType($class);
     $class = $reflection->getName();
     if (!$reflection->implementsInterface('Nette\\Application\\IPresenter')) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is not Nette\\Application\\IPresenter implementor.");
     }
     if ($reflection->isAbstract()) {
         throw new InvalidPresenterException("Cannot load presenter '{$name}', class '{$class}' is abstract.");
     }
     // canonicalize presenter name
     $realName = $this->unformatPresenterClass($class);
     if ($name !== $realName) {
         if ($this->caseSensitive) {
             throw new InvalidPresenterException("Cannot load presenter '{$name}', case mismatch. Real name is '{$realName}'.");
         } else {
             $this->cache[$name] = array($class, $realName);
             $name = $realName;
         }
     } else {
         $this->cache[$name] = array($class, $realName);
     }
     return $class;
 }
开发者ID:pdostal,项目名称:nette-blog,代码行数:50,代码来源:PresenterFactory.php

示例6: findConstructorDaoParameters

 /**
  * Returns all parameters of the constructor which type is dao object.
  *
  * @param string $class
  * @return array array of parameter's names
  */
 private function findConstructorDaoParameters($class)
 {
     $reflection = new Reflection($class);
     $daoParameters = array();
     foreach ($reflection->constructor->parameters as $parameter) {
         $parameterClass = $parameter->getClassName();
         if ($parameterClass) {
             $parameterReflection = new Reflection($parameterClass);
             if ($parameterReflection->getName() === self::DAO_CLASS || $parameterReflection->isSubclassOf(self::DAO_CLASS)) {
                 $daoParameters[] = $parameter->getName();
             }
         }
     }
     return $daoParameters;
 }
开发者ID:mike227,项目名称:n-service-annotations,代码行数:21,代码来源:DaoManager.php

示例7: bindEventProperties

 protected function bindEventProperties(Nette\DI\ServiceDefinition $def, Nette\Reflection\ClassType $class)
 {
     foreach ($class->getProperties(Nette\Reflection\Property::IS_PUBLIC) as $property) {
         if (!preg_match('#^on[A-Z]#', $name = $property->getName())) {
             continue;
         }
         if ($property->hasAnnotation('persistent') || $property->hasAnnotation('inject')) {
             // definitely not an event
             continue;
         }
         $def->addSetup('$' . $name, array(new Nette\DI\Statement($this->prefix('@manager') . '::createEvent', array(array($class->getName(), $name), new Code\PhpLiteral('$service->' . $name)))));
     }
 }
开发者ID:hranicka,项目名称:kdyby-events,代码行数:13,代码来源:EventsExtension.php

示例8: bindEventProperties

 protected function bindEventProperties(Nette\DI\ServiceDefinition $def, Nette\Reflection\ClassType $class)
 {
     foreach ($class->getProperties(Nette\Reflection\Property::IS_PUBLIC) as $property) {
         if (!preg_match('#^on[A-Z]#', $name = $property->getName())) {
             continue;
         }
         if ($property->hasAnnotation('persistent') || $property->hasAnnotation('inject')) {
             // definitely not an event
             continue;
         }
         $def->addSetup('$' . $name, [new Nette\DI\Statement($this->prefix('@manager') . '::createEvent', [[$class->getName(), $name], new Code\PhpLiteral('$service->' . $name), NULL, $property->hasAnnotation('globalDispatchFirst') ? (bool) $property->getAnnotation('globalDispatchFirst') : $this->loadedConfig['globalDispatchFirst']])]);
     }
 }
开发者ID:LidskaSila,项目名称:kdyby-events,代码行数:13,代码来源:EventsExtension.php

示例9: findByInterfaces

 /**
  * @param array $dirs
  * @param array $interfaces
  * @return array
  */
 private function findByInterfaces(array $dirs, array $interfaces)
 {
     $loader = $this->createLoader();
     $loader->addDirectory($dirs);
     $loader->rebuild();
     $loader->register();
     $classes = [];
     foreach (array_keys($loader->getIndexedClasses()) as $class) {
         // Skip not existing class
         if (!class_exists($class, TRUE)) {
             continue;
         }
         // Detect by reflection
         $ct = new ClassType($class);
         // Skip abstract
         if ($ct->isAbstract()) {
             continue;
         }
         // Does class implement one of given interface
         foreach ($interfaces as $interface) {
             if ($ct->implementsInterface($interface)) {
                 $classes[] = $ct->getName();
             }
         }
     }
     return $classes;
 }
开发者ID:minetro,项目名称:service-autoloader,代码行数:32,代码来源:ServiceAutoloadExtension.php


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