Handle the update metric command.

@param \CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricCommand $command

@return \CachetHQ\Cachet\Models\Metric
166460
public function handle(UpdateMetricCommand $command)
    {
        $metric = $command->metric;

        $metric->update($this->filter($command));

        event(new MetricWasUpdatedEvent($this->auth->user(), $metric));

        return $metric;
    }
1262293
public function execute($command)
    {
        $validator = $this->translator->toValidator($command);

        if (class_exists($validator)) {
            $this->app->make($validator)->validate($command);
        }

        return $this->bus->execute($command);
    }
428694
public function handle($command)
    {
        if (!is_object($command)) {
            throw InvalidCommandException::forUnknownValue($command);
        }

        $middlewareChain = $this->middlewareChain;
        return $middlewareChain($command);
    }
561783
public function handle(CreateTagCommand $command)
    {
        return Tag::firstOrCreate([
            'name' => $command->name,
            'slug' => $command->slug ? $command->slug : Str::slug($command->name),
        ]);
    }
258226
protected function executeCmd($command)
    {
        $process = new $this->processClass($command);
        $process->run();

        if (false === $process->isSuccessful() && strlen($process->getErrorOutput()) > 0) {
            throw new \RuntimeException($process->getErrorOutput());
        }

        return $process->getOutput();
    }
410218
public function fire(Command $command)
    {
        $this->command = $command;

        if ($command->option('verbose')) {
            $command->blockMessage('Requirements', 'Checking System Requirements ...', 'comment');
        }

        $this->checkPHPVersion();
        $this->checkExtensions();

        $this->showResults();
    }
210541
public function handle(UpdateSubscriberSubscriptionCommand $command)
    {
        $subscriber = $command->subscriber;
        $subscriptions = $command->subscriptions ?: [];

        $components = Component::all();

        $updateSubscriptions = $components->filter(function ($item) use ($subscriptions) {
            return in_array($item->id, $subscriptions);
        });

        $subscriber->global = ($updateSubscriptions->count() === $components->count());

        $subscriber->subscriptions()->delete();

        if (!$updateSubscriptions->isEmpty()) {
            $updateSubscriptions->each(function ($subscription) use ($subscriber) {
                Subscription::firstOrCreate([
                    'subscriber_id' => $subscriber->id,
                    'component_id'  => $subscription->id,
                ]);
            });
        }

        $subscriber->save();

        event(new SubscriberHasUpdatedSubscriptionsEvent($subscriber));

        return $subscriber;
    }
1019705
public function handle(CollectionCommand $command)
    {
        $target = $command->getTarget();
        $collection = $command->getCollection();
        $options = $command->getOptions();
        $direction = $options->getDirection();
        $comparator = $collection->getComparator();
        if ($direction->isDown()) {
            $comparator = $comparator->getReverse();
        }

        // filter to only get versions that need to be migrated
        $filter = function (DeltaInterface $v) use ($target, $comparator, $direction) {
            return ($direction->isUp() ^ $v->isMigrated()) // direction must be opposite to migration status
                    && $comparator->compare($v, $target) <= 0; // version must be before or be equal to target (not
                                                               // affected by direction because comparator is reversed)
        };
        $scheduled = $collection->filter($filter)->sort($comparator);
        // we don't check if $scheduled is empty after filtering because the collection-before and -after events should
        // still be triggered by the runner

        $event = $this->createRunnerFor($scheduled)->run($target, $options);

        return $command->getVersionRepository()->updateAll($event->getCollection());
    }
195470
public function handle(UpdateComponentCommand $command)
    {
        $component = $command->component;
        $originalStatus = $component->status;

        if ($command->status && (int) $originalStatus !== (int) $command->status) {
            event(new ComponentStatusWasChangedEvent($this->auth->user(), $component, $originalStatus, $command->status, $command->silent));
        }

        $component->update($this->filter($command));

        event(new ComponentWasUpdatedEvent($this->auth->user(), $component));

        return $component;
    }
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();
    }
346693
protected function registerDatabaseUpgradeCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Database\Commands\DatabaseUpgradeCommand($app);
        });
    }
328201
public function updateCommands(TaskCommand $command)
    {
        $definition = $command->getDefinition();
        $options = $definition->getOptions();

        foreach (array_keys($options) as $name) {
            switch ($name) {
                case 'where':
                    $options['where'] = new InputOption('where', null, InputOption::VALUE_REQUIRED, 'Dump only rows selected by given WHERE condition.');
                    break;
                case 'database':
                    $options['database'] = new InputOption('database', null, InputOption::VALUE_REQUIRED, 'The local db to push to.');
                    break;
                case 'defaults-local':
                    $options['defaults-local'] = new InputOption('defaults-local', null, InputOption::VALUE_REQUIRED, 'The defaults file used fot the mysql client. <comment>(defaults to ./etc/mysql/local.cnf if exists.)</comment>');
                    break;
                case 'defaults-remote':
                    $options['defaults-remote'] = new InputOption('defaults-remote', null, InputOption::VALUE_REQUIRED, 'The defaults file used for the mysqldump. <comment>(defaults to ~/.my.cnf on remote.)</comment>');
                    break;
                case 'table':
                    $options['table'] = new InputOption('table', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'Dump only the given table.');
                    break;
                case 'no-drop':
                    $options['no-drop'] = new InputOption('no-drop', null, InputOption::VALUE_NONE, 'Do not drop the local database (default if a table or where option is given).');
                    break;
                case 'drop':
                    $options['drop'] = new InputOption('drop', null, InputOption::VALUE_NONE, 'Drop local database <comment>(default true, if no table or where option is given)</comment>.');
                    break;
                case 'no-local':
                    $options['no-local'] = new InputOption('no-local', null, InputOption::VALUE_NONE, 'Do not wrap the mysqldump in a ssh command.');
                    break;
                case 'local':
                    $options['local'] = new InputOption('local', 'l', InputOption::VALUE_NONE, 'Wrappes the mysqldump in a ssh command <comment>(default true)</comment>.');
                    break;
                case 'no-stdout':
                    $options['no-stdout'] = new InputOption('no-stdout', null, InputOption::VALUE_NONE, 'Will forward the mysqldump stdout to a mysqlclient local <comment>default true</comment>.');
                    break;
                case 'stdout':
                    $options['stdout'] = new InputOption('stdout', 'o', InputOption::VALUE_NONE, 'Print the mysqldump to stdout.');
                    break;
                case 'file':
                    $options['file'] = new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Cat file and redirect output to mysql client.');
                    break;
                case 'no-backup':
                    $options['no-backup'] = new InputOption('no-backup', null, InputOption::VALUE_NONE, 'Do not create a backup before pushing to the remote.');
                    break;
                case 'backup':
                    $options['backup'] = new InputOption('backup', null, InputOption::VALUE_NONE, 'Create a backup from a remote before pushing <comment>(default true)</comment>.');
                    break;
            }
        }
        $definition->setOptions($options);
    }
1156799
public function handle($command)
    {
        $user = new User();
        $user
            ->setEmail($command->getEmail())
            ->setPassword($command->getPassword())
            ->setRoles($this->registeredUserRoles)
            ->setEnabled(true);

        // validate user
        $errors = $this->validator->validate($user);
        if (count($errors) > 0) {
            $exception = new InvalidCommandException("User is invalid");
            $exception->setConstraintViolationList($errors);
            throw $exception;
        }

        // persist user
        $this->entityManager->persist($user);
        $this->entityManager->flush();

        return $user;
    }
1236718
protected function handle(CommandInterface $command)
	{
		if($command instanceof SelfHandlingCommandInterface)
		{
			return $command->handle();
		}

		$handler = $this->resolveCommandHandler($command);

		return $this->executeCommandHandler($handler, $command);
	}
1155892
protected function registerDatabaseStatusCommand($command)
    {
        $this->app->singleton($command, function ($app) {
            return new Database\Commands\DatabaseStatusCommand($app);
        });
    }
57850
public function handle(CreateMetricPointCommand $command)
    {
        $metric = $command->metric;
        $createdAt = $command->created_at;

        // Do we have an existing point with the same value?
        $point = $this->findOrCreatePoint($command);

        $point->increment('counter', 1);

        event(new MetricPointWasCreatedEvent($this->auth->user(), $point));

        return $point;
    }
775666
public function handle(UpdateIncidentCommand $command)
    {
        if ($template = IncidentTemplate::where('slug', '=', $command->template)->first()) {
            $command->message = $this->parseTemplate($template, $command);
        }

        $incident = $command->incident;
        $incident->fill($this->filter($command));

        // The incident occurred at a different time.
        if ($occurredAt = $command->occurred_at) {
            if ($date = $this->dates->create('Y-m-d H:i', $occurredAt)) {
                $incident->fill(['occurred_at' => $date]);
            } else {
                throw new InvalidIncidentTimestampException("Unable to pass timestamp {$occurredAt}");
            }
        }

        // Rather than making lots of updates, just fill and save.
        $incident->save();

        // Store any meta?
        if ($meta = $command->meta) {
            $this->storeMeta($command->meta, 'incidents', $incident->id);
        }

        // Update the component.
        if ($component = Component::find($command->component_id)) {
            execute(new UpdateComponentCommand(
                Component::find($command->component_id),
                null,
                null,
                $command->component_status,
                null,
                null,
                null,
                null,
                null,
                false
            ));
        }

        event(new IncidentWasUpdatedEvent($this->auth->user(), $incident));

        return $incident;
    }