本文整理匯總了PHP中Symfony\Component\DependencyInjection\DefinitionDecorator::setMethodCalls方法的典型用法代碼示例。如果您正苦於以下問題:PHP DefinitionDecorator::setMethodCalls方法的具體用法?PHP DefinitionDecorator::setMethodCalls怎麽用?PHP DefinitionDecorator::setMethodCalls使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\DefinitionDecorator
的用法示例。
在下文中一共展示了DefinitionDecorator::setMethodCalls方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: convert
/**
* Converts class hierarchy metadata to definition instances.
*
* @param ClassHierarchyMetadata $metadata
* @return array an array of Definition instances
*/
public function convert(ClassHierarchyMetadata $metadata)
{
static $count = 0;
$definitions = array();
$previous = null;
foreach ($metadata->classMetadata as $classMetadata) {
if (null === $previous && null === $classMetadata->parent) {
$definition = new Definition();
} else {
$definition = new DefinitionDecorator($classMetadata->parent ?: $previous->id);
}
$definition->setClass($classMetadata->name);
if (null !== $classMetadata->scope) {
$definition->setScope($classMetadata->scope);
}
if (null !== $classMetadata->public) {
$definition->setPublic($classMetadata->public);
}
if (null !== $classMetadata->abstract) {
$definition->setAbstract($classMetadata->abstract);
}
if (null !== $classMetadata->lazy) {
$definition->setLazy($classMetadata->lazy);
}
if (null !== $classMetadata->arguments) {
$definition->setArguments($classMetadata->arguments);
}
$definition->setMethodCalls($classMetadata->methodCalls);
$definition->setTags($classMetadata->tags);
$definition->setProperties($classMetadata->properties);
if (null !== $classMetadata->decorates) {
if (!method_exists($definition, 'setDecoratedService')) {
throw new InvalidAnnotationException(sprintf("decorations require symfony >=2.8 on class %s", $classMetadata->name));
}
$definition->setDecoratedService($classMetadata->decorates, $classMetadata->decoration_inner_name);
}
if (null !== $classMetadata->deprecated && method_exists($definition, 'setDeprecated')) {
$definition->setDeprecated(true, $classMetadata->deprecated);
}
if (null === $classMetadata->id) {
$classMetadata->id = '_jms_di_extra.unnamed.service_' . $count++;
}
if (0 !== count($classMetadata->initMethods)) {
foreach ($classMetadata->initMethods as $initMethod) {
$definition->addMethodCall($initMethod);
}
} elseif (null !== $classMetadata->initMethod) {
@trigger_error('ClassMetadata::$initMethod is deprecated since version 1.7 and will be removed in 2.0. Use ClassMetadata::$initMethods instead.', E_USER_DEPRECATED);
$definition->addMethodCall($classMetadata->initMethod);
}
$definitions[$classMetadata->id] = $definition;
$previous = $classMetadata;
}
return $definitions;
}
示例2: convert
/**
* Converts class hierarchy metadata to definition instances.
*
* @param ClassHierarchyMetadata $metadata
* @return array an array of Definition instances
*/
public function convert(ClassHierarchyMetadata $metadata)
{
static $count = 0;
$definitions = array();
$previous = null;
foreach ($metadata->classMetadata as $classMetadata) {
if (null === $previous && null === $classMetadata->parent) {
$definition = new Definition();
} else {
$definition = new DefinitionDecorator($classMetadata->parent ?: $previous->id);
}
$definition->setClass($classMetadata->name);
if (null !== $classMetadata->scope) {
$definition->setScope($classMetadata->scope);
}
if (null !== $classMetadata->public) {
$definition->setPublic($classMetadata->public);
}
if (null !== $classMetadata->abstract) {
$definition->setAbstract($classMetadata->abstract);
}
if (null !== $classMetadata->arguments) {
$definition->setArguments($classMetadata->arguments);
}
$definition->setMethodCalls($classMetadata->methodCalls);
$definition->setTags($classMetadata->tags);
$definition->setProperties($classMetadata->properties);
if (null === $classMetadata->id) {
$classMetadata->id = '_jms_di_extra.unnamed.service_' . $count++;
}
if ($classMetadata->initMethod) {
if (!method_exists($definition, 'setInitMethod')) {
throw new \RuntimeException(sprintf('@AfterSetup is not available on your Symfony version.'));
}
$definition->setInitMethod($classMetadata->initMethod);
}
$definitions[$classMetadata->id] = $definition;
$previous = $classMetadata;
}
return $definitions;
}