If I understood correctly, I think you are asking about implementing minimalistic single responsibility event listeners declared in the YML config file, like in this Java example:
class MyListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
myTextArea.append('Hello from MyListener');
}
}
That is not possible since this is this what the EventDispatcher
actually does:
public function addSubscriber(EventSubscriberInterface $subscriber)
{
foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
if (is_string($params)) {
$this->addListener($eventName, array($subscriber, $params));
} elseif (is_string($params[0])) {
$this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
} else {
foreach ($params as $listener) {
$this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
}
}
}
}
You can still have your separate ActionListener
's, but you would have to write some code to call them from your implementation of EventSubscriberInterface
.