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


PHP ContainerBuilder::getCompiler方法代码示例

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


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

示例1: then_compiler_passes_are_added

 private function then_compiler_passes_are_added()
 {
     $passes = $this->container->getCompiler()->getPassConfig()->getBeforeOptimizationPasses();
     $classes = array_map(function ($pass) {
         return get_class($pass);
     }, $passes);
     $expectedPassClasses = array('Devhelp\\PiwikBundle\\DependencyInjection\\Compiler\\AddPiwikClientDefinition', 'Devhelp\\PiwikBundle\\DependencyInjection\\Compiler\\InsertParamsServices');
     $this->assertEquals($expectedPassClasses, $classes);
 }
开发者ID:devhelp,项目名称:piwik-bundle,代码行数:9,代码来源:DevhelpPiwikBundleTest.php

示例2: process

 public function process(ContainerBuilder $container)
 {
     $compiler = $container->getCompiler();
     $formatter = $compiler->getLoggingFormatter();
     $tags = array_unique(array_merge($container->findTags(), $this->whitelist));
     foreach ($container->findUnusedTags() as $tag) {
         // skip whitelisted tags
         if (in_array($tag, $this->whitelist)) {
             continue;
         }
         // check for typos
         $candidates = array();
         foreach ($tags as $definedTag) {
             if ($definedTag === $tag) {
                 continue;
             }
             if (false !== strpos($definedTag, $tag) || levenshtein($tag, $definedTag) <= strlen($tag) / 3) {
                 $candidates[] = $definedTag;
             }
         }
         $services = array_keys($container->findTaggedServiceIds($tag));
         $message = sprintf('Tag "%s" was defined on service(s) "%s", but was never used.', $tag, implode('", "', $services));
         if (!empty($candidates)) {
             $message .= sprintf(' Did you mean "%s"?', implode('", "', $candidates));
         }
         $compiler->addLogMessage($formatter->format($this, $message));
     }
 }
开发者ID:skelpo,项目名称:framework,代码行数:28,代码来源:UnusedTagsPass.php

示例3: process

    /**
     * Process the ContainerBuilder to replace ChildDefinition instances with their real Definition instances.
     *
     * @param ContainerBuilder $container
     */
    public function process(ContainerBuilder $container)
    {
        $this->compiler = $container->getCompiler();
        $this->formatter = $this->compiler->getLoggingFormatter();

        $container->setDefinitions($this->resolveArguments($container, $container->getDefinitions(), true));
    }
开发者ID:symfony,项目名称:symfony,代码行数:12,代码来源:ResolveDefinitionTemplatesPass.php

示例4: process

 /**
  * Processes the ContainerBuilder for inline service definitions.
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $this->compiler = $container->getCompiler();
     $this->formatter = $this->compiler->getLoggingFormatter();
     $this->graph = $this->compiler->getServiceReferenceGraph();
     $container->setDefinitions($this->inlineArguments($container, $container->getDefinitions(), true));
 }
开发者ID:nuwe1,项目名称:symfony,代码行数:12,代码来源:InlineServiceDefinitionsPass.php

示例5: getMethodsToAutowire

    /**
     * Gets the list of methods to autowire.
     *
     * @param string           $id
     * @param \ReflectionClass $reflectionClass
     * @param string[]         $autowiredMethods
     *
     * @return \ReflectionMethod[]
     */
    private function getMethodsToAutowire($id, \ReflectionClass $reflectionClass, array $autowiredMethods)
    {
        $found = array();
        $regexList = array();
        foreach ($autowiredMethods as $pattern) {
            $regexList[] = '/^'.str_replace('\*', '.*', preg_quote($pattern, '/')).'$/i';
        }

        foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
            if ($reflectionMethod->isStatic()) {
                continue;
            }

            foreach ($regexList as $k => $regex) {
                if (preg_match($regex, $reflectionMethod->name)) {
                    $found[] = $autowiredMethods[$k];
                    yield $reflectionMethod;

                    continue 2;
                }
            }
        }

        if ($notFound = array_diff($autowiredMethods, $found)) {
            $compiler = $this->container->getCompiler();
            $compiler->addLogMessage($compiler->getLoggingFormatter()->formatUnusedAutowiringPatterns($this, $id, $notFound));
        }
    }
开发者ID:symfony,项目名称:symfony,代码行数:37,代码来源:AutowirePass.php

示例6: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$this->integrationExtension->isTransactionalAutoGenerateProxy()) {
         // Transactional system or auto generate proxy is disabled
         return;
     }
     $transactionalId = $this->integrationExtension->getTransactionalService();
     // Validate transactional service
     $transactionalDefinition = $container->getDefinition($transactionalId);
     $class = $transactionalDefinition->getClass();
     try {
         $class = $container->getParameterBag()->resolveValue($class);
         $refClass = new \ReflectionClass($class);
         $requiredInterface = 'FivePercent\\Component\\Transactional\\TransactionalInterface';
         if (!$refClass->implementsInterface($requiredInterface)) {
             throw new \RuntimeException(sprintf('The transactional service with class "%s" should implement %s.', $class, $requiredInterface));
         }
     } catch (\Exception $e) {
         throw new \RuntimeException(sprintf('The transactional service with id "%s" is invalid.', $transactionalId), 0, $e);
     }
     // Get all services
     $serviceIds = $container->getServiceIds();
     $directory = $container->getParameter('kernel.cache_dir') . '/transactional';
     foreach ($serviceIds as $serviceId) {
         if ($container->hasAlias($serviceId)) {
             // Not check in alias.
             continue;
         }
         $serviceDefinition = $container->getDefinition($serviceId);
         if ($serviceDefinition->isAbstract()) {
             // Not check in abstract service.
             continue;
         }
         $class = $serviceDefinition->getClass();
         $class = $container->getParameterBag()->resolveValue($class);
         if (!$class) {
             continue;
         }
         try {
             $proxyCodeGenerator = new ProxyFileGenerator($directory, $class);
         } catch (\ReflectionException $e) {
             $container->getCompiler()->addLogMessage(sprintf('%s Error with create proxy code generator for class "%s". Maybe class not found?', get_class($this), $class));
             continue;
         }
         if ($proxyCodeGenerator->needGenerate()) {
             // Generate proxy file
             $filePath = $proxyCodeGenerator->generate();
             $serviceDefinition->setClass($proxyCodeGenerator->getProxyClassName());
             // Add "__setTransactional" method call for set transactional layer
             $methodCalls = $serviceDefinition->getMethodCalls();
             array_unshift($methodCalls, ['___setTransactional', [new Reference($transactionalId)]]);
             $serviceDefinition->setMethodCalls($methodCalls);
             // Add resource for control cache
             $container->addResource(new FileResource($filePath));
             $realClassReflection = new \ReflectionClass($class);
             $container->addResource(new FileResource($realClassReflection->getFileName()));
         }
     }
 }
开发者ID:Gtvar,项目名称:FivePercent-IntegrationBundle,代码行数:62,代码来源:GenerateProxyTransactionalPass.php

示例7: process

 /**
  * Processes the ContainerBuilder for inline service definitions.
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $this->graph = $container->getCompiler()->getServiceReferenceGraph();
     foreach ($container->getDefinitions() as $definition) {
         $definition->setArguments($this->inlineArguments($container, $definition->getArguments()));
         $definition->setMethodCalls($this->inlineArguments($container, $definition->getMethodCalls()));
     }
 }
开发者ID:rooster,项目名称:symfony,代码行数:13,代码来源:InlineServiceDefinitionsPass.php

示例8: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (FALSE === $container->hasDefinition('webprofiler.services')) {
         return;
     }
     $definition = $container->getDefinition('webprofiler.services');
     $graph = $container->getCompiler()->getServiceReferenceGraph();
     $definition->addMethodCall('setServices', [$this->extractData($container, $graph)]);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:ServicePass.php

示例9: process

 /**
  * Checks the ContainerBuilder object for circular references.
  *
  * @param ContainerBuilder $container The ContainerBuilder instances
  */
 public function process(ContainerBuilder $container)
 {
     $graph = $container->getCompiler()->getServiceReferenceGraph();
     foreach ($graph->getNodes() as $id => $node) {
         $this->currentId = $id;
         $this->currentPath = array($id);
         $this->checkOutEdges($node->getOutEdges());
     }
 }
开发者ID:usefulthink,项目名称:symfony,代码行数:14,代码来源:CheckCircularReferencesPass.php

示例10: build

 public function build(ContainerBuilder $container)
 {
     $config = $container->getCompiler()->getPassConfig();
     $passes = $config->getBeforeOptimizationPasses();
     array_unshift($passes, new AnnotationConfigurationPass($this->kernel));
     $config->setBeforeOptimizationPasses($passes);
     $container->addCompilerPass(new IntegrationPass());
     $container->addCompilerPass(new ResourceOptimizationPass(), PassConfig::TYPE_AFTER_REMOVING);
 }
开发者ID:almaaro,项目名称:Ilmokilke,代码行数:9,代码来源:JMSDiExtraBundle.php

示例11: registerLegacyPass

 private function registerLegacyPass(ContainerBuilder $container)
 {
     $passConfig = $container->getCompiler()->getPassConfig();
     $passConfig->setAfterRemovingPasses(array());
     $passConfig->setBeforeOptimizationPasses(array());
     $passConfig->setBeforeRemovingPasses(array());
     $passConfig->setOptimizationPasses(array());
     $passConfig->setRemovingPasses(array());
     $container->addCompilerPass(new LegacyPass());
 }
开发者ID:tahermarkos,项目名称:Transport,代码行数:10,代码来源:SensioFrameworkExtraExtensionTest.php

示例12: process

 /**
  * Process the repeatable passes that run more than once.
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $compiler = $container->getCompiler();
     $this->repeat = false;
     foreach ($this->passes as $pass) {
         $pass->process($container);
     }
     if ($this->repeat) {
         $this->process($container);
     }
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:16,代码来源:RepeatedPass.php

示例13: process

 /**
  * Removes abstract definitions from the ContainerBuilder
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $compiler = $container->getCompiler();
     $formatter = $compiler->getLoggingFormatter();
     foreach ($container->getDefinitions() as $id => $definition) {
         if ($definition->isAbstract()) {
             $container->removeDefinition($id);
             $compiler->addLogMessage($formatter->formatRemoveService($this, $id, 'abstract'));
         }
     }
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:16,代码来源:RemoveAbstractDefinitionsPass.php

示例14: process

 /**
  * Processes the ContainerBuilder for inline service definitions.
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $this->compiler = $container->getCompiler();
     $this->formatter = $this->compiler->getLoggingFormatter();
     $this->graph = $this->compiler->getServiceReferenceGraph();
     foreach ($container->getDefinitions() as $id => $definition) {
         $this->currentId = $id;
         $definition->setArguments($this->inlineArguments($container, $definition->getArguments()));
         $definition->setMethodCalls($this->inlineArguments($container, $definition->getMethodCalls()));
         $definition->setProperties($this->inlineArguments($container, $definition->getProperties()));
     }
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:17,代码来源:InlineServiceDefinitionsPass.php

示例15: process

 public function process(ContainerBuilder $container)
 {
     $compiler = $container->getCompiler();
     $this->repeat = false;
     foreach ($this->passes as $pass) {
         $time = microtime(true);
         $pass->process($container);
         $compiler->addLogMessage(sprintf('%s finished in %.3fs', get_class($pass), microtime(true) - $time));
     }
     if ($this->repeat) {
         $this->process($container);
     }
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:13,代码来源:RepeatedPass.php


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