diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 7c0a458..d54f7c7 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -5,6 +5,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Entity\Plugin\DataType\EntityReference; use Drupal\Core\Field\BaseFieldDefinition; +use Drupal\Core\Field\Plugin\Field\FieldType\StatusItem; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Session\AccountInterface; @@ -815,6 +816,30 @@ public function isNewTranslation() { /** * {@inheritdoc} */ + public function isArchived() { + $status_key = $this->getEntityType()->getKey('status'); + if ($this->hasField($status_key)) { + $status = $this->$status_key->getValue(); + if ($status[0]['value'] == -1) { + return TRUE; + } + } + return FALSE; + } + + /** + * {@inheritdoc} + */ + public function setArchived($archived) { + $status_key = $this->getEntityType()->getKey('status'); + if ($this->hasField($status_key) && $archived) { + $this->set($status_key, -1); + } + } + + /** + * {@inheritdoc} + */ public function addTranslation($langcode, array $values = array()) { // Make sure we do not attempt to create a translation if an invalid // language is specified or the entity cannot be translated. diff --git a/core/lib/Drupal/Core/Entity/ContentEntityInterface.php b/core/lib/Drupal/Core/Entity/ContentEntityInterface.php index 0c3f04b..8aba3b7 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityInterface.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityInterface.php @@ -53,4 +53,11 @@ public function setRevisionTranslationAffected($affected); */ public function isRevisionTranslationAffected(); + /** + * Checks whether the entity is archived. + * + * @return bool + * True is the entity is archived, FALSE otherwise. + */ + public function isArchived(); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StatusItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StatusItem.php index 054067b..dfc3770 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StatusItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StatusItem.php @@ -14,4 +14,12 @@ */ class StatusItem extends IntegerItem { + /** + * @inheritDoc + */ + public function __get($name) { + $value = parent::__get($name); + return $value; + } + }