You are here

public function LoadHelper::importProfile in YAML Content 8

Import specified yaml content file(s) from a designated profile.

Parameters

string $profile: The profile to look for content files within.

This command assumes files will be contained within a `content/` directory at the top of the module's main directory. Any files within matching the pattern `*.content.yml` will then be imported.

string|string[] $file: (Optional) The name of a file to be imported or an array of files to import. If this argument is not provided then all files in the directory matching `*.content.yml` are queued for import.

File

src/Service/LoadHelper.php, line 109

Class

LoadHelper
A helper class to support the content loading process.

Namespace

Drupal\yaml_content\Service

Code

public function importProfile($profile, $file = NULL) {
  $path = drupal_get_path('profile', $profile);
  $this->loader
    ->setContentPath($path);

  // Identify files for import.
  $mask = '/' . (isset($file) ? $file : '.*') . '\\.content\\.yml/';
  $files = $this
    ->discoverFiles($path . '/content', $mask);
  $this
    ->importFiles($files);
}