Aimeos\ShopBundle\Composer\ScriptHandler::executeCommand PHP Method

executeCommand() protected static method

Executes a Symphony command.
protected static executeCommand ( Composer\Script\CommandEvent $event, string $cmd, array $options = [] )
$event Composer\Script\CommandEvent Command event object
$cmd string Command name to execute, e.g. "aimeos:update"
$options array
    protected static function executeCommand(CommandEvent $event, $cmd, array $options = array())
    {
        $php = escapeshellarg(self::getPhp());
        $console = escapeshellarg(self::getConsoleDir($event) . '/console');
        $cmd = escapeshellarg($cmd);
        foreach ($options as $key => $option) {
            $options[$key] = escapeshellarg($option);
        }
        if ($event->getIO()->isDecorated()) {
            $console .= ' --ansi';
        }
        $process = new Process($php . ' ' . $console . ' ' . $cmd . ' ' . implode(' ', $options), null, null, null, 3600);
        $process->run(function ($type, $buffer) use($event) {
            $event->getIO()->write($buffer, false);
        });
        if (!$process->isSuccessful()) {
            throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command', escapeshellarg($cmd)));
        }
    }