class Node

Defines the node entity class.

Plugin annotation


@EntityType(
  id = "node",
  label = @Translation("Content"),
  bundle_label = @Translation("Content type"),
  module = "node",
  controllers = {
    "storage" = "Drupal\node\NodeStorageController",
    "render" = "Drupal\node\NodeRenderController",
    "access" = "Drupal\node\NodeAccessController",
    "form" = {
      "default" = "Drupal\node\NodeFormController",
      "edit" = "Drupal\node\NodeFormController"
    },
    "translation" = "Drupal\node\NodeTranslationController"
  },
  base_table = "node",
  data_table = "node_field_data",
  revision_table = "node_field_revision",
  uri_callback = "node_uri",
  fieldable = TRUE,
  translatable = TRUE,
  entity_keys = {
    "id" = "nid",
    "revision" = "vid",
    "bundle" = "type",
    "label" = "title",
    "uuid" = "uuid"
  },
  bundle_keys = {
    "bundle" = "type"
  },
  route_base_path = "admin/structure/types/manage/{bundle}",
  permission_granularity = "bundle",
  links = {
    "canonical" = "/node/{node}",
    "edit-form" = "/node/{node}/edit",
    "version-history" = "/node/{node}/revisions"
  }
)

Hierarchy

Expanded class hierarchy of Node

1 file declares its use of Node
taxonomy.module in drupal/core/modules/taxonomy/taxonomy.module
Enables the organization of content into categories.
47 string references to 'Node'
comment_token_info in drupal/core/modules/comment/comment.tokens.inc
Implements hook_token_info().
field_views_field_default_views_data in drupal/core/modules/field/field.views.inc
Default views data implementation for a field.
file_field_views_data_views_data_alter in drupal/core/modules/file/file.views.inc
Implements hook_field_views_data_views_data_alter().
forum_views_data in drupal/core/modules/forum/forum.views.inc
Implements hook_views_data().
image_field_views_data_views_data_alter in drupal/core/modules/image/image.views.inc
Implements hook_field_views_data_views_data_alter().

... See full list

File

drupal/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php, line 59
Definition of Drupal\node\Plugin\Core\Entity\Node.

Namespace

Drupal\node\Plugin\Core\Entity
View source
class Node extends EntityNG implements NodeInterface {

  /**
   * The node ID.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $nid;

  /**
   * The node revision ID.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $vid;

  /**
   * The node UUID.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $uuid;

  /**
   * The node content type (bundle).
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $type;

  /**
   * The node language code.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $langcode;

  /**
   * The node title.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $title;

  /**
   * The node owner's user ID.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $uid;

  /**
   * The node published status indicator.
   *
   * Unpublished nodes are only visible to their authors and to administrators.
   * The value is either NODE_PUBLISHED or NODE_NOT_PUBLISHED.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $status;

  /**
   * The node creation timestamp.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $created;

  /**
   * The node modification timestamp.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $changed;

  /**
   * The node comment status indicator.
   *
   * COMMENT_NODE_HIDDEN => no comments
   * COMMENT_NODE_CLOSED => comments are read-only
   * COMMENT_NODE_OPEN => open (read/write)
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $comment;

  /**
   * The node promotion status.
   *
   * Promoted nodes should be displayed on the front page of the site. The value
   * is either NODE_PROMOTED or NODE_NOT_PROMOTED.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $promote;

  /**
   * The node sticky status.
   *
   * Sticky nodes should be displayed at the top of lists in which they appear.
   * The value is either NODE_STICKY or NODE_NOT_STICKY.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $sticky;

  /**
   * The node translation set ID.
   *
   * Translations sets are based on the ID of the node containing the source
   * text for the translation set.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $tnid;

  /**
   * The node translation status.
   *
   * If the translation page needs to be updated, the value is 1; otherwise 0.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $translate;

  /**
   * The node revision creation timestamp.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $revision_timestamp;

  /**
   * The node revision author's user ID.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $revision_uid;

  /**
   * The node revision log message.
   *
   * @var \Drupal\Core\Entity\Field\FieldInterface
   */
  public $log;

  /**
   * Overrides \Drupal\Core\Entity\EntityNG::init().
   */
  protected function init() {
    parent::init();

    // We unset all defined properties, so magic getters apply.
    unset($this->nid);
    unset($this->vid);
    unset($this->uuid);
    unset($this->type);
    unset($this->title);
    unset($this->uid);
    unset($this->status);
    unset($this->created);
    unset($this->changed);
    unset($this->comment);
    unset($this->promote);
    unset($this->sticky);
    unset($this->tnid);
    unset($this->translate);
    unset($this->revision_timestamp);
    unset($this->revision_uid);
    unset($this->log);
  }

  /**
   * Implements Drupal\Core\Entity\EntityInterface::id().
   */
  public function id() {
    return $this
      ->get('nid')->value;
  }

  /**
   * Overrides Drupal\Core\Entity\Entity::getRevisionId().
   */
  public function getRevisionId() {
    return $this
      ->get('vid')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function getBCEntity() {
    if (!isset($this->bcEntity)) {
      $this
        ->getPropertyDefinitions();
      $this->bcEntity = new NodeBCDecorator($this, $this->fieldDefinitions);
    }
    return $this->bcEntity;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Entity::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
Entity::$entityType protected property The entity type.
Entity::$isDefaultRevision protected property Indicates whether this is the default revision. 1
Entity::$newRevision protected property Boolean indicating whether a new revision should be created on save.
Entity::access public function Implements \Drupal\Core\TypedData\AccessibleInterface::access(). Overrides AccessibleInterface::access
Entity::delete public function Implements \Drupal\Core\Entity\EntityInterface::delete(). Overrides EntityInterface::delete 3
Entity::enforceIsNew public function Implements \Drupal\Core\Entity\EntityInterface::enforceIsNew(). Overrides EntityInterface::enforceIsNew
Entity::entityInfo public function Implements \Drupal\Core\Entity\EntityInterface::entityInfo(). Overrides EntityInterface::entityInfo
Entity::entityType public function Implements \Drupal\Core\Entity\EntityInterface::entityType(). Overrides EntityInterface::entityType
Entity::getConstraints public function Implements \Drupal\Core\TypedData\TypedDataInterface::getConstraints(). Overrides TypedDataInterface::getConstraints
Entity::getDefinition public function Implements \Drupal\Core\TypedData\TypedDataInterface::getDefinition(). Overrides TypedDataInterface::getDefinition
Entity::getExportProperties public function Implements \Drupal\Core\Entity\EntityInterface::getExportProperties(). Overrides EntityInterface::getExportProperties 1
Entity::getName public function Implements \Drupal\Core\TypedData\TypedDataInterface::getName(). Overrides TypedDataInterface::getName
Entity::getNGEntity public function Implements \Drupal\Core\Entity\EntityInterface::getNGEntity(). Overrides EntityInterface::getNGEntity
Entity::getParent public function Implements \Drupal\Core\TypedData\TypedDataInterface::getParent(). Overrides TypedDataInterface::getParent
Entity::getPropertyPath public function Implements \Drupal\Core\TypedData\TypedDataInterface::getPropertyPath(). Overrides TypedDataInterface::getPropertyPath
Entity::getRoot public function Implements \Drupal\Core\TypedData\TypedDataInterface::getRoot(). Overrides TypedDataInterface::getRoot
Entity::getString public function Implements \Drupal\Core\TypedData\TypedDataInterface::getString(). Overrides TypedDataInterface::getString
Entity::getValue public function Implements \Drupal\Core\TypedData\TypedDataInterface::getValue(). Overrides TypedDataInterface::getValue
Entity::isDefaultRevision public function Implements \Drupal\Core\Entity\EntityInterface::isDefaultRevision(). Overrides EntityInterface::isDefaultRevision 1
Entity::isNew public function Implements \Drupal\Core\Entity\EntityInterface::isNew(). Overrides EntityInterface::isNew 1
Entity::isNewRevision public function Implements \Drupal\Core\Entity\EntityInterface::isNewRevision(). Overrides EntityInterface::isNewRevision
Entity::isTranslatable public function Implements \Drupal\Core\Entity\EntityInterface::isTranslatable(). Overrides EntityInterface::isTranslatable
Entity::onChange public function Implements \Drupal\Core\TypedData\ComplexDataInterface::onChange(). Overrides ComplexDataInterface::onChange
Entity::save public function Implements \Drupal\Core\Entity\EntityInterface::save(). Overrides EntityInterface::save 6
Entity::setContext public function Implements \Drupal\Core\TypedData\TypedDataInterface::setContext(). Overrides TypedDataInterface::setContext
Entity::setNewRevision public function Implements \Drupal\Core\Entity\EntityInterface::setNewRevision(). Overrides EntityInterface::setNewRevision
Entity::setValue public function Implements \Drupal\Core\TypedData\TypedDataInterface::setValue(). Overrides TypedDataInterface::setValue
Entity::uriRelationships public function Returns a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityNG::$bcEntity protected property An instance of the backward compatibility decorator.
EntityNG::$bundle protected property Local cache holding the value of the bundle field.
EntityNG::$fieldDefinitions protected property Local cache for field definitions.
EntityNG::$fields protected property The array of fields, each being an instance of FieldInterface.
EntityNG::$uriPlaceholderReplacements protected property Local cache for URI placeholder substitution values.
EntityNG::$values protected property The plain data values of the contained fields. 3
EntityNG::bundle public function Implements \Drupal\Core\Entity\EntityInterface::bundle(). Overrides Entity::bundle
EntityNG::createDuplicate public function Overrides Entity::createDuplicate(). Overrides Entity::createDuplicate 1
EntityNG::get public function Implements \Drupal\Core\TypedData\ComplexDataInterface::get(). Overrides Entity::get
EntityNG::getIterator public function Implements \IteratorAggregate::getIterator(). Overrides Entity::getIterator
EntityNG::getProperties public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getProperties(). Overrides Entity::getProperties
EntityNG::getPropertyDefinition public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinition(). Overrides Entity::getPropertyDefinition
EntityNG::getPropertyDefinitions public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions(). Overrides Entity::getPropertyDefinitions
EntityNG::getPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyValues(). Overrides Entity::getPropertyValues
EntityNG::getTranslatedField protected function Gets a translated field.
EntityNG::getTranslation public function Implements \Drupal\Core\TypedData\TranslatableInterface::getTranslation(). Overrides Entity::getTranslation
EntityNG::getTranslationLanguages public function Implements \Drupal\Core\TypedData\TranslatableInterface::getTranslationLanguages(). Overrides Entity::getTranslationLanguages
EntityNG::getType public function Gets the typed data type of the entity. Overrides Entity::getType
EntityNG::isEmpty public function Implements \Drupal\Core\TypedData\ComplexDataInterface::isEmpty(). Overrides Entity::isEmpty
EntityNG::label public function Overrides Entity::label() to access the label field with the new API. Overrides Entity::label 3
EntityNG::language public function Implements \Drupal\Core\TypedData\TranslatableInterface::language(). Overrides Entity::language
EntityNG::set public function Implements \Drupal\Core\TypedData\ComplexDataInterface::set(). Overrides Entity::set
EntityNG::setPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::setPropertyValues(). Overrides Entity::setPropertyValues
EntityNG::translations public function Overrides Entity::translations(). Overrides Entity::translations
EntityNG::updateOriginalValues public function Updates the original values with the interim changes.
EntityNG::uri public function Implements \Drupal\Core\Entity\EntityInterface::uri(). Overrides Entity::uri 1
EntityNG::uriPlaceholderReplacements protected function Returns an array of placeholders for this entity.
EntityNG::uuid public function Overrides Entity::uuid(). Overrides Entity::uuid
EntityNG::validate public function Implements \Drupal\Core\TypedData\TypedDataInterface::validate(). Overrides Entity::validate
EntityNG::__clone public function Magic method: Implements a deep clone.
EntityNG::__construct public function Overrides Entity::__construct(). Overrides Entity::__construct
EntityNG::__get public function Implements the magic method for setting object properties.
EntityNG::__isset public function Implements the magic method for isset().
EntityNG::__set public function Implements the magic method for setting object properties.
EntityNG::__unset public function Implements the magic method for unset.
EntityNG::__wakeup public function Magic __wakeup() implementation.
Node::$changed public property The node modification timestamp.
Node::$comment public property The node comment status indicator.
Node::$created public property The node creation timestamp.
Node::$langcode public property The node language code. Overrides Entity::$langcode
Node::$log public property The node revision log message.
Node::$nid public property The node ID.
Node::$promote public property The node promotion status.
Node::$revision_timestamp public property The node revision creation timestamp.
Node::$revision_uid public property The node revision author's user ID.
Node::$status public property The node published status indicator.
Node::$sticky public property The node sticky status.
Node::$title public property The node title.
Node::$tnid public property The node translation set ID.
Node::$translate public property The node translation status.
Node::$type public property The node content type (bundle).
Node::$uid public property The node owner's user ID.
Node::$uuid public property The node UUID.
Node::$vid public property The node revision ID.
Node::getBCEntity public function Overrides Entity::getBCEntity(). Overrides EntityNG::getBCEntity
Node::getRevisionId public function Overrides Drupal\Core\Entity\Entity::getRevisionId(). Overrides Entity::getRevisionId
Node::id public function Implements Drupal\Core\Entity\EntityInterface::id(). Overrides EntityNG::id
Node::init protected function Overrides \Drupal\Core\Entity\EntityNG::init(). Overrides EntityNG::init