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


PHP Definition::setClass方法代码示例

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


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

示例1: loadRegistrationSubscriber

 private function loadRegistrationSubscriber(ContainerBuilder $container, array $config)
 {
     $definition = new Definition();
     if (array_key_exists('class', $config)) {
         $definition->setClass($config['class']);
     } else {
         $definition->setClass('Tahoe\\Bundle\\MultiTenancyBundle\\EventSubscriber\\RegistrationSubscriber');
     }
     $definition->addTag('kernel.event_subscriber');
     if (array_key_exists('manager', $config)) {
         $definition->addArgument(new Reference($config['manager']));
     } else {
         $definition->addArgument(new Reference('tahoe.multi_tenancy.registration_manager'));
     }
     if (array_key_exists('router', $config)) {
         $definition->addMethodCall('setRouter', array(new Reference($config['router'])));
     } else {
         $definition->addMethodCall('setRouter', array(new Reference('tahoe.multi_tenancy.tenant_aware_router')));
     }
     if (array_key_exists('redirect_route', $config)) {
         $container->setParameter(sprintf("%s.registration_subscriber.redirect_route", $this->getAlias()), $config['redirect_route']);
     } else {
         // default parameter
         $container->setParameter(sprintf("%s.registration_subscriber.redirect_route", $this->getAlias()), 'dashboard');
     }
     // we add the definition to the container
     $container->setDefinition('tahoe.multi_tenancy.registration_subscriber', $definition);
 }
开发者ID:adrianoaguiar,项目名称:multi-tenancy-bundle,代码行数:28,代码来源:TahoeMultiTenancyExtension.php

示例2: addFormType

 protected function addFormType(array $config, ContainerBuilder $container, $method)
 {
     $fullMethod = 'multisafepay_' . $method;
     $definition = new Definition();
     $definition->setClass('%ruudk_payment_multisafepay.form.default_type.class%');
     $definition->addArgument($fullMethod);
     if ($method === 'ideal') {
         $definition->setClass('%ruudk_payment_multisafepay.form.ideal_type.class%');
         $definition->addArgument(sprintf('%%ruudk_payment_multisafepay.ideal.issuers.%s%%', $config['test'] ? 'test' : 'live'));
     }
     $definition->addTag('payment.method_form_type');
     $definition->addTag('form.type', array('alias' => $fullMethod));
     $container->setDefinition(sprintf('ruudk_payment_multisafepay.form.%s_type', $method), $definition);
 }
开发者ID:ruudk,项目名称:payment-multisafepay-bundle,代码行数:14,代码来源:RuudkPaymentMultisafepayExtension.php

示例3: addFormType

 protected function addFormType(array $config, ContainerBuilder $container, $method)
 {
     $mollieMethod = 'mollie_' . $method;
     $definition = new Definition();
     $definition->setClass('%ruudk_payment_mollie.form.mollie_type.class%');
     $definition->addArgument($mollieMethod);
     if ($method === 'ideal') {
         $definition->setClass('%ruudk_payment_mollie.form.ideal_type.class%');
         $definition->addArgument(sprintf('%%ruudk_payment_mollie.ideal.issuers.%s%%', substr($config['api_key'], 0, 4) == 'live' ? 'live' : 'test'));
     }
     $definition->addTag('payment.method_form_type');
     $definition->addTag('form.type', array('alias' => $mollieMethod));
     $container->setDefinition(sprintf('ruudk_payment_mollie.form.%s_type', $method), $definition);
 }
开发者ID:insparcs,项目名称:PaymentMollieBundle,代码行数:14,代码来源:RuudkPaymentMollieExtension.php

示例4: addFormType

 protected function addFormType(ContainerBuilder $container, $method)
 {
     $mollieMethod = 'mollie_' . $method;
     $definition = new Definition();
     $definition->setClass('%ruudk_payment_mollie.form.mollie_type.class%');
     $definition->addArgument($mollieMethod);
     if ($method === 'ideal') {
         $definition->setClass('%ruudk_payment_mollie.form.ideal_type.class%');
         $definition->addArgument('%kernel.cache_dir%');
     }
     $definition->addTag('payment.method_form_type');
     $definition->addTag('form.type', array('alias' => $mollieMethod));
     $container->setDefinition(sprintf('ruudk_payment_mollie.form.%s_type', $method), $definition);
 }
开发者ID:kalinowski5,项目名称:PaymentMollieBundle,代码行数:14,代码来源:RuudkPaymentMollieExtension.php

示例5: process

 public function process(ContainerBuilder $container)
 {
     $extensions = $container->findTaggedServiceIds('neoclient.extension_class');
     $commandManager = $container->getDefinition('neoclient.command_manager');
     $httpClient = $container->getDefinition('neoclient.http_client');
     $requestBuilder = $container->getDefinition('neoclient.request_builder');
     $extManager = $container->getDefinition('neoclient.extension_manager');
     foreach ($extensions as $id => $params) {
         $definition = $container->getDefinition($id);
         $class = $definition->getClass();
         $commands = $class::getAvailableCommands();
         $extManager->addMethodCall('addExtension', array($class));
         foreach ($commands as $alias => $props) {
             if (array_key_exists($alias, $this->registeredCommands)) {
                 throw new \InvalidArgumentException(sprintf('The command with alias "%s" already exist', $alias));
             }
             $def = new Definition();
             $def->setClass($props['class']);
             $def->addArgument($httpClient);
             $def->addArgument($requestBuilder);
             $container->setDefinition(sprintf('neoclient.command.%s', $alias), $def);
             $commandManager->addMethodCall('registerCommand', array($alias, $def));
             $this->registeredCommands[$alias] = true;
         }
     }
     $customCommands = $container->findTaggedServiceIds('neoclient.custom_command');
     foreach ($customCommands as $id => $params) {
         $def = $container->getDefinition($id);
         $def->addArgument($httpClient);
         $class = $def->getClass();
         $commandManager->addMethodCall('registerCommand', array($params[0][0], $def));
     }
 }
开发者ID:siddhartham-ysg,项目名称:neo4j-neoclient,代码行数:33,代码来源:NeoClientExtensionsCompilerPass.php

示例6: createTransportDefinition

 /**
  * creates a transport definitions based on config
  *
  * @param ContainerBuilder $container
  * @param array $config
  * @param Definition $typeDef
  * @return Definition
  * @author Daniel Wendlandt
  */
 private function createTransportDefinition(ContainerBuilder $container, array $config, Definition $typeDef)
 {
     $transportDef = new Definition();
     $transportDef->setPublic(false);
     switch ($config['protocol']) {
         case 'thrift':
             $transportDef->setClass($container->getParameter('elastification_php_client.transport.thrift.class'));
             break;
         default:
             $transportDef->setClass($container->getParameter('elastification_php_client.transport.http.class'));
             break;
     }
     $transportDef->setArguments(array($typeDef));
     $container->setDefinition(ElastificationPhpClientExtension::SERVICE_TRANSPORT_KEY, $transportDef);
     return $transportDef;
 }
开发者ID:elastification,项目名称:php-client-bundle,代码行数:25,代码来源:TransportCompilerPass.php

示例7: 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');
     foreach ($config['connections'] as $name => $values) {
         $def = new Definition();
         $def->setClass($container->getParameter('agentsib_sphinx.connection.class'));
         $params = array('host' => $values['host'], 'port' => $values['port']);
         if ($values['socket']) {
             $params['socket'] = $values['socket'];
         }
         $def->setArguments(array($name, $values['driver'], $params));
         $def->addMethodCall('addLogger', array(new Reference('agentsib_sphinx.logger')));
         $container->setDefinition(sprintf('agentsib_sphinx.%s.connection', $name), $def);
         $helperDef = new DefinitionDecorator('agentsib_sphinx.factory.helper');
         $helperDef->setFactoryClass($container->getParameter('agentsib_sphinx.helper.class'));
         $helperDef->setFactoryMethod('create');
         $helperDef->addArgument(new Reference(sprintf('agentsib_sphinx.%s.connection', $name)));
         $helperDef->setPublic(true);
         $container->setDefinition(sprintf('agentsib_sphinx.%s.helper', $name), $helperDef);
         if ($name == $config['default_connection']) {
             $container->setAlias('agentsib_sphinx.connection', sprintf('agentsib_sphinx.%s.connection', $name));
             $container->setAlias('agentsib_sphinx.helper', sprintf('agentsib_sphinx.%s.helper', $name));
         }
     }
 }
开发者ID:agentsib,项目名称:sphinx-bundle,代码行数:31,代码来源:AgentSIBSphinxExtension.php

示例8: it_should_not_override_default_theme_factory

 public function it_should_not_override_default_theme_factory(ContainerBuilder $container, Definition $definition)
 {
     $container->hasDefinition('sylius.factory.theme')->willReturn(false);
     $container->getDefinition('sylius.factory.theme')->shouldNotBeCalled();
     $definition->setClass(ThemeFactory::class)->shouldNotBeCalled();
     $this->process($container)->shouldReturn(null);
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:7,代码来源:OverrideThemeFactoryPassSpec.php

示例9: notify

 public function notify(\Exception $exception)
 {
     if (!$exception instanceof ServiceNotFoundException) {
         return;
     }
     $serviceId = $exception->getId();
     $guessedFqcn = $this->guessFqcn($serviceId);
     $definition = new Definition();
     $definition->setClass($guessedFqcn);
     $containerBuilder = new ContainerBuilder();
     $containerBuilder->addDefinitions([$serviceId => $definition]);
     $dumper = new YamlDumper($containerBuilder);
     $result = $dumper->dump();
     $message = sprintf('Service `%s` missing. Define it in your services.yml:', $serviceId);
     $this->output->writeln('--- ' . $message . PHP_EOL);
     $this->output->write($result, true);
     $errorMessages = ['Service ' . $serviceId . ' was not found.'];
     $formatter = new FormatterHelper();
     $formattedBlock = $formatter->formatBlock($errorMessages, 'error', true);
     $this->output->writeln('');
     $this->output->writeln($formattedBlock);
     $this->output->writeln('');
     $question = sprintf('<question>Do you want to create a specification for %s? (Y/n)</question>', $guessedFqcn);
     $dialog = new DialogHelper();
     if ($dialog->askConfirmation($this->output, $question, true)) {
         $this->specRunner->runDescCommand($guessedFqcn);
     }
 }
开发者ID:kix,项目名称:behat-sf2-service-generator,代码行数:28,代码来源:NonExistentServiceObserver.php

示例10: testDumpOptimizationString

    public function testDumpOptimizationString()
    {
        $definition = new Definition();
        $definition->setClass('stdClass');
        $definition->addArgument(array(
            'only dot' => '.',
            'concatenation as value' => '.\'\'.',
            'concatenation from the start value' => '\'\'.',
            '.' => 'dot as a key',
            '.\'\'.' => 'concatenation as a key',
            '\'\'.' =>'concatenation from the start key',
            'optimize concatenation' => "string1%some_string%string2",
            'optimize concatenation with empty string' => "string1%empty_value%string2",
            'optimize concatenation from the start' => '%empty_value%start',
            'optimize concatenation at the end' => 'end%empty_value%',
        ));

        $container = new ContainerBuilder();
        $container->setDefinition('test', $definition);
        $container->setParameter('empty_value', '');
        $container->setParameter('some_string', '-');
        $container->compile();

        $dumper = new PhpDumper($container);
        $this->assertStringEqualsFile(self::$fixturesPath.'/php/services10.php', $dumper->dump(), '->dump() dumps an empty container as an empty PHP class');
    }
开发者ID:usefulthink,项目名称:symfony,代码行数:26,代码来源:PhpDumperTest.php

示例11: buildTranslationStorageDefinition

 /**
  * Build the 'lexik_translation.translation_storage' service definition.
  *
  * @param ContainerBuilder $container
  * @param string           $storage
  * @param string           $objectManager
  */
 protected function buildTranslationStorageDefinition(ContainerBuilder $container, $storage, $objectManager)
 {
     $container->setParameter('lexik_translation.storage.type', $storage);
     if ('orm' == $storage) {
         if (isset($objectManager)) {
             $objectManagerReference = new Reference(sprintf('doctrine.orm.%s_entity_manager', $objectManager));
         } else {
             $objectManagerReference = new Reference('doctrine.orm.entity_manager');
         }
     } else {
         if ('mongodb' == $storage) {
             if (isset($objectManager)) {
                 $objectManagerReference = new Reference(sprintf('doctrine_mongodb.odm.%s_document_manager', $objectManager));
             } else {
                 $objectManagerReference = new Reference('doctrine.odm.mongodb.document_manager');
             }
         } else {
             if ('propel' == $storage) {
                 // In the Propel case the object_manager setting is used for the connection name
                 if (isset($objectManager)) {
                     $objectManagerReference = $objectManager;
                 } else {
                     $objectManagerReference = null;
                 }
             } else {
                 throw new \RuntimeException(sprintf('Unsupported storage "%s".', $storage));
             }
         }
     }
     $storageDefinition = new Definition();
     $storageDefinition->setClass(new Parameter(sprintf('lexik_translation.%s.translation_storage.class', $storage)));
     $storageDefinition->setArguments(array($objectManagerReference, array('trans_unit' => new Parameter(sprintf('lexik_translation.%s.trans_unit.class', $storage)), 'translation' => new Parameter(sprintf('lexik_translation.%s.translation.class', $storage)), 'file' => new Parameter(sprintf('lexik_translation.%s.file.class', $storage)))));
     $container->setDefinition('lexik_translation.translation_storage', $storageDefinition);
 }
开发者ID:StuartApp,项目名称:LexikTranslationBundle,代码行数:41,代码来源:LexikTranslationExtension.php

示例12: testProviderIsAdded

 public function testProviderIsAdded()
 {
     $targetService = new Definition();
     $targetService->setClass('Faker\\Generator');
     $provider = $this->getMock('Acme\\Faker\\Provider\\CustomFakeDataProvider');
     $providerService = new Definition();
     $providerService->setClass(get_class($provider));
     $providerService->addTag('bazinga_faker.provider');
     $builder = new ContainerBuilder();
     $builder->addDefinitions(array('faker.generator' => $targetService, 'acme.faker.provider.custom' => $providerService));
     $builder->addCompilerPass(new AddProvidersPass());
     $builder->compile();
     $this->assertNotEmpty($builder->getServiceIds(), 'The services have been injected.');
     $this->assertNotEmpty($builder->get('faker.generator'), 'The faker.generator service has been injected.');
     $this->assertNotEmpty($builder->get('acme.faker.provider.custom'), 'The provider service has been injected.');
     /*
      * Schema:
      *
      * [0] The list of methods.
      *   [0] The name of the method to call.
      *   [1] The arguments to pass into the method call.
      *     [0] First argument to pass into the method call.
      *     ...
      */
     $targetMethodCalls = $builder->getDefinition('faker.generator')->getMethodCalls();
     $this->assertNotEmpty($targetMethodCalls, 'The faker.generator service got method calls added.');
     $this->assertEquals('addProvider', $targetMethodCalls[0][0], 'The faker.generator service got a provider added.');
     $this->assertEquals('acme.faker.provider.custom', $targetMethodCalls[0][1][0], 'The faker.generator service got the correct provider added.');
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:29,代码来源:AddProvidersPassTest.php

示例13: compileDefinition

 /**
  * Compiles the $id service's $definition with all the aspects provided.
  *
  * @param string $id
  * @param \Symfony\Component\DependencyInjection\Definition $definition
  */
 protected function compileDefinition($id, Definition $definition)
 {
     $refClass = new ReflectionClass($definition->getClass());
     $aspectGenerator = new AspectGenerator($this->annotationReader, $this->annotationClassName);
     if ($aspectGenerator->hasAnnotation($refClass)) {
         $pg = new ProxyGenerator($refClass, array($aspectGenerator));
         $filename = $this->proxyDirectory . '/' . str_replace('\\', '-', $refClass->name) . '.php';
         $pg->writeClass($filename);
         $definition->setClass($pg->getClassName($refClass));
         $definition->setFile($filename);
         $definition->setClass($pg->getClassName($refClass));
         foreach ($this->serviceNames as $serviceName) {
             $definition->addArgument(new Reference($serviceName));
         }
     }
 }
开发者ID:pugx,项目名称:aop,代码行数:22,代码来源:Symfony2.php

示例14: it_should_not_override_default_theme_assets_installer

 public function it_should_not_override_default_theme_assets_installer(ContainerBuilder $container, Definition $definition)
 {
     $container->hasDefinition('sylius.theme.asset.assets_installer')->willReturn(false);
     $container->getDefinition('sylius.theme.asset.assets_installer')->shouldNotBeCalled();
     $definition->setClass(AssetsInstaller::class)->shouldNotBeCalled();
     $this->process($container)->shouldReturn(null);
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:7,代码来源:OverrideThemeAssetsInstallerPassSpec.php

示例15: registerResponseListener

 protected function registerResponseListener(ContainerBuilder $container)
 {
     $definition = new Definition();
     $definition->setClass($container->getParameter('xsolve.cookie_acknowledgement_bar.event_listener.class'));
     $definition->addArgument(new Reference('xsolve.cookie_acknowledgement_bar.service'));
     $definition->addTag('kernel.event_listener', array('event' => 'kernel.response', 'method' => 'onKernelResponse'));
     $container->setDefinition('xsolve.cookie_acknowledgement_bar.event_listener', $definition);
 }
开发者ID:vladab,项目名称:cookie-acknowledgement-bundle,代码行数:8,代码来源:XsolveCookieAcknowledgementExtension.php


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