You are here

public function RealisticDummyContentFileGroup::__construct in Realistic Dummy Content 8.2

Same name and namespace in other branches
  1. 7.2 api/src/includes/RealisticDummyContentFileGroup.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentFileGroup::__construct()
  2. 3.x api/src/includes/RealisticDummyContentFileGroup.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentFileGroup::__construct()

Constructor for a file object.

Several actual files can reside in the same file object if their names have the same radical, for example:

a.b.c a.c

have the same radical, a.c.

Parameters

string $radical: The radical file name, which may or may not exist on the filesystem. For example, if the file is called a.b.c, the radical is a.c, even though a.c does not exist on the filesystem.

object $file: The radical drupal file object, or NULL if it does not exist on the file system.

array $attributes: An array in the format: array( 'attribute_name' => [file object], ), (where attribute_name can be "b" as in the above example).

Throws

RealisticDummyContentException

File

api/src/includes/RealisticDummyContentFileGroup.php, line 78

Class

RealisticDummyContentFileGroup
Represents files as groups.

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public function __construct($radical, $file, $attributes) {
  if (!is_string($radical)) {
    throw new RealisticDummyContentException('Please use string for radical');
  }
  if ($file && !is_object($file)) {
    throw new RealisticDummyContentException('Please use NULL or object for file');
  }
  if (!is_array($attributes)) {
    throw new RealisticDummyContentException('Please use array for attributes');
  }
  $this->radical = $radical;
  $this->file = $file;
  $this->attributes = $attributes;
}