@param AddToCart $command

@throws \Exception
975299
public function handle(AddToCart $command)
    {
        $product = $this->products->getBySku(new SKU($command->sku()));

        $cart = $this->carts->getById(new CartId($command->cartId()));
        $cart->add($product, $command->quantity());
    }
896789
protected function _commandEdit($command)
    {
        $entity = $this->getController()->getItem();
        $view = $this->getController()->getView()->getName();

        $layout = pick($command->layout, 'edit');

        $command->append(array('label' => AnTranslator::_('LIB-AN-ACTION-EDIT')))
        ->href($entity->getURL().'&layout='.$layout)
        ->setAttribute('data-action', 'edit');
    }
1209845
public function addCommand(Command $command)
    {
        if (is_string($command)) {
            $command = new $command;
        }
        $map = (new CommandMapping($this->parser))->map($command);

        CommandBag::add($map->name, [
            'object' => $command,
            'map' => $map
        ]);

        return $this;
    }
757391
protected function _commandNew(KControllerToolbarCommand $command)
    {
        if (empty($command->href))
        {
            $identifier    = $this->getController()->getIdentifier();
            $command->href = 'component='.$identifier->package.'&view='.$identifier->name;
        }

        $command->icon = 'k-icon-plus';
    }
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');
    }
811219
public function registerCommand($command, $callable, array $options = [])
    {
        if (array_key_exists($command, $this->commands)) {
            throw new \Exception("A command with the name {$command} already exists.");
        }

        list($commandInstance, $options) = $this->buildCommand($command, $callable, $options);
        $this->commands[$command]        = $commandInstance;

        foreach ($options['aliases'] as $alias) {
            $this->addCommandAlias($alias, $command);
        }

        return $commandInstance;
    }
269551
public function registerCommand($command, $help)
    {
        if (isset($this->setup[$command])) {
            throw new Exception("Command $command already registered");
        }

        $this->setup[$command] = array(
            'opts' => array(),
            'args' => array(),
            'help' => $help
        );

    }
921437
protected function sendCommand($command)
    {
        if (!\Erebot\Utils::stringifiable($command)) {
            throw new \Exception('Invalid command (not a string)');
        }
        $this->connection->getIO()->push((string) $command);
    }
180548
public function addCustomCommand($command)
    {
        $name = lcfirst(class_basename($command));

        $this->customCommands[$name] = $command;
    }
254013
public function add($command)
    {
        if (is_string($command)) {
            $command = new $command($this->container);
        }

        if (!$command instanceof Console\Commands) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Argument 1 passed to %s must be an instance of %s, %s given',
                    __FUNCTION__,
                    Console\Commands::class,
                    get_class($command)
                )
            );
        }

        if (array_key_exists($command->name(), $this->commands)) {
            throw new \RuntimeException(
                sprintf('Command %s already registered', $command->name())
            );
        }

        $this->commands[$command->name()] = $command;

        return $this;
    }
1291407
public function addCommand($command, $config = array())
    {
        if (!($command instanceof KControllerToolbarCommand)) {
            $command = $this->getCommand($command, $config);
        }

        return $this->getDelegate()->addCommand($command, $config);
    }
93324
public function add(ICommand $command, bool $overwrite = false)
    {
        if (!$overwrite && $this->has($command->getName())) {
            throw new InvalidArgumentException("A command with name \"{$command->getName()}\" already exists");
        }

        $command->setCommandCollection($this);
        $this->commands[$command->getName()] = $command;
    }
1043150
public function validateOptions($command)
    {
        if ($command->option('ui') && !in_array($command->option('ui'), ['bootstrap', 'semantic'])) {
            throw new Exception('The UI you selected is not suppported. It must be: bootstrap or semantic.', 1);
        }

        if ((!is_null($command->option('schema')) && !$command->option('migration')) ||
            (!is_null($command->option('relationships')) && !$command->option('migration'))
        ) {
            throw new Exception('In order to use Schema or Relationships you need to use Migrations', 1);
        }

        return true;
    }
894505
public function fire(Command $command)
    {
        if ($command->option('verbose')) {
            $command->blockMessage('Seeds', 'Running the module seeds ...', 'comment');
        }

        $this->demoSeedCoreModules($command);
        $this->demoSeedAdditionalModules($command);
    }
626597
public function addCommand($command)
    {
        if (!is_object($command)) {
            if (!class_exists($command)) {
                throw new TelegramSDKException(
                    sprintf(
                        'Command class "%s" not found! Please make sure the class exists.',
                        $command
                    )
                );
            }

            if ($this->telegram->hasContainer()) {
                $command = $this->buildDependencyInjectedAnswer($command);
            } else {
                $command = new $command();
            }
        }

        if ($command instanceof CommandInterface) {

            /*
             * At this stage we definitely have a proper command to use.
             *
             * @var Command $command
             */
            $this->commands[$command->getName()] = $command;

            $aliases = $command->getAliases();

            if (empty($aliases)) {
                return $this;
            }

            foreach ($command->getAliases() as $alias) {
                if (isset($this->commands[$alias])) {
                    throw new TelegramSDKException(sprintf(
                        '[Error] Alias [%s] conflicts with command name of "%s" try with another name or remove this alias from the list.',
                        $alias,
                        get_class($command)
                    ));
                }

                if (isset($this->commandAliases[$alias])) {
                    throw new TelegramSDKException(sprintf(
                        '[Error] Alias [%s] conflicts with another command\'s alias list: "%s", try with another name or remove this alias from the list.',
                        $alias,
                        get_class($command)
                    ));
                }

                $this->commandAliases[$alias] = $command;
            }

            return $this;
        }

        throw new TelegramSDKException(
            sprintf(
                'Command class "%s" should be an instance of "Telegram\Bot\Commands\CommandInterface"',
                get_class($command)
            )
        );
    }
666681
public function addCommand($command, $config = array())
    {
        if (!($command instanceof KControllerToolbarCommandInterface)) {
            $command = $this->getCommand($command, $config);
        }

        //Set the command parent
        $command->setParent($this);

        $this->_commands[$command->getName()] = $command;
        return $command;
    }
1365839
protected function execute($command)
    {
        $process = new Process($command);
        $process->setTimeout(null);
        $process->run();

        if (!$process->isSuccessful()) {
            throw new \RuntimeException($process->getErrorOutput());
        }
    }