You are here

public function FormOverrides::getFormConfigNames in Configuration Override Warn 8

Get the config names that correspond with a form.

Parameters

\Drupal\Core\Form\FormInterface $form: The form object.

Return value

array An array of config names.

1 call to FormOverrides::getFormConfigNames()
FormOverrides::getFormOverrides in src/FormOverrides.php
Get overrides for a form.

File

src/FormOverrides.php, line 76

Class

FormOverrides
Contains logic for inspecting config forms and their overridden values.

Namespace

Drupal\config_override_warn

Code

public function getFormConfigNames(FormInterface $form) {
  $names = [];
  if ($form instanceof EntityForm) {
    $entity = $form
      ->getEntity();
    if ($entity instanceof ConfigEntityInterface && !$entity
      ->isNew()) {
      $names = [
        $entity
          ->getConfigDependencyName(),
      ];
    }
  }
  elseif (method_exists($form, 'getEditableConfigNames')) {

    // Grr... this is a protected method ConfigFormBaseTrait.
    // @see https://www.drupal.org/project/drupal/issues/2095289
    $method = new \ReflectionMethod($form, 'getEditableConfigNames');
    $method
      ->setAccessible(TRUE);
    $names = $method
      ->invoke($form);
  }
  return $names;
}