Created
August 21, 2020 12:15
-
-
Save sivaji/d08418cafd1ad9b3f633aca1c67d1702 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/contrib/commerce/modules/store/src/Entity/Store.php b/modules/contrib/commerce/modules/store/src/Entity/Store.php | |
index 9a570a32..ef7b8e6d 100644 | |
--- a/modules/contrib/commerce/modules/store/src/Entity/Store.php | |
+++ b/modules/contrib/commerce/modules/store/src/Entity/Store.php | |
@@ -2,6 +2,8 @@ | |
namespace Drupal\commerce_store\Entity; | |
+use Drupal\Core\Entity\EntityPublishedTrait; | |
+use Drupal\Core\Entity\EntityChangedTrait; | |
use CommerceGuys\Addressing\AddressFormat\AddressField; | |
use CommerceGuys\Addressing\AddressFormat\FieldOverride; | |
use Drupal\address\AddressInterface; | |
@@ -65,6 +67,7 @@ | |
* "langcode" = "langcode", | |
* "owner" = "uid", | |
* "uid" = "uid", | |
+ * "published" = "status", | |
* }, | |
* links = { | |
* "canonical" = "/store/{commerce_store}", | |
@@ -82,8 +85,11 @@ | |
*/ | |
class Store extends ContentEntityBase implements StoreInterface { | |
+ use EntityPublishedTrait; | |
+ use EntityChangedTrait; | |
use EntityOwnerTrait; | |
+ | |
/** | |
* {@inheritdoc} | |
*/ | |
@@ -210,6 +216,21 @@ public function setDefault($is_default) { | |
return $this; | |
} | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ public function getCreatedTime() { | |
+ return $this->get('created')->value; | |
+ } | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ public function setCreatedTime($timestamp) { | |
+ $this->set('created', $timestamp); | |
+ return $this; | |
+ } | |
+ | |
/** | |
* {@inheritdoc} | |
*/ | |
@@ -259,6 +280,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { | |
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { | |
$fields = parent::baseFieldDefinitions($entity_type); | |
$fields += static::ownerBaseFieldDefinitions($entity_type); | |
+ $fields += static::publishedBaseFieldDefinitions($entity_type); | |
$fields['type'] = BaseFieldDefinition::create('entity_reference') | |
->setLabel(t('Type')) | |
@@ -389,6 +411,33 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { | |
->setDisplayConfigurable('view', TRUE) | |
->setDisplayConfigurable('form', TRUE); | |
+ $fields['status'] | |
+ ->setLabel(t('Published')) | |
+ ->setDisplayOptions('form', [ | |
+ 'type' => 'boolean_checkbox', | |
+ 'settings' => [ | |
+ 'display_label' => TRUE, | |
+ ], | |
+ 'weight' => 90, | |
+ ]) | |
+ ->setDisplayConfigurable('form', TRUE); | |
+ | |
+ $fields['created'] = BaseFieldDefinition::create('created') | |
+ ->setLabel(t('Created')) | |
+ ->setDescription(t('The time when the product was created.')) | |
+ ->setTranslatable(TRUE) | |
+ ->setDisplayOptions('form', [ | |
+ 'type' => 'datetime_timestamp', | |
+ 'weight' => 10, | |
+ ]) | |
+ ->setDisplayConfigurable('form', TRUE) | |
+ ->setDisplayConfigurable('view', TRUE); | |
+ | |
+ $fields['changed'] = BaseFieldDefinition::create('changed') | |
+ ->setLabel(t('Changed')) | |
+ ->setDescription(t('The time when the product was last edited.')) | |
+ ->setTranslatable(TRUE); | |
+ | |
return $fields; | |
} | |
diff --git a/modules/contrib/commerce/modules/store/src/Entity/StoreInterface.php b/modules/contrib/commerce/modules/store/src/Entity/StoreInterface.php | |
index 172e6139..e09995d4 100644 | |
--- a/modules/contrib/commerce/modules/store/src/Entity/StoreInterface.php | |
+++ b/modules/contrib/commerce/modules/store/src/Entity/StoreInterface.php | |
@@ -5,12 +5,14 @@ | |
use Drupal\address\AddressInterface; | |
use Drupal\commerce_price\Entity\CurrencyInterface; | |
use Drupal\Core\Entity\ContentEntityInterface; | |
+use Drupal\Core\Entity\EntityChangedInterface; | |
+use Drupal\Core\Entity\EntityPublishedInterface; | |
use Drupal\user\EntityOwnerInterface; | |
/** | |
* Defines the interface for stores. | |
*/ | |
-interface StoreInterface extends ContentEntityInterface, EntityOwnerInterface { | |
+interface StoreInterface extends ContentEntityInterface, EntityOwnerInterface, EntityPublishedInterface, EntityChangedInterface { | |
/** | |
* Gets the store name. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment