Build reduced href required by legacy callbacks.

@param CommandInterface $command The command for which the href shall get built.

@return string
423672
protected function buildHref(CommandInterface $command)
    {
        $arrParameters = (array) $command->getParameters();
        $strHref       = '';

        foreach ($arrParameters as $key => $value) {
            $strHref .= \sprintf('&%s=%s', $key, $value);
        }

        return $strHref;
    }
948339
private function intercept(Command $command)
    {
        foreach ($this->dispatchInterceptors as $dispatchInterceptor) {
            $command = $dispatchInterceptor->handle($command);
        }

        return $command;
    }
263931
public function handle(CommandInterface $command)
    {
        $object = $command->getParameter('data');

        if ($command->hasParameter('class')) {
            $class = $command->getParameter('class');
            if (!($object instanceof $class)) {
                return CommandResult::error('invalid_instance');
            }
        }

        try {
            $this->objectManager->flush();
        } catch (ForeignKeyConstraintViolationException $e) {
            return CommandResult::error('constraint_violation');
        }
    }
683884
public function drush($command) {
    // @todo Set to silent if verbosity is less than very verbose.
    $bin = $this->getConfigValue('composer.bin');
    /** @var \Robo\Common\ProcessExecutor $process_executor */
    $drush_alias = $this->getConfigValue('drush.alias');
    $command_string = "'$bin/drush' @$drush_alias $command";

    // URIs do not work on remote drush aliases in Drush 9. Instead, it is
    // expected that the alias define the uri in its configuration.
    if ($drush_alias != 'self') {
      $command_string .= ' --uri=' . $this->getConfigValue('site');
    }

    $process_executor = Robo::process(new Process($command_string));

    return $process_executor->dir($this->getConfigValue('docroot'))
      ->interactive(FALSE)
      ->printOutput(TRUE)
      ->printMetadata(TRUE)
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERY_VERBOSE);
  }
1206743
public static function first(CommandInterface $command, $prefix)
    {
        if ($arguments = $command->getArguments()) {
            $arguments[0] = "$prefix{$arguments[0]}";
            $command->setRawArguments($arguments);
        }
    }
32770
protected function _getServerHttpUrlFromCommand($command)
    {
        $base = null;

        $cmMethod = strtolower( (string) $command );
        switch ($cmMethod) {
            case 'getauthurl':
                $base = 'auth';
                break;
            case 'token':
                $base = 'auth/token';
                break;

            case 'register':
                $base = 'api/v1/members';
                break;

            case 'accountinfo':
                $params = iterator_to_array($command);
                if (isset($params['username']))
                    $postfix = 'u/'.$params['username'];
                else
                    $postfix = '-'.current($params);
                $base = 'api/v1/members/profile/'.$postfix;
                break;

            case 'listaccountsinfo':
                $base = 'api/v1/members/profiles';
                break;

            case 'recover::validate':
                /** @var Validate $command */
                $params = iterator_to_array($command);
                $base = 'api/v1/me/identifiers/change/confirm/'.$params['validation_code'];
                break;
            case 'recover::resendcode':
                /** @var Validate $command */
                $params = iterator_to_array($command);
                $base = 'recover/validate/resend/'.$params['validation_code'].'/'.$params['identifier_type'];
                break;

            case 'members::exists':
                /** @var Exists $command */
                $base = 'api/v1/members/exists';
                break;
            case 'members::whois':
                /** @var Whois $command */
                $base = 'api/v1/members/whois';
                break;
            case 'members::validateuseridentifier':
                /** @var ValidateUserIdentifier $command */
                $base = 'api/v1/members/'.$command->getUserId().'/validate/'.$command->getIdentifier();
                break;

            case 'me::accountinfo':
                $postfix = '';
                /** @var AccountInfo $command */
                if ( $command->getIncludeGrants() )
                    $postfix = '?grants';

                $base = 'api/v1/me/profile'.$postfix;
                break;
            case 'me::changepassword':
                $base = 'api/v1/me/grants/password';
                break;
            case 'me::changeidentity':
                $base = 'api/v1/me/identifiers/change';
                break;
        }

        $serverUrl = rtrim($this->serverBaseUrl, '/');
        (! $base ) ?: $serverUrl .= '/'. trim($base, '/');
        return $serverUrl;
    }
1264962
public function dispatch(CommandInterface $command)
    {
        $this->commandStack[] = $command;

        if ($this->executing) {
            return array();
        }

        $first          = true;
        $aggregateRoots = array();

        while ($command = array_shift($this->commandStack)) {
            $aggregateRoots[] = $this->invokeHandler($command, $first);
            $first            = false;
        }

        return $aggregateRoots;
    }
495553
public static function migrate(CommandInterface $command, $prefix)
    {
        if ($arguments = $command->getArguments()) {
            $arguments[2] = "$prefix{$arguments[2]}";
            $command->setRawArguments($arguments);
        }
    }
41354
protected function getKeyFromSortCommand(CommandInterface $command)
    {
        $arguments = $command->getArguments();
        $firstKey = $arguments[0];

        if (1 === $argc = count($arguments)) {
            return $firstKey;
        }

        $keys = array($firstKey);

        for ($i = 1; $i < $argc; ++$i) {
            if (strtoupper($arguments[$i]) === 'STORE') {
                $keys[] = $arguments[++$i];
            }
        }

        if ($this->checkSameSlotForKeys($keys)) {
            return $firstKey;
        }
    }
34142
private function getCommandLabel(CommandInterface $command)
    {
        if (null === $label = $command->getLabel()) {
            $label = $command->getName();
        }

        $label = $this->translate($label);

        return \is_array($label) ? $label[0] : $label;
    }
1086780
protected function getKeyFromGeoradiusCommands(CommandInterface $command)
    {
        $arguments = $command->getArguments();
        $argc = count($arguments);
        $startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;

        if ($argc > $startIndex) {
            $keys = array($arguments[0]);

            for ($i = $startIndex; $i < $argc; ++$i) {
                $argument = strtoupper($arguments[$i]);
                if ($argument === 'STORE' || $argument === 'STOREDIST') {
                    $keys[] = $arguments[++$i];
                }
            }

            if ($this->checkSameSlotForKeys($keys)) {
                return $arguments[0];
            } else {
                return;
            }
        }

        return $arguments[0];
    }
238599
public function parse(CommandInterface $command)
    {
        $response = $command->getRequest()->getResponse();

        // If there is no response or Body, just return it
        if ($response === null || !$response->getBody()) {
            return $response;
        }

        $responseArray = $this->parseResponseIntoArray($response);

        // Handle multi-result responses
        if (array_key_exists('results', $responseArray)) {
            return $this->createMultiResultResponse($response);
        }

        return $this->createSingleResultResponse($response);
    }
35639
public function prepare($command)
    {
        // change path for php
        if (substr($command, 0, 4) == 'php ') {
            $command = $this->finder->getPath().substr($command, 3);
        }

        // change path to console
        $command = str_replace(' app/console ', ' '.$this->console.' ', $command);

        // change /dev/null for Windows
        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
            $command = str_replace('/dev/null', 'nul', $command);
        }

        return $command;
    }
54513
protected function _commandDelete($command)
    {
        $entity = $this->getController()->getItem();

        $name = AnInflector::pluralize($this->getController()->getIdentifier()->name);
        $redirect = 'option=com_'.$this->getIdentifier()->package.'&view='.$name;

        $command->append(array('label' => AnTranslator::_('LIB-AN-ACTION-DELETE')))
        ->href(route($entity->getURL()))
        ->setAttribute('data-action', 'delete')
        ->setAttribute('data-redirect', route($redirect))
        ->class('action-delete');
    }
323058
public function handle(CommandInterface $command)
    {
        $handleAll = $command->getParameter('selectedAll');
        $ids = $command->getParameter('selected');

        try {
            $this->queryExecutor->beginTransaction();

            if ($handleAll) {
                $criteria = \json_decode($command->getParameter('query'), true);
                $this->displayCriteriaFactory->setAttributes($criteria);
                $displayCriteria = $this->displayCriteriaFactory->createCriteria([
                    'filter' => $this->filterFactory->create($criteria['filter_type']),
                ]);
                $displayCriteria->getPager()->disable();

                $this->handleAll($displayCriteria);
            } else {
                foreach ($ids as $id) {
                    $result = $this->handleOne($id);

                    if (!$result->isSuccessful()) {
                        throw new \Exception();
                    }
                }
            }

            $this->queryExecutor->commit();
        } catch (\Exception $e) {
            $this->queryExecutor->rollback();

            $return = CommandResult::error('batch_error');
            if (isset($result)) {
                $return->addMessages($result->getMessages());
            }

            return $return;
        }

        return CommandResult::success('batch_success', ['%count%' => \count($ids)]);
    }
682467
protected function formattedCommand($command)
    {
        $structure = [
            $this->getEnvVariable(),
            $this->executable,
            $this->getOptions(),
            $command
        ];

        return implode(' ', array_filter($structure));
    }
862620
public function resolveCommand($command)
    {
        if ($fullPaths = $this->findWhere($command)) {
            $fullPaths = preg_split('/[\r\n]/', trim($fullPaths));
            $command = end($fullPaths);
        }

        return $command;
    }