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


PHP DefinitionDecorator::setScope方法代碼示例

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


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

示例1: createPackageDefinition

 /**
  * Returns a definition for an asset package.
  *
  * @param ContainerBuilder $container   Container
  * @param array            $httpUrls    SSL assets_base_urls
  * @param array            $sslUrls     assets_base_urls
  * @param string           $rootDir     Directory where to look for reved assets
  * @param string           $summaryFile Grunt filerev summary file
  * @param string           $cacheDir    Kernel cache dir
  * @param bool             $debug       Debug mode?
  * @param string           $name        Package name
  *
  * @return DefinitionDecorator
  */
 private function createPackageDefinition(ContainerBuilder $container, array $httpUrls, array $sslUrls, $rootDir, $summaryFile, $cacheDir, $debug, $name = null)
 {
     if (!$httpUrls) {
         $package = new DefinitionDecorator('grunt.filerev.templating.asset.path_package');
         $package->setPublic(false)->setScope('request')->replaceArgument(1, $rootDir)->replaceArgument(2, $summaryFile)->replaceArgument(3, $cacheDir)->replaceArgument(4, $debug);
         return $package;
     }
     if ($httpUrls == $sslUrls) {
         $package = new DefinitionDecorator('grunt.filerev.templating.asset.url_package');
         $package->setPublic(false)->replaceArgument(0, $sslUrls)->replaceArgument(1, $rootDir)->replaceArgument(2, $summaryFile)->replaceArgument(3, $cacheDir)->replaceArgument(4, $debug);
         return $package;
     }
     $prefix = $name ? 'templating.asset.package.' . $name : 'templating.asset.default_package';
     $httpPackage = new DefinitionDecorator('grunt.filerev.templating.asset.url_package');
     $httpPackage->replaceArgument(0, $httpUrls)->replaceArgument(1, $rootDir)->replaceArgument(2, $summaryFile)->replaceArgument(3, $cacheDir)->replaceArgument(4, $debug);
     $container->setDefinition($prefix . '.http', $httpPackage);
     if ($sslUrls) {
         $sslPackage = new DefinitionDecorator('grunt.filerev.templating.asset.url_package');
         $sslPackage->replaceArgument(0, $sslUrls)->replaceArgument(1, $rootDir)->replaceArgument(2, $summaryFile)->replaceArgument(3, $cacheDir)->replaceArgument(4, $debug);
     } else {
         $sslPackage = new DefinitionDecorator('grunt.filerev.templating.asset.path_package');
         $sslPackage->setScope('request')->replaceArgument(1, $rootDir)->replaceArgument(2, $summaryFile)->replaceArgument(3, $cacheDir)->replaceArgument(4, $debug);
     }
     $container->setDefinition($prefix . '.ssl', $sslPackage);
     $package = new DefinitionDecorator('templating.asset.request_aware_package');
     $package->setPublic(false)->setScope('request')->replaceArgument(1, $prefix . '.http')->replaceArgument(2, $prefix . '.ssl');
     return $package;
 }
開發者ID:necatikartal,項目名稱:generator-grunt-symfony,代碼行數:42,代碼來源:GruntExtension.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->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

示例3: 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

示例4: createPackageDefinition

 /**
  * Returns a definition for an asset package.
  */
 private function createPackageDefinition(ContainerBuilder $container, array $httpUrls, array $sslUrls, $version, $format, $name = null)
 {
     if (!$httpUrls) {
         $package = new DefinitionDecorator('templating.asset.path_package');
         $package->setPublic(false)->setScope('request')->replaceArgument(1, $version)->replaceArgument(2, $format);
         return $package;
     }
     if ($httpUrls == $sslUrls) {
         $package = new DefinitionDecorator('templating.asset.url_package');
         $package->setPublic(false)->replaceArgument(0, $sslUrls)->replaceArgument(1, $version)->replaceArgument(2, $format);
         return $package;
     }
     $prefix = $name ? 'templating.asset.package.' . $name : 'templating.asset.default_package';
     $httpPackage = new DefinitionDecorator('templating.asset.url_package');
     $httpPackage->replaceArgument(0, $httpUrls)->replaceArgument(1, $version)->replaceArgument(2, $format);
     $container->setDefinition($prefix . '.http', $httpPackage);
     if ($sslUrls) {
         $sslPackage = new DefinitionDecorator('templating.asset.url_package');
         $sslPackage->replaceArgument(0, $sslUrls)->replaceArgument(1, $version)->replaceArgument(2, $format);
     } else {
         $sslPackage = new DefinitionDecorator('templating.asset.path_package');
         $sslPackage->setScope('request')->replaceArgument(1, $version)->replaceArgument(2, $format);
     }
     $container->setDefinition($prefix . '.ssl', $sslPackage);
     $package = new DefinitionDecorator('templating.asset.request_aware_package');
     $package->setPublic(false)->setScope('request')->replaceArgument(1, $prefix . '.http')->replaceArgument(2, $prefix . '.ssl');
     return $package;
 }
開發者ID:nesQuick,項目名稱:symfony,代碼行數:31,代碼來源:FrameworkExtension.php


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