You are here

protected static function Command::getConfigPrefix in Config Importer and Tools 8

Same name and namespace in other branches
  1. 8.2 src/Drush/Command.php \Drupal\config_import\Drush\Command::getConfigPrefix()
  2. 8.0 src/Drush/Command.php \Drupal\config_import\Drush\Command::getConfigPrefix()

Returns prefix for the type of configuration.

Parameters

string $type: Type of configuration.

Return value

string Prefix for the type of configuration.

1 call to Command::getConfigPrefix()
Command::processOptions in src/Drush/Command.php
Process a list of options for the current command.

File

src/Drush/Command.php, line 139

Class

Command
Class Command.

Namespace

Drupal\config_import\Drush

Code

protected static function getConfigPrefix($type) {
  if ('system.simple' === $type) {
    return '';
  }

  // If type does not exists an exception will be thrown.
  $definition = \Drupal::entityTypeManager()
    ->getDefinition($type);

  // For instance, the entities of "user" type cannot be exported.
  if (!$definition instanceof ConfigEntityTypeInterface) {
    throw new \RuntimeException(dt('Export is available only for entities of "@type" type.', [
      '@type' => ConfigEntityTypeInterface::class,
    ]));
  }
  return $definition
    ->getConfigPrefix() . '.';
}