You are here

class Paragraph in Paragraphs 8

Defines the Paragraph entity.

Plugin annotation


@ContentEntityType(
  id = "paragraph",
  label = @Translation("Paragraph"),
  label_collection = @Translation("Paragraphs"),
  label_singular = @Translation("Paragraph"),
  label_plural = @Translation("Paragraphs"),
  label_count = @PluralTranslation(
    singular = "@count Paragraph",
    plural = "@count Paragraphs",
  ),
  bundle_label = @Translation("Paragraph type"),
  handlers = {
    "view_builder" = "Drupal\paragraphs\ParagraphViewBuilder",
    "access" = "Drupal\paragraphs\ParagraphAccessControlHandler",
    "storage_schema" = "Drupal\paragraphs\ParagraphStorageSchema",
    "form" = {
      "default" = "Drupal\Core\Entity\ContentEntityForm",
      "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",
      "edit" = "Drupal\Core\Entity\ContentEntityForm"
    },
    "views_data" = "Drupal\views\EntityViewsData",
  },
  base_table = "paragraphs_item",
  data_table = "paragraphs_item_field_data",
  revision_table = "paragraphs_item_revision",
  revision_data_table = "paragraphs_item_revision_field_data",
  translatable = TRUE,
  entity_revision_parent_type_field = "parent_type",
  entity_revision_parent_id_field = "parent_id",
  entity_revision_parent_field_name_field = "parent_field_name",
  entity_keys = {
    "id" = "id",
    "uuid" = "uuid",
    "bundle" = "type",
    "langcode" = "langcode",
    "revision" = "revision_id",
    "published" = "status"
  },
  bundle_entity_type = "paragraphs_type",
  field_ui_base_route = "entity.paragraphs_type.edit_form",
  common_reference_revisions_target = TRUE,
  content_translation_ui_skip = TRUE,
  render_cache = FALSE,
  default_reference_revision_settings = {
    "field_storage_config" = {
      "cardinality" = -1,
      "settings" = {
        "target_type" = "paragraph"
      }
    },
    "field_config" = {
      "settings" = {
        "handler" = "default:paragraph"
      }
    },
    "entity_form_display" = {
      "type" = "paragraphs"
    },
    "entity_view_display" = {
      "type" = "entity_reference_revisions_entity_view"
    }
  },
  serialized_field_property_names = {
    "behavior_settings" = {
      "value"
    }
  }
)

Hierarchy

Expanded class hierarchy of Paragraph

22 files declare their use of Paragraph
ParagraphsAdministrationTest.php in tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php
ParagraphsAdministrationTest.php in tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php
ParagraphsBehaviorBase.php in src/ParagraphsBehaviorBase.php
ParagraphsBehaviorInterface.php in src/ParagraphsBehaviorInterface.php
ParagraphsBehaviorPluginsTest.php in tests/src/Kernel/ParagraphsBehaviorPluginsTest.php

... See full list

12 string references to 'Paragraph'
core.entity_form_display.node.paragraphed_content_demo.default.yml in modules/paragraphs_demo/config/install/core.entity_form_display.node.paragraphed_content_demo.default.yml
modules/paragraphs_demo/config/install/core.entity_form_display.node.paragraphed_content_demo.default.yml
core.entity_form_display.paragraph.nested_paragraph.default.yml in modules/paragraphs_demo/config/install/core.entity_form_display.paragraph.nested_paragraph.default.yml
modules/paragraphs_demo/config/install/core.entity_form_display.paragraph.nested_paragraph.default.yml
InlineParagraphsWidget::defaultSettings in src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
Defines the default settings for this plugin.
ParagraphsAdministrationTest::testParagraphsCreation in tests/src/Functional/WidgetLegacy/ParagraphsAdministrationTest.php
Tests the paragraph creation.
ParagraphsAdministrationTest::testParagraphsCreation in tests/src/Functional/WidgetStable/ParagraphsAdministrationTest.php
Tests the paragraph creation.

... See full list

File

src/Entity/Paragraph.php, line 100

Namespace

Drupal\paragraphs\Entity
View source
class Paragraph extends ContentEntityBase implements ParagraphInterface {
  use EntityNeedsSaveTrait;
  use EntityPublishedTrait;
  use StringTranslationTrait;

  /**
   * The behavior plugin data for the paragraph entity.
   *
   * @var array
   */
  protected $unserializedBehaviorSettings;

  /**
   * Number of summaries.
   *
   * @var int
   */
  protected $summaryCount;

  /**
   * {@inheritdoc}
   */
  public function getParentEntity() {
    if (!isset($this
      ->get('parent_type')->value) || !isset($this
      ->get('parent_id')->value)) {
      return NULL;
    }
    $parent = \Drupal::entityTypeManager()
      ->getStorage($this
      ->get('parent_type')->value)
      ->load($this
      ->get('parent_id')->value);

    // Return current translation of parent entity, if it exists.
    if ($parent != NULL && $parent instanceof TranslatableInterface && $parent
      ->hasTranslation($this
      ->language()
      ->getId())) {
      return $parent
        ->getTranslation($this
        ->language()
        ->getId());
    }
    return $parent;
  }

  /**
   * {@inheritdoc}
   */
  public function setParentEntity(ContentEntityInterface $parent, $parent_field_name) {
    $this
      ->set('parent_type', $parent
      ->getEntityTypeId());
    $this
      ->set('parent_id', $parent
      ->id());
    $this
      ->set('parent_field_name', $parent_field_name);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function label() {
    if (($parent = $this
      ->getParentEntity()) && $parent
      ->hasField($this
      ->get('parent_field_name')->value)) {
      $parent_field = $this
        ->get('parent_field_name')->value;
      $field = $parent
        ->get($parent_field);
      $label = $parent
        ->label() . ' > ' . $field
        ->getFieldDefinition()
        ->getLabel();

      // A previous or draft revision or a deleted stale Paragraph.
      $postfix = ' (previous revision)';
      foreach ($field as $value) {
        if ($value->entity && $value->entity
          ->getRevisionId() == $this
          ->getRevisionId()) {
          $postfix = '';
          break;
        }
      }
      if ($postfix) {
        $label .= $postfix;
      }
    }
    else {
      $label = $this
        ->t('Orphaned @type: @summary', [
        '@summary' => Unicode::truncate(strip_tags($this
          ->getSummary()), 50, FALSE, TRUE),
        '@type' => $this
          ->get('type')->entity
          ->label(),
      ]);
    }
    return $label;
  }

  /**
   * {@inheritdoc}
   */
  public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);

    // If behavior settings are not set then get them from the entity.
    if ($this->unserializedBehaviorSettings !== NULL) {
      $this
        ->set('behavior_settings', serialize($this->unserializedBehaviorSettings));
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getAllBehaviorSettings() {
    if ($this->unserializedBehaviorSettings === NULL) {
      $this->unserializedBehaviorSettings = unserialize($this
        ->get('behavior_settings')->value);
    }
    if (!is_array($this->unserializedBehaviorSettings)) {
      $this->unserializedBehaviorSettings = [];
    }
    return $this->unserializedBehaviorSettings;
  }

  /**
   * {@inheritdoc}
   */
  public function &getBehaviorSetting($plugin_id, $key, $default = NULL) {
    $settings = $this
      ->getAllBehaviorSettings();
    $exists = NULL;
    $value =& NestedArray::getValue($settings, array_merge((array) $plugin_id, (array) $key), $exists);
    if (!$exists) {
      $value = $default;
    }
    return $value;
  }

  /**
   * {@inheritdoc}
   */
  public function setAllBehaviorSettings(array $settings) {

    // Set behavior settings fields.
    $this->unserializedBehaviorSettings = $settings;
  }

  /**
   * {@inheritdoc}
   */
  public function setBehaviorSettings($plugin_id, array $settings) {

    // Get existing behaviors first.
    $this
      ->getAllBehaviorSettings();

    // Set behavior settings fields.
    $this->unserializedBehaviorSettings[$plugin_id] = $settings;
  }

  /**
   * {@inheritdoc}
   */
  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    $this
      ->setNeedsSave(FALSE);
    parent::postSave($storage, $update);
  }

  /**
   * {@inheritdoc}
   */
  public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
    parent::preSaveRevision($storage, $record);
  }

  /**
   * {@inheritdoc}
   */
  public function getCreatedTime() {
    return $this
      ->get('created')->value;
  }

  /**
   * {@inheritdoc}
   *
   * @deprecated Paragraphs no longer have their own author,
   *  check the parent entity instead.
   */
  public function getOwner() {
    $parent = $this
      ->getParentEntity();
    if ($parent instanceof EntityOwnerInterface) {
      return $parent
        ->getOwner();
    }
    else {
      return NULL;
    }
  }

  /**
   * {@inheritdoc}
   *
   * @deprecated Paragraphs no longer have their own author,
   *  check the parent entity instead.
   */
  public function getOwnerId() {
    $parent = $this
      ->getParentEntity();
    if ($parent instanceof EntityOwnerInterface) {
      return $parent
        ->getOwnerId();
    }
    else {
      return NULL;
    }
  }

  /**
   * {@inheritdoc}
   *
   * @deprecated Paragraphs no longer have their own author,
   *  check the parent entity instead.
   */
  public function setOwnerId($uid) {
    return $this;
  }

  /**
   * {@inheritdoc}
   *
   * @deprecated Paragraphs no longer have their own author,
   *  check the parent entity instead.
   */
  public function setOwner(UserInterface $account) {
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getType() {
    return $this
      ->bundle();
  }

  /**
   * {@inheritdoc}
   */
  public function getParagraphType() {
    return $this->type->entity;
  }

  /**
   * {@inheritdoc}
   *
   * @deprecated Paragraphs no longer have their own author,
   *  check the parent entity instead.
   */
  public function getRevisionAuthor() {
    $parent = $this
      ->getParentEntity();
    if ($parent) {
      return $parent
        ->get('revision_uid')->entity;
    }
    return NULL;
  }

  /**
   * {@inheritdoc}
   *
   * @deprecated Paragraphs no longer have their own author,
   *  check the parent entity instead.
   */
  public function setRevisionAuthorId($uid) {
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getRevisionLog() {
    return '';
  }

  /**
   * {@inheritdoc}
   */
  public function setRevisionLog($revision_log) {
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['langcode'] = BaseFieldDefinition::create('language')
      ->setLabel(t('Language code'))
      ->setDescription(t('The paragraphs entity language code.'))
      ->setRevisionable(TRUE);
    $fields['status'] = BaseFieldDefinition::create('boolean')
      ->setLabel(t('Published'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE)
      ->setDefaultValue(TRUE)
      ->setDisplayConfigurable('form', TRUE);
    $fields['created'] = BaseFieldDefinition::create('created')
      ->setLabel(t('Authored on'))
      ->setDescription(t('The time that the Paragraph was created.'))
      ->setRevisionable(TRUE)
      ->setTranslatable(TRUE)
      ->setDisplayOptions('form', array(
      'region' => 'hidden',
      'weight' => 0,
    ))
      ->setDisplayConfigurable('form', TRUE);
    $fields['parent_id'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Parent ID'))
      ->setDescription(t('The ID of the parent entity of which this entity is referenced.'))
      ->setSetting('is_ascii', TRUE)
      ->setRevisionable(TRUE);
    $fields['parent_type'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Parent type'))
      ->setDescription(t('The entity parent type to which this entity is referenced.'))
      ->setSetting('is_ascii', TRUE)
      ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH)
      ->setRevisionable(TRUE);
    $fields['parent_field_name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Parent field name'))
      ->setDescription(t('The entity parent field name to which this entity is referenced.'))
      ->setSetting('is_ascii', TRUE)
      ->setSetting('max_length', FieldStorageConfig::NAME_MAX_LENGTH)
      ->setRevisionable(TRUE);
    $fields['behavior_settings'] = BaseFieldDefinition::create('string_long')
      ->setLabel(t('Behavior settings'))
      ->setDescription(t('The behavior plugin settings'))
      ->setRevisionable(TRUE)
      ->setDefaultValue(serialize([]));
    return $fields;
  }

  /**
   * {@inheritdoc}
   */
  public function createDuplicate() {
    $duplicate = parent::createDuplicate();

    // Loop over entity fields and duplicate nested paragraphs.
    foreach ($duplicate
      ->getFields() as $fieldItemList) {
      if ($fieldItemList instanceof EntityReferenceFieldItemListInterface && $fieldItemList
        ->getSetting('target_type') === $this
        ->getEntityTypeId()) {
        foreach ($fieldItemList as $delta => $item) {
          if ($item->entity) {
            $fieldItemList[$delta] = $item->entity
              ->createDuplicate();
          }
        }
      }
    }
    return $duplicate;
  }

  /**
   * {@inheritdoc}
   */
  public function getSummary(array $options = []) {
    $summary_items = $this
      ->getSummaryItems($options);
    $summary = [
      '#theme' => 'paragraphs_summary',
      '#summary' => $summary_items,
      '#expanded' => isset($options['expanded']) ? $options['expanded'] : FALSE,
    ];
    return \Drupal::service('renderer')
      ->renderPlain($summary);
  }

  /**
   * {@inheritdoc}
   */
  public function getSummaryItems(array $options = []) {
    $summary = [
      'content' => [],
      'behaviors' => [],
    ];
    $show_behavior_summary = isset($options['show_behavior_summary']) ? $options['show_behavior_summary'] : TRUE;
    $depth_limit = isset($options['depth_limit']) ? $options['depth_limit'] : 1;

    // Add content summary items.
    $this->summaryCount = 0;
    $components = \Drupal::service('entity_display.repository')
      ->getFormDisplay('paragraph', $this
      ->getType())
      ->getComponents();
    uasort($components, 'Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
    foreach (array_keys($components) as $field_name) {

      // Components can be extra fields, check if the field really exists.
      if (!$this
        ->hasField($field_name)) {
        continue;
      }
      $field_definition = $this
        ->getFieldDefinition($field_name);

      // We do not add content to the summary from base fields, skip them
      // keeps performance while building the paragraph summary.
      if (!$field_definition instanceof FieldConfigInterface || !$this
        ->get($field_name)
        ->access('view')) {
        continue;
      }
      if ($field_definition
        ->getType() == 'image' || $field_definition
        ->getType() == 'file') {
        $file_summary = $this
          ->getFileSummary($field_name);
        if ($file_summary != '') {
          $summary['content'][] = $file_summary;
        }
      }
      $text_summary = $this
        ->getTextSummary($field_name, $field_definition);
      if ($text_summary != '') {
        $summary['content'][] = $text_summary;
      }
      if ($field_definition
        ->getType() == 'entity_reference_revisions') {

        // Decrease the depth, since we are entering a nested paragraph.
        $nested_summary = $this
          ->getNestedSummary($field_name, [
          'show_behavior_summary' => FALSE,
          'depth_limit' => $depth_limit - 1,
        ]);
        $summary['content'] = array_merge($summary['content'], $nested_summary);
      }
      if ($field_definition
        ->getType() === 'entity_reference') {
        $referenced_entities = $this
          ->get($field_name)
          ->referencedEntities();

        /** @var \Drupal\Core\Entity\EntityInterface[] $referenced_entities */
        foreach ($referenced_entities as $referenced_entity) {
          if ($referenced_entity
            ->access('view label')) {

            // Switch to the entity translation in the current context.
            $entity = \Drupal::service('entity.repository')
              ->getTranslationFromContext($referenced_entity, $this->activeLangcode);
            $summary['content'][] = $entity
              ->label();
          }
        }
      }

      // Add the Block admin label referenced by block_field.
      if ($field_definition
        ->getType() == 'block_field') {
        if (!empty($this
          ->get($field_name)
          ->first())) {
          if ($block = $block_admin_label = $this
            ->get($field_name)
            ->first()
            ->getBlock()) {
            $block_admin_label = $block
              ->getPluginDefinition()['admin_label'];
          }
          $summary['content'][] = $block_admin_label;
        }
      }
      if ($field_definition
        ->getType() == 'link') {
        if (!empty($this
          ->get($field_name)
          ->first())) {

          // If title is not set, fallback to the uri.
          if ($title = $this
            ->get($field_name)->title) {
            $summary['content'][] = $title;
          }
          else {
            $summary['content'][] = $this
              ->get($field_name)->uri;
          }
        }
      }
    }

    // Add behaviors summary items.
    if ($show_behavior_summary) {
      $paragraphs_type = $this
        ->getParagraphType();
      foreach ($paragraphs_type
        ->getEnabledBehaviorPlugins() as $plugin) {
        if ($plugin_summary = $plugin
          ->settingsSummary($this)) {
          foreach ($plugin_summary as $plugin_summary_element) {
            if (!is_array($plugin_summary_element)) {
              $plugin_summary_element = [
                'value' => $plugin_summary_element,
              ];
            }
            $summary['behaviors'][] = $plugin_summary_element;
          }
        }
      }
    }
    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function getIcons(array $options = []) {
    $show_behavior_info = isset($options['show_behavior_icon']) ? $options['show_behavior_icon'] : TRUE;
    $icons = [];

    // For now we depend here on the fact that summaryCount is already
    // initialized. That means that getSummary() should be called before
    // getIcons().
    // @todo - should we fix this dependency somehow?
    if ($this->summaryCount) {
      $icons['count'] = [
        '#markup' => $this->summaryCount,
        '#prefix' => '<span class="paragraphs-badge" title="' . (string) \Drupal::translation()
          ->formatPlural($this->summaryCount, '1 child', '@count children') . '">',
        '#suffix' => '</span>',
      ];
    }
    if ($show_behavior_info) {
      $paragraphs_type = $this
        ->getParagraphType();
      foreach ($paragraphs_type
        ->getEnabledBehaviorPlugins() as $plugin) {
        if ($plugin_info = $plugin
          ->settingsIcon($this)) {
          $icons = array_merge($icons, $plugin_info);
        }
      }
    }
    return $icons;
  }

  /**
   * Returns an array of field names to skip in ::isChanged.
   *
   * @return array
   *   An array of field names.
   */
  protected function getFieldsToSkipFromChangedCheck() {

    // A list of revision fields which should be skipped from the comparision.
    $fields = [
      $this
        ->getEntityType()
        ->getKey('revision'),
    ];
    return $fields;
  }

  /**
   * {@inheritdoc}
   */
  public function isChanged() {
    if ($this
      ->isNew()) {
      return TRUE;
    }

    // $this->original only exists during save. If it exists we re-use it here
    // for performance reasons.

    /** @var \Drupal\paragraphs\ParagraphInterface $original */
    $original = $this->original ?: NULL;
    if (!$original) {
      $original = $this
        ->entityTypeManager()
        ->getStorage($this
        ->getEntityTypeId())
        ->loadRevision($this
        ->getLoadedRevisionId());
    }

    // If the current revision has just been added, we have a change.
    if ($original
      ->isNewRevision()) {
      return TRUE;
    }

    // The list of fields to skip from the comparision.
    $skip_fields = $this
      ->getFieldsToSkipFromChangedCheck();

    // Compare field item current values with the original ones to determine
    // whether we have changes. We skip also computed fields as comparing them
    // with their original values might not be possible or be meaningless.
    foreach ($this
      ->getFieldDefinitions() as $field_name => $definition) {
      if (in_array($field_name, $skip_fields, TRUE)) {
        continue;
      }
      $field = $this
        ->get($field_name);

      // When saving entities in the user interface, the changed timestamp is
      // automatically incremented by ContentEntityForm::submitForm() even if
      // nothing was actually changed. Thus, the changed time needs to be
      // ignored when determining whether there are any actual changes in the
      // entity.
      if (!$field instanceof ChangedFieldItemList && !$definition
        ->isComputed()) {
        $items = $field
          ->filterEmptyItems();
        $original_items = $original
          ->get($field_name)
          ->filterEmptyItems();
        if (!$items
          ->equals($original_items)) {
          return TRUE;
        }
      }
    }
    return FALSE;
  }

  /**
   * Returns summary for file paragraph.
   *
   * @param string $field_name
   *   Field name from field definition.
   *
   * @return string
   *   Summary for image.
   */
  protected function getFileSummary($field_name) {
    $summary = '';
    if ($this
      ->get($field_name)->entity) {
      foreach ($this
        ->get($field_name) as $file_value) {
        $text = '';
        if ($file_value->description != '') {
          $text = $file_value->description;
        }
        elseif ($file_value->title != '') {
          $text = $file_value->title;
        }
        elseif ($file_value->alt != '') {
          $text = $file_value->alt;
        }
        elseif ($file_value->entity && $file_value->entity
          ->getFileName()) {
          $text = $file_value->entity
            ->getFileName();
        }
        if (strlen($text) > 150) {
          $text = Unicode::truncate($text, 150);
        }
        $summary = $text;
      }
    }
    return trim($summary);
  }

  /**
   * Returns summary items for nested paragraphs.
   *
   * @param string $field_name
   *   Field definition id for paragraph.
   * @param array $options
   *   (optional) An associative array of additional options.
   *   See \Drupal\paragraphs\ParagraphInterface::getSummary() for all of the
   *   available options.
   *
   * @return array
   *   List of content summary items for nested elements.
   */
  protected function getNestedSummary($field_name, array $options) {
    $summary_content = [];
    if ($options['depth_limit'] >= 0) {
      foreach ($this
        ->get($field_name) as $item) {
        $entity = $item->entity;
        if ($entity instanceof ParagraphInterface) {

          // Switch to the entity translation in the current context if exists.
          $entity = \Drupal::service('entity.repository')
            ->getTranslationFromContext($entity, $this->activeLangcode);
          $content_summary_items = $entity
            ->getSummaryItems($options)['content'];
          $summary_content = array_merge($summary_content, array_values($content_summary_items));
          $this->summaryCount++;
        }
      }
    }
    return $summary_content;
  }

  /**
   * Returns summary for all text type paragraph.
   *
   * @param string $field_name
   *   Field definition id for paragraph.
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
   *   Field definition for paragraph.
   *
   * @return string
   *   Short summary for text paragraph.
   */
  public function getTextSummary($field_name, FieldDefinitionInterface $field_definition) {
    $text_types = [
      'text_with_summary',
      'text',
      'text_long',
      'list_string',
      'string',
    ];
    $excluded_text_types = [
      'parent_id',
      'parent_type',
      'parent_field_name',
    ];
    $summary = '';
    if (in_array($field_definition
      ->getType(), $text_types)) {
      if (in_array($field_name, $excluded_text_types)) {
        return '';
      }
      $text = $this
        ->get($field_name)->value;
      $summary = Unicode::truncate(trim(strip_tags($text)), 150);
      if (empty($summary)) {

        // Autoescape is applied to the summary when it is rendered with twig,
        // make it a Markup object so HTML tags are displayed correctly.
        $summary = Markup::create(Unicode::truncate(htmlspecialchars(trim($text)), 150));
      }
    }
    return $summary;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ContentEntityBase::$activeLangcode protected property Language code identifying the entity active language.
ContentEntityBase::$defaultLangcode protected property Local cache for the default language code.
ContentEntityBase::$defaultLangcodeKey protected property The default langcode entity key.
ContentEntityBase::$enforceRevisionTranslationAffected protected property Whether the revision translation affected flag has been enforced.
ContentEntityBase::$entityKeys protected property Holds untranslatable entity keys such as the ID, bundle, and revision ID.
ContentEntityBase::$fieldDefinitions protected property Local cache for field definitions.
ContentEntityBase::$fields protected property The array of fields, each being an instance of FieldItemListInterface.
ContentEntityBase::$fieldsToSkipFromTranslationChangesCheck protected static property Local cache for fields to skip from the checking for translation changes.
ContentEntityBase::$isDefaultRevision protected property Indicates whether this is the default revision.
ContentEntityBase::$langcodeKey protected property The language entity key.
ContentEntityBase::$languages protected property Local cache for the available language objects.
ContentEntityBase::$loadedRevisionId protected property The loaded revision ID before the new revision was set.
ContentEntityBase::$newRevision protected property Boolean indicating whether a new revision should be created on save.
ContentEntityBase::$revisionTranslationAffectedKey protected property The revision translation affected entity key.
ContentEntityBase::$translatableEntityKeys protected property Holds translatable entity keys such as the label.
ContentEntityBase::$translationInitialize protected property A flag indicating whether a translation object is being initialized.
ContentEntityBase::$translations protected property An array of entity translation metadata.
ContentEntityBase::$validated protected property Whether entity validation was performed.
ContentEntityBase::$validationRequired protected property Whether entity validation is required before saving the entity.
ContentEntityBase::$values protected property The plain data values of the contained fields.
ContentEntityBase::access public function Checks data value access. Overrides EntityBase::access 1
ContentEntityBase::addTranslation public function Adds a new translation to the translatable object. Overrides TranslatableInterface::addTranslation
ContentEntityBase::bundle public function Gets the bundle of the entity. Overrides EntityBase::bundle
ContentEntityBase::bundleFieldDefinitions public static function Provides field definitions for a specific bundle. Overrides FieldableEntityInterface::bundleFieldDefinitions 4
ContentEntityBase::clearTranslationCache protected function Clear entity translation object cache to remove stale references.
ContentEntityBase::get public function Gets a field item list. Overrides FieldableEntityInterface::get
ContentEntityBase::getEntityKey protected function Gets the value of the given entity key, if defined. 1
ContentEntityBase::getFieldDefinition public function Gets the definition of a contained field. Overrides FieldableEntityInterface::getFieldDefinition
ContentEntityBase::getFieldDefinitions public function Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface::getFieldDefinitions
ContentEntityBase::getFields public function Gets an array of all field item lists. Overrides FieldableEntityInterface::getFields
ContentEntityBase::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip in ::hasTranslationChanges. 1
ContentEntityBase::getIterator public function
ContentEntityBase::getLanguages protected function
ContentEntityBase::getLoadedRevisionId public function Gets the loaded Revision ID of the entity. Overrides RevisionableInterface::getLoadedRevisionId
ContentEntityBase::getRevisionId public function Gets the revision identifier of the entity. Overrides RevisionableInterface::getRevisionId
ContentEntityBase::getTranslatableFields public function Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface::getTranslatableFields
ContentEntityBase::getTranslatedField protected function Gets a translated field.
ContentEntityBase::getTranslation public function Gets a translation of the data. Overrides TranslatableInterface::getTranslation
ContentEntityBase::getTranslationLanguages public function Returns the languages the data is translated to. Overrides TranslatableInterface::getTranslationLanguages
ContentEntityBase::getTranslationStatus public function Returns the translation status. Overrides TranslationStatusInterface::getTranslationStatus
ContentEntityBase::getUntranslated public function Returns the translatable object referring to the original language. Overrides TranslatableInterface::getUntranslated
ContentEntityBase::hasField public function Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface::hasField
ContentEntityBase::hasTranslation public function Checks there is a translation for the given language code. Overrides TranslatableInterface::hasTranslation
ContentEntityBase::hasTranslationChanges public function Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface::hasTranslationChanges
ContentEntityBase::id public function Gets the identifier. Overrides EntityBase::id
ContentEntityBase::initializeTranslation protected function Instantiates a translation object for an existing translation.
ContentEntityBase::isDefaultRevision public function Checks if this entity is the default revision. Overrides RevisionableInterface::isDefaultRevision
ContentEntityBase::isDefaultTranslation public function Checks whether the translation is the default one. Overrides TranslatableInterface::isDefaultTranslation
ContentEntityBase::isDefaultTranslationAffectedOnly public function Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface::isDefaultTranslationAffectedOnly
ContentEntityBase::isLatestRevision public function Checks if this entity is the latest revision. Overrides RevisionableInterface::isLatestRevision
ContentEntityBase::isLatestTranslationAffectedRevision public function Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface::isLatestTranslationAffectedRevision
ContentEntityBase::isNewRevision public function Determines whether a new revision should be created on save. Overrides RevisionableInterface::isNewRevision
ContentEntityBase::isNewTranslation public function Checks whether the translation is new. Overrides TranslatableInterface::isNewTranslation
ContentEntityBase::isRevisionTranslationAffected public function Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffected
ContentEntityBase::isRevisionTranslationAffectedEnforced public function Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface::isRevisionTranslationAffectedEnforced
ContentEntityBase::isTranslatable public function Returns the translation support status. Overrides TranslatableInterface::isTranslatable
ContentEntityBase::isValidationRequired public function Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::isValidationRequired
ContentEntityBase::language public function Gets the language of the entity. Overrides EntityBase::language
ContentEntityBase::onChange public function Reacts to changes to a field. Overrides FieldableEntityInterface::onChange
ContentEntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityBase::postCreate
ContentEntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityBase::referencedEntities 1
ContentEntityBase::removeTranslation public function Removes the translation identified by the given language code. Overrides TranslatableInterface::removeTranslation
ContentEntityBase::set public function Sets a field value. Overrides FieldableEntityInterface::set
ContentEntityBase::setDefaultLangcode protected function Populates the local cache for the default language code.
ContentEntityBase::setNewRevision public function Enforces an entity to be saved as a new revision. Overrides RevisionableInterface::setNewRevision
ContentEntityBase::setRevisionTranslationAffected public function Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffected
ContentEntityBase::setRevisionTranslationAffectedEnforced public function Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface::setRevisionTranslationAffectedEnforced
ContentEntityBase::setValidationRequired public function Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface::setValidationRequired
ContentEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray
ContentEntityBase::updateFieldLangcodes protected function Updates language for already instantiated fields.
ContentEntityBase::updateLoadedRevisionId public function Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface::updateLoadedRevisionId
ContentEntityBase::updateOriginalValues public function Updates the original values with the interim changes.
ContentEntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase::uuid
ContentEntityBase::validate public function Validates the currently set values. Overrides FieldableEntityInterface::validate
ContentEntityBase::wasDefaultRevision public function Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface::wasDefaultRevision
ContentEntityBase::__clone public function Magic method: Implements a deep clone.
ContentEntityBase::__construct public function Constructs an Entity object. Overrides EntityBase::__construct
ContentEntityBase::__get public function Implements the magic method for getting object properties.
ContentEntityBase::__isset public function Implements the magic method for isset().
ContentEntityBase::__set public function Implements the magic method for setting object properties.
ContentEntityBase::__sleep public function Overrides EntityBase::__sleep
ContentEntityBase::__unset public function Implements the magic method for unset().
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface::getCacheTagsToInvalidate 2
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityInterface::getConfigDependencyName 1
EntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityInterface::getConfigTarget 1
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getOriginalId public function Gets the original ID. Overrides EntityInterface::getOriginalId 1
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::invalidateTagsOnDelete protected static function Invalidates an entity's cache tags upon delete. 1
EntityBase::invalidateTagsOnSave protected function Invalidates an entity's cache tags upon save. 1
EntityBase::isNew public function Determines whether the entity is new. Overrides EntityInterface::isNew 2
EntityBase::languageManager protected function Gets the language manager.
EntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface::link 1
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface::postDelete 16
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface::preDelete 4
EntityBase::save public function Saves an entity permanently. Overrides EntityInterface::save 3
EntityBase::setOriginalId public function Sets the original ID. Overrides EntityInterface::setOriginalId 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityInterface::toUrl 2
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::url public function Gets the public URL for this entity. Overrides EntityInterface::url 2
EntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityInterface::urlInfo 1
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuidGenerator protected function Gets the UUID generator.
EntityChangesDetectionTrait::getFieldsToSkipFromTranslationChangesCheck protected function Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck
EntityNeedsSaveTrait::$needsSave protected property Whether the entity needs to be saved or not.
EntityNeedsSaveTrait::needsSave public function
EntityNeedsSaveTrait::setNeedsSave public function
EntityPublishedTrait::isPublished public function
EntityPublishedTrait::publishedBaseFieldDefinitions public static function Returns an array of base field definitions for publishing status.
EntityPublishedTrait::setPublished public function
EntityPublishedTrait::setUnpublished public function
Paragraph::$summaryCount protected property Number of summaries.
Paragraph::$unserializedBehaviorSettings protected property The behavior plugin data for the paragraph entity.
Paragraph::baseFieldDefinitions public static function Provides base field definitions for an entity type. Overrides ContentEntityBase::baseFieldDefinitions
Paragraph::createDuplicate public function Creates a duplicate of the entity. Overrides ContentEntityBase::createDuplicate
Paragraph::getAllBehaviorSettings public function Gets all the behavior settings. Overrides ParagraphInterface::getAllBehaviorSettings
Paragraph::getBehaviorSetting public function Gets the behavior setting of an specific plugin. Overrides ParagraphInterface::getBehaviorSetting
Paragraph::getCreatedTime public function
Paragraph::getFieldsToSkipFromChangedCheck protected function Returns an array of field names to skip in ::isChanged.
Paragraph::getFileSummary protected function Returns summary for file paragraph.
Paragraph::getIcons public function Returns info icons render array for a paragraph. Overrides ParagraphInterface::getIcons
Paragraph::getNestedSummary protected function Returns summary items for nested paragraphs.
Paragraph::getOwner Deprecated public function Overrides EntityOwnerInterface::getOwner
Paragraph::getOwnerId Deprecated public function Overrides EntityOwnerInterface::getOwnerId
Paragraph::getParagraphType public function Returns the paragraph type. Overrides ParagraphInterface::getParagraphType
Paragraph::getParentEntity public function Gets the parent entity of the paragraph. Overrides ParagraphInterface::getParentEntity
Paragraph::getRevisionAuthor Deprecated public function
Paragraph::getRevisionLog public function
Paragraph::getSummary public function Returns a short summary for the Paragraph. Overrides ParagraphInterface::getSummary
Paragraph::getSummaryItems public function Returns the summary items of the Paragraph. Overrides ParagraphInterface::getSummaryItems
Paragraph::getTextSummary public function Returns summary for all text type paragraph.
Paragraph::getType public function Returns the paragraph type / bundle name as string. Overrides ParagraphInterface::getType
Paragraph::isChanged public function Returns a flag whether a current revision has been changed. Overrides ParagraphInterface::isChanged
Paragraph::label public function Gets the label of the entity. Overrides ContentEntityBase::label
Paragraph::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityNeedsSaveTrait::postSave
Paragraph::preSave public function Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase::preSave
Paragraph::preSaveRevision public function Acts on a revision before it gets saved. Overrides ContentEntityBase::preSaveRevision
Paragraph::setAllBehaviorSettings public function Sets all the behavior settings of a plugin. Overrides ParagraphInterface::setAllBehaviorSettings
Paragraph::setBehaviorSettings public function Sets the behavior settings of a plugin. Overrides ParagraphInterface::setBehaviorSettings
Paragraph::setOwner Deprecated public function Overrides EntityOwnerInterface::setOwner
Paragraph::setOwnerId Deprecated public function Overrides EntityOwnerInterface::setOwnerId
Paragraph::setParentEntity public function Set the parent entity of the paragraph. Overrides ParagraphInterface::setParentEntity
Paragraph::setRevisionAuthorId Deprecated public function
Paragraph::setRevisionLog public function
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function
TranslationStatusInterface::TRANSLATION_CREATED constant Status code identifying a newly created translation.
TranslationStatusInterface::TRANSLATION_EXISTING constant Status code identifying an existing translation.
TranslationStatusInterface::TRANSLATION_REMOVED constant Status code identifying a removed translation.