getPlatformState(); } return ($state->getBooleanStatus() === true); } /** * Enable the platform by updating storage */ public function enablePlatform() { $this->setPlatformState(MaintenanceState::LIVE_MODE); } /** * Disable the platform by updating storage */ public function disablePlatform() { $this->setPlatformState(MaintenanceState::OFFLINE_MODE); } /** * Get the current maintenance state of the platform * * @return MaintenanceState */ public function getPlatformState() { try { return $this->getStorage()->getCurrentPlatformState(); } catch (\common_exception_NotFound $e) { $this->enablePlatform(); return new MaintenanceState( [MaintenanceState::STATUS => MaintenanceState::LIVE_MODE] ); } } /** * Update platform state * * @param $status */ protected function setPlatformState($status) { $state = new MaintenanceState([ MaintenanceState::STATUS => $status ]); $this->getStorage()->setPlatformState($state); } /** * Get the maintenance storage * * @return MaintenanceStorage * @throws InconsistencyConfigException */ public function getStorage() { if (! $this->storage) { if (! $this->hasOption(self::OPTION_PERSISTENCE)) { throw new InconsistencyConfigException(__('Maintenance service must have a persistence option.')); } $this->storage = new MaintenanceStorage( \common_persistence_Manager::getPersistence($this->getOption(self::OPTION_PERSISTENCE)) ); } return $this->storage; } }