You are here

public function ConfigDevelCommands::importSingle in Configuration development 8

Import a single config item into active storage.

List which configuration settings you want to export in the module's info file by listing them under 'config_devel', as shown below:

config_devel: install:

  • entity.view_display.node.article.default
  • entity.view_display.node.article.teaser
  • field.instance.node.article.body

optional:

  • field.instance.node.article.tags

@command config:devel-import-one

@usage drush config-devel-import-one system.site.yml Import the contents of system.site.yml into the config object system.site. @usage drush config-devel-import-one system.site Import the standard input into the config object system.site. Helpful for scripting copying to remote. @aliases cdi1,cd-i1,config-devel-import-one

Parameters

string $path Config file name.:

Throws

\Exception Thrown when the given file was not found.

1 call to ConfigDevelCommands::importSingle()
ConfigDevelCommands::importConfig in src/Commands/ConfigDevelCommands.php
Imports a list of configuration entities.

File

src/Commands/ConfigDevelCommands.php, line 228

Class

ConfigDevelCommands
Drush integration for the Configuration Development module.

Namespace

Drupal\config_devel\Commands

Code

public function importSingle($path) {
  $contents = '';
  if (!file_exists($path)) {
    if (substr($path, -4) != '.yml') {
      $contents = file_get_contents('php://stdin');
    }
    elseif (!empty($_SERVER['PWD'])) {
      $path = $_SERVER['PWD'] . '/' . trim($path, '/');
    }
  }
  if ($contents || file_exists($path)) {
    $new_hash = $this->configImportExport
      ->importConfig($path, '', $contents);
    if ($new_hash) {
      $this
        ->output()
        ->writeln('Imported config from file ' . $path . '.');
    }
  }
  else {
    throw new \Exception("File '{$path}' not found.");
  }
}