You are here

public function EntityReferenceFieldInheritanceFactory::__construct in Field Inheritance 8

Same name and namespace in other branches
  1. 2.0.x src/EntityReferenceFieldInheritanceFactory.php \Drupal\field_inheritance\EntityReferenceFieldInheritanceFactory::__construct()

Constructs a TypedData object given its definition and context.

Parameters

\Drupal\Core\Field\BaseFieldDefinition $definition: The data definition.

string $name: (optional) The name of the created property, or NULL if it is the root of a typed data tree. Defaults to NULL.

\Drupal\Core\TypedData\TypedDataInterface $parent: (optional) The parent object of the data property, or NULL if it is the root of a typed data tree. Defaults to NULL.

Overrides TypedData::__construct

See also

\Drupal\Core\TypedData\TypedDataManager::create()

File

src/EntityReferenceFieldInheritanceFactory.php, line 35

Class

EntityReferenceFieldInheritanceFactory
The EntityReferenceFieldInheritanceFactory class.

Namespace

Drupal\field_inheritance

Code

public function __construct(BaseFieldDefinition $definition, $name = NULL, TypedDataInterface $parent = NULL) {
  parent::__construct($definition, $name, $parent);
  if ($this
    ->getSetting('plugin') === NULL) {
    throw new \InvalidArgumentException("The definition's 'plugin' key has to specify the plugin to use to inherit data.");
  }
  if ($this
    ->getSetting('method') === NULL) {
    throw new \InvalidArgumentException("The definition's 'method' key has to specify the method to use to inherit data. Valid options are inherit, prepend, replace, and append.");
  }
  if ($this
    ->getSetting('source entity type') === NULL) {
    throw new \InvalidArgumentException("The definition's 'source entity type' key has to specify the entity type from which to inherit data.");
  }
  if ($this
    ->getSetting('source entity bundle') === NULL) {
    throw new \InvalidArgumentException("The definition's 'source entity bundle' key has to specify the entity bundle from which to inherit data.");
  }
  if ($this
    ->getSetting('source field') === NULL) {
    throw new \InvalidArgumentException("The definition's 'source field' key has to specify the field from which to inherit data.");
  }
}