function BaseFieldDefinition::setCustomStorage

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::setCustomStorage()
  2. 8.9.x core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::setCustomStorage()
  3. 11.x core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::setCustomStorage()

Sets the storage behavior for this field.

Parameters

bool $custom_storage: Pass FALSE if the storage takes care of storing the field, TRUE otherwise.

Return value

$this

Throws

\LogicException Thrown if custom storage is to be set to FALSE for a computed field.

File

core/lib/Drupal/Core/Field/BaseFieldDefinition.php, line 721

Class

BaseFieldDefinition
A class for defining entity fields.

Namespace

Drupal\Core\Field

Code

public function setCustomStorage($custom_storage) {
    if (!$custom_storage && $this->isComputed()) {
        throw new \LogicException("Entity storage cannot store a computed field.");
    }
    $this->definition['custom_storage'] = $custom_storage;
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.