Handle the report incident command.

@param \CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand $command

@return \CachetHQ\Cachet\Models\IncidentUpdate
763967
public function handle(CreateIncidentUpdateCommand $command)
    {
        $data = [
            'incident_id' => $command->incident->id,
            'status'      => $command->status,
            'message'     => $command->message,
            'user_id'     => $command->user->id,
        ];

        // Create the incident update.
        $update = IncidentUpdate::create($data);

        // Update the original incident with the new status.
        execute(new UpdateIncidentCommand(
            $command->incident,
            null,
            $command->status,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            []
        ));

        event(new IncidentUpdateWasReportedEvent($this->auth->user(), $update));

        return $update;
    }
1083017
public function handle(IncidentWasCreatedEvent $event)
    {
        $incident = $event->incident;

        if (!$event->notify || !$this->system->canNotifySubscribers()) {
            return false;
        }

        // Only send emails for public incidents.
        if (!$incident->visible) {
            return;
        }

        // First notify all global subscribers.
        $globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();

        $globalSubscribers->each(function ($subscriber) use ($incident) {
            $subscriber->notify(new NewIncidentNotification($incident));
        });

        if (!$incident->component) {
            return;
        }

        $notified = $globalSubscribers->pluck('id')->all();

        // Notify the remaining component specific subscribers.
        $componentSubscribers = $this->subscriber
            ->isVerified()
            ->forComponent($incident->component->id)
            ->get()
            ->reject(function ($subscriber) use ($notified) {
                return in_array($subscriber->id, $notified);
            })->each(function ($subscriber) use ($incident) {
                $subscriber->notify(new NewIncidentNotification($incident));
            });
    }
376114
protected function handleCommand(string $clientAddress, string $command) : bool
    {
        switch ($command) {
            case 'stop':
                $this->respondToClient($clientAddress, 'ok');
                $this->stop();
                return true;
            case 'status':
                $statusData = $this->getStatusData();
                $this->respondToClient($clientAddress, json_encode($statusData));
                return true;
            case 'flush_queue':
                $result = ($this->flushQueue() === true) ? 'ok' : 'error';
                $this->respondToClient($clientAddress, $result);
                return true;

        }
        $this->respondToClient($clientAddress, 'error');
        throw new ServerException('Received unknown command.');
    }
1261101
public function handle(CreateMetricCommand $command)
    {
        $metric = Metric::create([
            'name'          => $command->name,
            'suffix'        => $command->suffix,
            'description'   => $command->description,
            'default_value' => $command->default_value,
            'calc_type'     => $command->calc_type,
            'display_chart' => $command->display_chart,
            'places'        => $command->places,
            'default_view'  => $command->default_view,
            'threshold'     => $command->threshold,
            'order'         => $command->order,
            'visible'       => $command->visible,
        ]);

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

        return $metric;
    }
103905
public function fire(Command $command)
    {
        if (! $this->finder->isFile('.env')) {
            throw new Exception('SocietyCMS is not installed. Please run "php artisan society:install" first.');
        }

        if ($command->option('refresh') && ! App::environment('demo')) {
            throw new Exception('Refresh option is only available in demo mode.');
        }

        if (! $command->option('force') && ! $command->option('refresh')) {
            if (! $command->confirm('Are you sure you want to start Demo Mode?')) {
                throw new Exception('Demo Mode cancelled');
            }
        }
    }
1232751
final public function handle(Command $command): void
    {
        if (!$command instanceof ReceivedCommand && $this->discriminator->shouldEnqueue($command)) {
            $this->queue->send($command);

            return;
        }

        if ($command instanceof ReceivedCommand) {
            $command = $command->getOriginalCommand();
        }

        $this->wrappedCommandBus->handle($command);
    }
470246
protected function fireBeforeCommandEvent($command)
	{
		$eventName = $this->commandNameToEventName($command);

		$args = [$command];

		$this->fireEvent($eventName, 'before', $args);
	}
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)]);
    }
421738
public function handle(UnsubscribeSubscriberCommand $command)
    {
        $subscriber = $command->subscriber;

        // First remove subscriptions.
        $subscriber->subscriptions()->delete();

        event(new SubscriberHasUnsubscribedEvent($subscriber));

        // Then remove the subscriber.
        $subscriber->delete();
    }
1320983
public function handle(MigrateMessage $command)
    {
        $input = $command->getInput();
        $output = $command->getOutput();
        $this->command = $command;

        $targetArg = (string) $input->getArgument(MigrateMessage::ARG_TARGET);
        $strategy = (string) $this->getStrategyOption($input);

        $options = new Options(Options::DIRECTION_UP); // this value will get replaced by timeline later
        $options->setDryRun($input->getOption(MigrateMessage::OPT_DRY_RUN));
        $options->setExceptionOnSkip(false);

        $this->saveChanges = !$input->getOption(MigrateMessage::OPT_NO_STORAGE) && !$options->isDryRun();

        $this->trackProgress = ($output->getVerbosity() !== OutputInterface::VERBOSITY_QUIET)
            && !$input->getOption(MigrateMessage::OPT_NOPROGRESS);

        $this->attachEvents($output, $command->getTimeline()->getEventDispatcher());

        /* @var \Baleen\Migrations\Version\Collection\LinkedVersions $results */
        $command->getTimeline()->$strategy($targetArg, $options);
    }
1310430
public function fireInstallingCommand(Command $command)
    {
        $this->handleMainCommand($command);

        event(new SystemWasInstalledEvent());

        $command->info('System was installed!');
    }
36704
public function handle(UpdateConfigCommand $command)
    {
        foreach ($command->values as $setting => $value) {
            $this->writeEnv($setting, $value);
        }
    }
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');
        }
    }
185526
public function deleteIncidentAction(Incident $incident)
    {
        execute(new RemoveIncidentCommand($incident));

        return cachet_redirect('dashboard.incidents')
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.delete.success')));
    }
1075591
public function execute(Command $command)
    {
        $handler = $this->resolver->resolve($command);

        return $handler->handle($command);
    }
591014
public function dispatchNow( $command )
	{
		return $this->pipeline->send( $command )->through( $this->pipes )->then( function ( $command )
		{
			UniversalBuilder::call( [$command, 'handle'] );
		} );
	}
892750
public function showCreateIncidentUpdateAction(Incident $incident)
    {
        return View::make('dashboard.incidents.updates.add')
            ->withIncident($incident)
            ->withNotificationsEnabled($this->system->canNotifySubscribers());
    }