You are here

public function IsStub::getValue in Multiversion 8

Same name and namespace in other branches
  1. 8.2 src/IsStub.php \Drupal\multiversion\IsStub::getValue()

Gets the data value.

Return value

mixed The data value.

Overrides TypedData::getValue

File

src/IsStub.php, line 15

Class

IsStub
The 'is_stub' property for revision token fields.

Namespace

Drupal\multiversion

Code

public function getValue($langcode = NULL) {

  // Check if we have explicitly set a value.
  if (isset($this->value) && $this->value !== NULL) {
    return $this->value;
  }

  // Check if the entity was saved as a stub earlier.

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $this
    ->getRoot()
    ->getValue();
  if (!$entity
    ->isNew() && $entity->_rev->value == '0-00000000000000000000000000000000') {
    return TRUE;
  }

  // Fall back on FALSE as the default value.
  return FALSE;
}