本文整理汇总了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);
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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');
}
示例7: setContainer
/**
* @Inject("@Service_container")
* @param Container $container
*/
public function setContainer(Container $container)
{
$this->parameterBag = $container->getParameterBag();
}
示例8: __construct
public function __construct(Container $container, LoggerInterface $logger)
{
$this->initConfig($container->getParameterBag()->all());
$this->logger = $logger;
}
示例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());