public function dispatch($signalClassName, $signalName, array $signalArguments = [])
{
if (!isset($this->slots[$signalClassName][$signalName])) {
return;
}
foreach ($this->slots[$signalClassName][$signalName] as $slotInformation) {
if (isset($slotInformation['object'])) {
$object = $slotInformation['object'];
} elseif (substr($slotInformation['method'], 0, 2) === '::') {
if (!isset($this->objectManager)) {
if (is_callable($slotInformation['class'] . $slotInformation['method'])) {
$object = $slotInformation['class'];
} else {
throw new Exception\InvalidSlotException(sprintf('Cannot dispatch %s::%s to class %s. The object manager is not yet available in the Signal Slot Dispatcher and therefore it cannot dispatch classes.', $signalClassName, $signalName, $slotInformation['class']), 1298113624);
}
} else {
$object = $this->objectManager->getClassNameByObjectName($slotInformation['class']);
}
$slotInformation['method'] = substr($slotInformation['method'], 2);
} else {
if (!isset($this->objectManager)) {
throw new Exception\InvalidSlotException(sprintf('Cannot dispatch %s::%s to class %s. The object manager is not yet available in the Signal Slot Dispatcher and therefore it cannot dispatch classes.', $signalClassName, $signalName, $slotInformation['class']), 1298113624);
}
if (!$this->objectManager->isRegistered($slotInformation['class'])) {
throw new Exception\InvalidSlotException('The given class "' . $slotInformation['class'] . '" is not a registered object.', 1245673367);
}
$object = $this->objectManager->get($slotInformation['class']);
}
if ($slotInformation['passSignalInformation'] === true) {
$signalArguments[] = $signalClassName . '::' . $signalName;
}
if (!method_exists($object, $slotInformation['method'])) {
throw new Exception\InvalidSlotException('The slot method ' . get_class($object) . '->' . $slotInformation['method'] . '() does not exist.', 1245673368);
}
call_user_func_array([$object, $slotInformation['method']], $signalArguments);
}
}