當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassType::from方法代碼示例

本文整理匯總了PHP中Nette\Reflection\ClassType::from方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassType::from方法的具體用法?PHP ClassType::from怎麽用?PHP ClassType::from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Reflection\ClassType的用法示例。


在下文中一共展示了ClassType::from方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: injectComponentFactories

 /**
  * @param \Nette\DI\Container $dic
  * @throws MemberAccessException
  * @internal
  */
 public function injectComponentFactories(Nette\DI\Container $dic)
 {
     if (!$this instanceof Nette\Application\UI\PresenterComponent && !$this instanceof Nette\Application\UI\Component) {
         throw new MemberAccessException('Trait ' . __TRAIT__ . ' can be used only in descendants of PresenterComponent.');
     }
     $this->autowireComponentFactoriesLocator = $dic;
     $storage = $dic->hasService('autowired.cacheStorage') ? $dic->getService('autowired.cacheStorage') : $dic->getByType('Nette\\Caching\\IStorage');
     $cache = new Nette\Caching\Cache($storage, 'Kdyby.Autowired.AutowireComponentFactories');
     if ($cache->load($presenterClass = get_class($this)) !== NULL) {
         return;
     }
     $ignore = class_parents('Nette\\Application\\UI\\Presenter') + ['ui' => 'Nette\\Application\\UI\\Presenter'];
     $rc = new ClassType($this);
     foreach ($rc->getMethods() as $method) {
         if (in_array($method->getDeclaringClass()->getName(), $ignore, TRUE) || !Strings::startsWith($method->getName(), 'createComponent')) {
             continue;
         }
         foreach ($method->getParameters() as $parameter) {
             if (!($class = $parameter->getClassName())) {
                 // has object type hint
                 continue;
             }
             if (!$this->findByTypeForFactory($class) && !$parameter->allowsNull()) {
                 throw new MissingServiceException("No service of type {$class} found. Make sure the type hint in {$method} is written correctly and service of this type is registered.");
             }
         }
     }
     $files = array_map(function ($class) {
         return ClassType::from($class)->getFileName();
     }, array_diff(array_values(class_parents($presenterClass) + ['me' => $presenterClass]), $ignore));
     $files[] = ClassType::from($this->autowireComponentFactoriesLocator)->getFileName();
     $cache->save($presenterClass, TRUE, [$cache::FILES => $files]);
 }
開發者ID:kdyby,項目名稱:autowired,代碼行數:38,代碼來源:AutowireComponentFactories.php

示例2: setupServices

 private function setupServices()
 {
     $builder = $this->getContainerBuilder();
     $config = $this->validateConfig($this->defaults);
     $gopay = $builder->getDefinition($this->prefix('gopay'));
     $services = ['payment' => PaymentService::class, 'recurrentPayment' => RecurrentPaymentService::class, 'preAuthorizedPayment' => PreAuthorizedPaymentService::class];
     foreach ($services as $serviceName => $serviceClass) {
         $def = $builder->addDefinition($this->prefix("service.{$serviceName}"))->setClass($serviceClass, [$gopay]);
         if (is_bool($config['payments']['changeChannel'])) {
             $def->addSetup('allowChangeChannel', [$config['payments']['changeChannel']]);
         }
         if (isset($config['payments']['channels'])) {
             $constants = ClassType::from(Gopay::class);
             foreach ($config['payments']['channels'] as $code => $channel) {
                 $constChannel = 'METHOD_' . strtoupper($code);
                 if ($constants->hasConstant($constChannel)) {
                     $code = $constants->getConstant($constChannel);
                 }
                 if (is_array($channel)) {
                     $channel['code'] = $code;
                     $def->addSetup('addChannel', $channel);
                 } else {
                     if (is_scalar($channel)) {
                         $def->addSetup('addChannel', [$code, $channel]);
                     }
                 }
             }
         }
     }
 }
開發者ID:markette,項目名稱:gopay,代碼行數:30,代碼來源:Extension.php

示例3: getSchema

 /**
  * @param $class
  */
 public function getSchema($class)
 {
     if (!isset($this->_annotationSchema[$class])) {
         $schema = array();
         $ref = ClassType::from($class);
         if ($ref->hasAnnotation('secured')) {
             foreach ($ref->getMethods() as $method) {
                 $name = $method->getName();
                 if (substr($name, 0, 6) !== 'action' && substr($name, 0, 6) !== 'handle') {
                     continue;
                 }
                 if ($method->hasAnnotation('secured')) {
                     $secured = $method->getAnnotation('secured');
                     $name = $method->getName();
                     $schema[$name] = array();
                     $schema[$name]['resource'] = $this->getSchemaOfResource($method, $secured);
                     $schema[$name]['privilege'] = $this->getSchemaOfPrivilege($method, $secured);
                     $schema[$name]['roles'] = $this->getSchemaOfRoles($method, $secured);
                     $schema[$name]['users'] = $this->getSchemaOfUsers($method, $secured);
                 }
             }
         }
         $this->_annotationSchema[$class] = $schema;
     }
     return $this->_annotationSchema[$class];
 }
開發者ID:svobodni,項目名稱:web,代碼行數:29,代碼來源:AnnotationReader.php

示例4: build

 public static function build($className)
 {
     $reflection = \Nette\Reflection\ClassType::from($className);
     $annotations = $reflection->getAnnotations();
     $ret = array('entityClass' => $className);
     foreach ($annotations as $key => $value) {
         if ($key == "Entity") {
             $entity = $value[0];
             if (isset($entity->repositoryClass)) {
                 $ret['repositoryClass'] = (string) $entity->repositoryClass;
             } elseif (isset($entity->validatorClass)) {
                 $ret['validatorClass'] = (string) $entity->validatorClass;
             }
         } elseif ($key == "Table") {
             $table = $value[0];
             $ret['table'] = (string) $table->name;
             $ret['mainIndex'] = isset($table->mainIndex) ? (string) $table->mainIndex : NULL;
             $ret['topicIndex'] = isset($table->topicIndex) ? (string) $table->topicIndex : NULL;
         } elseif ($key == "Column") {
             foreach ($value as $column) {
                 $name = $column->name;
                 unset($column->name);
                 $ret['columns'][$name] = (array) $column;
             }
         } elseif (in_array($key, array("AssociationHasOne", "AssociationHasMany"))) {
             foreach ($value as $association) {
                 $name = $association->name;
                 unset($association->name);
                 $ret['associations'][$name] = (array) $association;
             }
         }
     }
     return $ret;
 }
開發者ID:matak,項目名稱:dbrecord,代碼行數:34,代碼來源:Annotations.php

示例5: testSignalAllow

	public function testSignalAllow()
	{
		$this->presenter->setSignalMock("test2");
		$this->presenter->checkRequirements(ClassType::from(__NAMESPACE__ . '\BackendPresenter\PresenterMock'));

		$this->assertFalse($this->presenter->isAllowedMock('handleTest1'));
		$this->assertTrue($this->presenter->isAllowedMock('handleTest2'));
	}
開發者ID:norbe,項目名稱:framework,代碼行數:8,代碼來源:BackendPresenterTest.php

示例6: __construct

 public function __construct($type)
 {
     if (strpos($type, '*') !== FALSE) {
         $this->pattern = str_replace('\\*', '.*', preg_quote($type));
     } else {
         $this->type = Nette\Reflection\ClassType::from($type)->getName();
     }
 }
開發者ID:kdyby,項目名稱:aop,代碼行數:8,代碼來源:WithinMatcher.php

示例7: __set

 /**
  * Sets a variable in this session section.
  * @param  string  name
  * @param  mixed   value
  * @return void
  */
 public function __set($name, $value)
 {
     $this->start();
     $this->data[$name] = $value;
     if (is_object($value)) {
         $this->meta[$name]['V'] = Nette\Reflection\ClassType::from($value)->getAnnotation('serializationVersion');
     }
 }
開發者ID:cujan,項目名稱:atlas-mineralov-a-hornin,代碼行數:14,代碼來源:SessionSection.php

示例8: loadConfiguration

 public function loadConfiguration()
 {
     $builder = $this->getContainerBuilder();
     $latte = $builder->hasDefinition('nette.latteFactory') ? $builder->getDefinition('nette.latteFactory') : $builder->getDefinition('nette.latte');
     $latte->addSetup('Lohini\\Latte\\Macros\\CoreMacros::install(?->getCompiler())', ['@self']);
     foreach (\Nette\Reflection\ClassType::from('Lohini\\Latte\\Filters')->getMethods() as $method) {
         $latte->addSetup('addFilter', [$method->name, ['Lohini\\Latte\\Filters', $method->name]]);
     }
 }
開發者ID:lohini,項目名稱:framework,代碼行數:9,代碼來源:Extension.php

示例9: __construct

 public function __construct(Nette\DI\ServiceDefinition $def, $serviceId)
 {
     $this->serviceDefinition = $def;
     if (empty($def->class)) {
         throw new Kdyby\Aop\InvalidArgumentException("Given service definition has unresolved class, please specify service type explicitly.");
     }
     $this->originalType = Nette\Reflection\ClassType::from($def->class);
     $this->serviceId = $serviceId;
 }
開發者ID:kdyby,項目名稱:aop,代碼行數:9,代碼來源:ServiceDefinition.php

示例10: registerExtension

 /**
  * Registers adapter for given file extension.
  * @param  string  file extension
  * @param  string  class name (IConfigAdapter)
  * @return void
  */
 public static function registerExtension($extension, $class)
 {
     if (!class_exists($class)) {
         throw new Nette\InvalidArgumentException("Class '{$class}' was not found.");
     }
     if (!Nette\Reflection\ClassType::from($class)->implementsInterface('Nette\\Config\\IAdapter')) {
         throw new Nette\InvalidArgumentException("Configuration adapter '{$class}' is not Nette\\Config\\IAdapter implementor.");
     }
     self::$extensions[strtolower($extension)] = $class;
 }
開發者ID:bazo,項目名稱:Tatami,代碼行數:16,代碼來源:Config.php

示例11: beforeCompile

 public function beforeCompile()
 {
     $builder = $this->getContainerBuilder();
     $mapping = $builder->getDefinition('movi.entityMapping');
     foreach (array_keys($builder->findByTag(self::REPOSITORY_TAG)) as $repository) {
         $reflection = ClassType::from($builder->getDefinition($repository)->class);
         $class = $reflection->newInstanceWithoutConstructor();
         $mapping->addSetup('registerEntities', array($class->getEntities()));
     }
 }
開發者ID:peterzadori,項目名稱:movi,代碼行數:10,代碼來源:RepositoriesExtension.php

示例12: getTests

 public function getTests()
 {
     $tests = [];
     foreach (ClassType::from($this)->getMethods(Method::IS_PUBLIC) as $method) {
         $name = $method->getShortName();
         if (preg_match(static::METHOD_PATTERN, $name)) {
             $tests[] = $name;
         }
     }
     return $tests;
 }
開發者ID:VasekPurchart,項目名稱:khanovaskola-v3,代碼行數:11,代碼來源:TestCase.php

示例13: getValues

 /**
  * Získá všechny hodnoty z entity, které mají anotaci @column a nemají anotaci @id.
  * @return array
  */
 public function getValues()
 {
     $reflector = \Nette\Reflection\ClassType::from($this);
     $values = array();
     foreach ($reflector->getProperties() as $property) {
         if ($property->hasAnnotation("column") && !$property->hasAnnotation("id")) {
             $name = $property->getName();
             $values[$this->normalizeColumnName($name)] = $this->{$name};
         }
     }
     return $values;
 }
開發者ID:JZechy,項目名稱:ZBox,代碼行數:16,代碼來源:BaseEntity.php

示例14: preFlush

 public function preFlush(PreFlushEventArgs $args)
 {
     $em = $args->getEntityManager();
     $uow = $em->getUnitOfWork();
     foreach ($uow->getScheduledEntityInsertions() as $entity) {
         $reflection = Nette\Reflection\ClassType::from($entity);
         if ($reflection->hasProperty("priority")) {
             $repository = $em->getRepository($reflection->getName());
             $result = $repository->createQueryBuilder("p")->select("MAX(p.priority)")->getQuery()->execute();
             $entity->priority = ($result ? (int) $result[0][1] : 0) + 1;
         }
     }
 }
開發者ID:Kotys,項目名稱:eventor.io,代碼行數:13,代碼來源:FillPriorityFieldSubscriber.php

示例15: createBaseQuery

 /**
  * @param $entity
  * @param callable $modifier
  * @return \Kdyby\Doctrine\QueryBuilder
  */
 private function createBaseQuery($entity, $modifier)
 {
     $reflection = ClassType::from($entity);
     if (!$reflection->hasProperty('priority')) {
         throw new InvalidArgumentException('Entity has not property $priority');
     }
     $qb = $this->entityManager->getRepository($reflection->getName())->createQueryBuilder("e")->select();
     if ($modifier !== NULL) {
         $modifier($qb);
     }
     $qb->setMaxResults(1);
     return $qb;
 }
開發者ID:Kotys,項目名稱:eventor.io,代碼行數:18,代碼來源:Sorter.php


注:本文中的Nette\Reflection\ClassType::from方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。