You are here

abstract class RealisticDummyContentGenerator in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/includes/RealisticDummyContentGenerator.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentGenerator
  2. 7.2 api/src/includes/RealisticDummyContentGenerator.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentGenerator

Abstract dummy content generator class.

This module can generate dummy content using an extensible system of "generators", which are subclasses of this class.

Hierarchy

Expanded class hierarchy of RealisticDummyContentGenerator

File

api/src/includes/RealisticDummyContentGenerator.php, line 11

Namespace

Drupal\realistic_dummy_content_api\includes
View source
abstract class RealisticDummyContentGenerator {

  /**
   * Whether or not to kill previous content.
   *
   * @var bool
   */
  private $kill;

  /**
   * The type of entity to generate.
   *
   * @var string
   */
  private $type;

  /**
   * The bundle of the entity to generate.
   *
   * @var mixed
   */
  private $bundle;

  /**
   * The amount of entities to generate.
   *
   * @var mixed
   */
  private $num;

  /**
   * Placeholder for more information about this entity generation.
   *
   * @var mixed
   */
  private $more;

  /**
   * Constructor.
   *
   * @param string $type
   *   An entity type such as "user" or "node".
   * @param mixed $bundle
   *   An entity bundle.
   * @param mixed $num
   *   Number of entities to generate.
   * @param array $more
   *   Can contain:
   *     kill => TRUE|FALSE.
   */
  public function __construct(string $type, $bundle, $num, array $more) {
    $this->type = $type;
    $this->bundle = $bundle;
    $this->num = $num;
    if (isset($more['kill']) && $more['kill']) {
      $this->kill = TRUE;
    }
    else {
      $this->kill = FALSE;
    }
  }

  /**
   * Getter for the bundle property.
   */
  public function getBundle() {
    return $this->bundle;
  }

  /**
   * Getter for the type property.
   */
  public function getType() {
    return $this->type;
  }

  /**
   * Getter for the kill property.
   */
  public function getKill() {
    return $this->kill;
  }

  /**
   * Getter for the num propert.
   */
  public function getNum() {
    return $this->num;
  }

  /**
   * Generate content.
   */
  public function generate() {
    $this
      ->implementGenerate();
  }

  /**
   * Generate content. Used internally in the class.
   */
  public abstract function implementGenerate();

}

Members

Namesort descending Modifiers Type Description Overrides
RealisticDummyContentGenerator::$bundle private property The bundle of the entity to generate.
RealisticDummyContentGenerator::$kill private property Whether or not to kill previous content.
RealisticDummyContentGenerator::$more private property Placeholder for more information about this entity generation.
RealisticDummyContentGenerator::$num private property The amount of entities to generate.
RealisticDummyContentGenerator::$type private property The type of entity to generate.
RealisticDummyContentGenerator::generate public function Generate content.
RealisticDummyContentGenerator::getBundle public function Getter for the bundle property.
RealisticDummyContentGenerator::getKill public function Getter for the kill property.
RealisticDummyContentGenerator::getNum public function Getter for the num propert.
RealisticDummyContentGenerator::getType public function Getter for the type property.
RealisticDummyContentGenerator::implementGenerate abstract public function Generate content. Used internally in the class. 1
RealisticDummyContentGenerator::__construct public function Constructor.