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

@param CommandInterface $command Command instance.
@param string           $prefix  Prefix string.
495553
public static function migrate(CommandInterface $command, $prefix)
    {
        if ($arguments = $command->getArguments()) {
            $arguments[2] = "$prefix{$arguments[2]}";
            $command->setRawArguments($arguments);
        }
    }
884313
public function dispatch(CommandInterface $command, bool $qeueEvents = false): void
    {
        try {
            if ($command instanceof CommandInterface) {
                // Reset aggregates.
                $this->aggregates = [];

                /**
                 * Get Handler for Command.
                 *
                 * @var HandlerInterface $handler
                 */
                $handlerClass = $command->getHandlerClass();
                $handler = new $handlerClass($this->messageBus, $this->aggregateFactory);

                if ($handler instanceof HandlerInterface) {
                    // Invoke Handler.
                    $handler($command, $this->aggregates);

                    // Check for events on aggregates, pass them to EventBus#publish()
                    $events = [];

                    /** @var AggregateInterface $aggregate */
                    foreach ($this->aggregates as $aggregate) {
                        /** @var array $pendingEvents */
                        $pendingEvents = $aggregate->getPendingEvents();

                        $events += $pendingEvents;
                    }

                    $this->eventBus->publish($events, $this, $qeueEvents);
                } else {
                    throw new InterfaceException(\get_class($handler).' must implement '.HandlerInterface::class);
                }
            } else {
                throw new InterfaceException(\get_class($command).' must implement '.CommandInterface::class);
            }
        } catch (InterfaceException $e) {
            $this->messageBus->dispatch(new Message(
                $e->getMessage(),
                $e->getCode(),
                $command->getUuid(),
                $command->getAggregateUuid(),
                $e
            ));
        }
    }
8743
protected function setExcluded(CommandInterface $command, array $definition)
    {
        if (isset($definition[static::CONFIG_EXCLUDED]) && $definition[static::CONFIG_EXCLUDED]) {
            $command->markAsExcluded();
        }
    }
958712
final public function handle(Command $command): void
    {
        $supportedCommandType = $this->getSupportedCommandType();
        if (!\is_a($command, $supportedCommandType)) {
            throw new InvalidCommandException(\sprintf(
                'Command must be a %s, %s given',
                $supportedCommandType,
                \get_class($command)
            ));
        }

        $this->handleCommand($command);
    }
971132
public function handle(CommandInterface $command)
    {
        $class = $command->getParameter('class');
        $object = $command->hasParameter('object') ? $command->getParameter('object') : null;

        // if no object has been given, try loading it using a query object
        if (!$object) {
            $object = $this->queryExecutor->execute($command->getParameter('query_object'));
        }

        // try removing the object if it is valid
        if ($object instanceof $class) {
            try {
                $this->objectManager->remove($object);
                $this->objectManager->flush();
            } catch (ForeignKeyConstraintViolationException $e) {
                return CommandResult::error('constraint_violation');
            }
        }
    }
776095
public function runCommand(Command $command, InputInterface $input, OutputInterface $output) {
    return $this->doRunCommand($command, $input, $output);
  }
50310
protected function resolveCommandHandler(CommandInterface $command): CommandHandlerInterface
	{
		$class = get_class($command);

		// Build handler class name

		$commandSuffixLength = strlen(static::COMMAND_SUFFIX);

		if(static::COMMAND_SUFFIX === substr($class, -$commandSuffixLength))
		{
			$handler = substr_replace($class, static::HANDLER_SUFFIX, strrpos($class, static::COMMAND_SUFFIX), $commandSuffixLength);
		}
		else
		{
			$handler = $class . static::HANDLER_SUFFIX;
		}

		// Return handler instance

		return $this->container->get($handler);
	}
1153136
public static function sort(CommandInterface $command, $prefix)
    {
        if ($arguments = $command->getArguments()) {
            $arguments[0] = "$prefix{$arguments[0]}";

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

                        case 'GET':
                            $value = $arguments[++$i];
                            if ($value !== '#') {
                                $arguments[$i] = "$prefix$value";
                            }
                            break;

                        case 'LIMIT';
                            $i += 2;
                            break;
                    }
                }
            }

            $command->setRawArguments($arguments);
        }
    }
617319
public function setCommand($command, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
    {
        if (method_exists(Process::class, 'fromShellCommandline')) {
            $this->process = Process::fromShellCommandline($command, $cwd, $env, $input, $timeout, $options);

        } else {
            $this->process = new Process($command, $cwd, $env, $input, $timeout, $options);
        }
    }
1243816
public function dispatch($command): void
    {
        $this->commandStack[] = $command;

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

        $this->transactionManager->begin();
        try {
            while ($command = array_shift($this->commandStack)) {
                $this->invokeHandler($command);
            }
            $this->eventPublisher->publishEvents();
            $this->transactionManager->commit();
        } catch (Exception $e) {
            $this->transactionManager->rollback();
            throw $e;
        }
    }
950054
public function setPathPrefix($prefix)
	{
		$prefix = (string) $prefix;
		if ($prefix === '') {
			$this->pathPrefix = '';

			return;
		}

		$this->pathPrefix = \rtrim($prefix, '\\/') . $this->pathSeparator;
	}
551327
public function run(CommandInterface $command)
    {
        $result = null;

        /** @var RunnerInterface $runner */
        foreach($this->runners as $runner) {
            $result = $runner->run($command, $result);
        }

        return $result;
    }
139215
protected function getKeyFromAllArguments(CommandInterface $command)
    {
        $arguments = $command->getArguments();

        if ($this->checkSameSlotForKeys($arguments)) {
            return $arguments[0];
        }
    }
805130
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');
            }
        }

        $this->objectManager->persist($object);
        $this->objectManager->flush();
    }
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;
        }
    }
241285
public function setPrefix(string $prefix): FieldTypeInterface
    {
        $this->prefix = $prefix;

        // Update all attached fields with the given prefix.
        foreach ($this->repository->all() as $field) {
            /** @var FieldTypeInterface $field */
            $field->setPrefix($prefix);
        }

        return $this;
    }
685640
public function setPrefix($prefix)
    {
        if (is_string($prefix) === false) {
            $msg = "The prefix argument must be a string.";
            throw new InvalidArgumentException($msg);
        } elseif ($prefix === '') {
            $msg = "The prefix argument must be a non-empty string.";
            throw new InvalidArgumentException($msg);
        } else {
            $this->prefix = $prefix;
        }
    }