You are here

public function MaintenanceMode::execute in DRD Agent 4.0.x

Same name and namespace in other branches
  1. 8.3 src/Agent/Action/MaintenanceMode.php \Drupal\drd_agent\Agent\Action\MaintenanceMode::execute()

Execute an action.

Return value

mixed The response of the action as an array which will be encrypted before returned to DRD.

Overrides Base::execute

File

src/Agent/Action/MaintenanceMode.php, line 15

Class

MaintenanceMode
Provides a 'MaintenanceMode' code.

Namespace

Drupal\drd_agent\Agent\Action

Code

public function execute() {
  $args = $this
    ->getArguments();
  if ($args['mode'] === 'getStatus') {
    return [
      'data' => $this->state
        ->get('system.maintenance_mode'),
    ];
  }
  $this->state
    ->set('system.maintenance_mode', $args['mode'] === 'on');
  drupal_flush_all_caches();
  return [];
}