/**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Retrieve a list of modules to install and their dependencies.
     $modules = $this->buildModuleList($form_state);
     // Check if we have to install any dependencies. If there is one or more
     // dependencies that are not installed yet, redirect to the confirmation
     // form.
     if (!empty($modules['dependencies']) || !empty($modules['missing'])) {
         // Write the list of changed module states into a key value store.
         $account = $this->currentUser()->id();
         $this->keyValueExpirable->setWithExpire($account, $modules, 60);
         // Redirect to the confirmation form.
         $form_state->setRedirect('system.modules_list_confirm');
         // We can exit here because at least one modules has dependencies
         // which we have to prompt the user for in a confirmation form.
         return;
     }
     // Install the given modules.
     if (!empty($modules['install'])) {
         try {
             $this->moduleInstaller->install(array_keys($modules['install']));
             $module_names = array_values($modules['install']);
             drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', array('%name' => $module_names[0], '%names' => implode(', ', $module_names))));
         } catch (PreExistingConfigException $e) {
             $config_objects = $e->flattenConfigObjects($e->getConfigObjects());
             drupal_set_message($this->formatPlural(count($config_objects), 'Unable to install @extension, %config_names already exists in active configuration.', 'Unable to install @extension, %config_names already exist in active configuration.', array('%config_names' => implode(', ', $config_objects), '@extension' => $modules['install'][$e->getExtension()])), 'error');
             return;
         } catch (UnmetDependenciesException $e) {
             drupal_set_message($e->getTranslatedMessage($this->getStringTranslation(), $modules['install'][$e->getExtension()]), 'error');
             return;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Retrieve a list of modules to install and their dependencies.
     $modules = $this->buildModuleList($form_state);
     // Check if we have to install any dependencies. If there is one or more
     // dependencies that are not installed yet, redirect to the confirmation
     // form.
     if (!empty($modules['dependencies']) || !empty($modules['missing'])) {
         // Write the list of changed module states into a key value store.
         $account = $this->currentUser()->id();
         $this->keyValueExpirable->setWithExpire($account, $modules, 60);
         // Redirect to the confirmation form.
         $form_state->setRedirect('system.modules_list_confirm');
         // We can exit here because at least one modules has dependencies
         // which we have to prompt the user for in a confirmation form.
         return;
     }
     // Gets list of modules prior to install process.
     $before = $this->moduleHandler->getModuleList();
     // There seem to be no dependencies that would need approval.
     if (!empty($modules['install'])) {
         $this->moduleHandler->install(array_keys($modules['install']));
     }
     // Gets module list after install process, flushes caches and displays a
     // message if there are changes.
     if ($before != $this->moduleHandler->getModuleList()) {
         drupal_set_message(t('The configuration options have been saved.'));
     }
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Save all the values in an expirable key value store.
     $modules = $form_state->getValue('uninstall');
     $uninstall = array_keys(array_filter($modules));
     $account = $this->currentUser()->id();
     $this->keyValueExpirable->setWithExpire($account, $uninstall, 60);
     // Redirect to the confirm form.
     $form_state->setRedirect('system.modules_uninstall_confirm');
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     // Save all the values in an expirable key value store.
     $modules = $form_state['values']['uninstall'];
     $uninstall = array_keys(array_filter($modules));
     $account = $this->currentUser()->id();
     $this->keyValueExpirable->setWithExpire($account, $uninstall, 60);
     // Redirect to the confirm form.
     $form_state['redirect_route']['route_name'] = 'system.modules_uninstall_confirm';
 }
示例#5
0
 /**
  * Stores a particular key/value pair in this SharedTempStore.
  *
  * @param string $key
  *   The key of the data to store.
  * @param mixed $value
  *   The data to store.
  */
 public function set($key, $value)
 {
     if (!$this->lockBackend->acquire($key)) {
         $this->lockBackend->wait($key);
         if (!$this->lockBackend->acquire($key)) {
             throw new TempStoreException("Couldn't acquire lock to update item '{$key}' in '{$this->storage->getCollectionName()}' temporary storage.");
         }
     }
     $value = (object) array('owner' => $this->owner, 'data' => $value, 'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'));
     $this->storage->setWithExpire($key, $value, $this->expire);
     $this->lockBackend->release($key);
 }
 /**
  * Stores a particular key/value pair in this SharedTempStore.
  *
  * @param string $key
  *   The key of the data to store.
  * @param mixed $value
  *   The data to store.
  */
 public function set($key, $value)
 {
     if (!$this->lockBackend->acquire($key)) {
         $this->lockBackend->wait($key);
         if (!$this->lockBackend->acquire($key)) {
             throw new TempStoreException(String::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array('%key' => $key, '%collection' => $this->storage->getCollectionName())));
         }
     }
     $value = (object) array('owner' => $this->owner, 'data' => $value, 'updated' => REQUEST_TIME);
     $this->storage->setWithExpire($key, $value, $this->expire);
     $this->lockBackend->release($key);
 }
 /**
  * Stores a particular key/value pair in this PrivateTempStore.
  *
  * @param string $key
  *   The key of the data to store.
  * @param mixed $value
  *   The data to store.
  */
 public function set($key, $value)
 {
     $key = $this->createkey($key);
     if (!$this->lockBackend->acquire($key)) {
         $this->lockBackend->wait($key);
         if (!$this->lockBackend->acquire($key)) {
             throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array('%key' => $key, '%collection' => $this->storage->getCollectionName())));
         }
     }
     $value = (object) array('owner' => $this->getOwner(), 'data' => $value, 'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'));
     $this->storage->setWithExpire($key, $value, $this->expire);
     $this->lockBackend->release($key);
 }
示例#8
0
 /**
  * {@inheritdoc}
  */
 public function processFetchTask($project)
 {
     global $base_url;
     // This can be in the middle of a long-running batch, so REQUEST_TIME won't
     // necessarily be valid.
     $request_time_difference = time() - REQUEST_TIME;
     if (empty($this->failed)) {
         // If we have valid data about release history XML servers that we have
         // failed to fetch from on previous attempts, load that.
         $this->failed = $this->tempStore->get('fetch_failures');
     }
     $max_fetch_attempts = $this->updateSettings->get('fetch.max_attempts');
     $success = FALSE;
     $available = array();
     $site_key = Crypt::hmacBase64($base_url, $this->privateKey->get());
     $fetch_url_base = $this->updateFetcher->getFetchBaseUrl($project);
     $project_name = $project['name'];
     if (empty($this->failed[$fetch_url_base]) || $this->failed[$fetch_url_base] < $max_fetch_attempts) {
         $data = $this->updateFetcher->fetchProjectData($project, $site_key);
     }
     if (!empty($data)) {
         $available = $this->parseXml($data);
         // @todo: Purge release data we don't need. See
         //   https://www.drupal.org/node/238950.
         if (!empty($available)) {
             // Only if we fetched and parsed something sane do we return success.
             $success = TRUE;
         }
     } else {
         $available['project_status'] = 'not-fetched';
         if (empty($this->failed[$fetch_url_base])) {
             $this->failed[$fetch_url_base] = 1;
         } else {
             $this->failed[$fetch_url_base]++;
         }
     }
     $frequency = $this->updateSettings->get('check.interval_days');
     $available['last_fetch'] = REQUEST_TIME + $request_time_difference;
     $this->availableReleasesTempStore->setWithExpire($project_name, $available, $request_time_difference + 60 * 60 * 24 * $frequency);
     // Stash the $this->failed data back in the DB for the next 5 minutes.
     $this->tempStore->setWithExpire('fetch_failures', $this->failed, $request_time_difference + 60 * 5);
     // Whether this worked or not, we did just (try to) check for updates.
     $this->stateStore->set('update.last_check', REQUEST_TIME + $request_time_difference);
     // Now that we processed the fetch task for this project, clear out the
     // record for this task so we're willing to fetch again.
     $this->fetchTaskStore->delete($project_name);
     return $success;
 }
示例#9
0
 /**
  * {@inheritdoc}
  */
 public function getProjects()
 {
     if (empty($this->projects)) {
         // Retrieve the projects from storage, if present.
         $this->projects = $this->projectStorage('update_project_projects');
         if (empty($this->projects)) {
             // Still empty, so we have to rebuild.
             $module_data = system_rebuild_module_data();
             $theme_data = $this->themeHandler->rebuildThemeData();
             $project_info = new ProjectInfo();
             $project_info->processInfoList($this->projects, $module_data, 'module', TRUE);
             $project_info->processInfoList($this->projects, $theme_data, 'theme', TRUE);
             if ($this->updateSettings->get('check.disabled_extensions')) {
                 $project_info->processInfoList($this->projects, $module_data, 'module', FALSE);
                 $project_info->processInfoList($this->projects, $theme_data, 'theme', FALSE);
             }
             // Allow other modules to alter projects before fetching and comparing.
             $this->moduleHandler->alter('update_projects', $this->projects);
             // Store the site's project data for at most 1 hour.
             $this->keyValueStore->setWithExpire('update_project_projects', $this->projects, 3600);
         }
     }
     return $this->projects;
 }
示例#10
0
 /**
  * {@inheritdoc}
  */
 public function import(Row $row, array $old_destination_id_values = array())
 {
     $source = $row->getSource();
     $this->tempStore->setWithExpire($source['uuid'], $source, $this->expire);
     return array($this->entityIdKey => $source[$this->entityIdKey]);
 }