public function invokeLifecycleCallbacks($event, $document, array $arguments = null)
{
if (!$document instanceof $this->name) {
throw new \InvalidArgumentException(sprintf('Expected document class "%s"; found: "%s"', $this->name, get_class($document)));
}
if (empty($this->lifecycleCallbacks[$event])) {
return;
}
foreach ($this->lifecycleCallbacks[$event] as $callback) {
if ($arguments !== null) {
call_user_func_array(array($document, $callback), $arguments);
} else {
$document->{$callback}();
}
}
}