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


PHP Definition::isSynthetic方法代码示例

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


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

示例1: 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)]);
 }
开发者ID:Werkint,项目名称:CacheBundle,代码行数:35,代码来源:CacheProviderPass.php

示例2: addService

 /**
  * Adds a service.
  *
  * @param string     $id
  * @param Definition $definition
  *
  * @return string
  */
 private function addService($id, $definition)
 {
     $code = "    {$id}:\n";
     if ($definition->getClass()) {
         $code .= sprintf("        class: %s\n", $definition->getClass());
     }
     if (!$definition->isPublic()) {
         $code .= "        public: false\n";
     }
     $tagsCode = '';
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $att = array();
             foreach ($attributes as $key => $value) {
                 $att[] = sprintf('%s: %s', $this->dumper->dump($key), $this->dumper->dump($value));
             }
             $att = $att ? ', ' . implode(', ', $att) : '';
             $tagsCode .= sprintf("            - { name: %s%s }\n", $this->dumper->dump($name), $att);
         }
     }
     if ($tagsCode) {
         $code .= "        tags:\n" . $tagsCode;
     }
     if ($definition->getFile()) {
         $code .= sprintf("        file: %s\n", $definition->getFile());
     }
     if ($definition->isSynthetic()) {
         $code .= sprintf("        synthetic: true\n");
     }
     if ($definition->isLazy()) {
         $code .= sprintf("        lazy: true\n");
     }
     if ($definition->getArguments()) {
         $code .= sprintf("        arguments: %s\n", $this->dumper->dump($this->dumpValue($definition->getArguments()), 0));
     }
     if ($definition->getProperties()) {
         $code .= sprintf("        properties: %s\n", $this->dumper->dump($this->dumpValue($definition->getProperties()), 0));
     }
     if ($definition->getMethodCalls()) {
         $code .= sprintf("        calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
     }
     if (ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope())) {
         $code .= sprintf("        scope: %s\n", $scope);
     }
     if (null !== ($decorated = $definition->getDecoratedService())) {
         list($decorated, $renamedId) = $decorated;
         $code .= sprintf("        decorates: %s\n", $decorated);
         if (null !== $renamedId) {
             $code .= sprintf("        decoration_inner_name: %s\n", $renamedId);
         }
     }
     if ($callable = $definition->getFactory()) {
         $code .= sprintf("        factory: %s\n", $this->dumper->dump($this->dumpCallable($callable), 0));
     }
     if ($callable = $definition->getConfigurator()) {
         $code .= sprintf("        configurator: %s\n", $this->dumper->dump($this->dumpCallable($callable), 0));
     }
     return $code;
 }
开发者ID:rgeraads,项目名称:symfony,代码行数:67,代码来源:YamlDumper.php

示例3: validate

 public function validate(Definition $definition)
 {
     if ($definition->isAbstract()) {
         return;
     }
     if ($definition->isSynthetic()) {
         return;
     }
     $constructor = $this->constructorResolver->resolve($definition);
     if ($constructor === null) {
         return;
     }
     $arguments = $definition->getArguments();
     $this->argumentsValidator->validate($constructor, array_values($arguments));
 }
开发者ID:bendavies,项目名称:symfony-service-definition-validator,代码行数:15,代码来源:DefinitionArgumentsValidator.php

示例4: processDefinition

    private function processDefinition(Definition $definition, $pointcuts, &$interceptors)
    {
        if ($definition->isSynthetic()) {
            return;
        }

        if ($definition->getFactoryService() || $definition->getFactoryClass()) {
            return;
        }

        if ($file = $definition->getFile()) {
            require_once $file;
        }

        $class = new \ReflectionClass($definition->getClass());

        // check if class is matched
        $matchingPointcuts = array();
        foreach ($pointcuts as $interceptor => $pointcut) {
            if ($pointcut->matchesClass($class)) {
                $matchingPointcuts[$interceptor] = $pointcut;
            }
        }

        if (empty($matchingPointcuts)) {
            return;
        }

        $this->addResources($class, $this->container);

        if ($class->isFinal()) {
            return;
        }

        $classAdvices = array();
        foreach ($class->getMethods(\ReflectionMethod::IS_PROTECTED | \ReflectionMethod::IS_PUBLIC) as $method) {
            if ($method->isFinal()) {
                continue;
            }

            $advices = array();
            foreach ($matchingPointcuts as $interceptor => $pointcut) {
                if ($pointcut->matchesMethod($method)) {
                    $advices[] = $interceptor;
                }
            }

            if (empty($advices)) {
                continue;
            }

            $classAdvices[$method->name] = $advices;
        }

        if (empty($classAdvices)) {
            return;
        }

        $interceptors[ClassUtils::getUserClass($class->name)] = $classAdvices;

        $generator = new InterceptionGenerator();
        $generator->setFilter(function(\ReflectionMethod $method) use ($classAdvices) {
            return isset($classAdvices[$method->name]);
        });
        if ($file) {
            $generator->setRequiredFile($file);
        }
        $enhancer = new Enhancer($class, array(), array(
            $generator
        ));
        $enhancer->writeClass($filename = $this->cacheDir.'/'.str_replace('\\', '-', $class->name).'.php');
        $definition->setFile($filename);
        $definition->setClass($enhancer->getClassName($class));
        $definition->addMethodCall('__CGInterception__setLoader', array(
            new Reference('jms_aop.interceptor_loader')
        ));
    }
开发者ID:naknak,项目名称:JMSAopBundle,代码行数:77,代码来源:PointcutMatchingPass.php

示例5: addService

 /**
  * Adds a service.
  *
  * @param Definition  $definition
  * @param string      $id
  * @param \DOMElement $parent
  */
 private function addService($definition, $id, \DOMElement $parent)
 {
     $service = $this->document->createElement('service');
     if (null !== $id) {
         $service->setAttribute('id', $id);
     }
     if ($class = $definition->getClass()) {
         if ('\\' === substr($class, 0, 1)) {
             $class = substr($class, 1);
         }
         $service->setAttribute('class', $class);
     }
     if (!$definition->isShared()) {
         $service->setAttribute('shared', 'false');
     }
     if (!$definition->isPublic()) {
         $service->setAttribute('public', 'false');
     }
     if ($definition->isSynthetic()) {
         $service->setAttribute('synthetic', 'true');
     }
     if ($definition->isLazy()) {
         $service->setAttribute('lazy', 'true');
     }
     if (null !== ($decorated = $definition->getDecoratedService())) {
         list($decorated, $renamedId, $priority) = $decorated;
         $service->setAttribute('decorates', $decorated);
         if (null !== $renamedId) {
             $service->setAttribute('decoration-inner-name', $renamedId);
         }
         if (0 !== $priority) {
             $service->setAttribute('decoration-priority', $priority);
         }
     }
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $tag = $this->document->createElement('tag');
             $tag->setAttribute('name', $name);
             foreach ($attributes as $key => $value) {
                 $tag->setAttribute($key, $value);
             }
             $service->appendChild($tag);
         }
     }
     if ($definition->getFile()) {
         $file = $this->document->createElement('file');
         $file->appendChild($this->document->createTextNode($definition->getFile()));
         $service->appendChild($file);
     }
     if ($parameters = $definition->getArguments()) {
         $this->convertParameters($parameters, 'argument', $service);
     }
     if ($parameters = $definition->getProperties()) {
         $this->convertParameters($parameters, 'property', $service, 'name');
     }
     $this->addMethodCalls($definition->getMethodCalls(), $service);
     if ($callable = $definition->getFactory()) {
         $factory = $this->document->createElement('factory');
         if (is_array($callable) && $callable[0] instanceof Definition) {
             $this->addService($callable[0], null, $factory);
             $factory->setAttribute('method', $callable[1]);
         } elseif (is_array($callable)) {
             $factory->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
             $factory->setAttribute('method', $callable[1]);
         } else {
             $factory->setAttribute('function', $callable);
         }
         $service->appendChild($factory);
     }
     if ($definition->isDeprecated()) {
         $deprecated = $this->document->createElement('deprecated');
         $deprecated->appendChild($this->document->createTextNode($definition->getDeprecationMessage('%service_id%')));
         $service->appendChild($deprecated);
     }
     if ($definition->isAutowired()) {
         $service->setAttribute('autowire', 'true');
     }
     foreach ($definition->getAutowiringTypes() as $autowiringTypeValue) {
         $autowiringType = $this->document->createElement('autowiring-type');
         $autowiringType->appendChild($this->document->createTextNode($autowiringTypeValue));
         $service->appendChild($autowiringType);
     }
     if ($callable = $definition->getConfigurator()) {
         $configurator = $this->document->createElement('configurator');
         if (is_array($callable) && $callable[0] instanceof Definition) {
             $this->addService($callable[0], null, $configurator);
             $configurator->setAttribute('method', $callable[1]);
         } elseif (is_array($callable)) {
             $configurator->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
             $configurator->setAttribute('method', $callable[1]);
         } else {
             $configurator->setAttribute('function', $callable);
         }
//.........这里部分代码省略.........
开发者ID:Ener-Getick,项目名称:symfony,代码行数:101,代码来源:XmlDumper.php

示例6: addService

 /**
  * Adds a service.
  *
  * @param Definition  $definition
  * @param string      $id
  * @param \DOMElement $parent
  */
 private function addService($definition, $id, \DOMElement $parent)
 {
     $service = $this->document->createElement('service');
     if (null !== $id) {
         $service->setAttribute('id', $id);
     }
     if ($class = $definition->getClass()) {
         if ('\\' === substr($class, 0, 1)) {
             $class = substr($class, 1);
         }
         $service->setAttribute('class', $class);
     }
     if ($definition->getFactoryMethod()) {
         $service->setAttribute('factory-method', $definition->getFactoryMethod());
     }
     if ($definition->getFactoryClass()) {
         $service->setAttribute('factory-class', $definition->getFactoryClass());
     }
     if ($definition->getFactoryService()) {
         $service->setAttribute('factory-service', $definition->getFactoryService());
     }
     if (ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope())) {
         $service->setAttribute('scope', $scope);
     }
     if (!$definition->isPublic()) {
         $service->setAttribute('public', 'false');
     }
     if ($definition->isSynthetic()) {
         $service->setAttribute('synthetic', 'true');
     }
     if ($definition->isSynchronized()) {
         $service->setAttribute('synchronized', 'true');
     }
     if ($definition->isLazy()) {
         $service->setAttribute('lazy', 'true');
     }
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $tag = $this->document->createElement('tag');
             $tag->setAttribute('name', $name);
             foreach ($attributes as $key => $value) {
                 $tag->setAttribute($key, $value);
             }
             $service->appendChild($tag);
         }
     }
     if ($definition->getFile()) {
         $file = $this->document->createElement('file');
         $file->appendChild($this->document->createTextNode($definition->getFile()));
         $service->appendChild($file);
     }
     if ($parameters = $definition->getArguments()) {
         $this->convertParameters($parameters, 'argument', $service);
     }
     if ($parameters = $definition->getProperties()) {
         $this->convertParameters($parameters, 'property', $service, 'name');
     }
     $this->addMethodCalls($definition->getMethodCalls(), $service);
     if ($callable = $definition->getConfigurator()) {
         $configurator = $this->document->createElement('configurator');
         if (is_array($callable)) {
             $configurator->setAttribute($callable[0] instanceof Reference ? 'service' : 'class', $callable[0]);
             $configurator->setAttribute('method', $callable[1]);
         } else {
             $configurator->setAttribute('function', $callable);
         }
         $service->appendChild($configurator);
     }
     $parent->appendChild($service);
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:77,代码来源:XmlDumper.php

示例7: addService

 /**
  * Adds a service.
  *
  * @param string     $id
  * @param Definition $definition
  *
  * @return string
  */
 private function addService($id, $definition)
 {
     $code = "    {$id}:\n";
     if ($class = $definition->getClass()) {
         if ('\\' === substr($class, 0, 1)) {
             $class = substr($class, 1);
         }
         $code .= sprintf("        class: %s\n", $this->dumper->dump($class));
     }
     if (!$definition->isPublic()) {
         $code .= "        public: false\n";
     }
     $tagsCode = '';
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $att = array();
             foreach ($attributes as $key => $value) {
                 $att[] = sprintf('%s: %s', $this->dumper->dump($key), $this->dumper->dump($value));
             }
             $att = $att ? ', ' . implode(', ', $att) : '';
             $tagsCode .= sprintf("            - { name: %s%s }\n", $this->dumper->dump($name), $att);
         }
     }
     if ($tagsCode) {
         $code .= "        tags:\n" . $tagsCode;
     }
     if ($definition->getFile()) {
         $code .= sprintf("        file: %s\n", $this->dumper->dump($definition->getFile()));
     }
     if ($definition->isSynthetic()) {
         $code .= sprintf("        synthetic: true\n");
     }
     if ($definition->isSynchronized(false)) {
         $code .= sprintf("        synchronized: true\n");
     }
     if ($definition->isDeprecated()) {
         $code .= sprintf("        deprecated: %s\n", $definition->getDeprecationMessage('%service_id%'));
     }
     if ($definition->isAutowired()) {
         $code .= "        autowire: true\n";
     }
     $autowiringTypesCode = '';
     foreach ($definition->getAutowiringTypes() as $autowiringType) {
         $autowiringTypesCode .= sprintf("            - %s\n", $this->dumper->dump($autowiringType));
     }
     if ($autowiringTypesCode) {
         $code .= sprintf("        autowiring_types:\n%s", $autowiringTypesCode);
     }
     if ($definition->getFactoryClass(false)) {
         $code .= sprintf("        factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
     }
     if ($definition->isLazy()) {
         $code .= sprintf("        lazy: true\n");
     }
     if ($definition->getFactoryMethod(false)) {
         $code .= sprintf("        factory_method: %s\n", $this->dumper->dump($definition->getFactoryMethod(false)));
     }
     if ($definition->getFactoryService(false)) {
         $code .= sprintf("        factory_service: %s\n", $this->dumper->dump($definition->getFactoryService(false)));
     }
     if ($definition->getArguments()) {
         $code .= sprintf("        arguments: %s\n", $this->dumper->dump($this->dumpValue($definition->getArguments()), 0));
     }
     if ($definition->getProperties()) {
         $code .= sprintf("        properties: %s\n", $this->dumper->dump($this->dumpValue($definition->getProperties()), 0));
     }
     if ($definition->getMethodCalls()) {
         $code .= sprintf("        calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
     }
     if (!$definition->isShared()) {
         $code .= "        shared: false\n";
     }
     if (ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope(false))) {
         $code .= sprintf("        scope: %s\n", $this->dumper->dump($scope));
     }
     if (null !== ($decorated = $definition->getDecoratedService())) {
         list($decorated, $renamedId, $priority) = $decorated;
         $code .= sprintf("        decorates: %s\n", $decorated);
         if (null !== $renamedId) {
             $code .= sprintf("        decoration_inner_name: %s\n", $renamedId);
         }
         if (0 !== $priority) {
             $code .= sprintf("        decoration_priority: %s\n", $priority);
         }
     }
     if ($callable = $definition->getFactory()) {
         $code .= sprintf("        factory: %s\n", $this->dumper->dump($this->dumpCallable($callable), 0));
     }
     if ($callable = $definition->getConfigurator()) {
         $code .= sprintf("        configurator: %s\n", $this->dumper->dump($this->dumpCallable($callable), 0));
     }
     return $code;
//.........这里部分代码省略.........
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:101,代码来源:YamlDumper.php

示例8: addService

 /**
  * Adds a service
  *
  * @param string     $id
  * @param Definition $definition
  *
  * @return string
  */
 private function addService($id, $definition)
 {
     $code = "    {$id}:\n";
     if ($definition->getClass()) {
         $code .= sprintf("        class: %s\n", $definition->getClass());
     }
     if (!$definition->isPublic()) {
         $code .= "        public: false\n";
     }
     $tagsCode = '';
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $att = array();
             foreach ($attributes as $key => $value) {
                 $att[] = sprintf('%s: %s', $this->dumper->dump($key), $this->dumper->dump($value));
             }
             $att = $att ? ', ' . implode(' ', $att) : '';
             $tagsCode .= sprintf("            - { name: %s%s }\n", $this->dumper->dump($name), $att);
         }
     }
     if ($tagsCode) {
         $code .= "        tags:\n" . $tagsCode;
     }
     if ($definition->getFile()) {
         $code .= sprintf("        file: %s\n", $definition->getFile());
     }
     if ($definition->isSynthetic()) {
         $code .= sprintf("        synthetic: true\n");
     }
     if ($definition->isSynchronized()) {
         $code .= sprintf("        synchronized: true\n");
     }
     if ($definition->getFactoryClass()) {
         $code .= sprintf("        factory_class: %s\n", $definition->getFactoryClass());
     }
     if ($definition->isLazy()) {
         $code .= sprintf("        lazy: true\n");
     }
     if ($definition->getFactoryMethod()) {
         $code .= sprintf("        factory_method: %s\n", $definition->getFactoryMethod());
     }
     if ($definition->getFactoryService()) {
         $code .= sprintf("        factory_service: %s\n", $definition->getFactoryService());
     }
     if ($definition->getArguments()) {
         $code .= sprintf("        arguments: %s\n", $this->dumper->dump($this->dumpValue($definition->getArguments()), 0));
     }
     if ($definition->getProperties()) {
         $code .= sprintf("        properties: %s\n", $this->dumper->dump($this->dumpValue($definition->getProperties()), 0));
     }
     if ($definition->getMethodCalls()) {
         $code .= sprintf("        calls:\n%s\n", $this->dumper->dump($this->dumpValue($definition->getMethodCalls()), 1, 12));
     }
     if (ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope())) {
         $code .= sprintf("        scope: %s\n", $scope);
     }
     if ($callable = $definition->getConfigurator()) {
         if (is_array($callable)) {
             if ($callable[0] instanceof Reference) {
                 $callable = array($this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]);
             } else {
                 $callable = array($callable[0], $callable[1]);
             }
         }
         $code .= sprintf("        configurator: %s\n", $this->dumper->dump($callable, 0));
     }
     return $code;
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:76,代码来源:YamlDumper.php

示例9: testSetIsSynthetic

 /**
  * @covers Symfony\Component\DependencyInjection\Definition::setSynthetic
  * @covers Symfony\Component\DependencyInjection\Definition::isSynthetic
  */
 public function testSetIsSynthetic()
 {
     $def = new Definition('stdClass');
     $this->assertFalse($def->isSynthetic(), '->isSynthetic() returns false by default');
     $this->assertSame($def, $def->setSynthetic(true), '->setSynthetic() implements a fluent interface');
     $this->assertTrue($def->isSynthetic(), '->isSynthetic() returns true if the service is synthetic.');
 }
开发者ID:nuwe1,项目名称:symfony,代码行数:11,代码来源:DefinitionTest.php

示例10: getContainerDefinitionData

 /**
  * @param Definition $definition
  * @param bool       $omitTags
  *
  * @return array
  */
 private function getContainerDefinitionData(Definition $definition, $omitTags = false)
 {
     $data = array('class' => (string) $definition->getClass(), 'public' => $definition->isPublic(), 'synthetic' => $definition->isSynthetic(), 'lazy' => $definition->isLazy());
     if (method_exists($definition, 'isShared')) {
         $data['shared'] = $definition->isShared();
     }
     $data['abstract'] = $definition->isAbstract();
     if (method_exists($definition, 'isAutowired')) {
         $data['autowire'] = $definition->isAutowired();
         $data['autowiring_types'] = array();
         foreach ($definition->getAutowiringTypes() as $autowiringType) {
             $data['autowiring_types'][] = $autowiringType;
         }
     }
     $data['file'] = $definition->getFile();
     if ($factory = $definition->getFactory()) {
         if (is_array($factory)) {
             if ($factory[0] instanceof Reference) {
                 $data['factory_service'] = (string) $factory[0];
             } elseif ($factory[0] instanceof Definition) {
                 throw new \InvalidArgumentException('Factory is not describable.');
             } else {
                 $data['factory_class'] = $factory[0];
             }
             $data['factory_method'] = $factory[1];
         } else {
             $data['factory_function'] = $factory;
         }
     }
     $calls = $definition->getMethodCalls();
     if (count($calls) > 0) {
         $data['calls'] = array();
         foreach ($calls as $callData) {
             $data['calls'][] = $callData[0];
         }
     }
     if (!$omitTags) {
         $data['tags'] = array();
         if (count($definition->getTags())) {
             foreach ($definition->getTags() as $tagName => $tagData) {
                 foreach ($tagData as $parameters) {
                     $data['tags'][] = array('name' => $tagName, 'parameters' => $parameters);
                 }
             }
         }
     }
     return $data;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:54,代码来源:JsonDescriptor.php

示例11: describeContainerDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeContainerDefinition(Definition $definition, array $options = array())
 {
     $description = isset($options['id']) ? array($this->formatSection('container', sprintf('Information for service <info>%s</info>', $options['id']))) : array();
     $description[] = sprintf('<comment>Service Id</comment>       %s', isset($options['id']) ? $options['id'] : '-');
     $description[] = sprintf('<comment>Class</comment>            %s', $definition->getClass() ?: "-");
     $tags = $definition->getTags();
     if (count($tags)) {
         $description[] = '<comment>Tags</comment>';
         foreach ($tags as $tagName => $tagData) {
             foreach ($tagData as $parameters) {
                 $description[] = sprintf('    - %-30s (%s)', $tagName, implode(', ', array_map(function ($key, $value) {
                     return sprintf('<info>%s</info>: %s', $key, $value);
                 }, array_keys($parameters), array_values($parameters))));
             }
         }
     } else {
         $description[] = '<comment>Tags</comment>             -';
     }
     $description[] = sprintf('<comment>Scope</comment>            %s', $definition->getScope());
     $description[] = sprintf('<comment>Public</comment>           %s', $definition->isPublic() ? 'yes' : 'no');
     $description[] = sprintf('<comment>Synthetic</comment>        %s', $definition->isSynthetic() ? 'yes' : 'no');
     $description[] = sprintf('<comment>Required File</comment>    %s', $definition->getFile() ? $definition->getFile() : '-');
     $this->writeText(implode("\n", $description) . "\n", $options);
 }
开发者ID:makhloufi-lounis,项目名称:tuto_symfony,代码行数:27,代码来源:TextDescriptor.php

示例12: shouldDefinitionHaveAClass

 /**
  * Find out whether or not the given definition should have a class (i.e. not when it is a synthetic or abstract
  * definition)
  *
  * @param Definition $definition
  * @return bool
  */
 private function shouldDefinitionHaveAClass(Definition $definition)
 {
     if ($definition->isSynthetic()) {
         return false;
     }
     if ($definition->isAbstract()) {
         return false;
     }
     return true;
 }
开发者ID:seclu,项目名称:symfony-service-definition-validator,代码行数:17,代码来源:ServiceDefinitionValidator.php

示例13: getContainerDefinitionData

 /**
  * @param Definition $definition
  * @param bool       $omitTags
  *
  * @return array
  */
 private function getContainerDefinitionData(Definition $definition, $omitTags = false)
 {
     $data = array('class' => (string) $definition->getClass(), 'scope' => $definition->getScope(), 'public' => $definition->isPublic(), 'synthetic' => $definition->isSynthetic(), 'lazy' => $definition->isLazy(), 'synchronized' => $definition->isSynchronized(), 'abstract' => $definition->isAbstract(), 'file' => $definition->getFile());
     if ($definition->getFactoryClass()) {
         $data['factory_class'] = $definition->getFactoryClass();
     }
     if ($definition->getFactoryService()) {
         $data['factory_service'] = $definition->getFactoryService();
     }
     if ($definition->getFactoryMethod()) {
         $data['factory_method'] = $definition->getFactoryMethod();
     }
     if ($factory = $definition->getFactory()) {
         if (is_array($factory)) {
             if ($factory[0] instanceof Reference) {
                 $data['factory_service'] = (string) $factory[0];
             } elseif ($factory[0] instanceof Definition) {
                 throw new \InvalidArgumentException('Factory is not describable.');
             } else {
                 $data['factory_class'] = $factory[0];
             }
             $data['factory_method'] = $factory[1];
         } else {
             $data['factory_function'] = $factory;
         }
     }
     if (!$omitTags) {
         $data['tags'] = array();
         if (count($definition->getTags())) {
             foreach ($definition->getTags() as $tagName => $tagData) {
                 foreach ($tagData as $parameters) {
                     $data['tags'][] = array('name' => $tagName, 'parameters' => $parameters);
                 }
             }
         }
     }
     return $data;
 }
开发者ID:tonydub,项目名称:jarvis,代码行数:44,代码来源:JsonDescriptor.php

示例14: processDefinition

 /**
  * @param array<PointcutInterface> $pointcuts
  * @param array<string,string> $interceptors
  */
 private function processDefinition(Definition $definition, $pointcuts, &$interceptors)
 {
     if ($definition->isSynthetic()) {
         return;
     }
     // Symfony 2.6 getFactory method
     // TODO: Use only getFactory when bumping require to Symfony >= 2.6
     if (method_exists($definition, 'getFactory') && $definition->getFactory()) {
         return;
     }
     if (!method_exists($definition, 'getFactory') && ($definition->getFactoryService() || $definition->getFactoryClass())) {
         return;
     }
     if ($originalFilename = $definition->getFile()) {
         require_once $originalFilename;
     }
     if (!class_exists($definition->getClass())) {
         return;
     }
     $class = new \ReflectionClass($definition->getClass());
     // check if class is matched
     $matchingPointcuts = array();
     foreach ($pointcuts as $interceptor => $pointcut) {
         if ($pointcut->matchesClass($class)) {
             $matchingPointcuts[$interceptor] = $pointcut;
         }
     }
     if (empty($matchingPointcuts)) {
         return;
     }
     $this->addResources($class, $this->container);
     if ($class->isFinal()) {
         return;
     }
     $classAdvices = array();
     foreach (ReflectionUtils::getOverrideableMethods($class) as $method) {
         if ('__construct' === $method->name) {
             continue;
         }
         $advices = array();
         foreach ($matchingPointcuts as $interceptor => $pointcut) {
             if ($pointcut->matchesMethod($method)) {
                 $advices[] = $interceptor;
             }
         }
         if (empty($advices)) {
             continue;
         }
         $classAdvices[$method->name] = $advices;
     }
     if (empty($classAdvices)) {
         return;
     }
     $interceptors[ClassUtils::getUserClass($class->name)] = $classAdvices;
     $proxyFilename = $this->cacheDir . '/' . str_replace('\\', '-', $class->name) . '.php';
     $generator = new InterceptionGenerator();
     $generator->setFilter(function (\ReflectionMethod $method) use($classAdvices) {
         return isset($classAdvices[$method->name]);
     });
     if ($originalFilename) {
         $relativeOriginalFilename = $this->relativizePath($proxyFilename, $originalFilename);
         if ($relativeOriginalFilename[0] === '.') {
             $generator->setRequiredFile(new RelativePath($relativeOriginalFilename));
         } else {
             $generator->setRequiredFile($relativeOriginalFilename);
         }
     }
     $enhancer = new Enhancer($class, array(), array($generator));
     $enhancer->setNamingStrategy(new DefaultNamingStrategy('EnhancedProxy' . substr(md5($this->container->getParameter('jms_aop.cache_dir')), 0, 8)));
     $enhancer->writeClass($proxyFilename);
     $definition->setFile($proxyFilename);
     $definition->setClass($enhancer->getClassName($class));
     $definition->addMethodCall('__CGInterception__setLoader', array(new Reference('jms_aop.interceptor_loader')));
 }
开发者ID:jmcclell,项目名称:JMSAopBundle,代码行数:78,代码来源:PointcutMatchingPass.php

示例15: addService

    /**
     * Adds a service.
     *
     * @param string     $id
     * @param Definition $definition
     *
     * @return string
     */
    private function addService($id, $definition)
    {
        $this->definitionVariables = new \SplObjectStorage();
        $this->referenceVariables = array();
        $this->variableCount = 0;

        $return = array();

        if ($definition->isSynthetic()) {
            $return[] = '@throws RuntimeException always since this service is expected to be injected dynamically';
        } elseif ($class = $definition->getClass()) {
            $return[] = sprintf('@return %s A %s instance', 0 === strpos($class, '%') ? 'object' : '\\'.ltrim($class, '\\'), ltrim($class, '\\'));
        } elseif ($definition->getFactory()) {
            $factory = $definition->getFactory();
            if (is_string($factory)) {
                $return[] = sprintf('@return object An instance returned by %s()', $factory);
            } elseif (is_array($factory) && (is_string($factory[0]) || $factory[0] instanceof Definition || $factory[0] instanceof Reference)) {
                if (is_string($factory[0]) || $factory[0] instanceof Reference) {
                    $return[] = sprintf('@return object An instance returned by %s::%s()', (string) $factory[0], $factory[1]);
                } elseif ($factory[0] instanceof Definition) {
                    $return[] = sprintf('@return object An instance returned by %s::%s()', $factory[0]->getClass(), $factory[1]);
                }
            }
        } elseif ($definition->getFactoryClass(false)) {
            $return[] = sprintf('@return object An instance returned by %s::%s()', $definition->getFactoryClass(false), $definition->getFactoryMethod(false));
        } elseif ($definition->getFactoryService(false)) {
            $return[] = sprintf('@return object An instance returned by %s::%s()', $definition->getFactoryService(false), $definition->getFactoryMethod(false));
        }

        $scope = $definition->getScope(false);
        if (!in_array($scope, array(ContainerInterface::SCOPE_CONTAINER, ContainerInterface::SCOPE_PROTOTYPE))) {
            if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
                $return[] = '';
            }
            $return[] = sprintf("@throws InactiveScopeException when the '%s' service is requested while the '%s' scope is not active", $id, $scope);
        }

        if ($definition->isDeprecated()) {
            if ($return && 0 === strpos($return[count($return) - 1], '@return')) {
                $return[] = '';
            }

            $return[] = sprintf('@deprecated %s', $definition->getDeprecationMessage($id));
        }

        $return = str_replace("\n     * \n", "\n     *\n", implode("\n     * ", $return));

        $doc = '';
        if ($definition->isShared() && ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
            $doc .= <<<'EOF'

     *
     * This service is shared.
     * This method always returns the same instance of the service.
EOF;
        }

        if (!$definition->isPublic()) {
            $doc .= <<<'EOF'

     *
     * This service is private.
     * If you want to be able to request this service from the container directly,
     * make it public, otherwise you might end up with broken code.
EOF;
        }

        if ($definition->isAutowired()) {
            $doc = <<<EOF

     *
     * This service is autowired.
EOF;
        }

        if ($definition->isLazy()) {
            $lazyInitialization = '$lazyLoad = true';
            $lazyInitializationDoc = "\n     * @param bool    \$lazyLoad whether to try lazy-loading the service with a proxy\n     *";
        } else {
            $lazyInitialization = '';
            $lazyInitializationDoc = '';
        }

        // with proxies, for 5.3.3 compatibility, the getter must be public to be accessible to the initializer
        $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
        $visibility = $isProxyCandidate ? 'public' : 'protected';
        $code = <<<EOF

    /*{$this->docStar}
     * Gets the '$id' service.$doc
     *$lazyInitializationDoc
     * $return
//.........这里部分代码省略.........
开发者ID:nwdrupal,项目名称:nwdrupalwebsite,代码行数:101,代码来源:PhpDumper.php


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