/** * Execute a function in maintenance mode * * @param callable $closure */ protected function maintenanceOperation($closure) { $mode = $this->entity_manager->getMaintenanceMode(); $this->entity_manager->setMaintenanceMode(true); try { $closure(); } finally { $this->entity_manager->setMaintenanceMode($mode); } }