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


PHP DefinitionDecorator::setProperties方法代碼示例

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


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

示例1: convert

 /**
  * Converts class hierarchy metadata to definition instances.
  *
  * @param ClassHierarchyMetadata $metadata
  * @return array an array of Definition instances
  */
 public function convert(ClassHierarchyMetadata $metadata)
 {
     static $count = 0;
     $definitions = array();
     $previous = null;
     foreach ($metadata->classMetadata as $classMetadata) {
         if (null === $previous && null === $classMetadata->parent) {
             $definition = new Definition();
         } else {
             $definition = new DefinitionDecorator($classMetadata->parent ?: $previous->id);
         }
         $definition->setClass($classMetadata->name);
         if (null !== $classMetadata->scope) {
             $definition->setScope($classMetadata->scope);
         }
         if (null !== $classMetadata->public) {
             $definition->setPublic($classMetadata->public);
         }
         if (null !== $classMetadata->abstract) {
             $definition->setAbstract($classMetadata->abstract);
         }
         if (null !== $classMetadata->lazy) {
             $definition->setLazy($classMetadata->lazy);
         }
         if (null !== $classMetadata->arguments) {
             $definition->setArguments($classMetadata->arguments);
         }
         $definition->setMethodCalls($classMetadata->methodCalls);
         $definition->setTags($classMetadata->tags);
         $definition->setProperties($classMetadata->properties);
         if (null !== $classMetadata->decorates) {
             if (!method_exists($definition, 'setDecoratedService')) {
                 throw new InvalidAnnotationException(sprintf("decorations require symfony >=2.8 on class %s", $classMetadata->name));
             }
             $definition->setDecoratedService($classMetadata->decorates, $classMetadata->decoration_inner_name);
         }
         if (null !== $classMetadata->deprecated && method_exists($definition, 'setDeprecated')) {
             $definition->setDeprecated(true, $classMetadata->deprecated);
         }
         if (null === $classMetadata->id) {
             $classMetadata->id = '_jms_di_extra.unnamed.service_' . $count++;
         }
         if (0 !== count($classMetadata->initMethods)) {
             foreach ($classMetadata->initMethods as $initMethod) {
                 $definition->addMethodCall($initMethod);
             }
         } elseif (null !== $classMetadata->initMethod) {
             @trigger_error('ClassMetadata::$initMethod is deprecated since version 1.7 and will be removed in 2.0. Use ClassMetadata::$initMethods instead.', E_USER_DEPRECATED);
             $definition->addMethodCall($classMetadata->initMethod);
         }
         $definitions[$classMetadata->id] = $definition;
         $previous = $classMetadata;
     }
     return $definitions;
 }
開發者ID:alber999,項目名稱:JMSDiExtraBundle,代碼行數:61,代碼來源:MetadataConverter.php

示例2: convert

 /**
  * Converts class hierarchy metadata to definition instances.
  *
  * @param ClassHierarchyMetadata $metadata
  * @return array an array of Definition instances
  */
 public function convert(ClassHierarchyMetadata $metadata)
 {
     static $count = 0;
     $definitions = array();
     $previous = null;
     foreach ($metadata->classMetadata as $classMetadata) {
         if (null === $previous && null === $classMetadata->parent) {
             $definition = new Definition();
         } else {
             $definition = new DefinitionDecorator($classMetadata->parent ?: $previous->id);
         }
         $definition->setClass($classMetadata->name);
         if (null !== $classMetadata->scope) {
             $definition->setScope($classMetadata->scope);
         }
         if (null !== $classMetadata->public) {
             $definition->setPublic($classMetadata->public);
         }
         if (null !== $classMetadata->abstract) {
             $definition->setAbstract($classMetadata->abstract);
         }
         if (null !== $classMetadata->arguments) {
             $definition->setArguments($classMetadata->arguments);
         }
         $definition->setMethodCalls($classMetadata->methodCalls);
         $definition->setTags($classMetadata->tags);
         $definition->setProperties($classMetadata->properties);
         if (null === $classMetadata->id) {
             $classMetadata->id = '_jms_di_extra.unnamed.service_' . $count++;
         }
         if ($classMetadata->initMethod) {
             if (!method_exists($definition, 'setInitMethod')) {
                 throw new \RuntimeException(sprintf('@AfterSetup is not available on your Symfony version.'));
             }
             $definition->setInitMethod($classMetadata->initMethod);
         }
         $definitions[$classMetadata->id] = $definition;
         $previous = $classMetadata;
     }
     return $definitions;
 }
開發者ID:laubosslink,項目名稱:lab,代碼行數:47,代碼來源:MetadataConverter.php


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