You are here

public function TextFormatConfigurationHandler::loadFromDatabase in Configuration Management 7.3

Loads the configuration from the database.

Parameters

string $identifier: The identifier of the configuration to load.

Return value

\Configuration\Configuration A configuration object.

Overrides ConfigurationHandler::loadFromDatabase

File

src/Handlers/TextFormatConfigurationHandler.php, line 23

Class

TextFormatConfigurationHandler

Namespace

Configuration\Handlers

Code

public function loadFromDatabase($identifier) {
  $name = $this
    ->getInternalId($identifier);
  $configuration = new Configuration();
  $configuration
    ->setIdentifier($identifier);
  $format = $this->configuration_manager
    ->drupal()
    ->text_format_getFilterFormat($name);
  if (!empty($format)) {
    $filters_info = $this->configuration_manager
      ->drupal()
      ->filter_get_filters();
    $format->filters = array();
    foreach ($this->configuration_manager
      ->drupal()
      ->filter_list_format($format->format) as $filter) {
      if (!empty($filter->status)) {
        $format->filters[$filter->name]['weight'] = $filter->weight;
        $format->filters[$filter->name]['status'] = $filter->status;
        $format->filters[$filter->name]['settings'] = $filter->settings;
        $configuration
          ->addModule($filters_info[$filter->name]['module']);
      }
    }
    $configuration
      ->setData($format);
  }
  $event = $this
    ->triggerEvent('load_from_database', $configuration);
  return $event->configuration;
}