You are here

class Config in Rename Admin Paths 8.2

Config for rename_admin_paths module

Hierarchy

  • class \Drupal\rename_admin_paths\Config

Expanded class hierarchy of Config

4 files declare their use of Config
RenameAdminPathEventSubscriberTest.php in tests/src/Unit/EventSubscriber/RenameAdminPathEventSubscriberTest.php
RenameAdminPathsEventSubscriber.php in src/EventSubscriber/RenameAdminPathsEventSubscriber.php
RenameAdminPathsSettingsForm.php in src/Form/RenameAdminPathsSettingsForm.php
RenameAdminPathsSettingsFormTest.php in tests/src/Unit/Form/RenameAdminPathsSettingsFormTest.php

File

src/Config.php, line 12

Namespace

Drupal\rename_admin_paths
View source
class Config {

  /**
   * Config storage key.
   */
  const CONFIG_KEY = 'rename_admin_paths.settings';

  /**
   * @var ConfigFactoryInterface
   */
  private $configFactory;

  /**
   * @var CoreConfig
   */
  private $configEditable;

  /**
   * @var ImmutableConfig
   */
  private $configImmutable;

  /**
   * @param ConfigFactoryInterface $configFactory
   */
  public function __construct(ConfigFactoryInterface $configFactory) {
    $this->configFactory = $configFactory;
  }

  /**
   * @return CoreConfig
   */
  private function getEditableConfig() : CoreConfig {
    if (empty($this->configEditable)) {
      $this->configEditable = $this->configFactory
        ->getEditable(self::CONFIG_KEY);
    }
    return $this->configEditable;
  }

  /**
   * @return ImmutableConfig
   */
  private function getImmutableConfig() : ImmutableConfig {
    if (empty($this->configImmutable)) {
      $this->configImmutable = $this->configFactory
        ->get(self::CONFIG_KEY);
    }
    return $this->configImmutable;
  }

  /**
   * @param string $path
   *
   * @return bool
   */
  public function isPathEnabled(string $path) : bool {
    return !empty($this
      ->getImmutableConfig()
      ->get(sprintf('%s_path', $path)));
  }

  /**
   * @param string $path
   *
   * @return string
   */
  public function getPathValue(string $path) : string {
    return $this
      ->getImmutableConfig()
      ->get(sprintf('%s_path_value', $path));
  }

  /**
   * @param string $path
   * @param string $enabled
   */
  public function setPathEnabled(string $path, string $enabled) : void {
    $this
      ->getEditableConfig()
      ->set(sprintf('%s_path', $path), $enabled);
  }

  /**
   * @param string $path
   * @param string $value
   */
  public function setPathValue(string $path, string $value) : void {
    $this
      ->getEditableConfig()
      ->set(sprintf('%s_path_value', $path), $value);
  }
  public function save() : void {
    $this
      ->getEditableConfig()
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Config::$configEditable private property
Config::$configFactory private property
Config::$configImmutable private property
Config::CONFIG_KEY constant Config storage key.
Config::getEditableConfig private function
Config::getImmutableConfig private function
Config::getPathValue public function
Config::isPathEnabled public function
Config::save public function
Config::setPathEnabled public function
Config::setPathValue public function
Config::__construct public function