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


PHP Container::getParameterBag方法代码示例

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


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

示例1: __construct

 /**
  * __construct function.
  *
  * @access public
  * @param Container $container
  */
 public function __construct(Container $container)
 {
     // Getting all symfony parameters
     $this->parameters = $container->getParameterBag()->all();
     // Getting all parameters keys
     $this->keys = array_keys($this->parameters);
 }
开发者ID:xavier-dubreuil,项目名称:LightCMS,代码行数:13,代码来源:ParametersService.php

示例2: __construct

 /**
  * __construct function.
  *
  * Constructing the discriminator mapping from parameters and entities:
  * - Search parameters starting with "discriminator_map"
  * - Fetching map from entities configuration
  * The Entity disciminator map has priority against parameter map
  *
  * @access public
  * @param Container $container
  */
 public function __construct(Container $container)
 {
     // Getting all symfony parameters
     $parameters = $container->getParameterBag()->all();
     // Getting all parameters keys
     $parametesKeys = array_keys($parameters);
     // Matching parameters with specific key "discriminator_map"
     $matches = preg_grep('/^inheritance_joined_map\\..+/i', $parametesKeys);
     // Looping on matching configurations
     foreach ($matches as $match) {
         // Looping on map name
         foreach ($parameters[$match] as $ename => $parent) {
             // Looping on each map for a specific entity
             foreach ($parent['map'] as $name => $class) {
                 // Adding the map to the mapping
                 $this->mapping[$parent['entity']][$name] = $class;
             }
         }
     }
     // The mapping defined in the entity has priority against parameters
     // Loop on entities in mapping to get the original mapping
     foreach (array_keys($this->mapping) as $entityName) {
         // Loop on map defined in entity
         foreach ($this->getEntityDiscriminatorMap($entityName) as $name => $map) {
             // Adding the map to the mapping
             $this->mapping[$entityName][$name] = $map;
         }
     }
 }
开发者ID:xavier-dubreuil,项目名称:LightCMS,代码行数:40,代码来源:DiscriminatorMapListener.php

示例3: getHttpKernel

 public function getHttpKernel()
 {
     if (!$this->silexKernel) {
         $this->silexKernel = new SilexKernel($this->httpConfig, $this->isDebugMode);
         $this->silexKernel->addControllerInjectedArg($this);
         $this->silexKernel->addExtraParameters($this->container->getParameterBag()->all());
     }
     return $this->silexKernel;
 }
开发者ID:oasmobile,项目名称:php-slimapp,代码行数:9,代码来源:SlimApp.php

示例4: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $content = $asset->getContent();
     /**
      * Find All Params In %%
      */
     $regex_pattern = '/\\%[a-z0-9A-Z\\._]+\\%/';
     $boolean = preg_match_all($regex_pattern, $content, $matches_out);
     $replaces = array();
     if ($boolean) {
         $matches = array_unique($matches_out[0]);
         foreach ($matches as $match) {
             if ($value = $this->container->getParameterBag()->resolveValue($match)) {
                 $replaces[$match] = $value;
             }
         }
         $content = str_replace(array_keys($replaces), array_values($replaces), $content);
     }
     $asset->setContent($content);
 }
开发者ID:kazak,项目名称:forum,代码行数:20,代码来源:ExposedFilter.php

示例5: generateI18nPatterns

 public function generateI18nPatterns($routeName, Route $route)
 {
     $patterns = [];
     /** @var FrozenParameterBag $parameterBag */
     $parameterBag = $this->container->getParameterBag();
     if (empty($this->offices)) {
         $this->offices = $this->container->get('doctrine')->getRepository('OctavaMuiBundle:Office')->getRoutingOffices();
     }
     $translation = null;
     if ($structureId = $route->getDefault(Structure::ROUTING_ID_NAME)) {
         $structureRepository = $this->container->get('doctrine.orm.entity_manager')->getRepository('OctavaStructureBundle:Structure');
         $translation = $structureRepository->getTranslations($structureRepository->getById($structureId));
     }
     foreach (array_keys($this->offices) as $locale) {
         if ($translation !== null && empty($translation[$locale]['state'])) {
             // отключенная страница
             continue;
         }
         $office = $this->offices[$locale];
         $i18nPattern = $route->getPath();
         $paths = $route->getOption('translatable_path');
         if (!empty($paths[$locale])) {
             $i18nPattern = $paths[$locale];
         }
         if ($office->getIncludeLangInUrl()) {
             $i18nPattern = '/{_locale}' . $i18nPattern;
         }
         if (null !== ($prefix = $route->getOption('i18n_prefix'))) {
             $prefix = $parameterBag->resolveValue($prefix);
             $i18nPattern = $prefix . $i18nPattern;
         }
         $host = $office->getHost();
         if (empty($patterns[$i18nPattern][$host])) {
             $patterns[$i18nPattern][$host] = [];
         }
         $patterns[$i18nPattern][$host][] = $locale;
     }
     return $patterns;
 }
开发者ID:octava,项目名称:cms,代码行数:39,代码来源:PatternGenerationStrategy.php

示例6: testGetParameterBag

 public function testGetParameterBag()
 {
     $sc = new Container();
     $this->assertEquals(array(), $sc->getParameterBag()->all(), '->getParameterBag() returns an empty array if no parameter has been defined');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:5,代码来源:ContainerTest.php

示例7: setContainer

 /**
  * @Inject("@Service_container")
  * @param Container $container
  */
 public function setContainer(Container $container)
 {
     $this->parameterBag = $container->getParameterBag();
 }
开发者ID:brainexe,项目名称:core,代码行数:8,代码来源:ConfigTrait.php

示例8: __construct

 public function __construct(Container $container, LoggerInterface $logger)
 {
     $this->initConfig($container->getParameterBag()->all());
     $this->logger = $logger;
 }
开发者ID:anushr,项目名称:OmnipayBundle,代码行数:5,代码来源:Omnipay.php

示例9: Container

<?php

use Symfony\Component\DependencyInjection\Container;
require_once __DIR__ . '/bootstrap.php';
$container = new Container();
$container->set('foo', new stdClass());
dump($container->get('foo'));
$container->setParameter('bar', TRUE);
dump($container->getParameterBag()->all());
开发者ID:fprochazka,项目名称:dic-nette-vs-symfony,代码行数:9,代码来源:01-container.symfony.php


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