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


PHP Definition::getFactory方法代码示例

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


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

示例1: assertDefinition

 /**
  * @param Definition $definition
  * @param string     $class
  * @param string     $repository
  */
 private function assertDefinition(Definition $definition, $class, $repository)
 {
     $this->assertSame($definition->getClass(), $repository);
     $factory = $definition->getFactory();
     $this->assertSame($factory[1], "getRepository");
     $this->assertSame($definition->getArgument(0), $class);
 }
开发者ID:itkg-canne,项目名称:open-orchestra-media-bundle,代码行数:12,代码来源:OpenOrchestraMediaModelExtensionTest.php

示例2: assertDefinition

 /**
  * @param Definition $definition
  * @param string     $class
  * @param string     $repository
  * @param bool       $filterType
  */
 private function assertDefinition(Definition $definition, $class, $repository, $filterType)
 {
     $this->assertSame($definition->getClass(), $repository);
     $factory = $definition->getFactory();
     $this->assertSame($factory[1], "getRepository");
     $this->assertSame($definition->getArgument(0), $class);
     if ($filterType) {
         $this->assertTrue($definition->hasMethodCall('setFilterTypeManager'));
     }
 }
开发者ID:open-orchestra,项目名称:open-orchestra-workflow-function-bundle,代码行数:16,代码来源:OpenOrchestraWorkflowFunctionModelExtensionTest.php

示例3: updateDefinition

 private function updateDefinition(ContainerBuilder $container, $id, Definition $definition, array $previous = array())
 {
     // circular reference
     if (isset($previous[$id])) {
         return;
     }
     $factory = $definition->getFactory();
     if (null === $factory || null !== $definition->getClass()) {
         return;
     }
     $class = null;
     if (is_string($factory)) {
         try {
             $m = new \ReflectionFunction($factory);
         } catch (\ReflectionException $e) {
             return;
         }
     } else {
         if ($factory[0] instanceof Reference) {
             $previous[$id] = true;
             $factoryDefinition = $container->findDefinition((string) $factory[0]);
             $this->updateDefinition($container, (string) $factory[0], $factoryDefinition, $previous);
             $class = $factoryDefinition->getClass();
         } else {
             $class = $factory[0];
         }
         try {
             $m = new \ReflectionMethod($class, $factory[1]);
         } catch (\ReflectionException $e) {
             return;
         }
     }
     $returnType = $m->getReturnType();
     if (null !== $returnType && !$returnType->isBuiltin()) {
         $returnType = (string) $returnType;
         if (null !== $class) {
             $declaringClass = $m->getDeclaringClass()->getName();
             if ('self' === $returnType) {
                 $returnType = $declaringClass;
             } elseif ('parent' === $returnType) {
                 $returnType = get_parent_class($declaringClass) ?: null;
             }
         }
         $definition->setClass($returnType);
     }
 }
开发者ID:ayoah,项目名称:symfony,代码行数:46,代码来源:FactoryReturnTypePass.php

示例4: shouldFactoryBuiltDefinitionBeAutowired

 /**
  * @param ContainerBuilder $containerBuilder
  * @param Definition $definition
  *
  * @return bool
  */
 private function shouldFactoryBuiltDefinitionBeAutowired(ContainerBuilder $containerBuilder, Definition $definition) : bool
 {
     $factory = $definition->getFactory();
     // functions specified as string are not supported
     if (is_string($factory)) {
         return false;
     }
     list($class, $method) = $factory;
     if ($class instanceof Reference) {
         $factoryClassDefinition = $containerBuilder->getDefinition($class);
         $class = $factoryClassDefinition->getClass();
     }
     $factoryMethodReflection = new ReflectionMethod($class, $method);
     if (!$this->hasMethodArguments($factoryMethodReflection)) {
         return false;
     }
     if ($this->areAllMethodArgumentsRequired($definition, $factoryMethodReflection)) {
         return false;
     }
     if (!$this->haveMissingArgumentsTypehints($definition, $factoryMethodReflection)) {
         return false;
     }
     return true;
 }
开发者ID:Symplify,项目名称:DefaultAutowire,代码行数:30,代码来源:DefinitionAnalyzer.php

示例5: describeContainerDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeContainerDefinition(Definition $definition, array $options = array())
 {
     $output = '- Class: `' . $definition->getClass() . '`' . "\n" . '- Scope: `' . $definition->getScope() . '`' . "\n" . '- Public: ' . ($definition->isPublic() ? 'yes' : 'no') . "\n" . '- Synthetic: ' . ($definition->isSynthetic() ? 'yes' : 'no') . "\n" . '- Lazy: ' . ($definition->isLazy() ? 'yes' : 'no') . "\n" . '- Synchronized: ' . ($definition->isSynchronized() ? 'yes' : 'no') . "\n" . '- Abstract: ' . ($definition->isAbstract() ? 'yes' : 'no');
     if ($definition->getFile()) {
         $output .= "\n" . '- File: `' . $definition->getFile() . '`';
     }
     if ($definition->getFactoryClass()) {
         $output .= "\n" . '- Factory Class: `' . $definition->getFactoryClass() . '`';
     }
     if ($definition->getFactoryService()) {
         $output .= "\n" . '- Factory Service: `' . $definition->getFactoryService() . '`';
     }
     if ($definition->getFactoryMethod()) {
         $output .= "\n" . '- Factory Method: `' . $definition->getFactoryMethod() . '`';
     }
     if ($factory = $definition->getFactory()) {
         if (is_array($factory)) {
             if ($factory[0] instanceof Reference) {
                 $output .= "\n" . '- Factory Service: `' . $factory[0] . '`';
             } elseif ($factory[0] instanceof Definition) {
                 throw new \InvalidArgumentException('Factory is not describable.');
             } else {
                 $output .= "\n" . '- Factory Class: `' . $factory[0] . '`';
             }
             $output .= "\n" . '- Factory Method: `' . $factory[1] . '`';
         } else {
             $output .= "\n" . '- Factory Function: `' . $factory . '`';
         }
     }
     if (!(isset($options['omit_tags']) && $options['omit_tags'])) {
         foreach ($definition->getTags() as $tagName => $tagData) {
             foreach ($tagData as $parameters) {
                 $output .= "\n" . '- Tag: `' . $tagName . '`';
                 foreach ($parameters as $name => $value) {
                     $output .= "\n" . '    - ' . ucfirst($name) . ': ' . $value;
                 }
             }
         }
     }
     $this->write(isset($options['id']) ? sprintf("%s\n%s\n\n%s\n", $options['id'], str_repeat('~', strlen($options['id'])), $output) : $output);
 }
开发者ID:tonydub,项目名称:jarvis,代码行数:44,代码来源:MarkdownDescriptor.php

示例6: getServiceDefinition

 /**
  * Gets a service definition as PHP array.
  *
  * @param \Symfony\Component\DependencyInjection\Definition $definition
  *   The definition to process.
  *
  * @return array
  *   The service definition as PHP array.
  *
  * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
  *   Thrown when the definition is marked as decorated, or with an explicit
  *   scope different from SCOPE_CONTAINER and SCOPE_PROTOTYPE.
  */
 protected function getServiceDefinition(Definition $definition)
 {
     $service = array();
     if ($definition->getClass()) {
         $service['class'] = $definition->getClass();
     }
     if (!$definition->isPublic()) {
         $service['public'] = FALSE;
     }
     if ($definition->getFile()) {
         $service['file'] = $definition->getFile();
     }
     if ($definition->isSynthetic()) {
         $service['synthetic'] = TRUE;
     }
     if ($definition->isLazy()) {
         $service['lazy'] = TRUE;
     }
     if ($definition->getArguments()) {
         $arguments = $definition->getArguments();
         $service['arguments'] = $this->dumpCollection($arguments);
         $service['arguments_count'] = count($arguments);
     } else {
         $service['arguments_count'] = 0;
     }
     if ($definition->getProperties()) {
         $service['properties'] = $this->dumpCollection($definition->getProperties());
     }
     if ($definition->getMethodCalls()) {
         $service['calls'] = $this->dumpMethodCalls($definition->getMethodCalls());
     }
     if (($scope = $definition->getScope()) !== ContainerInterface::SCOPE_CONTAINER) {
         if ($scope === ContainerInterface::SCOPE_PROTOTYPE) {
             // Scope prototype has been replaced with 'shared' => FALSE.
             // This is a Symfony 2.8 forward compatibility fix.
             // Reference: https://github.com/symfony/symfony/blob/2.8/UPGRADE-2.8.md#dependencyinjection
             $service['shared'] = FALSE;
         } else {
             throw new InvalidArgumentException("The 'scope' definition is deprecated in Symfony 3.0 and not supported by Drupal 8.");
         }
     }
     // By default services are shared, so just provide the flag, when needed.
     if ($definition->isShared() === FALSE) {
         $service['shared'] = $definition->isShared();
     }
     if (($decorated = $definition->getDecoratedService()) !== NULL) {
         throw new InvalidArgumentException("The 'decorated' definition is not supported by the Drupal 8 run-time container. The Container Builder should have resolved that during the DecoratorServicePass compiler pass.");
     }
     if ($callable = $definition->getFactory()) {
         $service['factory'] = $this->dumpCallable($callable);
     }
     if ($callable = $definition->getConfigurator()) {
         $service['configurator'] = $this->dumpCallable($callable);
     }
     return $service;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:69,代码来源:OptimizedPhpArrayDumper.php

示例7: addNewInstance

 private function addNewInstance($id, Definition $definition, $return, $instantiation)
 {
     $class = $this->dumpValue($definition->getClass());
     $arguments = array();
     foreach ($definition->getArguments() as $value) {
         $arguments[] = $this->dumpValue($value);
     }
     if (null !== $definition->getFactory()) {
         $callable = $definition->getFactory();
         if (is_array($callable)) {
             if ($callable[0] instanceof Reference || $callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0])) {
                 return sprintf("        {$return}{$instantiation}%s->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
             }
             $class = $this->dumpValue($callable[0]);
             // If the class is a string we can optimize call_user_func away
             if (strpos($class, "'") === 0) {
                 return sprintf("        {$return}{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : '');
             }
             return sprintf("        {$return}{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', ' . implode(', ', $arguments) : '');
         }
         return sprintf("        {$return}{$instantiation}\\%s(%s);\n", $callable, $arguments ? implode(', ', $arguments) : '');
     } elseif (null !== $definition->getFactoryMethod(false)) {
         if (null !== $definition->getFactoryClass(false)) {
             $class = $this->dumpValue($definition->getFactoryClass(false));
             // If the class is a string we can optimize call_user_func away
             if (strpos($class, "'") === 0) {
                 return sprintf("        {$return}{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $definition->getFactoryMethod(false), $arguments ? implode(', ', $arguments) : '');
             }
             return sprintf("        {$return}{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass(false)), $definition->getFactoryMethod(false), $arguments ? ', ' . implode(', ', $arguments) : '');
         }
         if (null !== $definition->getFactoryService(false)) {
             return sprintf("        {$return}{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService(false)), $definition->getFactoryMethod(false), implode(', ', $arguments));
         }
         throw new RuntimeException(sprintf('Factory method requires a factory service or factory class in service definition for %s', $id));
     }
     if (false !== strpos($class, '$')) {
         return sprintf("        \$class = %s;\n\n        {$return}{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments));
     }
     return sprintf("        {$return}{$instantiation}new %s(%s);\n", $this->dumpLiteralClass($class), implode(', ', $arguments));
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:40,代码来源:PhpDumper.php

示例8: addNewInstance

    private function addNewInstance(Definition $definition, $return, $instantiation, $id)
    {
        $class = $this->dumpValue($definition->getClass());

        $arguments = array();
        foreach ($definition->getArguments() as $value) {
            $arguments[] = $this->dumpValue($value);
        }

        if (null !== $definition->getFactory()) {
            $callable = $definition->getFactory();
            if (is_array($callable)) {
                if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $callable[1])) {
                    throw new RuntimeException(sprintf('Cannot dump definition because of invalid factory method (%s)', $callable[1] ?: 'n/a'));
                }

                if ($callable[0] instanceof Reference
                    || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
                    return sprintf("        $return{$instantiation}%s->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
                }

                $class = $this->dumpValue($callable[0]);
                // If the class is a string we can optimize call_user_func away
                if (0 === strpos($class, "'") && false === strpos($class, '$')) {
                    if ("''" === $class) {
                        throw new RuntimeException(sprintf('Cannot dump definition: The "%s" service is defined to be created by a factory but is missing the service reference, did you forget to define the factory service id or class?', $id));
                    }

                    return sprintf("        $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : '');
                }

                if (0 === strpos($class, 'new ')) {
                    return sprintf("        $return{$instantiation}(%s)->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
                }

                return sprintf("        $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
            }

            return sprintf("        $return{$instantiation}%s(%s);\n", $this->dumpLiteralClass($this->dumpValue($callable)), $arguments ? implode(', ', $arguments) : '');
        }

        if (false !== strpos($class, '$')) {
            return sprintf("        \$class = %s;\n\n        $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments));
        }

        return sprintf("        $return{$instantiation}new %s(%s);\n", $this->dumpLiteralClass($class), implode(', ', $arguments));
    }
开发者ID:symfony,项目名称:symfony,代码行数:47,代码来源:PhpDumper.php

示例9: addNewInstance

    private function addNewInstance($id, Definition $definition, $return, $instantiation)
    {
        $class = $this->dumpValue($definition->getClass());

        $arguments = array();
        foreach ($definition->getArguments() as $value) {
            $arguments[] = $this->dumpValue($value);
        }

        if (null !== $definition->getFactory()) {
            $callable = $definition->getFactory();
            if (is_array($callable)) {
                if ($callable[0] instanceof Reference
                    || ($callable[0] instanceof Definition && $this->definitionVariables->contains($callable[0]))) {
                    return sprintf("        $return{$instantiation}%s->%s(%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? implode(', ', $arguments) : '');
                }

                $class = $this->dumpValue($callable[0]);
                // If the class is a string we can optimize call_user_func away
                if (strpos($class, "'") === 0) {
                    return sprintf("        $return{$instantiation}%s::%s(%s);\n", $this->dumpLiteralClass($class), $callable[1], $arguments ? implode(', ', $arguments) : '');
                }

                return sprintf("        $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($callable[0]), $callable[1], $arguments ? ', '.implode(', ', $arguments) : '');
            }

            return sprintf("        $return{$instantiation}\\%s(%s);\n", $callable, $arguments ? implode(', ', $arguments) : '');
        }

        if (false !== strpos($class, '$')) {
            return sprintf("        \$class = %s;\n\n        $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments));
        }

        return sprintf("        $return{$instantiation}new %s(%s);\n", $this->dumpLiteralClass($class), implode(', ', $arguments));
    }
开发者ID:ninvfeng,项目名称:symfony,代码行数:35,代码来源:PhpDumper.php

示例10: 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

示例11: 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

示例12: canDefinitionBeAutowired

 /**
  * @param string $serviceId
  * @param Definition $definition
  * @return boolean
  */
 private function canDefinitionBeAutowired($serviceId, Definition $definition)
 {
     foreach ($this->getIgnoredServicePatterns() as $pattern) {
         if ($pattern[0] === "/" && preg_match($pattern, $serviceId) || strcasecmp($serviceId, $pattern) == 0) {
             return false;
         }
     }
     if ($definition->isAbstract() || $definition->isSynthetic() || !$definition->isPublic() || !$definition->getClass() || $definition->getFactory() || $definition->getFactoryClass(false) || $definition->getFactoryService(false) || $definition->getFactoryMethod(false)) {
         return false;
     }
     return true;
 }
开发者ID:mzstic,项目名称:autowiring-bundle,代码行数:17,代码来源:AutowiringCompilerPass.php

示例13: hydrateDefinitionFactory

 /**
  * Try to hydrate definition factory from entity into definition array.
  *
  * @param  Definition $definition
  * @param  array      &$definitionArray
  * @return [type]
  */
 private function hydrateDefinitionFactory(Definition $definition, array &$definitionArray)
 {
     if (null !== $definition->getFactory()) {
         foreach ($definition->getFactory() as $argument) {
             $definitionArray['factory'][] = $this->convertArgument($argument);
         }
     }
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:15,代码来源:PhpArrayDumper.php

示例14: 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>Lazy</comment>             %s', $definition->isLazy() ? 'yes' : 'no');
     $description[] = sprintf('<comment>Synchronized</comment>     %s', $definition->isSynchronized() ? 'yes' : 'no');
     $description[] = sprintf('<comment>Abstract</comment>         %s', $definition->isAbstract() ? 'yes' : 'no');
     if ($definition->getFile()) {
         $description[] = sprintf('<comment>Required File</comment>    %s', $definition->getFile() ? $definition->getFile() : '-');
     }
     if ($definition->getFactoryClass()) {
         $description[] = sprintf('<comment>Factory Class</comment>    %s', $definition->getFactoryClass());
     }
     if ($definition->getFactoryService()) {
         $description[] = sprintf('<comment>Factory Service</comment>  %s', $definition->getFactoryService());
     }
     if ($definition->getFactoryMethod()) {
         $description[] = sprintf('<comment>Factory Method</comment>   %s', $definition->getFactoryMethod());
     }
     if ($factory = $definition->getFactory()) {
         if (is_array($factory)) {
             if ($factory[0] instanceof Reference) {
                 $description[] = sprintf('<comment>Factory Service</comment>  %s', $factory[0]);
             } elseif ($factory[0] instanceof Definition) {
                 throw new \InvalidArgumentException('Factory is not describable.');
             } else {
                 $description[] = sprintf('<comment>Factory Class</comment>    %s', $factory[0]);
             }
             $description[] = sprintf('<comment>Factory Method</comment>   %s', $factory[1]);
         } else {
             $description[] = sprintf('<comment>Factory Function</comment>    %s', $factory);
         }
     }
     $this->writeText(implode("\n", $description) . "\n", $options);
 }
开发者ID:Chaireeee,项目名称:chaireeee,代码行数:55,代码来源:TextDescriptor.php

示例15: getServiceDefinition

 /**
  * Gets a service definition as PHP array.
  *
  * @param \Symfony\Component\DependencyInjection\Definition $definition
  *   The definition to process.
  *
  * @return array
  *   The service definition as PHP array.
  */
 protected function getServiceDefinition($definition)
 {
     $service = array();
     if ($definition->getClass()) {
         $service['class'] = $definition->getClass();
     }
     if (!$definition->isPublic()) {
         $service['public'] = FALSE;
     }
     /*
         $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()) {
         $service['file'] = $definition->getFile();
     }
     if ($definition->isSynthetic()) {
         $service['synthetic'] = TRUE;
     }
     if ($definition->isLazy()) {
         $service['lazy'] = TRUE;
     }
     if ($definition->getArguments()) {
         $service['arguments'] = $this->dumpValue($definition->getArguments());
     }
     if ($definition->getProperties()) {
         $service['properties'] = $this->dumpValue($definition->getProperties());
     }
     if ($definition->getMethodCalls()) {
         $service['calls'] = $this->dumpValue($definition->getMethodCalls());
     }
     if (($scope = $definition->getScope()) !== ContainerInterface::SCOPE_CONTAINER) {
         $service['scope'] = $scope;
     }
     if (($decorated = $definition->getDecoratedService()) !== NULL) {
         $service['decorates'] = $decorated;
     }
     if ($callable = $definition->getFactory()) {
         $service['factory'] = $this->dumpCallable($callable);
     }
     if ($callable = $definition->getConfigurator()) {
         $service['configurator'] = $this->dumpCallable($callable);
     }
     return $service;
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:67,代码来源:PhpArrayDumper.php


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