You are here

class LanguageConfigurationHandler in Configuration Management 7.3

Hierarchy

Expanded class hierarchy of LanguageConfigurationHandler

File

src/Handlers/LanguageConfigurationHandler.php, line 9

Namespace

Configuration\Handlers
View source
class LanguageConfigurationHandler extends ConfigurationHandler {
  public static function getSupportedTypes() {
    return array(
      'language',
    );
  }
  public function getIdentifiers() {
    return $this->configuration_manager
      ->drupal()
      ->locale_language_list('native', TRUE);
  }
  public function loadFromDatabase($identifier) {
    $name = $this
      ->getInternalId($identifier);
    $language_list = $this->configuration_manager
      ->drupal()
      ->language_list();
    $language = $language_list[$name];
    $configuration = new Configuration();
    $configuration
      ->setIdentifier($identifier);
    $configuration
      ->setData($language);
    $configuration
      ->addModule('locale');
    $event = $this
      ->triggerEvent('load_from_database', $configuration);
    return $event->configuration;
  }
  public function writeToDatabase(Configuration $configuration) {
    $name = $this
      ->getInternalId($configuration
      ->getIdentifier());
    $event = $this
      ->triggerEvent('write_to_database', $configuration);
    $language = $event->configuration
      ->getData();
    $this->configuration_manager
      ->drupal()
      ->locale_writeToDatabase($language);
  }
  public function removeFromDatabase(Configuration $configuration) {
    $langcode = $this
      ->getInternalId($configuration
      ->getIdentifier());
    $event = $this
      ->triggerEvent('remove_from_database', $configuration);
    $this->configuration_manager
      ->drupal()
      ->locale_removeFromDatabase($langcode);
  }
  public static function getSubscribedEvents() {
    return array(
      'write_to_database.variable' => array(
        'onVariableSave',
        0,
      ),
    );
  }
  public function onVariableSave($event) {
    $identifier = $event->configuration
      ->getIdentifier();
    if ($identifier == 'variable.language_default') {
      $data = $event->configuration
        ->getData();
      $event->configuration
        ->setData((object) $data);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurationHandler::$configuration_manager protected property
ConfigurationHandler::$type protected property
ConfigurationHandler::export public function Generates the JSON representation of this configuration.
ConfigurationHandler::exportToJson protected function
ConfigurationHandler::getExportPath public function
ConfigurationHandler::getInternalId protected function
ConfigurationHandler::getType public function
ConfigurationHandler::getTypeFromId protected function
ConfigurationHandler::import public function
ConfigurationHandler::importFromJson public function
ConfigurationHandler::importFromJsonAsArray protected function 1
ConfigurationHandler::jsonAsArray protected function 9
ConfigurationHandler::registerProcessors protected function 2
ConfigurationHandler::triggerEvent protected function
ConfigurationHandler::__construct public function 1
LanguageConfigurationHandler::getIdentifiers public function Returns the configuration identifiers handled by this instance. Overrides ConfigurationHandler::getIdentifiers
LanguageConfigurationHandler::getSubscribedEvents public static function Overrides ConfigurationHandler::getSubscribedEvents
LanguageConfigurationHandler::getSupportedTypes public static function Returns the types of configurations that this class can handle. Overrides ConfigurationHandler::getSupportedTypes
LanguageConfigurationHandler::loadFromDatabase public function Loads the configuration from the database. Overrides ConfigurationHandler::loadFromDatabase
LanguageConfigurationHandler::onVariableSave public function
LanguageConfigurationHandler::removeFromDatabase public function Deletes a configuration from the database. Overrides ConfigurationHandler::removeFromDatabase
LanguageConfigurationHandler::writeToDatabase public function Saves the given configuration into the database. Overrides ConfigurationHandler::writeToDatabase