setParameter() public method

Sets a parameter.
public setParameter ( string $name, mixed $value )
$name string The parameter name
$value mixed The parameter value
 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));
 }
 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'));
 }
Example #3
0
 /**
  * @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);
 }
Example #4
0
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');
}
 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());
     }
 }
 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);
 }
 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);
         }
     }
 }
Example #8
0
 /**
  * @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);
 }
 /**
  * @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);
         }
     }
 }
 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);
 }
Example #11
0
 /**
  * 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);
     }
 }
Example #12
0
 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);
 }
 /**
  * @param string $name
  * @param string $value
  */
 protected function setParameter($name, $value)
 {
     $parameterPrefix = $this->getParameterPrefix();
     $this->container->setParameter((strlen($parameterPrefix) > 0 ? strtolower($parameterPrefix) . '.' : '') . $name, $value);
 }
 public function setUpContainer(Kernel $kernel, ContainerInterface $container)
 {
     $container->setParameter('foo', $kernel->getEnvironment());
 }
Example #15
0
 /**
  * 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);
 }
 /**
  * @dataProvider provideWarmerNotExecuted
  */
 public function testWarmerNotExecuted($autoGenerate)
 {
     $this->container->setParameter('doctrine_mongodb.odm.auto_generate_hydrator_classes', $autoGenerate);
     $this->hydratorMock->expects($this->exactly(0))->method('generateHydratorClasses');
     $this->warmer->warmUp('meh');
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 public function setParameter($name, $value)
 {
     $this->container->setParameter($name, $value);
 }
 /**
  * @param ContainerInterface $container
  * @param $configs
  */
 private function setupBundleConfigs(ContainerInterface $container, $configs)
 {
     $globalConfig = $configs['global'];
     //set image_render config as param
     if (isset($globalConfig['image_render'])) {
         $container->setParameter('ep_display.config.image_render', $globalConfig['image_render']);
     } else {
         $container->setParameter('ep_display.config.image_render', true);
     }
     //set file_render config as param
     if (isset($globalConfig['file_render'])) {
         $container->setParameter('ep_display.config.file_render', $globalConfig['file_render']);
     } else {
         $container->setParameter('ep_display.config.file_render', true);
     }
     //set templating config as param
     if (isset($globalConfig['template'])) {
         $container->setParameter('ep_display.config.template', $globalConfig['template']);
     } else {
         $container->setParameter('ep_display.config.template', 'EPDisplayBundle:display.html.twig');
     }
     //set exclude_vars config as param
     if (isset($globalConfig['exclude_vars'])) {
         $container->setParameter('ep_display.config.exclude_vars', $globalConfig['exclude_vars']);
     } else {
         $container->setParameter('ep_display.config.exclude_vars', []);
     }
     //set array_collection_render config as param
     if (isset($globalConfig['array_collection_render'])) {
         $container->setParameter('ep_display.config.array_collection_render', $globalConfig['array_collection_render']);
     } else {
         $container->setParameter('ep_display.config.array_collection_render', true);
     }
     //set collection_item_count config as param
     if (isset($globalConfig['collection_item_count'])) {
         $container->setParameter('ep_display.config.collection_item_count', $globalConfig['collection_item_count']);
     } else {
         $container->setParameter('ep_display.config.collection_item_count', 10);
     }
     return;
 }
Example #19
0
 /**
  * Tests that Container::setParameter() in a frozen case works properly.
  *
  * @covers ::setParameter
  *
  * @expectedException LogicException
  */
 public function testSetParameterWithFrozenContainer()
 {
     $this->container = new $this->containerClass($this->containerDefinition);
     $this->container->setParameter('some_config', 'new_value');
 }
 /**
  * @param ContainerInterface $container
  * @param $key
  * @param $value
  * @param null $type
  */
 protected function setParameter(ContainerInterface $container, $key, $value, $type = null)
 {
     $container->setParameter(Configuration::ROOT . '.' . $this->webSpaceKey . ($type ? '.' . $type : '') . '.' . $key, $value);
 }
Example #21
0
 /**
  * Set a parameter.
  *
  * @param string $name  The parameter name
  * @param mixed  $value The parameter value
  *
  * @return void
  *
  * @api
  * @since 4.0.0
  */
 public function setParameter($name, $value)
 {
     $this->_underlyingSymfonyContainer->setParameter($name, $value);
 }