You are here

class YamlContentCommands in YAML Content 8

YAML Content commands class for Drush 9.0.0-beta5 and above.

Hierarchy

Expanded class hierarchy of YamlContentCommands

1 string reference to 'YamlContentCommands'
drush.services.yml in ./drush.services.yml
drush.services.yml
1 service uses YamlContentCommands
yaml_content.commands in ./drush.services.yml
\Drupal\yaml_content\Commands\YamlContentCommands

File

src/Commands/YamlContentCommands.php, line 10

Namespace

Drupal\yaml_content\Commands
View source
class YamlContentCommands extends DrushCommands {

  /**
   * Content Loader.
   *
   * @var \Drupal\yaml_content\ContentLoader\ContentLoaderInterface
   */
  protected $loader;

  /**
   * ContentLoader constructor.
   *
   * @param \Drupal\yaml_content\Service\LoadHelper $loader
   *   YAML Content loader service.
   */
  public function __construct(LoadHelper $loader) {
    $this->loader = $loader;
  }

  /**
   * Import yaml content from a module.
   *
   * @param string $module
   *   The machine name of a module to be searched for content.
   * @param string $file
   *   (Optional) The name of a content file to be imported.
   * @param array $options
   *   An associative array of options whose values come from cli, aliases,
   *   config, etc.
   *
   * @command yaml_content:import:module
   * @option create-new
   *   Set this to create content even if it is already in the system.
   * @aliases ycim,yaml-content-import-module
   */
  public function contentImportModule($module, $file = NULL, array $options = [
    'create-new' => NULL,
  ]) {
    $this->loader
      ->importModule($module, $file);
  }

  /**
   * Import yaml content.
   *
   * @param string $directory
   *   The directory path where content files may be found.
   * @param string $file
   *   (Optional) The name of a content file to be imported.
   * @param array $options
   *   An associative array of options whose values come from cli, aliases,
   *   config, etc.
   *
   * @command yaml_content:import
   * @option create-new
   *   Set this to create content even if it is already in the system.
   * @aliases yci,yaml-content-import
   */
  public function contentImport($directory, $file = NULL, array $options = [
    'create-new' => NULL,
  ]) {
    $this->loader
      ->importDirectory($directory, $file);
  }

  /**
   * Import yaml content from a profile.
   *
   * @param string $profile
   *   The machine name of a profile to be searched for content.
   * @param string $file
   *   (Optional) The name of a content file to be imported.
   * @param array $options
   *   An associative array of options whose values come from cli, aliases,
   *   config, etc.
   *
   * @command yaml_content:import:profile
   * @option create-new
   *   Set this to create content even if it is already in the system.
   * @aliases ycip,yaml-content-import-profile
   */
  public function contentImportProfile($profile, $file = NULL, array $options = [
    'create-new' => NULL,
  ]) {
    $this->loader
      ->importProfile($profile, $file);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
YamlContentCommands::$loader protected property Content Loader.
YamlContentCommands::contentImport public function Import yaml content.
YamlContentCommands::contentImportModule public function Import yaml content from a module.
YamlContentCommands::contentImportProfile public function Import yaml content from a profile.
YamlContentCommands::__construct public function ContentLoader constructor.