/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $modules = $input->getArgument('module'); if (!$this->lock->acquire('cron', 900.0)) { $io->warning($this->trans('commands.cron.execute.messages.lock')); return 1; } if (in_array('all', $modules)) { $modules = $this->moduleHandler->getImplementations('cron'); } foreach ($modules as $module) { if (!$this->moduleHandler->implementsHook($module, 'cron')) { $io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module)); continue; } try { $io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module)); $this->moduleHandler->invoke($module, 'cron'); } catch (\Exception $e) { watchdog_exception('cron', $e); $io->error($e->getMessage()); } } $this->state->set('system.cron_last', REQUEST_TIME); $this->lock->release('cron'); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); $io->success($this->trans('commands.cron.execute.messages.success')); return 0; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $io->newLine(); $io->comment($this->trans('commands.node.access.rebuild.messages.rebuild')); $batch = $input->getOption('batch'); try { node_access_rebuild($batch); } catch (\Exception $e) { $io->error($e->getMessage()); return 1; } $needs_rebuild = $this->state->get('node.node_access_needs_rebuild') ?: false; if ($needs_rebuild) { $io->error($this->trans('commands.node.access.rebuild.messages.failed')); return 1; } $io->success($this->trans('commands.node.access.rebuild.messages.completed')); return 0; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); //$state = $this->getDrupalService('state'); $io->info($this->trans('commands.site.maintenance.messages.maintenance-on')); $io->info($this->trans('commands.update.entities.messages.start')); $this->state->set('system.maintenance_mode', true); try { $this->entityDefinitionUpdateManager->applyUpdates(); /* @var EntityStorageException $e */ } catch (EntityStorageException $e) { /* @var Error $variables */ $variables = Error::decodeException($e); $io->info($this->trans('commands.update.entities.messages.error')); $io->info($variables); } $this->state->set('system.maintenance_mode', false); $io->info($this->trans('commands.update.entities.messages.end')); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); $io->info($this->trans('commands.site.maintenance.messages.maintenance-off')); }
/** * {@inheritdoc} */ public function batchVariableSet(array $variables) { $state_variables = xmlsitemap_state_variables(); $config_variables = xmlsitemap_config_variables(); foreach ($variables as $variable => $value) { if (isset($state_variables[$variable])) { $this->state->set($variable, $value); } else { $this->config->set($variable, $value); } } $this->config->save(); }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $this->module = $input->getArgument('module'); $this->update_n = $input->getArgument('update-n'); $this->site->loadLegacyFile('/core/includes/install.inc'); $this->site->loadLegacyFile('/core/includes/update.inc'); drupal_load_updates(); update_fix_compatibility(); $updates = update_get_update_list(); $this->checkUpdates($io); $io->info($this->trans('commands.site.maintenance.description')); $this->state->set('system.maintenance_mode', true); $this->runUpdates($io, $updates); $this->runPostUpdates($io); $this->state->set('system.maintenance_mode', false); $io->info($this->trans('commands.site.maintenance.messages.maintenance-off')); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); }
/** * Submit callback for the fields error form. */ public function submitFieldAttach(array &$form, FormStateInterface $form_state) { $this->state->set('ds.disabled', $this->state->get('ds.disabled', FALSE) ? FALSE : TRUE); drupal_set_message(t('The configuration options have been saved.')); }
/** * Perform the anonymous user redirection, if needed. * * This method is called whenever the KernelEvents::REQUEST event is * dispatched. * * @param GetResponseEvent $event */ public function redirect(GetResponseEvent $event) { // Skip if maintenance mode is enabled. if ($this->state->get('system.maintenance_mode')) { return; } // Skip if running from the command-line. if (PHP_SAPI === 'cli') { return; } // Skip if no paths are configured for redirecting. if (!($paths = $this->paths()) || empty($paths['include'])) { return; } // Skip if the user is not anonymous. if (!$this->current_user->isAnonymous()) { return; } // Determine the current path and alias. $current = [ 'path' => $this->path_current->getPath(), 'alias' => \Drupal::request()->getRequestUri(), ]; // Ignore PHP file requests. if (substr($current['path'], -4) == '.php') { return; } // Ignore the user login page. if ($current['path'] == '/user/login') { return; } // Convert the path to the front page token, if needed. $current['path'] = ($current['path'] != '/') ? $current['path'] : '<front>'; // Track if we should redirect. $redirect = FALSE; // Iterate the current path and alias. foreach ($current as &$check) { // Remove the leading slash. $check = substr($check, 1); // Check if there is a trailer slash. if (substr($check, -1) == '/') { // Remove it. $check = substr($check, 0, strlen($check) - 1); } // Redirect if the path is a match for included paths. if ($this->path_matcher->matchPath($check, implode("\n", $paths['include']))) { $redirect = TRUE; } // Do not redirect if the path is a match for excluded paths. if ($this->path_matcher->matchPath($check, implode("\n", $paths['exclude']))) { $redirect = FALSE; // Matching an excluded path is a hard-stop. break; } } // See if we're going to redirect. if ($redirect) { // See if we have a message to display. if ($message = $this->config_factory->get('anonymous_login.settings')->get('message')) { // @todo: translation? // @todo: This does not show after the redirect.. drupal_set_message($message); } // Redirect to the login, keeping the requested alias as the destination. $response = new RedirectResponse('/user/login?destination=' . $current['alias']); $response->send(); exit(); } }
/** * Reacts to post-row-save event. * * @param \Drupal\Migrate\Event\MigratePostRowSaveEvent $event * The migration event. * @param string $name * The event name. */ public function postRowSaveEventRecorder(MigratePostRowSaveEvent $event, $name) { $this->state->set('migrate_events_test.post_row_save_event', array('event_name' => $name, 'migration' => $event->getMigration(), 'row' => $event->getRow(), 'destination_id_values' => $event->getDestinationIdValues())); }