You are here

public function InPlaceUpdateController::update in Automatic Updates 8

Same name in this branch
  1. 8 src/Controller/InPlaceUpdateController.php \Drupal\automatic_updates\Controller\InPlaceUpdateController::update()
  2. 8 tests/modules/test_automatic_updates/src/Controller/InPlaceUpdateController.php \Drupal\test_automatic_updates\Controller\InPlaceUpdateController::update()

Builds the response.

1 string reference to 'InPlaceUpdateController::update'
automatic_updates.routing.yml in ./automatic_updates.routing.yml
automatic_updates.routing.yml

File

src/Controller/InPlaceUpdateController.php, line 45

Class

InPlaceUpdateController
Returns responses for Automatic Updates routes.

Namespace

Drupal\automatic_updates\Controller

Code

public function update($project, $type, $from, $to) {
  $metadata = new UpdateMetadata($project, $type, $from, $to);
  $updated = $this->updater
    ->update($metadata);
  $message_type = MessengerInterface::TYPE_STATUS;
  $message = $this
    ->t('Update successful');
  if (!$updated) {
    $message_type = MessengerInterface::TYPE_ERROR;
    $message = $this
      ->t('Update failed. Please review logs to determine the cause.');
  }
  $this
    ->messenger()
    ->addMessage($message, $message_type);
  return $this
    ->redirect('automatic_updates.settings');
}