addDependencyListsToForm example

$data = $this->moduleExtensionList->getList();
    $form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
    $form['modules'] = [
      '#theme' => 'item_list',
      '#items' => array_map(function D$module) use ($data) {
        return $data[$module]->info['name'];
      }$this->modules),
    ];

    // List the dependent entities.     $this->addDependencyListsToForm($form, 'module', $this->modules, $this->configManager, $this->entityTypeManager);

    return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Clear the key value store entry.     $account = $this->currentUser()->id();
    $this->keyValueExpirable->delete($account);

    
$form = parent::buildForm($form$form_state);
    $entity = $this->getEntity();
    // Only do dependency processing for configuration entities. Whilst it is     // possible for a configuration entity to be dependent on a content entity,     // these dependencies are soft and content delete permissions are often     // given to more users. This method should not make assumptions that $entity     // is a configuration entity in case we decide to remove the following     // condition.     if (!($entity instanceof ConfigEntityInterface)) {
      return $form;
    }
    $this->addDependencyListsToForm($form$entity->getConfigDependencyKey()$this->getConfigNamesToDelete($entity)$this->getConfigManager()$this->entityTypeManager);

    return $form;
  }

  /** * Gets the configuration manager. * * @return \Drupal\Core\Config\ConfigManager * The configuration manager. */
  protected function getConfigManager() {
    
Home | Imprint | This part of the site doesn't use cookies.