EntityformSubmission.php in Entityform 8.3
Definition of Drupal\entityform\Entity\EntityformSubmission.
Namespace
Drupal\entityform\EntityFile
src/Entity/EntityformSubmission.phpView source
<?php
/**
* @file
* Definition of Drupal\entityform\Entity\EntityformSubmission.
*/
namespace Drupal\entityform\Entity;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\UserInterface;
use Drupal\entityform\EntityformTypeForm;
use Drupal\Core\Entity\ContentEntityInterface;
/**
* Defines the entityform entity class.
*
*
* @ContentEntityType(
* id = "entityform_submission",
* label = @Translation("Entityform Submission"),
* bundle_label = @Translation("Entityform type"),
* controllers = {
* "storage" = "Drupal\Core\Entity\ContentEntityDatabaseStorage",
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "access" = "Drupal\Core\Entity\EntityAccessController",
* "form" = {
* "default" = "Drupal\Core\Entity\ContentEntityForm",
* "delete" = "Drupal\Core\Entity\Form\Entity\DeleteForm",
* "edit" = "Drupal\Core\Entity\ContentEntityForm"
* },
* },
* base_table = "entityform_submission",
* data_table = "entityform_submission_field_data",
* revision_table = "entityform_submission_revision",
* revision_data_table = "entityform_submission_field_revision",
* uri_callback = "entityform_submission_uri",
* fieldable = TRUE,
* translatable = TRUE,
* entity_keys = {
* "id" = "eid",
* "revision" = "vid",
* "bundle" = "type",
* "label" = "title",
* "uuid" = "uuid",
* "langcode" = "langcode"
* },
* bundle_entity_type = "entityform_type",
* permission_granularity = "bundle",
* links = {
* "canonical" = "entityform_submission.view",
* "edit-form" = "entityform_submission.page_edit",
* "version-history" = "entityform_submission.revision_overview"
* }
* )
*/
class EntityformSubmission extends ContentEntityBase implements ContentEntityInterface {
/**
* {@inheritdoc}
*/
public function getType() {
return $this
->bundle();
}
/**
* {@inheritdoc}
*/
public function getCreatedTime() {
return $this
->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this
->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getChangedTime() {
return $this
->get('changed')->value;
}
/**
* {@inheritdoc}
*/
public function getAuthor() {
return $this
->get('uid')->entity;
}
public function getOwner() {
return $this
->get('uid')->entity;
}
/**
* {@inheritdoc}
*/
public function getOwnerId() {
return $this
->get('uid')->target_id;
}
/**
* {@inheritdoc}
*/
public function setOwnerId($uid) {
$this
->set('uid', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this
->set('uid', $account
->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function getRevisionCreationTime() {
return $this
->get('revision_timestamp')->value;
}
/**
* {@inheritdoc}
*/
public function setRevisionCreationTime($timestamp) {
$this
->set('revision_timestamp', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getRevisionAuthor() {
return $this
->get('revision_uid')->entity;
}
/**
* {@inheritdoc}
*/
public function setRevisionAuthorId($uid) {
$this
->set('revision_uid', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['eid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Entityform Submission ID'))
->setDescription(t('The entityform submission ID.'))
->setReadOnly(TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The Entityform Submission UUID.'))
->setReadOnly(TRUE);
$fields['vid'] = BaseFieldDefinition::create('integer')
->setLabel(t('Revision ID'))
->setDescription(t('The Entityform Submission revision ID.'))
->setReadOnly(TRUE);
$fields['type'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Type'))
->setSetting('target_type', 'entityform_type')
->setReadOnly(TRUE);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Author'))
->setDescription(t('The user that is the node author.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setTranslatable(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the node was created.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the node was last edited.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE);
$fields['revision_timestamp'] = BaseFieldDefinition::create('created')
->setLabel(t('Revision timestamp'))
->setDescription(t('The time that the current revision was created.'))
->setQueryable(FALSE)
->setRevisionable(TRUE);
$fields['revision_uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Revision user ID'))
->setDescription(t('The user ID of the author of the current revision.'))
->setSetting('target_type', 'user')
->setQueryable(FALSE)
->setRevisionable(TRUE);
$fields['revision_log'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Revision log message'))
->setDescription(t('The log entry explaining the changes in this revision.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The Entityform Submission language code.'))
->setTranslatable(TRUE)
->setRevisionable(TRUE)
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
return $fields;
}
}
Classes
Name | Description |
---|---|
EntityformSubmission | Defines the entityform entity class. |