You are here

public function ContentTypeConfigurationHandler::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/ContentTypeConfigurationHandler.php, line 18

Class

ContentTypeConfigurationHandler

Namespace

Configuration\Handlers

Code

public function loadFromDatabase($identifier) {
  $content_type_name = $this
    ->getInternalId($identifier);
  $configuration = new Configuration();
  $configuration
    ->setIdentifier($identifier);
  $content_type = (object) $this->configuration_manager
    ->drupal()
    ->node_type_get_type($content_type_name);
  $data = new \StdClass();
  $keys = array(
    'type',
    'name',
    'description',
    'has_title',
    'title_label',
    'base',
    'module',
    'help',
  );
  foreach ($keys as $key) {
    $data->{$key} = $content_type->{$key};
  }

  // Force module name to be 'configuration' if set to 'node. If we leave as
  // 'node' the content type will be assumed to be database-stored by
  // the node module.
  if ($content_type->base === 'node') {
    $data->base = 'configuration';
  }
  $configuration
    ->setData($data);
  $event = $this
    ->triggerEvent('load_from_database', $configuration);
  $event_settings = array(
    'entity_type' => 'node',
    'bundle_name' => $data->type,
  );
  $event = $this
    ->triggerEvent('load_from_database.entity', $event->configuration, $event_settings, FALSE);
  return $event->configuration;
}