You are here

public function ConfigurationHandler::import in Configuration Management 7.3

File

src/Handlers/ConfigurationHandler.php, line 111

Class

ConfigurationHandler

Namespace

Configuration\Handlers

Code

public function import($path, $format = "json") {
  $import_path = drupal_realpath('public://' . $this->configuration_manager
    ->settings()
    ->get('import.path'));
  $directories = array(
    $import_path,
  );
  $locator = new FileLocator($directories);
  $config_full_path = $locator
    ->locate($path);
  if (!empty($config_full_path)) {
    $file_content = file_get_contents($config_full_path);
    switch ($format) {
      case 'json':
        return $this
          ->importFromJson($file_content);
        break;
      default:
        return '';
        break;
    }
  }
}