@param object $command
@param callable $next

@return mixed
549788
public function execute($command, callable $next)
    {
        $bus = $this->getBusForCommand($command);
        if ($bus === null) {
            return $next($command);
        }

        return $next($bus->handle($command));
    }
461759
public function handle(Request $request, callable $next)
    {
        $response = $next($request);
        if ( is_string($response) ) {
            return new Response($response);
        }

        return $response;
    }
362454
public function exec($command)
    {
        $this->_events[] = $event = new Event($this->_mutex, $command);
        return $event;
    }
615101
public function dispatchNow($command, $handler = null)
    {
        if ($handler || $handler = $this->getCommandHandler($command)) {
            $callback = function ($command) use ($handler) {
                return $handler->handle($command);
            };
        } else {
            $callback = function ($command) {
                return call_user_func_array([$command, 'handle'], ['kernel'=>Zilf::$container->getShare('consoleKernel')]);
            };
        }

        return $this->pipeline->send($command)->through($this->pipes)->then($callback);
    }
1058565
public function findCommandHandlerFor(Command $command)
    {
        if (!isset($this->subscriptions[$command->commandName()])) {
            throw new CommandHandlerNotFoundException(sprintf('No handler was found for command %s', $command->commandName()));
        }

        return $this->subscriptions[$command->commandName()];
    }
111426
public function handle($command, $next)
    {
        $command->files()->transform(function($item) use ($command) {
            $validateService = app(ValidateFilenameService::class);

            return [
                'name' => $validateService->execute($command->dir, $item['name'], $command->disk),
                'file' => $item['file'],
            ];
        });

        return $next($command);
    }
150829
public function execute($command, callable $next)
    {
        $this->entityManager->beginTransaction();

        try {
            $returnValue = $next($command);

            $this->entityManager->flush();
            $this->entityManager->commit();
        } catch (Exception $e) {
            $this->rollbackTransaction();

            throw $e;
        } catch (Throwable $e) {
            $this->rollbackTransaction();

            throw $e;
        }

        return $returnValue;
    }
773886
final public function execute($command, AnCommandContext $context)
    {
        $identifier = $context->caller->getIdentifier();

        if ($context->entity instanceof AnDomainEntityAbstract) {
            $identifier = $context->entity->getIdentifier();
        }

        $type = $identifier->path;
        $type = array_pop($type);

        $parts = explode('.', $command);
        $method = '_'.($parts[0]).ucfirst($type).ucfirst($parts[1]);

        $result = null;

        if (method_exists($this, $method)) {
            $result = $this->$method($context);
        }

        if ($context->entity) {
            $result = $context->entity->execute($command, $context);
        }

        return $result;
    }
268606
public function execute($command, callable $next)
    {
        try {
            $result = $next($command);
        } catch (\Exception $exception) {
            $this->eventRecorder->eraseEvents();

            throw $exception;
        }

        $recordedEvents = $this->eventRecorder->releaseEvents();

        foreach ($recordedEvents as $event) {
            $this->eventDispatcher->dispatch($event);
        }

        return $result;
    }
525016
public function getCommandCallbacks($command = null)
    {
        $result = array();
        if($command)
        {
            if(isset($this->__command_callbacks[$command])) {
                $result = $this->__command_callbacks[$command];
            }
        }
        else $result = $this->__command_callbacks;

        return $result;
    }
392411
public function execute(Command $command, callable $next)
    {
        $itemName = $this->getItemName($command->getFile()->path());
        $item = $this->dataStore->getItem($itemName);
        if ($item->isMiss() || $this->parser->isForced()) {
            return $this->updateCache($command, $next, $item);
        }

        /** @var File $cachedFile */
        $cachedFile = $item->get();

        if ($cachedFile === null) {
            return $this->updateCache($command, $next, $item);
        }

        if ($cachedFile->getHash() !== $command->getFile()->md5()) {
            return $this->updateCache($command, $next, $item);
        }

        return $cachedFile;
    }
387792
public function callCommand(string $command, array $arguments = [])
    {
        $newCommand = $this->getApplication()->find($command);

        $arguments['command'] = $command;

        return $newCommand->run(new ArrayInput($arguments), $this->getOutput());
    }
428694
public function handle($command)
    {
        if (!is_object($command)) {
            throw InvalidCommandException::forUnknownValue($command);
        }

        $middlewareChain = $this->middlewareChain;
        return $middlewareChain($command);
    }
272988
public function execute(Command $command, callable $next)
    {
        $filename = $command->getFile()->path();
        $this->log('Starting to parse file: ' . $filename, LogLevel::INFO);

        try {
            return $next($command);
        } catch (Exception $e) {
            $this->log(
                '  Unable to parse file "' . $filename . '", an error was detected: ' . $e->getMessage(),
                LogLevel::ALERT
            );
        }

        return null;
    }
1018668
protected function call($command, $params = [])
    {
        $parameters['command'] = $command;

        foreach($params as $key => $value) {
            $parameters[$key] = $value;
        }

        $command = $this->getApplication()->find($command);

        return $command->run(new ArrayInput($parameters), $this->output);
    }
253396
public function job($command)
    {
        $line = new Job($command, $this);
        $this->lines[] = $line;

        return $line;
    }
1317451
public function dispatchNow($command, Closure $afterResolving = null)
    {
        return $this->pipeline->send($command)->through($this->pipes)->then(function ($command) use ($afterResolving) {
            if ($command instanceof SelfHandling) {
                return $this->container->call([$command, 'handle']);
            }

            $handler = $this->resolveHandler($command);

            if ($afterResolving) {
                call_user_func($afterResolving, $handler);
            }

            return call_user_func(
                [$handler, $this->getHandlerMethod($command)], $command
            );
        });
    }