/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $modules = array_filter($form_state['values']['list']); $this->moduleHandler->uninstall($modules, FALSE); $this->moduleHandler->install($modules, FALSE); drupal_set_message(t('Uninstalled and installed: %names.', array('%names' => implode(', ', $modules)))); }
/** * {@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.')); } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('system.site')->set('name', $form_state->getValue('site_name'))->set('mail', $form_state->getValue('site_mail'))->save(); $this->config('system.date')->set('timezone.default', $form_state->getValue('date_default_timezone'))->set('country.default', $form_state->getValue('site_default_country'))->save(); $account_values = $form_state->getValue('account'); // Enable update.module if this option was selected. $update_status_module = $form_state->getValue('update_status_module'); if ($update_status_module[1]) { $this->moduleHandler->install(array('file', 'update'), FALSE); // Add the site maintenance account's email address to the list of // addresses to be notified when updates are available, if selected. if ($update_status_module[2]) { // Reset the configuration factory so it is updated with the new module. $this->resetConfigFactory(); $this->config('update.settings')->set('notification.emails', array($account_values['mail']))->save(); } } // We precreated user 1 with placeholder values. Let's save the real values. $account = $this->userStorage->load(1); $account->init = $account->mail = $account_values['mail']; $account->roles = $account->getRoles(); $account->activate(); $account->timezone = $form_state->getValue('date_default_timezone'); $account->pass = $account_values['pass']; $account->name = $account_values['name']; $account->save(); // Record when this install ran. $this->state->set('install_time', $_SERVER['REQUEST_TIME']); }
/** * Tests making use of a custom bundle field. */ public function testCustomBundleFieldUsage() { // Check that an entity with bundle entity_test does not have the custom // field. $this->moduleHandler->install(array('entity_bundle_field_test'), FALSE); $storage = $this->entityManager->getStorage('entity_test'); $entity = $storage->create(['type' => 'entity_test']); $this->assertFalse($entity->hasField('custom_field')); // Check that the custom bundle has the defined custom field and check // saving and deleting of custom field data. $entity = $storage->create(['type' => 'custom']); $this->assertTrue($entity->hasField('custom_field')); $entity->custom_field->value = 'swanky'; $entity->save(); $storage->resetCache(); $entity = $storage->load($entity->id()); $this->assertEqual($entity->custom_field->value, 'swanky', 'Entity was saved correct.y'); $entity->custom_field->value = 'cozy'; $entity->save(); $storage->resetCache(); $entity = $storage->load($entity->id()); $this->assertEqual($entity->custom_field->value, 'cozy', 'Entity was updated correctly.'); $entity->delete(); $table = $storage->_fieldTableName($entity->getFieldDefinition('custom_field')); $result = $this->database->select($table, 'f')->fields('f')->condition('f.entity_id', $entity->id())->execute(); $this->assertFalse($result->fetchAssoc(), 'Field data has been deleted'); // Create another entity to test that values are marked as deleted when a // bundle is deleted. $entity = $storage->create(['type' => 'custom', 'custom_field' => 'new']); $entity->save(); entity_test_delete_bundle('custom'); $table = $storage->_fieldTableName($entity->getFieldDefinition('custom_field')); $result = $this->database->select($table, 'f')->condition('f.entity_id', $entity->id())->condition('deleted', 1)->countQuery()->execute(); $this->assertEqual(1, $result->fetchField(), 'Field data has been deleted'); // @todo Test field purge and table deletion once supported. // $this->assertFalse($this->database->schema()->tableExists($table), 'Custom field table was deleted'); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Remove the key value store entry. $account = $this->currentUser()->id(); $this->keyValueExpirable->delete($account); // Gets list of modules prior to install process. $before = $this->moduleHandler->getModuleList(); // Install the given modules. if (!empty($this->modules['install'])) { $this->moduleHandler->install(array_keys($this->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($this->t('The configuration options have been saved.')); } $form_state->setRedirectUrl($this->getCancelUrl()); }