/**
* @param object $command
* @param callable $next
*/
public function execute($command, callable $next)
{
if ($command instanceof Command) {
$this->extensionRegistry->pre($command);
}
try {
$next($command);
} catch (\Exception $exception) {
$this->extensionRegistry->passException($command, $exception);
throw $exception;
}
if ($command instanceof Command) {
$this->extensionRegistry->post($command);
}
}