PrivateMessageThreadDeleteTime.php in Private Message 8
File
src/Entity/PrivateMessageThreadDeleteTime.php
View source
<?php
namespace Drupal\private_message\Entity;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\user\UserInterface;
class PrivateMessageThreadDeleteTime extends ContentEntityBase implements PrivateMessageThreadDeleteTimeInterface {
public function setDeleteTime($timestamp) {
$this
->set('delete_time', $timestamp);
return $this;
}
public function getDeleteTime() {
return $this
->get('delete_time')->value;
}
public function getOwner() {
return $this
->get('owner')->entity;
}
public function getOwnerId() {
return $this
->get('owner')->target_id;
}
public function setOwnerId($uid) {
$this
->set('owner', $uid);
return $this;
}
public function setOwner(UserInterface $account) {
$this
->set('owner', $account
->id());
return $this;
}
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id']
->setLabel(t('Custom private message ID'))
->setDescription(t('The private message ID.'));
$fields['uuid']
->setDescription(t('The custom private message UUID.'));
$fields['owner'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('User Name'))
->setDescription(t('The Name of the associated user.'))
->setSetting('target_type', 'user')
->setSetting('handler', 'default');
$fields['delete_time'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Delete Time'))
->setDescription(t('The time at which the user deleted the private message thread that references this entity'));
return $fields;
}
}