本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::setParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::setParameter方法的具体用法?PHP ContainerBuilder::setParameter怎么用?PHP ContainerBuilder::setParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::setParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configLoad
/**
* Loads the Swift Mailer configuration.
*
* Usage example:
*
* <swiftmailer:config transport="gmail">
* <swiftmailer:username>fabien</swift:username>
* <swiftmailer:password>xxxxx</swift:password>
* <swiftmailer:spool path="/path/to/spool/" />
* </swiftmailer:config>
*
* @param array $config An array of configuration settings
* @param ContainerBuilder $container A ContainerBuilder instance
*/
public function configLoad(array $config, ContainerBuilder $container)
{
if (!$container->hasDefinition('swiftmailer.mailer')) {
$loader = new XmlFileLoader($container, __DIR__ . '/../Resources/config');
$loader->load('swiftmailer.xml');
$container->setAlias('mailer', 'swiftmailer.mailer');
}
$r = new \ReflectionClass('Swift_Message');
$container->setParameter('swiftmailer.base_dir', dirname(dirname(dirname($r->getFilename()))));
$transport = $container->getParameter('swiftmailer.transport.name');
if (array_key_exists('transport', $config)) {
if (null === $config['transport']) {
$transport = 'null';
} elseif ('gmail' === $config['transport']) {
$config['encryption'] = 'ssl';
$config['auth_mode'] = 'login';
$config['host'] = 'smtp.gmail.com';
$transport = 'smtp';
} else {
$transport = $config['transport'];
}
$container->setParameter('swiftmailer.transport.name', $transport);
}
$container->setAlias('swiftmailer.transport', 'swiftmailer.transport.' . $transport);
if (isset($config['encryption']) && 'ssl' === $config['encryption'] && !isset($config['port'])) {
$config['port'] = 465;
}
foreach (array('encryption', 'port', 'host', 'username', 'password', 'auth_mode') as $key) {
if (isset($config[$key])) {
$container->setParameter('swiftmailer.transport.' . $transport . '.' . $key, $config[$key]);
}
}
// spool?
if (isset($config['spool'])) {
$type = isset($config['spool']['type']) ? $config['spool']['type'] : 'file';
$container->setAlias('swiftmailer.transport.real', 'swiftmailer.transport.' . $transport);
$container->setAlias('swiftmailer.transport', 'swiftmailer.transport.spool');
$container->setAlias('swiftmailer.spool', 'swiftmailer.spool.' . $type);
foreach (array('path') as $key) {
if (isset($config['spool'][$key])) {
$container->setParameter('swiftmailer.spool.' . $type . '.' . $key, $config['spool'][$key]);
}
}
}
if (array_key_exists('delivery-address', $config)) {
$config['delivery_address'] = $config['delivery-address'];
}
if (isset($config['delivery_address']) && $config['delivery_address']) {
$container->setParameter('swiftmailer.single_address', $config['delivery_address']);
$container->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.redirecting')));
} else {
$container->setParameter('swiftmailer.single_address', null);
}
if (array_key_exists('disable-delivery', $config)) {
$config['disable_delivery'] = $config['disable-delivery'];
}
if (isset($config['disable_delivery']) && $config['disable_delivery']) {
$container->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.blackhole')));
}
}
示例2: setParameterSection
public function setParameterSection(ContainerBuilder $container, $page, array $captchaConfig)
{
$container->setParameter('captcha.config.' . $page, $captchaConfig);
$container->setParameter('captcha.config.' . $page . '.captcha_id', $captchaConfig['captcha_id']);
$container->setParameter('captcha.config.' . $page . '.user_input_id', $captchaConfig['user_input_id']);
$container->setParameter('captcha.config.' . $page . '.captcha_config_file_path', $captchaConfig['captcha_config_file_path']);
}
示例3: loadPhpcr
public function loadPhpcr($config, XmlFileLoader $loader, ContainerBuilder $container, $useImagine)
{
$container->setParameter($this->getAlias() . '.backend_type_phpcr', true);
$keys = array('string_document_class' => 'string_document.class', 'simple_document_class' => 'simple_document.class', 'container_document_class' => 'container_document.class', 'reference_document_class' => 'reference_document.class', 'menu_document_class' => 'menu_document.class', 'action_document_class' => 'action_document.class', 'imagine_document_class' => 'imagine_document.class', 'slideshow_document_class' => 'slideshow_document.class', 'string_admin_class' => 'string_admin.class', 'simple_admin_class' => 'simple_admin.class', 'container_admin_class' => 'container_admin.class', 'reference_admin_class' => 'reference_admin.class', 'menu_admin_class' => 'menu_admin.class', 'action_admin_class' => 'action_admin.class', 'imagine_admin_class' => 'imagine_admin.class', 'slideshow_admin_class' => 'slideshow_admin.class', 'block_basepath' => 'block_basepath', 'manager_name' => 'manager_name');
foreach ($keys as $sourceKey => $targetKey) {
if (isset($config[$sourceKey])) {
$container->setParameter($this->getAlias() . '.persistence.phpcr.' . $targetKey, $config[$sourceKey]);
}
}
$loader->load('persistence-phpcr.xml');
if ($config['use_sonata_admin']) {
$this->loadSonataPhpcrAdmin($config, $loader, $container, $useImagine);
}
$blockLoader = $container->getDefinition('cmf.block.service');
$blockLoader->replaceArgument(0, new Reference('doctrine_phpcr'));
$blockLoader->addMethodCall('setManagerName', array('%cmf_block.persistence.phpcr.manager_name%'));
$bundles = $container->getParameter('kernel.bundles');
if (isset($bundles['CmfCreateBundle'])) {
$blockLoader = $container->getDefinition('cmf.block.simple');
$blockLoader->addMethodCall('setTemplate', array('CmfBlockBundle:Block:block_simple_createphp.html.twig'));
$blockLoader = $container->getDefinition('cmf.block.string');
$blockLoader->addMethodCall('setTemplate', array('CmfBlockBundle:Block:block_string_createphp.html.twig'));
}
if (isset($bundles['CmfMenuBundle'])) {
$loader->load('menu.xml');
}
}
示例4: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
if (!isset($config['thread_per_page'])) {
throw new \InvalidArgumentException('The "thread_per_page" option must be set in "yosimitso_working_forum"');
}
if (!isset($config['post_per_page'])) {
throw new \InvalidArgumentException('The "post_per_page" option must be set in "yosimitso_working_forum"');
}
if (!isset($config['date_format'])) {
throw new \InvalidArgumentException('The "post_per_page" option must be set in "yosimitso_working_forum"');
}
if (!isset($config['allow_anonymous_read'])) {
throw new \InvalidArgumentException('The "allow_anonymous_read" option must be set in "yosimitso_working_forum"');
}
if (!isset($config['allow_moderator_delete_thread'])) {
throw new \InvalidArgumentException('The "allow_moderator_delete_thread" option must be set in "yosimitso_working_forum"');
}
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
$container->setParameter('yosimitso_working_forum.thread_per_page', $config['thread_per_page']);
$container->setParameter('yosimitso_working_forum.post_per_page', $config['post_per_page']);
$container->setParameter('yosimitso_working_forum.date_format', $config['date_format']);
$container->setParameter('yosimitso_working_forum.allow_anonymous_read', $config['allow_anonymous_read']);
$container->setParameter('yosimitso_working_forum.allow_moderator_delete_thread', $config['allow_moderator_delete_thread']);
}
示例5: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
if (!in_array(strtolower($config['db_driver']), array('orm'))) {
throw new \InvalidArgumentException(sprintf('Invalid database driver (bait_poll.db_driver) "%s".', $config['db_driver']));
}
$loader->load(sprintf('%s.xml', $config['db_driver']));
$container->setParameter('bait_poll.model_manager_name', $config['model_manager_name']);
$container->setParameter('bait_poll.form.type', $config['form']['type']);
$container->setParameter('bait_poll.form.name', $config['form']['name']);
$container->setAlias('bait_poll.form.factory', $config['form']['factory']);
$container->setParameter('bait_poll.poll.class', $config['poll']['class']);
$container->setParameter('bait_poll.field.class', $config['field']['class']);
$container->setParameter('bait_poll.vote.class', $config['vote']['class']);
$container->setParameter('bait_poll.form.template', $config['form']['template']);
$container->setParameter('bait_poll.form.theme', $config['form']['theme']);
$container->setAlias('bait_poll.vote.manager', $config['vote']['manager']);
$container->setAlias('bait_poll.poll.manager', $config['poll']['manager']);
$loader->load('form.xml');
$container->setParameter('bait_poll.cookie.prefix', $config['cookie']['prefix']);
$container->setParameter('bait_poll.cookie.duration', $config['cookie']['duration']);
$loader->load('poll.xml');
}
示例6: load
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load(sprintf('services.%s.yml', $config['db_driver']));
$container->setParameter($this->getAlias() . '.db_driver', $config['db_driver']);
$container->setParameter($this->getAlias() . '.model_manager_name', $config['model_manager_name']);
$container->setParameter($this->getAlias() . '.cronjob_class', $config['cronjob_class']);
$container->setParameter($this->getAlias() . '.cronjob_console', $config['cronjob_console']);
$container->setParameter($this->getAlias() . '.logs_path', $config['logs_path']);
if ('orm' === $config['db_driver']) {
$managerService = $this->getAlias() . '.entity_manager';
$doctrineService = 'doctrine';
} else {
$managerService = '';
$doctrineService = '';
}
$definition = $container->getDefinition($managerService);
if (method_exists($definition, 'setFactory')) {
$definition->setFactory(array(new Reference($doctrineService), 'getManager'));
} else {
$definition->setFactoryService($doctrineService);
$definition->setFactoryMethod('getManager');
}
$container->setAlias($this->getAlias() . '.manager', $config['crontab_manager']);
$definition = $container->getDefinition($config['crontab_manager']);
$definition->addMethodCall('registryConfigCronjobs', array($config['jobs']));
$loader->load('services.yml');
}
示例7: load
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(array(__DIR__ . '/../Resources/config')));
$loader->load('services.xml');
$container->setParameter('jms_i18n_routing.default_locale', $config['default_locale']);
$container->setParameter('jms_i18n_routing.locales', $config['locales']);
$container->setParameter('jms_i18n_routing.catalogue', $config['catalogue']);
$container->setParameter('jms_i18n_routing.strategy', $config['strategy']);
$this->addClassesToCompile(array($container->getDefinition('jms_i18n_routing.router')->getClass()));
if ('prefix' === $config['strategy']) {
$container->getDefinition('jms_i18n_routing.locale_choosing_listener')->setPublic(true)->addTag('kernel.event_listener', array('event' => 'kernel.exception', 'priority' => 128));
}
if ($config['hosts']) {
$container->getDefinition('jms_i18n_routing.router')->addMethodCall('setHostMap', array($config['hosts']));
$container->getDefinition('jms_i18n_routing.locale_changing_listener')->setPublic(true)->addTag('kernel.event_listener', array('event' => 'kernel.request', 'priority' => 120))->addArgument(array_flip($config['hosts']));
$this->addClassesToCompile(array($container->getDefinition('jms_i18n_routing.locale_changing_listener')->getClass()));
}
// remove route extractor if JMSTranslationBundle is not enabled to avoid any problems
$bundles = $container->getParameter('kernel.bundles');
if (!isset($bundles['JMSTranslationBundle'])) {
$container->removeDefinition('jms_i18n_routing.route_translation_extractor');
}
}
示例8: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$container->setParameter('enhavo_app.stylesheets', $config['stylesheets']);
$container->setParameter('enhavo_app.javascripts', $config['javascripts']);
$container->setParameter('enhavo_app.menu', $config['menu']);
$container->setParameter('enhavo_app.show_version', $config['show_version']);
$container->setParameter('enhavo_app.show_branding', $config['show_branding']);
$container->setParameter('enhavo_app.logo_path', $config['logo_path']);
$container->setParameter('enhavo_app.login_redirect', $config['login_redirect']);
$container->setParameter('enhavo_app.template', $config['template']);
$container->setParameter('enhavo_app.route.url_resolver', $config['route']['url_resolver']);
$container->setParameter('enhavo_app.route.auto_generator', $config['route']['auto_generator']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services/services.yml');
$loader->load('services/twig.yml');
$loader->load('services/viewer.yml');
$loader->load('services/block.yml');
$loader->load('services/button.yml');
$loader->load('services/routing.yml');
$loader->load('services/form.yml');
$loader->load('services/table.yml');
$loader->load('services/action.yml');
$loader->load('services/batch.yml');
$loader->load('services/menu.yml');
}
示例9: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
//generate_translation
$container->setParameter('dev_generator_tool.generate_translation', $config['generate_translation']);
//dir_skeleton
$container->setParameter('dev_generator_tool.dir_skeleton', $config['dir_skeleton']);
//core
$container->setParameter('dev_generator_tool.bundle.core.path', $config['bundle']['core_path']);
$bundleName = str_replace('/', '', $config['bundle']['core_path']);
$container->setParameter('dev_generator_tool.bundle.core.name', $bundleName);
$bundleNs = str_replace('/', '\\', $config['bundle']['core_path']);
$container->setParameter('dev_generator_tool.bundle.core.ns', $bundleNs);
$baseNs = explode('\\', $bundleNs)[0];
$container->setParameter('dev_generator_tool.bundle.core.base_ns', $baseNs);
//web
$container->setParameter('dev_generator_tool.bundle.web.path', $config['bundle']['web_path']);
$bundleName = str_replace('/', '', $config['bundle']['web_path']);
$container->setParameter('dev_generator_tool.bundle.web.name', $bundleName);
$bundleNs = str_replace('/', '\\', $config['bundle']['web_path']);
$container->setParameter('dev_generator_tool.bundle.web.ns', $bundleNs);
$baseNs = explode('\\', $bundleNs)[0];
$container->setParameter('dev_generator_tool.bundle.web.base_ns', $baseNs);
}
示例10: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
//Create configuration object
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
//Set orm-service in array of services
$services = array('orm' => 'orm-services');
//set supported encryptor classes
$supportedEncryptorClasses = self::$supportedEncryptorClasses;
//If no secret key is set, check for framework secret, otherwise throw exception
if (empty($config['secret_key'])) {
if ($container->hasParameter('secret')) {
$config['secret_key'] = $container->getParameter('secret');
} else {
throw new \RuntimeException('You must provide "secret_key" for DoctrineEncryptBundle or "secret" for framework');
}
}
//If empty encryptor class, use Rijndael 256 encryptor
if (empty($config['encryptor_class'])) {
if (isset($config['encryptor']) and isset($supportedEncryptorClasses[$config['encryptor']])) {
$config['encryptor_class'] = $supportedEncryptorClasses[$config['encryptor']];
} else {
$config['encryptor_class'] = $supportedEncryptorClasses['rijndael256'];
}
}
//Set parameters
$container->setParameter('ambta_doctrine_encrypt.encryptor_class_name', $config['encryptor_class']);
$container->setParameter('ambta_doctrine_encrypt.secret_key', $config['secret_key']);
//Load service file
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load(sprintf('%s.yml', $services['orm']));
}
示例11: process
/**
* Passes MinkExtension's base_url parameter
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
$frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path');
global $_FILE_TO_URL_MAPPING;
if ($container->getParameter('behat.mink.base_url')) {
// If base_url is already defined, also set it in the SilverStripe mapping
$_FILE_TO_URL_MAPPING[dirname($frameworkPath)] = $container->getParameter('behat.mink.base_url');
} else {
if ($envPath = $this->findEnvironmentConfigFile($frameworkPath)) {
// Otherwise try to retrieve it from _ss_environment
include_once $envPath;
if (isset($_FILE_TO_URL_MAPPING) && !($container->hasParameter('behat.mink.base_url') && $container->getParameter('behat.mink.base_url'))) {
$baseUrl = $this->findBaseUrlFromMapping(dirname($frameworkPath), $_FILE_TO_URL_MAPPING);
if ($baseUrl) {
$container->setParameter('behat.mink.base_url', $baseUrl);
}
}
}
}
if (!$container->getParameter('behat.mink.base_url')) {
throw new \InvalidArgumentException('"base_url" not configured. Please specify it in your behat.yml configuration, ' . 'or in your _ss_environment.php configuration through $_FILE_TO_URL_MAPPING');
}
// The Behat\MinkExtension\Extension class copies configuration into an internal hash,
// we need to follow this pattern to propagate our changes.
$parameters = $container->getParameter('behat.mink.parameters');
$parameters['base_url'] = $container->getParameter('behat.mink.base_url');
$container->setParameter('behat.mink.parameters', $parameters);
}
示例12: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$container->setParameter('rs_queue.queues', $config['queues']);
$container->setParameter('rs_queue.serializer.class', $config['serializer']);
$container->setParameter('rs_queue.server.redis', $config['server']['redis']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
// BC sf < 2.6
$definition = $container->getDefinition('rs_queue.serializer');
if (method_exists($definition, 'setFactory')) {
$definition->setFactory(array(new Reference('rs_queue.serializer.factory'), 'get'));
} else {
$definition->setFactoryService('rs_queue.serializer.factory');
$definition->setFactoryMethod('get');
}
// BC sf < 2.6
$definition = $container->getDefinition('rs_queue.redis');
if (method_exists($definition, 'setFactory')) {
$definition->setFactory(array(new Reference('rs_queue.redis.factory'), 'get'));
} else {
$definition->setFactoryService('rs_queue.redis.factory');
$definition->setFactoryMethod('get');
}
}
示例13: load
/**
* Loads a specific configuration.
*
* @param array $configs An array of configuration values
* @param ContainerBuilder $container A ContainerBuilder instance
*
* @throws InvalidArgumentException When provided tag is not defined in this extension
*/
public function load(array $configs, ContainerBuilder $container)
{
$container->setParameter('security.acl.permission.map.class', 'Kunstmaan\\AdminBundle\\Helper\\Security\\Acl\\Permission\\PermissionMap');
$container->setParameter('version_checker.url', 'http://bundles.kunstmaan.be/version-check');
$container->setParameter('version_checker.timeframe', 60 * 60 * 24);
$container->setParameter('version_checker.enabled', true);
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
if (array_key_exists('dashboard_route', $config)) {
$container->setParameter('kunstmaan_admin.dashboard_route', $config['dashboard_route']);
}
if (array_key_exists('admin_password', $config)) {
$container->setParameter('kunstmaan_admin.admin_password', $config['admin_password']);
}
$container->setParameter('kunstmaan_admin.admin_locales', $config['admin_locales']);
$container->setParameter('kunstmaan_admin.default_admin_locale', $config['default_admin_locale']);
$container->setParameter('kunstmaan_admin.session_security.ip_check', $config['session_security']['ip_check']);
$container->setParameter('kunstmaan_admin.session_security.user_agent_check', $config['session_security']['user_agent_check']);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
if (!empty($config['enable_console_exception_listener']) && $config['enable_console_exception_listener']) {
$loader->load('console_listener.yml');
}
if (0 !== sizeof($config['menu_items'])) {
$this->addSimpleMenuAdaptor($container, $config['menu_items']);
}
}
示例14: testPredefinedDiscovery
public function testPredefinedDiscovery()
{
$this->container->setParameter('kernel.debug', false);
$this->load(['service' => ['name' => 'phpunit'], 'discovery' => ['type' => 'predefined', 'endpoints' => ['name' => ['http://foo.com', 'https://foo.com']]]]);
$driver = $this->container->get('seven_service_bus.discovery');
$this->assertInstanceOf(PredefinedDiscovery::class, $driver);
}
示例15: load
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
if (array_key_exists('incident', $config)) {
$container->setParameter('zimban.incident.lifetime', $config['incident']['lifetime']);
}
if (array_key_exists('banner', $config)) {
$container->setParameter('zimban.banner.incidents_to_ban', $config['banner']['incidents_to_ban']);
$container->setParameter('zimban.banner.ban_time_frame', $config['banner']['ban_time_frame']);
}
if (array_key_exists('enabled', $config)) {
if ($container->hasDefinition('zimban.listener.security_hook_listener')) {
$definition = $container->getDefinition('zimban.listener.security_hook_listener');
if (!$definition->hasTag('kernel.event_subscriber') && $config['enabled']) {
$definition->addTag('kernel.event_subscriber', array());
}
if (!$config['enabled']) {
$container->removeDefinition('zimban.listener.security_hook_listener');
}
}
}
}