You are here

IsStub.php in Multiversion 8

Same filename and directory in other branches
  1. 8.2 src/IsStub.php

File

src/IsStub.php
View source
<?php

namespace Drupal\multiversion;

use Drupal\Core\TypedData\TypedData;

/**
 * The 'is_stub' property for revision token fields.
 */
class IsStub extends TypedData {

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Classes

Namesort descending Description
IsStub The 'is_stub' property for revision token fields.