當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。