本文整理汇总了PHP中Symfony\Components\DependencyInjection\BuilderConfiguration类的典型用法代码示例。如果您正苦于以下问题:PHP BuilderConfiguration类的具体用法?PHP BuilderConfiguration怎么用?PHP BuilderConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BuilderConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: barLoad
public function barLoad(array $config)
{
$configuration = new BuilderConfiguration();
$configuration->setDefinition('project.service.bar', new Definition('FooClass'));
$configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');
return $configuration;
}
示例2: ormLoad
/**
* Loads the Doctrine ORM configuration.
*
* @param array $config A configuration array
*
* @return BuilderConfiguration A BuilderConfiguration instance
*/
public function ormLoad($config)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->merge($loader->load($this->resources['orm']));
return $configuration;
}
示例3: buildContainer
public function buildContainer(ContainerInterface $container)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__ . '/Resources/config');
$configuration->merge($loader->load('config.xml'));
$configuration->merge($loader->load('logger.xml'));
return $configuration;
}
示例4: configLoad
public function configLoad($config)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->merge($loader->load('twig.xml'));
$configuration->setParameter('twig_options', array_replace($configuration->getParameter('twig_options'), $config));
return $configuration;
}
示例5: configLoad
public function configLoad($config, BuilderConfiguration $configuration)
{
if (!$configuration->hasDefinition('twig')) {
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->merge($loader->load('twig.xml'));
}
$configuration->setParameter('twig.options', array_replace($configuration->getParameter('twig.options'), $config));
}
示例6: odmLoad
public function odmLoad($config)
{
$configuration = new BuilderConfiguration();
$defaultConfiguration = array_merge(array('connection' => 'mongodb://localhost:27017', 'params' => array('connected' => true)), $config);
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->setParameter('mongo.connection', $defaultConfiguration['connection']);
$configuration->setParameter('mongo.params', $defaultConfiguration['params']);
$configuration->merge($loader->load($this->resources['odm']));
return $configuration;
}
示例7: configLoad
public function configLoad($config)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->merge($loader->load('collectors.xml'));
if (isset($config['toolbar']) && $config['toolbar']) {
$configuration->merge($loader->load('toolbar.xml'));
}
return $configuration;
}
示例8: merge
/**
* Merges a BuilderConfiguration with the current one.
*
* @param BuilderConfiguration $configuration
*
* @return BuilderConfiguration The current instance
*/
public function merge(BuilderConfiguration $configuration = null)
{
if (null === $configuration) {
return;
}
$this->addDefinitions($configuration->getDefinitions());
$this->addAliases($configuration->getAliases());
$this->addParameters($configuration->getParameters());
foreach ($configuration->getResources() as $resource) {
$this->addResource($resource);
}
return $this;
}
示例9: execute
/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$kernel = $this->container->getKernelService();
$container = new Builder($kernel->getDefaultParameters());
$configuration = new BuilderConfiguration();
foreach ($kernel->getBundles() as $bundle) {
$configuration->merge($bundle->buildContainer($container));
}
$configuration->merge($kernel->registerContainerConfiguration());
$container->merge($configuration);
$kernel->optimizeContainer($container);
$container->setService('kernel', $kernel);
$dumper = new GraphvizDumper($container);
$output->write($dumper->dump(), Output::OUTPUT_RAW);
}
示例10: buildContainer
/**
* Customizes the Container instance.
*
* @param Symfony\Components\DependencyInjection\ContainerInterface $container A ContainerInterface instance
*
* @return Symfony\Components\DependencyInjection\BuilderConfiguration A BuilderConfiguration instance
*/
public function buildContainer(ContainerInterface $container)
{
Loader::registerExtension(new WebExtension($container->getParameter('kernel.bundle_dirs'), $container->getParameter('kernel.bundles')));
$dirs = array('%kernel.root_dir%/views/%%bundle%%/%%controller%%/%%name%%%%format%%.%%renderer%%');
foreach ($container->getParameter('kernel.bundle_dirs') as $dir) {
$dirs[] = $dir . '/%%bundle%%/Resources/views/%%controller%%/%%name%%%%format%%.%%renderer%%';
}
$container->setParameter('templating.loader.filesystem.path', $dirs);
$configuration = new BuilderConfiguration();
if ($container->getParameter('kernel.debug')) {
$loader = new XmlFileLoader(__DIR__ . '/Resources/config');
$configuration->merge($loader->load('debug.xml'));
}
return $configuration;
}
示例11: load
/**
* Loads a resource.
*
* @param string $file An INI file path
*
* @return BuilderConfiguration A BuilderConfiguration instance
*
* @throws \InvalidArgumentException When ini file is not valid
*/
public function load($file)
{
$path = $this->findFile($file);
$configuration = new BuilderConfiguration();
$configuration->addResource(new FileResource($path));
$result = parse_ini_file($path, true);
if (false === $result || array() === $result) {
throw new \InvalidArgumentException(sprintf('The %s file is not valid.', $file));
}
if (isset($result['parameters']) && is_array($result['parameters'])) {
foreach ($result['parameters'] as $key => $value) {
$configuration->setParameter(strtolower($key), $value);
}
}
return $configuration;
}
示例12: debugLoad
public function debugLoad($config)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->merge($loader->load($this->resources['debug']));
if (isset($config['exception']) && $config['exception']) {
$configuration->merge($loader->load('debug_exception_handler.xml'));
}
if (isset($config['toolbar']) && $config['toolbar']) {
$configuration->merge($loader->load('debug_data_collector.xml'));
$configuration->merge($loader->load('debug_web_debug_toolbar.xml'));
}
if (isset($config['ide']) && 'textmate' === $config['ide']) {
$configuration->setParameter('web_debug.file_link_format', 'txmt://open?url=file://%%f&line=%%l');
}
$configuration->setAlias('event_dispatcher', 'debug.event_dispatcher');
return $configuration;
}
示例13: configLoad
public function configLoad($config, BuilderConfiguration $configuration)
{
if (isset($config['charset'])) {
$configuration->setParameter('kernel.charset', $config['charset']);
}
if (!array_key_exists('compilation', $config)) {
$classes = array('Symfony\\Components\\Routing\\Router', 'Symfony\\Components\\Routing\\RouterInterface', 'Symfony\\Components\\EventDispatcher\\Event', 'Symfony\\Components\\Routing\\Matcher\\UrlMatcherInterface', 'Symfony\\Components\\Routing\\Matcher\\UrlMatcher', 'Symfony\\Components\\HttpKernel\\HttpKernel', 'Symfony\\Components\\HttpKernel\\Request', 'Symfony\\Components\\HttpKernel\\Response', 'Symfony\\Components\\HttpKernel\\ResponseListener', 'Symfony\\Components\\Templating\\Loader\\LoaderInterface', 'Symfony\\Components\\Templating\\Loader\\Loader', 'Symfony\\Components\\Templating\\Loader\\FilesystemLoader', 'Symfony\\Components\\Templating\\Engine', 'Symfony\\Components\\Templating\\Renderer\\RendererInterface', 'Symfony\\Components\\Templating\\Renderer\\Renderer', 'Symfony\\Components\\Templating\\Renderer\\PhpRenderer', 'Symfony\\Components\\Templating\\Storage\\Storage', 'Symfony\\Components\\Templating\\Storage\\FileStorage', 'Symfony\\Framework\\FrameworkBundle\\RequestListener', 'Symfony\\Framework\\FrameworkBundle\\Controller', 'Symfony\\Framework\\FrameworkBundle\\Controller\\ControllerLoaderListener', 'Symfony\\Framework\\FrameworkBundle\\Templating\\Engine');
} else {
$classes = array();
foreach (explode("\n", $config['compilation']) as $class) {
if ($class) {
$classes[] = trim($class);
}
}
}
$configuration->setParameter('kernel.compiled_classes', $classes);
if (array_key_exists('error_handler_level', $config)) {
$configuration->setParameter('error_handler.level', $config['error_handler_level']);
}
return $configuration;
}
示例14: mailerLoad
/**
* Loads the Swift Mailer configuration.
*
* Usage example:
*
* <swift:mailer transport="gmail" delivery_strategy="spool">
* <swift:username>fabien</swift:username>
* <swift:password>xxxxx</swift:password>
* <swift:spool path="/path/to/spool/" />
* </swift:mailer>
*
* @param array $config A configuration array
*
* @return BuilderConfiguration A BuilderConfiguration instance
*/
public function mailerLoad($config)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->merge($loader->load($this->resources['mailer']));
if (isset($config['transport']) && null === $config['transport']) {
$config['transport'] = 'null';
} elseif (!isset($config['transport'])) {
$config['transport'] = 'smtp';
} elseif ('gmail' === $config['transport']) {
$config['encryption'] = 'ssl';
$config['auth_mode'] = 'login';
$config['host'] = 'smtp.gmail.com';
$config['transport'] = 'smtp';
}
$configuration->setAlias('swiftmailer.transport', 'swiftmailer.transport.' . $config['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])) {
$configuration->setParameter('swiftmailer.transport.' . $config['transport'] . '.' . $key, $config[$key]);
}
}
// spool?
if (isset($config['spool'])) {
$type = isset($config['type']) ? $config['type'] : 'file';
$configuration->setAlias('swiftmailer.transport.real', 'swiftmailer.transport.' . $config['transport']);
$configuration->setAlias('swiftmailer.transport', 'swiftmailer.transport.spool');
$configuration->setAlias('swiftmailer.spool', 'swiftmailer.spool.' . $type);
foreach (array('path') as $key) {
if (isset($config['spool'][$key])) {
$configuration->setParameter('swiftmailer.spool.' . $type . '.' . $key, $config['spool'][$key]);
}
}
}
$configuration->setAlias('mailer', 'swiftmailer.mailer');
return $configuration;
}
示例15: dbalLoad
/**
* Loads the DBAL configuration.
*
* @param array $config A configuration array
*
* @return BuilderConfiguration A BuilderConfiguration instance
*/
public function dbalLoad($config)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
$configuration->merge($loader->load($this->resources['propel']));
$defaultConnection = array('driver' => 'mysql', 'user' => 'root', 'password' => null, 'dsn' => null, 'classname' => 'DebugPDO', 'options' => array(), 'attributes' => array(), 'settings' => array('charset' => array('value' => 'UTF8')));
$config['default_connection'] = isset($config['default_connection']) ? $config['default_connection'] : 'default';
$connections = array();
if (isset($config['connections'])) {
foreach ($config['connections'] as $name => $connection) {
$connections[isset($connection['id']) ? $connection['id'] : $name] = $connection;
}
} else {
$connections = array($config['default_connection'] => $config);
}
$c = array('log' => array('level' => 7), 'datasources' => array());
foreach ($connections as $name => $connection) {
$connection = array_replace($defaultConnection, $connection);
$c['datasources'][$name] = array('adapter' => $connection['driver'], 'connection' => array('dsn' => $connection['dsn'], 'user' => $connection['user'], 'password' => $connection['password'], 'classname' => $connection['classname'], 'options' => $connection['options'], 'attributes' => $connection['attributes'], 'settings' => $connection['settings']));
}
$configuration->getDefinition('propel.configuration')->setArguments(array($c));
return $configuration;
}