Applies the specified prefix to the key of a GEORADIUS command.

@param CommandInterface $command Command instance.
@param string           $prefix  Prefix string.
508484
public static function georadius(CommandInterface $command, $prefix)
    {
        if ($arguments = $command->getArguments()) {
            $arguments[0] = "$prefix{$arguments[0]}";
            $startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4;

            if (($count = count($arguments)) > $startIndex) {
                for ($i = $startIndex; $i < $count; ++$i) {
                    switch (strtoupper($arguments[$i])) {
                        case 'STORE':
                        case 'STOREDIST':
                            $arguments[$i] = "$prefix{$arguments[++$i]}";
                            break;

                    }
                }
            }

            $command->setRawArguments($arguments);
        }
    }
1140223
protected function addCommandConditions(CommandInterface $command, array $definition)
    {
        if (!isset($definition[static::CONFIG_CONDITIONS])) {
            return;
        }

        foreach ($definition[static::CONFIG_CONDITIONS] as $condition) {
            $condition = $this->conditionFactory->createCondition($condition);
            $command->addCondition($condition);
        }
    }
350215
protected function setCommand($command)
    {
        $this->command = $command;

        if (!is_null($this->loader)) {
            $this->loader->setCommand($this->command);
        }
    }
1000735
protected function shouldBeExecuted(CommandInterface $command, ConfigurationInterface $configuration): bool
    {
        if ($configuration->isDryRun()) {
            $configuration->getOutput()->dryRunCommand($command);

            return false;
        }

        if ($command->isExcluded() || $this->hasConditionAndConditionNotMatched($command)) {
            return false;
        }

        return true;
    }
584367
protected function checkCommandType(CommandInterface $command)
    {
        $expectedCommandClass = $this->getCommandClass();
        if (!is_a($command, $expectedCommandClass, true)) {
            $actualCommandClass      = get_class($command);
            $handlerClass            = get_called_class();
            $invalidCommandException = new InvalidCommandException(
                "Command handler '$handlerClass' should only be registered to handle '$expectedCommandClass' commands"
            );
            $this->logError(
                "{$handlerClass} cannot handle commands of type {$actualCommandClass}",
                $invalidCommandException
            );
            throw $invalidCommandException;
        }
    }
8743
protected function setExcluded(CommandInterface $command, array $definition)
    {
        if (isset($definition[static::CONFIG_EXCLUDED]) && $definition[static::CONFIG_EXCLUDED]) {
            $command->markAsExcluded();
        }
    }
273585
private function checkExistenceWithCommand(CommandInterface $command)
    {
        try {
            $this->execute($command);
            return true;
        } catch (S3Exception $e) {
            if ($e->getAwsErrorCode() == 'AccessDenied') {
                return true;
            }
            if ($e->getStatusCode() >= 500) {
                throw $e;
            }
            return false;
        }
    }
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');
        }
    }
742134
public function setPrefix($prefix)
    {
        $this->prefix = $prefix;

        if (!empty($this->prefix)) {
            $this->prefix .= ".";
        }
    }
741995
protected function setEnv(CommandInterface $command, array $definition)
    {
        if (isset($definition[static::CONFIG_ENV])) {
            $command->setEnv($definition[static::CONFIG_ENV]);
        }
    }
757465
protected function validateCommand(CommandInterface $command)
    {
        $this->checkCommandType($command);

        if (!$this->validator instanceof ValidatorInterface) {
            $validatorUnavailableException = new \RuntimeException('Validator is not available');
            $this->logError('Validator service unavailable', $validatorUnavailableException);
            throw $validatorUnavailableException;
        }

        $violationsList = $this->validator->validate($command);

        if (count($violationsList) > 0) {
            throw new InvalidCommandParametersException($violationsList);
        }
    }
1324470
public function apply(AbstractCommand $command)
    {
        foreach ($this->mappingMethods as $method) {
            if (call_user_func_array([$this, $method], [$command, $this->registry->get($command->storage)])) {
                return true;
            }
        }

        return false;
    }
303840
public function run(CommandInterface $command, $result = null)
    {
        $key = $command->getRequestMethod() === 'GET' ? 'query' : 'body';
        $options = [$key => []];

        if(!empty($params = $command->getParams())) {
            $options[$key] = array_merge($options[$key], $params);
        }

        if($config = $this->getConfig()) {
            if(!empty($config->getSteamKey())) {
                $options[$key]['key'] = $config->getSteamKey();
            }

            $this->urlBuilder->setBaseUrl($config->getBaseSteamApiUrl());
        }

        $request = new Request(
            $command->getRequestMethod(),
            $this->urlBuilder->build($command)
        );

        return $this->client->sendAsync($request, $options);
    }
228348
protected function prepareRequest(
        CommandInterface $command,
        RequestInterface $request
    ) {
        $visitedLocations = [];
        $operation = $this->description->getOperation($command->getName());

        // Visit each actual parameter
        foreach ($operation->getParams() as $name => $param) {
            /* @var Parameter $param */
            $location = $param->getLocation();
            // Skip parameters that have not been set or are URI location
            if ($location == 'uri' || !$command->hasParam($name)) {
                continue;
            }
            if (!isset($this->locations[$location])) {
                throw new \RuntimeException("No location registered for $name");
            }
            $visitedLocations[$location] = true;
            $request = $this->locations[$location]->visit($command, $request, $param);
        }

        // Ensure that the after() method is invoked for additionalParameters
        /** @var Parameter $additional */
        if ($additional = $operation->getAdditionalParameters()) {
            $visitedLocations[$additional->getLocation()] = true;
        }

        // Call the after() method for each visited location
        foreach (array_keys($visitedLocations) as $location) {
            $request = $this->locations[$location]->after($command, $request, $operation);
        }

        return $request;
    }
269784
public function execute(CommandInterface $command)
    {
        $commandHandler = $this->handlerRepository->getHandler($command);

        if ($commandHandler instanceof CommandExecutorAwareInterface) {
            $commandHandler->setCommandExecutor($this);
        }

        try {
            $result = $commandHandler->handle($command);

            if (!($result instanceof CommandResultInterface)) {
                if (false === $result) {
                    $result = CommandResult::error();
                } else {
                    $result = CommandResult::success();
                }
            }
        } catch (\Exception $e) {
            if ($this->debug) {
                throw $e;
            }

            $result = CommandResult::error(null, [], $e);
        }

        $this->processMessages($command, $result);

        return $result;
    }
33404
function buildCommandPattern(string $prefix = null) {
        $pattern = '';
        if($prefix !== null) {
            $escapedPrefix = \preg_quote($prefix, '/');
            $pattern = '/^(<@!?'.$this->client->user->id.'>\s+(?:'.$escapedPrefix.'\s*)?|'.$escapedPrefix.'\s*)([^\s]+)/iu';
        } else {
            $pattern = '/^(<@!?'.$this->client->user->id.'>\s+)([^\s]+)/iu';
        }
        
        $this->commandPatterns[$prefix] = $pattern;
        
        $this->client->emit('debug', 'Built command pattern for prefix "'.$prefix.'": '.$pattern);
        return $pattern;
    }
1206743
public static function first(CommandInterface $command, $prefix)
    {
        if ($arguments = $command->getArguments()) {
            $arguments[0] = "$prefix{$arguments[0]}";
            $command->setRawArguments($arguments);
        }
    }