本文整理汇总了PHP中Symfony\Component\DependencyInjection\Definition::setPublic方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::setPublic方法的具体用法?PHP Definition::setPublic怎么用?PHP Definition::setPublic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Definition
的用法示例。
在下文中一共展示了Definition::setPublic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEnvironment
/**
* @param ContainerBuilder $container
* @param string $code
* @param Definition $formatter
* @param array $extensions
*
* @return string
*/
public function createEnvironment(ContainerBuilder $container, $code, Definition $formatter, array $extensions)
{
$loader = new Definition('Twig_Loader_String');
$loader->setPublic(false);
$container->setDefinition(sprintf('sonata.formatter.twig.loader.%s', $code), $loader);
$loaderSelector = new Definition('Sonata\\FormatterBundle\\Twig\\Loader\\LoaderSelector', array(new Reference(sprintf('sonata.formatter.twig.loader.%s', $code)), new Reference('twig.loader')));
$loaderSelector->setPublic(false);
$env = new Definition('Twig_Environment', array($loaderSelector, array('debug' => false, 'strict_variables' => false, 'charset' => 'UTF-8')));
$env->setPublic(false);
$container->setDefinition(sprintf('sonata.formatter.twig.env.%s', $code), $env);
$sandboxPolicy = new Definition('Sonata\\FormatterBundle\\Twig\\SecurityPolicyContainerAware', array(new Reference('service_container'), $extensions));
$sandboxPolicy->setPublic(false);
$container->setDefinition(sprintf('sonata.formatter.twig.sandbox.%s.policy', $code), $sandboxPolicy);
$sandbox = new Definition('Twig_Extension_Sandbox', array($sandboxPolicy, true));
$sandbox->setPublic(false);
$container->setDefinition(sprintf('sonata.formatter.twig.sandbox.%s', $code), $sandbox);
$env->addMethodCall('addExtension', array(new Reference(sprintf('sonata.formatter.twig.sandbox.%s', $code))));
foreach ($extensions as $extension) {
$env->addMethodCall('addExtension', array(new Reference($extension)));
}
$lexer = new Definition('Twig_Lexer', array(new Reference(sprintf('sonata.formatter.twig.env.%s', $code)), array('tag_comment' => array('<#', '#>'), 'tag_block' => array('<%', '%>'), 'tag_variable' => array('<%=', '%>'))));
$lexer->setPublic(false);
$container->setDefinition(new Reference(sprintf('sonata.formatter.twig.lexer.%s', $code)), $lexer);
$env->addMethodCall('setLexer', array(new Reference(sprintf('sonata.formatter.twig.lexer.%s', $code))));
return sprintf('sonata.formatter.twig.env.%s', $code);
}
示例2: getConnectionReference
/**
* @param string $name
* @param array $config
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*
* @return \Symfony\Component\DependencyInjection\Reference
*/
private function getConnectionReference($name, array $config, ContainerBuilder $container)
{
if (isset($config['connection_id'])) {
return new Reference($config['connection_id']);
}
$host = $config['host'];
$port = $config['port'];
$connClass = '%doctrine_cache.redis.connection.class%';
$connId = sprintf('doctrine_cache.services.%s_redis.connection', $name);
$connDef = new Definition($connClass);
$connParams = array($host, $port);
if (isset($config['timeout'])) {
$connParams[] = $config['timeout'];
}
$connDef->setPublic(false);
$connDef->addMethodCall('connect', $connParams);
if (isset($config['password'])) {
$password = $config['password'];
$connDef->addMethodCall('auth', array($password));
}
if (isset($config['database'])) {
$database = (int) $config['database'];
$connDef->addMethodCall('select', array($database));
}
$container->setDefinition($connId, $connDef);
return new Reference($connId);
}
示例3: configureTemplate
public function configureTemplate(ContainerBuilder $container, $configs)
{
$pageManager = $container->getDefinition('sonata.page.manager.page');
$snapshotManager = $container->getDefinition('sonata.page.manager.snapshot');
$defaults = array('name' => 'n-a', 'path' => 'SonataPageBundle::layout.html.twig');
if (!isset($configs['default_template'])) {
$configs['default_template'] = 'default';
}
if (!isset($configs['templates'])) {
$configs['templates'] = array('default' => array_merge($defaults, array('name' => 'default')));
}
$definitions = array();
foreach ($configs['templates'] as $code => $info) {
$info = array_merge($defaults, $info);
$definition = new Definition('Sonata\\PageBundle\\Model\\Template');
foreach ($defaults as $key => $value) {
$method = 'set' . ucfirst($key);
$definition->addMethodCall($method, array($info[$key]));
}
$definition->setPublic(false);
$definitions[$code] = $definition;
}
$pageManager->addMethodCall('setTemplates', array($definitions));
$snapshotManager->addMethodCall('setTemplates', array($definitions));
$pageManager->addMethodCall('setDefaultTemplateCode', array($configs['default_template']));
}
示例4: load
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
foreach ($config as $key => $value) {
$container->setParameter('migrations' . '.' . $key, $value);
}
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
$service = $container->getDefinition('migrations.migrator');
$migrationServices = [];
foreach (new \DirectoryIterator($config['dir_name']) as $item) {
if (!$item->isFile()) {
continue;
}
$className = basename($item->getFilename(), '.php');
$migrationDefinition = new Definition($config['namespace'] . '\\' . $className);
$migrationDefinition->setPublic(false);
$migrationServices['migrations.migrations.' . strtolower($className)] = $migrationDefinition;
}
$container->addDefinitions($migrationServices);
foreach (array_keys($migrationServices) as $id) {
$service->addMethodCall('addMigration', [new Reference($id)]);
}
}
示例5: processDefinition
/**
* @param Definition $definition
*/
protected function processDefinition(Definition $definition)
{
if ($definition->isSynthetic()) {
return;
}
if ($definition->getFactoryService() || $definition->getFactoryClass()) {
return;
}
if ($file = $definition->getFile()) {
require_once $file;
}
if (!class_exists($definition->getClass())) {
return;
}
$class = new \ReflectionClass($definition->getClass());
if (!$class->implementsInterface(static::INTERFACE_CLASS)) {
return;
}
$metadata = $this->getMetadataFactory()->getMetadataForClass($definition->getClass());
if (!$metadata instanceof ClassMetadata) {
return;
}
$namespace = $metadata->getNamespace() ?: static::ROOT_NAMESPACE;
$serviceName = static::PROVIDER_PREFIX . substr(sha1($namespace), 0, 10);
if (!$this->container->hasDefinition($serviceName)) {
$cacher = new Definition('Werkint\\Bundle\\CacheBundle\\Service\\CacheProvider', [$this->container->getParameter('kernel.cache_dir') . '/werkint_cache']);
$cacher->setPublic(true);
$cacher->addMethodCall('setNamespace', [$namespace]);
$this->container->setDefinition($serviceName, $cacher);
}
$definition->addMethodCall('setCacheProvider', [new Reference($serviceName)]);
}
示例6: getDataCollectorDefinition
private function getDataCollectorDefinition()
{
$definition = new Definition(ApiClientDataCollector::class, [new Reference('leoza_api_client.profiler')]);
$definition->setPublic(false);
$definition->addTag('data_collector', ['template' => 'LeozaApiClientBundle:DataCollector:ApiClientProfile.html.twig', 'id' => 'leoza_api_client.data_collector']);
return $definition;
}
示例7: registerRequestBinder
private function registerRequestBinder(ContainerBuilder $container)
{
$definition = new Definition(RequestObjectBinder::class, []);
$definition->setAutowired(true);
$definition->setPublic(false);
$container->setDefinition('request_object.request_binder', $definition);
}
示例8: loadConnections
/**
* Registers publisher services in container
*/
protected function loadConnections()
{
foreach ($this->config['connections'] as $key => $connection) {
$protocol = $connection['protocol'];
$host = $connection['host'];
$port = $connection['port'];
$path = $connection['path'];
$auth_key = $connection['auth_key'];
$auth_secret = $connection['auth_secret'];
$hostname = $connection['hostname'];
$ignoreSsl = $connection['ssl_ignore'];
if ($path[0] != '/') {
$path = '/' . $path;
}
$definition = new Definition("Facile\\CrossbarHTTPPublisherBundle\\Publisher\\Factory", array($protocol, $host, $port, $path, $auth_key, $auth_secret, $hostname, $ignoreSsl));
$definition->setPublic(false);
$factoryName = sprintf('facile.crossbar.publisher.factory.%s', $key);
$this->container->setDefinition($factoryName, $definition);
$definition = new Definition("Facile\\CrossbarHTTPPublisherBundle\\Publisher\\Publisher");
if (method_exists($definition, 'setFactory')) {
$definition->setFactory(array(new Reference($factoryName), 'createPublisher'));
} else {
$definition->setFactoryService($factoryName);
$definition->setFactoryMethod('createPublisher');
}
$this->container->setDefinition(sprintf('facile.crossbar.publisher.%s', $key), $definition);
}
}
开发者ID:facile-it,项目名称:crossbar-http-publisher-bundle,代码行数:31,代码来源:FacileCrossbarHTTPPublisherExtension.php
示例9: addProvider
protected function addProvider($name, array $arguments = array())
{
$provider = new Definition('%morbicer_converter.provider.' . $name . '.class%', $arguments);
$provider->setPublic(false)->addTag('morbicer_converter.provider');
$this->container->setDefinition('morbicer_converter.provider.' . $name, $provider);
return $provider;
}
示例10: loadTwigExtension
/**
* Loads the Twig global variable.
*
* @param ContainerBuilder $container
*/
private function loadTwigExtension(ContainerBuilder $container)
{
$service = new Definition('EmanueleMinotto\\FakerBundle\\Twig\\FakerGeneratorExtension', array(new Reference('faker')));
$service->addTag('twig.extension');
$service->setPublic(false);
$container->setDefinition('emanuele.minotto.faker.twig.extension', $service);
}
示例11: processAdapterConfiguration
private function processAdapterConfiguration(array $configuration, ContainerBuilder $container)
{
$definition = new Definition($configuration['class']);
$definition->addArgument($configuration['options']);
$definition->setPublic(false);
$container->setDefinition('search.adapter', $definition);
}
示例12: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$pool = $container->getDefinition('sonata.product.pool');
$calls = $pool->getMethodCalls();
$pool->setMethodCalls(array());
$map = array();
foreach ($calls as $method => $arguments) {
if ($arguments[0] !== '__hack') {
$pool->addMethodCall($arguments[0], $arguments[1]);
continue;
}
foreach ($arguments[1] as $code => $options) {
// define a new ProductDefinition
$definition = new Definition('Sonata\\Component\\Product\\ProductDefinition', array(new Reference($options['provider']), new Reference($options['manager'])));
$definition->setPublic(false);
$container->setDefinition($code, $definition);
$container->getDefinition($options['provider'])->addMethodCall('setCode', array($code));
$pool->addMethodCall('addProduct', array($code, new Reference($code)));
$map[$code] = $container->getDefinition($options['manager'])->getArgument(0);
$container->getDefinition($options['provider'])->addMethodCall('setBasketElementManager', array(new Reference('sonata.basket_element.manager')));
$container->getDefinition($options['provider'])->addMethodCall('setCurrencyPriceCalculator', array(new Reference('sonata.price.currency.calculator')));
$container->getDefinition($options['provider'])->addMethodCall('setProductCategoryManager', array(new Reference('sonata.product_category.product')));
$container->getDefinition($options['provider'])->addMethodCall('setProductCollectionManager', array(new Reference('sonata.product_collection.product')));
$container->getDefinition($options['provider'])->addMethodCall('setOrderElementClassName', array($container->getParameter('sonata.order.order_element.class')));
$container->getDefinition($options['provider'])->addMethodCall('setEventDispatcher', array(new Reference('event_dispatcher')));
if (array_key_exists('variations', $options)) {
$container->getDefinition($options['provider'])->addMethodCall('setVariationFields', array($options['variations']['fields']));
}
}
}
$container->getDefinition('sonata.product.subscriber.orm')->replaceArgument(0, $map);
}
示例13: loadConfigs
/**
* Process the adaptor config configuration.
*
* @param array $config
* @param ContainerBuilder $container
*/
protected function loadConfigs(array $config, ContainerBuilder $container)
{
foreach ($config['configs'] as $name => $arguments) {
if (!$arguments['enabled']) {
continue;
}
$id = 'integrated_channel.config.memory.' . $name;
if ($container->hasDefinition($id)) {
continue;
}
// first create the options and for that we need a unique service id
do {
$id_options = $id . '.options.' . uniqid();
} while ($container->hasDefinition($id_options));
$definition = new Definition('%integrated_channel.config.options.class%');
$definition->setPublic(false);
$definition->setArguments([$arguments['options']]);
$container->setDefinition($id_options, $definition);
// create the config it self
$definition = new Definition('%integrated_channel.config.class%');
$definition->setArguments([$name, $arguments['adaptor'], new Reference($id_options)]);
if ($arguments['channel']) {
foreach ($arguments['channel'] as $channel) {
$definition->addTag('integrated_channel.config', ['channel' => $channel]);
}
} else {
$definition->addTag('integrated_channel.config');
}
$container->setDefinition($id, $definition);
}
}
开发者ID:integratedfordevelopers,项目名称:integrated-channel-bundle,代码行数:37,代码来源:IntegratedChannelExtension.php
示例14: process
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
foreach ($container->findTaggedServiceIds('snc_redis.connection_parameters') as $id => $attr) {
$clientAlias = $attr[0]['clientAlias'];
$parameterDefinition = $container->getDefinition($id);
$parameters = $parameterDefinition->getArgument(0);
if ($parameters['logging']) {
$optionId = sprintf('snc_redis.client.%s_options', $clientAlias);
$option = $container->getDefinition($optionId);
if (1 < count($option->getArguments())) {
throw new \RuntimeException('Please check the predis option arguments.');
}
$arguments = $option->getArgument(0);
$connectionFactoryId = sprintf('snc_redis.%s_connectionfactory', $clientAlias);
$connectionFactoryDef = new Definition($container->getParameter('snc_redis.connection_factory.class'));
$connectionFactoryDef->setPublic(false);
$connectionFactoryDef->addArgument(new Reference(sprintf('snc_redis.client.%s_profile', $clientAlias)));
$connectionFactoryDef->addMethodCall('setConnectionWrapperClass', array($container->getParameter('snc_redis.connection_wrapper.class')));
$connectionFactoryDef->addMethodCall('setLogger', array(new Reference('snc_redis.logger')));
$container->setDefinition($connectionFactoryId, $connectionFactoryDef);
$arguments['connections'] = new Reference($connectionFactoryId);
$option->replaceArgument(0, $arguments);
}
}
}
示例15: configureSitemap
/**
* Configure the sitemap source manager.
*
* @param array $config
* @param ContainerBuilder $container
*/
protected function configureSitemap(array $config, ContainerBuilder $container)
{
$source = $container->getDefinition('sonata.seo.sitemap.manager');
if (method_exists($source, 'setShared')) {
// Symfony 2.8+
$source->setShared(false);
} else {
// For Symfony <2.8 compatibility
$source->setScope(ContainerInterface::SCOPE_PROTOTYPE);
}
foreach ($config['doctrine_orm'] as $pos => $sitemap) {
// define the connectionIterator
$connectionIteratorId = 'sonata.seo.source.doctrine_connection_iterator_' . $pos;
$connectionIterator = new Definition('%sonata.seo.exporter.database_source_iterator.class%', array(new Reference($sitemap['connection']), $sitemap['query']));
$connectionIterator->setPublic(false);
$container->setDefinition($connectionIteratorId, $connectionIterator);
// define the sitemap proxy iterator
$sitemapIteratorId = 'sonata.seo.source.doctrine_sitemap_iterator_' . $pos;
$sitemapIterator = new Definition('%sonata.seo.exporter.sitemap_source_iterator.class%', array(new Reference($connectionIteratorId), new Reference('router'), $sitemap['route'], $sitemap['parameters']));
$sitemapIterator->setPublic(false);
$container->setDefinition($sitemapIteratorId, $sitemapIterator);
$source->addMethodCall('addSource', array($sitemap['group'], new Reference($sitemapIteratorId), $sitemap['types']));
}
foreach ($config['services'] as $service) {
$source->addMethodCall('addSource', array($service['group'], new Reference($service['id']), $service['types']));
}
}