biig-io/DomainComponent

Potential issue following the documentation

Closed this issue · 1 comments

Nek- commented

usage defined here: https://github.com/biig-io/DomainComponent/blob/master/docs/domain_event_dispatcher.md#symfony-integration potentially fail because no event is specified

This is not normal (because the rule is actually a subscriber and return the event it's bound on) and should be fix.

Related lines:

private function addListenerForEventsInDefinition(string $id, string $class, array $attribute, Definition $definition)
{
// Rules may not implement the
$method = $attribute['method'] ?? null;
$event = $attribute['event'] ?? null;
$priority = $attribute['priority'] ?? 0;
if (!class_exists($class, false)) {
throw new InvalidArgumentException(
sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)
);
}
if (null === $method || null === $event) {
throw new InvalidArgumentException(sprintf(
'Impossible to register class "%s" as domain rule: the service configuration is wrong.',
$class
));
}
$definition->addMethodCall('addListener', [
$event,
[new ServiceClosureArgument(new Reference($id)), $method],
$priority,
]);
}

Nek- commented

Nothing wrong finally.