本文整理匯總了PHP中Symfony\Component\DependencyInjection\ContainerInterface::setParameter方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerInterface::setParameter方法的具體用法?PHP ContainerInterface::setParameter怎麽用?PHP ContainerInterface::setParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\ContainerInterface
的用法示例。
在下文中一共展示了ContainerInterface::setParameter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
protected function setUp()
{
$this->container = new Container();
$this->container->setParameter('payum.template.layout', 'theLayout');
$this->container->setParameter('payum.template.obtain_credit_card', 'theObtainCreditCardTemplate');
$this->container->set('payum.http_client', $this->getMock(HttpClientInterface::class));
$this->container->set('twig', $this->getMock(\Twig_Environment::class, [], [], '', false));
}
示例2: setUp
protected function setUp()
{
$this->container = new Container();
$this->container->setParameter('payum.template.layout', 'theLayout');
$this->container->setParameter('payum.template.obtain_credit_card', 'theObtainCreditCardTemplate');
$this->container->set('payum.buzz.client', $this->getMock('Buzz\Client\ClientInterface'));
$this->container->set('twig', $this->getMock('Twig_Environment'));
}
示例3: enable
/**
* @param string $bridge
* @throws RuntimeException
*/
public function enable($bridge)
{
if (!array_key_exists($bridge, self::$bridges)) {
throw new RuntimeException(sprintf('Bridge "%s" is not a valid FOSMessageBundle bridge (availabe bridges: %s)', $bridge, array_keys(self::$bridges)));
}
$bridgeClass = self::$bridges[$bridge];
if (!$bridgeClass::canBeEnabled()) {
throw new RuntimeException(sprintf('Bridge "%s" can not be enabled (probably because the underlying library / bundle is not available)', $bridge));
}
$this->container->setParameter('fos_message.bridges.states.' . $bridge, true);
}
示例4: convertEnvironmentVariableToBehatParameter
function convertEnvironmentVariableToBehatParameter(\Symfony\Component\DependencyInjection\ContainerInterface $container, $key, $override = false)
{
if (!$override && $container->hasParameter($key)) {
return;
}
$parameter = getenv($key);
if ($parameter) {
$container->setParameter(parseEnvironmentVariableKey($key), $parameter);
return;
}
$container->setParameter(parseEnvironmentVariableKey($key), 'EXPORT_PROPER_ENV');
}
示例5: transformToContainerParameters
public function transformToContainerParameters()
{
if (!is_null($this->configurationFile)) {
foreach (Yaml::parse($this->configurationFile) as $configurationID => $configurationPart) {
if (!is_null($configurationPart)) {
if (!array_key_exists($configurationID, $this->configuration)) {
$this->configuration[$configurationID] = array();
}
array_unshift($this->configuration[$configurationID], $configurationPart);
}
}
}
foreach ($this->configuration as $configurationID => $configurationParts) {
$configurations = array();
foreach ($configurationParts as $configurationPart) {
$configurations[] = $configurationPart;
}
if ($configurationID == GeneralConfiguration::getConfigurationID()) {
$transformerID = 'General';
} else {
$plugin = PluginRepository::findByPluginID($configurationID);
$transformerID = $plugin->getPluginID();
}
$transformerClass = __NAMESPACE__ . '\\' . $transformerID . 'Transformer';
$transformer = new $transformerClass($configurations, $this->container);
/* @var $transformer \Stagehand\TestRunner\DependencyInjection\Transformation\Transformer */
$transformer->transform();
}
if (is_null($this->container->getParameter('test_file_pattern'))) {
$this->container->setParameter('test_file_pattern', ApplicationContext::getInstance()->getPlugin()->getTestFilePattern());
}
}
示例6: setupAuthentication
public function setupAuthentication(ContainerInterface $container, $name, $options)
{
$container->setParameter("vss_oauth_extension.providers.{$name}.client_id", $options['client_id']);
$definition = new DefinitionDecorator("vss_oauth.security.auth.{$options['type']}");
$container->setDefinition("vss_oauth.security.auth.email.{$name}", $definition);
$definition->replaceArgument(0, $options);
}
示例7: loadGatewaysParameters
private function loadGatewaysParameters(ContainerInterface $container, $gateways)
{
foreach ($gateways as $gateway => $params) {
foreach ($params as $key => $paramater) {
$container->setParameter(sprintf("%s.%s.%s", $this->getAlias(), $gateway, $key), $paramater);
}
}
}
示例8: setMetaTag
/**
* @param string $name
* @param string $value
*/
public function setMetaTag($name, $value)
{
if (empty($name) || empty($value)) {
throw new \InvalidArgumentException(__('Empty argument at') . ':' . __FILE__ . '::' . __LINE__);
}
$metaTags = $this->container->hasParameter('zikula_view.metatags') ? $this->container->getParameter('zikula_view.metatags') : array();
$metaTags[$name] = \DataUtil::formatForDisplay($value);
$this->container->setParameter('zikula_view.metatags', $metaTags);
}
示例9: inject
/**
* @param array $config Config
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container DI container
* @param string $prefix Parameter name prefix
*/
public function inject(array $config, ContainerInterface $container, $prefix)
{
foreach ($config as $name => $value) {
$name = $prefix . '.' . $name;
$container->setParameter($name, $value);
if (is_array($value) && $this->isAssociative($value)) {
$this->inject($value, $container, $name);
}
}
}
示例10: setUp
protected function setUp()
{
parent::setUp();
$this->container = new Container();
$this->container->setParameter('hwi_oauth.templating.engine', 'twig');
$this->container->setParameter('hwi_oauth.connect', true);
$this->container->setParameter('hwi_oauth.firewall_names', array('default'));
$this->container->setParameter('hwi_oauth.connect.confirmation', true);
if (interface_exists('Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface')) {
$this->authorizationChecker = $this->getMockBuilder('\\Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface')->getMock();
$this->container->set('security.authorization_checker', $this->authorizationChecker);
$this->tokenStorage = $this->getMockBuilder('\\Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface')->getMock();
$this->container->set('security.token_storage', $this->tokenStorage);
} else {
$this->securityContext = $this->getMockBuilder('\\Symfony\\Component\\Security\\Core\\SecurityContextInterface')->getMock();
$this->container->set('security.context', $this->securityContext);
}
$this->templating = $this->getMockBuilder('Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface')->getMock();
$this->container->set('templating', $this->templating);
$this->router = $this->getMockBuilder('Symfony\\Component\\Routing\\RouterInterface')->getMock();
$this->container->set('router', $this->router);
$this->resourceOwner = $this->getMockBuilder('HWI\\Bundle\\OAuthBundle\\OAuth\\ResourceOwnerInterface')->getMock();
$this->resourceOwner->expects($this->any())->method('getUserInformation')->willReturn(new CustomUserResponse());
$this->resourceOwnerMap = $this->getMockBuilder('HWI\\Bundle\\OAuthBundle\\Security\\Http\\ResourceOwnerMap')->disableOriginalConstructor()->getMock();
$this->resourceOwnerMap->expects($this->any())->method('getResourceOwnerByName')->withAnyParameters()->willReturn($this->resourceOwner);
$this->container->set('hwi_oauth.resource_ownermap.default', $this->resourceOwnerMap);
$this->accountConnector = $this->getMockBuilder('HWI\\Bundle\\OAuthBundle\\Connect\\AccountConnectorInterface')->getMock();
$this->container->set('hwi_oauth.account.connector', $this->accountConnector);
$this->oAuthUtils = $this->getMockBuilder('HWI\\Bundle\\OAuthBundle\\Security\\OAuthUtils')->disableOriginalConstructor()->getMock();
$this->container->set('hwi_oauth.security.oauth_utils', $this->oAuthUtils);
$this->userChecker = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock();
$this->container->set('hwi_oauth.user_checker', $this->userChecker);
$this->eventDispatcher = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->getMock();
$this->container->set('event_dispatcher', $this->eventDispatcher);
$this->formFactory = $this->getMockBuilder('Symfony\\Component\\Form\\FormFactoryInterface')->getMock();
$this->container->set('form.factory', $this->formFactory);
$this->session = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface')->getMock();
$this->request = Request::create('/');
$this->request->setSession($this->session);
$this->controller = new ConnectController();
$this->controller->setContainer($this->container);
}
示例11: mapReservedScopeArray
/**
* Ensures settings array defined in a given "reserved scope" are registered properly.
* "Reserved scope" can typically be ConfigResolver::SCOPE_DEFAULT or ConfigResolver::SCOPE_GLOBAL.
*
* @param string $id
* @param array $config
* @param string $scope
*/
private function mapReservedScopeArray($id, array $config, $scope)
{
if (isset($config[$this->siteAccessNodeName][$scope][$id]) && !empty($config[$this->siteAccessNodeName][$scope][$id])) {
$key = "{$this->namespace}.{$scope}.{$id}";
$value = $config[$this->siteAccessNodeName][$scope][$id];
if ($this->container->hasParameter($key)) {
$value = array_merge($this->container->getParameter($key), $value);
}
$this->container->setParameter($key, $value);
}
}
示例12: writeParams
private function writeParams($data = array())
{
$params = array_merge($this->yamlManager->getParameters(), $data);
try {
$this->yamlManager->setParameters($params);
} catch (IOException $e) {
throw new AbortStageException(__f('Cannot write parameters to %s file.', 'custom_parameters.yml'));
}
// setup multilingual
$this->container->setParameter('language_i18n', $data['locale']);
$this->container->setParameter('multilingual', true);
$this->container->setParameter('languageurl', true);
$this->container->setParameter('language_detect', false);
// $_lang = ZLanguage::getInstance();
// $_lang->setup($request);
}
示例13: setParameter
/**
* @param string $name
* @param string $value
*/
protected function setParameter($name, $value)
{
$parameterPrefix = $this->getParameterPrefix();
$this->container->setParameter((strlen($parameterPrefix) > 0 ? strtolower($parameterPrefix) . '.' : '') . $name, $value);
}
示例14: setUpContainer
public function setUpContainer(Kernel $kernel, ContainerInterface $container)
{
$container->setParameter('foo', $kernel->getEnvironment());
}
示例15: getContainerLoader
/**
* Returns a loader for the container.
*
* @param ContainerInterface $container The service container
*
* @return DelegatingLoader The loader
*/
protected function getContainerLoader(ContainerInterface $container)
{
foreach ($this->configuration->getParameters() as $key => $val) {
$container->setParameter($key, $val);
}
$locator = new FileLocator($this);
$resolver = new LoaderResolver(array(new ArrayLoader($container), new XmlFileLoader($container, $locator), new YamlFileLoader($container, $locator), new IniFileLoader($container, $locator), new PhpFileLoader($container, $locator), new ClosureLoader($container)));
return new DelegatingLoader($resolver);
}