phpAttributeGroupFactory = $phpAttributeGroupFactory;
$this->attributeArrayNameInliner = $attributeArrayNameInliner;
$this->serviceMapProvider = $serviceMapProvider;
}
/**
* @return array
*/
public function extractOptionsFromServiceDefinition(ServiceDefinition $serviceDefinition) : array
{
$options = [];
foreach ($serviceDefinition->getTags() as $tag) {
if ($this->messengerTagName === $tag->getName()) {
$options = $tag->getData();
}
}
if ($options['from_transport']) {
$options['fromTransport'] = $options['from_transport'];
unset($options['from_transport']);
}
return $options;
}
/**
* @return ServiceDefinition[]
*/
public function getHandlersFromServices() : array
{
$serviceMap = $this->serviceMapProvider->provide();
return $serviceMap->getServicesByTag($this->messengerTagName);
}
/**
* @param array $options
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod $node
* @return \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\ClassMethod
*/
public function addAttribute($node, array $options = [])
{
$args = $this->phpAttributeGroupFactory->createArgsFromItems($options, self::AS_MESSAGE_HANDLER_ATTRIBUTE);
$args = $this->attributeArrayNameInliner->inlineArrayToArgs($args);
$node->attrGroups = \array_merge($node->attrGroups, [new AttributeGroup([new Attribute(new FullyQualified(self::AS_MESSAGE_HANDLER_ATTRIBUTE), $args)])]);
return $node;
}
}