getEditableConfigNames example

protected function config($name) {
    /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
    if (method_exists($this, 'configFactory')) {
      $config_factory = $this->configFactory();
    }
    elseif (property_exists($this, 'configFactory')) {
      $config_factory = $this->configFactory;
    }
    if (!isset($config_factory) || !($config_factory instanceof ConfigFactoryInterface)) {
      throw new \LogicException('No config factory available for ConfigFormBaseTrait');
    }
    if (in_array($name$this->getEditableConfigNames())) {
      // Get a mutable object from the factory.       $config = $config_factory->getEditable($name);
    }
    else {
      $config = $config_factory->get($name);
    }
    return $config;
  }

  /** * Gets the configuration names that will be editable. * * @return array * An array of configuration object names that are editable if called in * conjunction with the trait's config() method. */
Home | Imprint | This part of the site doesn't use cookies.