当前位置: 首页>>代码示例>>PHP>>正文


PHP Definition::setFactoryClass方法代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\Definition::setFactoryClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::setFactoryClass方法的具体用法?PHP Definition::setFactoryClass怎么用?PHP Definition::setFactoryClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DependencyInjection\Definition的用法示例。


在下文中一共展示了Definition::setFactoryClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('html_purifier.xml');
     /* Prepend the default configuration. This cannot be defined within the
      * Configuration class, since the root node's children are array
      * prototypes.
      *
      * This cache path may be suppressed by either unsetting the "default"
      * configuration (relying on canBeUnset() on the prototype node) or
      * setting the "Cache.SerializerPath" option to null.
      */
     array_unshift($configs, array('default' => array('Cache.SerializerPath' => '%kernel.cache_dir%/htmlpurifier')));
     $configs = $this->processConfiguration(new Configuration(), $configs);
     $configs = array_map(array($this, 'resolveServices'), $configs);
     $paths = array();
     foreach ($configs as $name => $config) {
         $configDefinition = new Definition('%exercise_html_purifier.config.class%');
         $configDefinition->setFactoryClass('%exercise_html_purifier.config.class%');
         if ('default' === $name) {
             $configDefinition->setFactoryMethod('create')->addArgument($config);
         } else {
             $configDefinition->setFactoryMethod('inherit')->addArgument(new Reference('exercise_html_purifier.config.default'))->addMethodCall('loadArray', array($config));
         }
         $configId = 'exercise_html_purifier.config.' . $name;
         $container->setDefinition($configId, $configDefinition);
         $container->setDefinition('exercise_html_purifier.' . $name, new Definition('%exercise_html_purifier.class%', array(new Reference($configId))));
         if (isset($config['Cache.SerializerPath'])) {
             $paths[] = $config['Cache.SerializerPath'];
         }
     }
     $container->setParameter('exercise_html_purifier.cache_warmer.serializer.paths', array_unique($paths));
 }
开发者ID:nonalweb,项目名称:rc-libre,代码行数:33,代码来源:ExerciseHTMLPurifierExtension.php

示例2: loadDoctrine

 private function loadDoctrine(ContainerBuilder $container, $config)
 {
     $this->loadConfiguration($container, $config);
     $definition = new Definition('Doctrine\\DBAL\\Connection', array(array('driver' => 'pdo_sqlite', 'memory' => true), new Reference('doctrine.configuration')));
     $definition->setFactoryClass('Doctrine\\DBAL\\DriverManager');
     $definition->setFactoryMethod('getConnection');
     $container->setDefinition('doctrine.connection', $definition);
 }
开发者ID:yosmanyga,项目名称:behat-doctrine-dbal-extension,代码行数:8,代码来源:DoctrineDbalExtension.php

示例3: loadDoctrine

 private function loadDoctrine(ContainerBuilder $container, $config)
 {
     $this->loadConfiguration($container, $config);
     $this->loadEventManager($container, $config);
     $definition = new Definition('Doctrine\\ORM\\EntityManager', array(array('driver' => 'pdo_sqlite', 'memory' => true), new Reference('doctrine.configuration'), new Reference('doctrine.event_manager')));
     $definition->setFactoryClass('Doctrine\\ORM\\EntityManager');
     $definition->setFactoryMethod('create');
     $container->setDefinition('doctrine', $definition);
 }
开发者ID:yosmanyga,项目名称:behat-doctrine-extension,代码行数:9,代码来源:DoctrineExtension.php

示例4: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $driver = $container->getDefinition('prezent_doctrine_translatable.driver_chain');
     foreach ($container->getParameter('doctrine.entity_managers') as $name => $manager) {
         $adapter = new Definition('Metadata\\Driver\\DriverInterface', array(new Reference(sprintf('doctrine.orm.%s_metadata_driver', $name))));
         $adapter->setFactoryClass('Prezent\\Doctrine\\Translatable\\Mapping\\Driver\\DoctrineAdapter');
         $adapter->setFactoryMethod('fromMetadataDriver');
         $driver->addMethodCall('addDriver', array($adapter));
     }
 }
开发者ID:alli-govender,项目名称:doctrine-translatable-bundle,代码行数:13,代码来源:DriverChainCompilerPass.php

示例5: testRecognizesNonExistingFactoryMethod

 public function testRecognizesNonExistingFactoryMethod()
 {
     $definition = new Definition('stdClass');
     $definition->setFactoryClass('Matthias\\SymfonyServiceDefinitionValidator\\Tests\\Fixtures\\FactoryClass');
     $definition->setFactoryMethod('nonExistingFactoryMethod');
     $containerBuilder = new ContainerBuilder();
     $validator = new ServiceDefinitionValidator($containerBuilder, $this->createMockDefinitionArgumentsValidator(), $this->createMockMethodCallsValidator());
     $this->setExpectedException('Matthias\\SymfonyServiceDefinitionValidator\\Exception\\MethodNotFoundException');
     $validator->validate($definition);
 }
开发者ID:seclu,项目名称:symfony-service-definition-validator,代码行数:10,代码来源:ServiceDefinitionValidatorTest.php

示例6: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('platinum_pixs_aws.xml');
     $configs = $this->processConfiguration(new Configuration(), $configs);
     $configs['default'] = array();
     foreach ($configs as $name => $config) {
         $definition = new Definition('%platinum_pixs_aws.class%');
         $definition->setFactoryClass('%platinum_pixs_aws.class%')->setFactoryMethod('factory')->setArguments(array($config))->addTag('platinum_pixs_aws');
         $container->setDefinition('platinum_pixs_aws.' . $name, $definition);
     }
 }
开发者ID:eexit,项目名称:aws-symfony2-bundle,代码行数:12,代码来源:PlatinumPixsAwsExtension.php

示例7: create

    /**
     * {@inheritDoc}
     */
    public function create(ContainerBuilder $container, $resolverName, array $config)
    {
        $awsS3ClientDefinition = new Definition('Aws\S3\S3Client');
        $awsS3ClientDefinition->setFactoryClass('Aws\S3\S3Client');
        $awsS3ClientDefinition->setFactoryMethod('factory');
        $awsS3ClientDefinition->addArgument($config['client_config']);
        $awsS3ClientId = 'liip_imagine.cache.resolver.'.$resolverName.'.client';
        $container->setDefinition($awsS3ClientId, $awsS3ClientDefinition);

        $resolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.aws_s3');
        $resolverDefinition->replaceArgument(0, new Reference($awsS3ClientId));
        $resolverDefinition->replaceArgument(1, $config['bucket']);
        $resolverDefinition->replaceArgument(2, $config['acl']);
        $resolverDefinition->replaceArgument(3, array_replace($config['url_options'], $config['get_options']));
        $resolverDefinition->replaceArgument(4, $config['put_options']);
        $resolverId = 'liip_imagine.cache.resolver.'.$resolverName;
        $container->setDefinition($resolverId, $resolverDefinition);

        if (isset($config['cache_prefix'])) {
            $resolverDefinition->addMethodCall('setCachePrefix', array($config['cache_prefix']));
        }

        if ($config['proxies']) {
            $proxiedResolverId = 'liip_imagine.cache.resolver.'.$resolverName.'.proxied';

            $container->setDefinition($proxiedResolverId, $resolverDefinition);

            $proxyResolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.proxy');
            $proxyResolverDefinition->replaceArgument(0, new Reference($proxiedResolverId));
            $proxyResolverDefinition->replaceArgument(1, $config['proxies']);

            $container->setDefinition($resolverId, $proxyResolverDefinition);
        }

        if ($config['cache']) {
            $cachedResolverId = 'liip_imagine.cache.resolver.'.$resolverName.'.cached';

            $container->setDefinition($cachedResolverId, $container->getDefinition($resolverId));

            $cacheResolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.cache');
            $cacheResolverDefinition->replaceArgument(0, new Reference($config['cache']));
            $cacheResolverDefinition->replaceArgument(1, new Reference($cachedResolverId));

            $container->setDefinition($resolverId, $cacheResolverDefinition);
        }

        $container->getDefinition($resolverId)->addTag('liip_imagine.cache.resolver', array(
            'resolver' => $resolverName,
        ));

        return $resolverId;
    }
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:55,代码来源:AwsS3ResolverFactory.php

示例8: createFactoryDefinition

 /**
  * Creates a complex setting factory.
  *
  * The factory has a variable number of arguments.
  * Dynamic settings are added as tupples: first the argument without the leading and trailing $, so that it is not
  * transformed by the config resolver pass, then the argument as a string, so that it does get transformed.
  *
  * @param string $argumentValue The original argument ($var$/$another_var$)
  * @param array $dynamicSettings Array of dynamic settings in $argumentValue
  *
  * @return Definition
  */
 private function createFactoryDefinition($argumentValue, $dynamicSettings)
 {
     $definition = new Definition('stdClass', array($argumentValue));
     $definition->setFactoryClass('eZ\\Bundle\\EzPublishCoreBundle\\DependencyInjection\\Configuration\\ComplexSettings\\ComplexSettingValueFactory');
     $definition->setFactoryMethod('getArgumentValue');
     foreach ($dynamicSettings as $dynamicSetting) {
         // Trim the '$'  so that the dynamic setting doesn't get transformed
         $definition->addArgument(trim($dynamicSetting, '$'));
         // This one will be transformed
         $definition->addArgument($dynamicSetting);
     }
     return $definition;
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:25,代码来源:ComplexSettingsPass.php

示例9: addApis

 /**
  * {@inheritDoc}
  */
 protected function addApis(Definition $paymentDefinition, ContainerBuilder $container, $contextName, array $config)
 {
     $internalConnectorDefinition = new Definition('Klarna_Checkout_ConnectorInterface');
     $internalConnectorDefinition->setFactoryClass('Klarna_Checkout_Connector');
     $internalConnectorDefinition->setFactoryMethod('create');
     $internalConnectorDefinition->addArgument($config['secret']);
     $internalConnectorId = 'payum.context.' . $contextName . '.internal_connector';
     $container->setDefinition($internalConnectorId, $internalConnectorDefinition);
     $connectorDefinition = new Definition('%payum.klarna.checkout.connector.class%');
     $connectorDefinition->addArgument(new Reference($internalConnectorId));
     $connectorDefinition->addArgument($config['merchant_id']);
     $connectorDefinition->addArgument($config['sandbox'] ? Constants::BASE_URI_SANDBOX : Constants::BASE_URI_LIVE);
     $connectorDefinition->addArgument(Constants::CONTENT_TYPE_V2_PLUS_JSON);
     $connectorId = 'payum.context.' . $contextName . '.connector';
     $container->setDefinition($connectorId, $connectorDefinition);
     $paymentDefinition->addMethodCall('addApi', array(new Reference($connectorId)));
 }
开发者ID:sanchojaf,项目名称:oldmytriptocuba,代码行数:20,代码来源:KlarnaCheckoutPaymentFactory.php

示例10: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = $this->getConfiguration($configs, $container);
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('metrics.xml');
     $registry = $container->getDefinition('beberlei_metrics.registry');
     $registry->addMethodCall('setDefaultName', array($config['default']));
     foreach ($config['collectors'] as $name => $collector) {
         $def = new Definition('Beberlei\\Metrics\\Collector\\Collector');
         $def->setFactoryMethod('create');
         $def->setFactoryClass('%beberlei_metrics.factory.class%');
         $def->setArguments(array($collector['type'], $collector));
         $container->setDefinition('beberlei_metrics.collector.' . $name, $def);
         $registry->addMethodCall('set', array($name, new Reference('beberlei_metrics.collector.' . $name)));
     }
 }
开发者ID:rcambien,项目名称:metrics,代码行数:17,代码来源:BeberleiMetricsExtension.php

示例11: 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'));
     $loader->load('services.xml');
     $container->setParameter('lexik_monolog_browser.base_layout', $config['base_layout']);
     $container->setParameter('lexik_monolog_browser.logs_per_page', $config['logs_per_page']);
     $container->setParameter('lexik_monolog_browser.doctrine.table_name', $config['doctrine']['table_name']);
     if (isset($config['doctrine']['connection_name'])) {
         $container->setAlias('lexik_monolog_browser.doctrine_dbal.connection', sprintf('doctrine.dbal.%s_connection', $config['doctrine']['connection_name']));
     }
     if (isset($config['doctrine']['connection'])) {
         $connectionDefinition = new Definition('Doctrine\\DBAL\\Connection', array($config['doctrine']['connection']));
         $connectionDefinition->setFactoryClass('Doctrine\\DBAL\\DriverManager');
         $connectionDefinition->setFactoryMethod('getConnection');
         $container->setDefinition('lexik_monolog_browser.doctrine_dbal.connection', $connectionDefinition);
     }
 }
开发者ID:BlueTM,项目名称:LexikMonologBrowserBundle,代码行数:22,代码来源:LexikMonologBrowserExtension.php

示例12: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('compat.xml');
     foreach ($configs as $config) {
         if (isset($config['default_layout_resource'])) {
             $container->setParameter('whitewashing.zfmvccompat.default_layout_resource', $config['default_layout_resource']);
         }
         if (isset($config['catchall_bundles'])) {
             $container->setParameter('whitewashing.zfmvccompat.catchall_bundles', $config['catchall_bundles']);
         }
         if (isset($config['db_conn'])) {
             $def = new Definition('Zend_Db_Adapter_Abstract');
             $def->setFactoryClass('Zend_Db');
             $def->setFactoryMethod('factory');
             $def->setArguments(array($config['db_conn']['adapter'], $config['db_conn']['params']));
             $container->setDefinition('whitewashing.zfmvcompat.db', $def);
         }
     }
 }
开发者ID:richardfullmer,项目名称:WhitewashingZFMvcCompatBundle,代码行数:20,代码来源:WhitewashingZFMvcCompatExtension.php

示例13: getAllParameters

 private function getAllParameters()
 {
     $service = new Definition();
     $service->setClass('stdClass');
     $service->setAbstract(true);
     $service->setFactoryClass('stdClass');
     $service->setFactoryMethod('get');
     $service->setFactoryService('service.fact');
     $service->setFile('/file.php');
     $service->setLazy(true);
     $service->addMethodCall('methodCall1');
     $service->addMethodCall('methodCall2', array('arg1', 'arg2'));
     $service->addMethodCall('methodCall3', array(new Reference('arg.one')));
     $service->setProperty('prop1', 'val1');
     $service->setProperty('prop2', new Reference('prop.one'));
     $service->setPublic(false);
     $service->setScope('request');
     $service->setSynchronized(true);
     $service->setSynthetic(true);
     return new ServiceElement('service.two', $service);
 }
开发者ID:vierbergenlars,项目名称:manipulator-bundle,代码行数:21,代码来源:ServiceElementTest.php

示例14: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     if (!isset($config['table'])) {
         return;
     }
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $aws_config = array();
     if (isset($config['aws'])) {
         $aws_config = $config['aws'];
     }
     if (!isset($config['dynamo_client_id'])) {
         $dynamoClass = $container->getParameter("dynamo_session_client.class");
         $def = new Definition($dynamoClass);
         $def->setFactoryClass($dynamoClass);
         $def->setFactoryMethod("factory");
         $def->setArguments(array($aws_config));
         $container->setDefinition("dynamo_session_client", $def);
         $config['dynamo_client_id'] = "dynamo_session_client";
     } else {
         $container->removeDefinition("dynamo_session_client");
         $container->setAlias("dynamo_session_client", $config['dynamo_client_id']);
     }
     $container->setParameter("dynamo_session_table", $config['table']);
     $container->setParameter("dynamo_session_read_capacity", $config['read_capacity']);
     $container->setParameter("dynamo_session_write_capacity", $config['write_capacity']);
     $dynamo_config = array('table_name' => $config['table'], 'locking_strategy' => $config['locking_strategy']);
     foreach (array('automatic_gc', 'gc_batch_size', 'session_lifetime') as $key) {
         if (isset($config[$key])) {
             $dynamo_config[$key] = $config[$key];
         }
     }
     $handler = $container->getDefinition("dynamo_session_handler");
     $handler->setArguments(array(new Reference("dynamo_session_client"), $dynamo_config));
 }
开发者ID:okdewit,项目名称:dynamo-session-bundle,代码行数:40,代码来源:GWKDynamoSessionExtension.php

示例15: resolveDefinition

 /**
  * Resolves the definition
  *
  * @param string              $id         The definition identifier
  * @param DefinitionDecorator $definition
  *
  * @return Definition
  */
 private function resolveDefinition($id, DefinitionDecorator $definition)
 {
     if (!$this->container->hasDefinition($parent = $definition->getParent())) {
         throw new RuntimeException(sprintf('The parent definition "%s" defined for definition "%s" does not exist.', $parent, $id));
     }
     $parentDef = $this->container->getDefinition($parent);
     if ($parentDef instanceof DefinitionDecorator) {
         $parentDef = $this->resolveDefinition($parent, $parentDef);
     }
     $this->compiler->addLogMessage($this->formatter->formatResolveInheritance($this, $id, $parent));
     $def = new Definition();
     // merge in parent definition
     // purposely ignored attributes: scope, abstract, tags
     $def->setClass($parentDef->getClass());
     $def->setArguments($parentDef->getArguments());
     $def->setMethodCalls($parentDef->getMethodCalls());
     $def->setProperties($parentDef->getProperties());
     $def->setFactoryClass($parentDef->getFactoryClass());
     $def->setFactoryMethod($parentDef->getFactoryMethod());
     $def->setFactoryService($parentDef->getFactoryService());
     $def->setConfigurator($parentDef->getConfigurator());
     $def->setFile($parentDef->getFile());
     $def->setPublic($parentDef->isPublic());
     // overwrite with values specified in the decorator
     $changes = $definition->getChanges();
     if (isset($changes['class'])) {
         $def->setClass($definition->getClass());
     }
     if (isset($changes['factory_class'])) {
         $def->setFactoryClass($definition->getFactoryClass());
     }
     if (isset($changes['factory_method'])) {
         $def->setFactoryMethod($definition->getFactoryMethod());
     }
     if (isset($changes['factory_service'])) {
         $def->setFactoryService($definition->getFactoryService());
     }
     if (isset($changes['configurator'])) {
         $def->setConfigurator($definition->getConfigurator());
     }
     if (isset($changes['file'])) {
         $def->setFile($definition->getFile());
     }
     if (isset($changes['public'])) {
         $def->setPublic($definition->isPublic());
     }
     // merge arguments
     foreach ($definition->getArguments() as $k => $v) {
         if (is_numeric($k)) {
             $def->addArgument($v);
             continue;
         }
         if (0 !== strpos($k, 'index_')) {
             throw new RuntimeException(sprintf('Invalid argument key "%s" found.', $k));
         }
         $index = (int) substr($k, strlen('index_'));
         $def->replaceArgument($index, $v);
     }
     // merge properties
     foreach ($definition->getProperties() as $k => $v) {
         $def->setProperty($k, $v);
     }
     // append method calls
     if (count($calls = $definition->getMethodCalls()) > 0) {
         $def->setMethodCalls(array_merge($def->getMethodCalls(), $calls));
     }
     // these attributes are always taken from the child
     $def->setAbstract($definition->isAbstract());
     $def->setScope($definition->getScope());
     $def->setTags($definition->getTags());
     // set new definition on container
     $this->container->setDefinition($id, $def);
     return $def;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:82,代码来源:ResolveDefinitionTemplatesPass.php


注:本文中的Symfony\Component\DependencyInjection\Definition::setFactoryClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。