Skip to content
Snippets Groups Projects
Commit 48ddeb48 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2024963 by Berdir: Move baseFieldDefinitions from storage to entity classes.

parent 52771351
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 535 additions and 430 deletions
......@@ -437,14 +437,6 @@ public function save(EntityInterface $entity) {
return $return;
}
/**
* {@inheritdoc}
*/
public function baseFieldDefinitions() {
// @todo: Define abstract once all entity types have been converted.
return array();
}
/**
* Invokes a hook on behalf of the entity.
*
......
......@@ -552,14 +552,6 @@ protected function invokeHook($hook, EntityInterface $entity) {
module_invoke_all('entity_' . $hook, $entity, $this->entityType);
}
/**
* {@inheritdoc}
*/
public function baseFieldDefinitions() {
// @todo: Define abstract once all entity types have been converted.
return array();
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServiceName().
*/
......
......@@ -634,4 +634,11 @@ public function initTranslation($langcode) {
// http://drupal.org/node/2004244
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
return array();
}
}
......@@ -619,4 +619,11 @@ public function initTranslation($langcode) {
$this->decorated->initTranslation($langcode);
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
return array();
}
}
......@@ -326,4 +326,20 @@ public function isTranslatable();
*/
public function initTranslation($langcode);
/**
* Defines the base fields of the entity type.
*
* @param string $entity_type
* The entity type to return properties for. Useful when a single class is
* used for multiple, possibly dynamic entity types.
*
* @return array
* An array of entity field definitions as specified by
* \Drupal\Core\Entity\EntityManager::getFieldDefinitions(), keyed by field
* name.
*
* @see \Drupal\Core\Entity\EntityManager::getFieldDefinitions()
*/
public static function baseFieldDefinitions($entity_type);
}
......@@ -395,8 +395,9 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) {
$this->entityFieldInfo[$entity_type] = $cache->data;
}
else {
$class = $this->factory->getPluginClass($entity_type, $this->getDefinition($entity_type));
$this->entityFieldInfo[$entity_type] = array(
'definitions' => $this->getStorageController($entity_type)->baseFieldDefinitions(),
'definitions' => $class::baseFieldDefinitions($entity_type),
// Contains definitions of optional (per-bundle) fields.
'optional' => array(),
// An array keyed by bundle name containing the optional fields added
......
......@@ -136,18 +136,6 @@ public function delete(array $entities);
*/
public function save(EntityInterface $entity);
/**
* Defines the base fields of the entity type.
*
* @return array
* An array of entity field definitions as specified by
* \Drupal\Core\Entity\EntityManager::getFieldDefinitions(), keyed by field
* name.
*
* @see \Drupal\Core\Entity\EntityManager::getFieldDefinitions()
*/
public function baseFieldDefinitions();
/**
* Gets the name of the service for the query for this entity storage.
*
......
......@@ -264,4 +264,82 @@ protected function clearBlockCacheDefinitions() {
}
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
$fields['fid'] = array(
'label' => t('ID'),
'description' => t('The ID of the aggregor feed.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$fields['title'] = array(
'label' => t('Title'),
'description' => t('The title of the feed.'),
'type' => 'string_field',
);
$fields['langcode'] = array(
'label' => t('Language code'),
'description' => t('The feed language code.'),
'type' => 'language_field',
);
$fields['url'] = array(
'label' => t('URL'),
'description' => t('The URL to the feed.'),
'type' => 'uri_field',
);
$fields['refresh'] = array(
'label' => t('Refresh'),
'description' => t('How often to check for new feed items, in seconds.'),
'type' => 'integer_field',
);
$fields['checked'] = array(
'label' => t('Checked'),
'description' => t('Last time feed was checked for new items, as Unix timestamp.'),
'type' => 'integer_field',
);
$fields['queued'] = array(
'label' => t('Queued'),
'description' => t('Time when this feed was queued for refresh, 0 if not queued.'),
'type' => 'integer_field',
);
$fields['link'] = array(
'label' => t('Link'),
'description' => t('The link of the feed.'),
'type' => 'uri_field',
);
$fields['description'] = array(
'label' => t('Description'),
'description' => t("The parent website's description that comes from the !description element in the feed.", array('!description' => '<description>')),
'type' => 'string_field',
);
$fields['image'] = array(
'label' => t('image'),
'description' => t('An image representing the feed.'),
'type' => 'uri_field',
);
$fields['hash'] = array(
'label' => t('Hash'),
'description' => t('Calculated hash of the feed data, used for validating cache.'),
'type' => 'string_field',
);
$fields['etag'] = array(
'label' => t('Etag'),
'description' => t('Entity tag HTTP response header, used for validating cache.'),
'type' => 'string_field',
);
$fields['modified'] = array(
'label' => t('Modified'),
'description' => t('When the feed was last modified, as a Unix timestamp.'),
'type' => 'integer_field',
);
$fields['block'] = array(
'label' => t('Block'),
'description' => t('Number of items to display in the feed’s block.'),
'type' => 'integer_field',
);
return $fields;
}
}
......@@ -154,4 +154,57 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
public static function preDelete(EntityStorageControllerInterface $storage_controller, array $entities) {
$storage_controller->deleteCategories($entities);
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
$fields['iid'] = array(
'label' => t('ID'),
'description' => t('The ID of the aggregor item.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$fields['fid'] = array(
'label' => t('Aggregator feed ID'),
'description' => t('The ID of the aggregator feed.'),
'type' => 'integer_field',
);
$fields['title'] = array(
'label' => t('Title'),
'description' => t('The title of the feed item.'),
'type' => 'string_field',
);
$fields['langcode'] = array(
'label' => t('Language code'),
'description' => t('The feed item language code.'),
'type' => 'language_field',
);
$fields['link'] = array(
'label' => t('Link'),
'description' => t('The link of the feed item.'),
'type' => 'uri_field',
);
$fields['author'] = array(
'label' => t('Author'),
'description' => t('The author of the feed item.'),
'type' => 'string_field',
);
$fields['description'] = array(
'label' => t('Description'),
'description' => t('The body of the feed item.'),
'type' => 'string_field',
);
$fields['timestamp'] = array(
'label' => t('Posted timestamp'),
'description' => t('Posted date of the feed item, as a Unix timestamp.'),
'type' => 'integer_field',
);
$fields['guid'] = array(
'label' => t('GUID'),
'description' => t('Unique identifier for the feed item.'),
'type' => 'string_field',
);
return $fields;
}
}
......@@ -27,84 +27,6 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) {
$this->loadCategories($queried_entities);
}
/**
* Implements Drupal\Core\Entity\DataBaseStorageControllerNG::baseFieldDefinitions().
*/
public function baseFieldDefinitions() {
$fields['fid'] = array(
'label' => t('ID'),
'description' => t('The ID of the aggregor feed.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$fields['title'] = array(
'label' => t('Title'),
'description' => t('The title of the feed.'),
'type' => 'string_field',
);
$fields['langcode'] = array(
'label' => t('Language code'),
'description' => t('The feed language code.'),
'type' => 'language_field',
);
$fields['url'] = array(
'label' => t('URL'),
'description' => t('The URL to the feed.'),
'type' => 'uri_field',
);
$fields['refresh'] = array(
'label' => t('Refresh'),
'description' => t('How often to check for new feed items, in seconds.'),
'type' => 'integer_field',
);
$fields['checked'] = array(
'label' => t('Checked'),
'description' => t('Last time feed was checked for new items, as Unix timestamp.'),
'type' => 'integer_field',
);
$fields['queued'] = array(
'label' => t('Queued'),
'description' => t('Time when this feed was queued for refresh, 0 if not queued.'),
'type' => 'integer_field',
);
$fields['link'] = array(
'label' => t('Link'),
'description' => t('The link of the feed.'),
'type' => 'uri_field',
);
$fields['description'] = array(
'label' => t('Description'),
'description' => t("The parent website's description that comes from the !description element in the feed.", array('!description' => '<description>')),
'type' => 'string_field',
);
$fields['image'] = array(
'label' => t('image'),
'description' => t('An image representing the feed.'),
'type' => 'uri_field',
);
$fields['hash'] = array(
'label' => t('Hash'),
'description' => t('Calculated hash of the feed data, used for validating cache.'),
'type' => 'string_field',
);
$fields['etag'] = array(
'label' => t('Etag'),
'description' => t('Entity tag HTTP response header, used for validating cache.'),
'type' => 'string_field',
);
$fields['modified'] = array(
'label' => t('Modified'),
'description' => t('When the feed was last modified, as a Unix timestamp.'),
'type' => 'integer_field',
);
$fields['block'] = array(
'label' => t('Block'),
'description' => t('Number of items to display in the feed’s block.'),
'type' => 'integer_field',
);
return $fields;
}
/**
* {@inheritdoc}
*/
......
......@@ -28,59 +28,6 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) {
$this->loadCategories($queried_entities);
}
/**
* Implements Drupal\Core\Entity\DataBaseStorageControllerNG::baseFieldDefinitions().
*/
public function baseFieldDefinitions() {
$fields['iid'] = array(
'label' => t('ID'),
'description' => t('The ID of the aggregor item.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$fields['fid'] = array(
'label' => t('Aggregator feed ID'),
'description' => t('The ID of the aggregator feed.'),
'type' => 'integer_field',
);
$fields['title'] = array(
'label' => t('Title'),
'description' => t('The title of the feed item.'),
'type' => 'string_field',
);
$fields['langcode'] = array(
'label' => t('Language code'),
'description' => t('The feed item language code.'),
'type' => 'language_field',
);
$fields['link'] = array(
'label' => t('Link'),
'description' => t('The link of the feed item.'),
'type' => 'uri_field',
);
$fields['author'] = array(
'label' => t('Author'),
'description' => t('The author of the feed item.'),
'type' => 'string_field',
);
$fields['description'] = array(
'label' => t('Description'),
'description' => t('The body of the feed item.'),
'type' => 'string_field',
);
$fields['timestamp'] = array(
'label' => t('Posted timestamp'),
'description' => t('Posted date of the feed item, as a Unix timestamp.'),
'type' => 'integer_field',
);
$fields['guid'] = array(
'label' => t('GUID'),
'description' => t('Unique identifier for the feed item.'),
'type' => 'string_field',
);
return $fields;
}
/**
* {@inheritdoc}
*/
......
......@@ -36,47 +36,4 @@ protected function attachLoad(&$blocks, $load_revision = FALSE) {
parent::attachLoad($blocks, $load_revision);
}
/**
* Implements \Drupal\Core\Entity\DataBaseStorageControllerNG::basePropertyDefinitions().
*/
public function baseFieldDefinitions() {
$properties['id'] = array(
'label' => t('ID'),
'description' => t('The custom block ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['uuid'] = array(
'label' => t('UUID'),
'description' => t('The custom block UUID.'),
'type' => 'uuid_field',
);
$properties['revision_id'] = array(
'label' => t('Revision ID'),
'description' => t('The revision ID.'),
'type' => 'integer_field',
);
$properties['langcode'] = array(
'label' => t('Language code'),
'description' => t('The comment language code.'),
'type' => 'language_field',
);
$properties['info'] = array(
'label' => t('Subject'),
'description' => t('The custom block name.'),
'type' => 'string_field',
);
$properties['type'] = array(
'label' => t('Block type'),
'description' => t('The block type.'),
'type' => 'string_field',
);
$properties['log'] = array(
'label' => t('Revision log message'),
'description' => t('The revision log message.'),
'type' => 'string_field',
);
return $properties;
}
}
......@@ -235,4 +235,47 @@ public function delete() {
parent::delete();
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
$properties['id'] = array(
'label' => t('ID'),
'description' => t('The custom block ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['uuid'] = array(
'label' => t('UUID'),
'description' => t('The custom block UUID.'),
'type' => 'uuid_field',
);
$properties['revision_id'] = array(
'label' => t('Revision ID'),
'description' => t('The revision ID.'),
'type' => 'integer_field',
);
$properties['langcode'] = array(
'label' => t('Language code'),
'description' => t('The comment language code.'),
'type' => 'language_field',
);
$properties['info'] = array(
'label' => t('Subject'),
'description' => t('The custom block name.'),
'type' => 'string_field',
);
$properties['type'] = array(
'label' => t('Block type'),
'description' => t('The block type.'),
'type' => 'string_field',
);
$properties['log'] = array(
'label' => t('Revision log message'),
'description' => t('The revision log message.'),
'type' => 'string_field',
);
return $properties;
}
}
......@@ -100,111 +100,6 @@ public function updateNodeStatistics($nid) {
}
}
/**
* {@inheritdoc}
*/
public function baseFieldDefinitions() {
$properties['cid'] = array(
'label' => t('ID'),
'description' => t('The comment ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['uuid'] = array(
'label' => t('UUID'),
'description' => t('The comment UUID.'),
'type' => 'uuid_field',
);
$properties['pid'] = array(
'label' => t('Parent ID'),
'description' => t('The parent comment ID if this is a reply to a comment.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'comment'),
);
$properties['nid'] = array(
'label' => t('Node ID'),
'description' => t('The ID of the node of which this comment is a reply.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'node'),
'required' => TRUE,
);
$properties['langcode'] = array(
'label' => t('Language code'),
'description' => t('The comment language code.'),
'type' => 'language_field',
);
$properties['subject'] = array(
'label' => t('Subject'),
'description' => t('The comment title or subject.'),
'type' => 'string_field',
);
$properties['uid'] = array(
'label' => t('User ID'),
'description' => t('The user ID of the comment author.'),
'type' => 'entity_reference_field',
'settings' => array(
'target_type' => 'user',
'default_value' => 0,
),
);
$properties['name'] = array(
'label' => t('Name'),
'description' => t("The comment author's name."),
'type' => 'string_field',
'settings' => array('default_value' => ''),
);
$properties['mail'] = array(
'label' => t('e-mail'),
'description' => t("The comment author's e-mail address."),
'type' => 'string_field',
);
$properties['homepage'] = array(
'label' => t('Homepage'),
'description' => t("The comment author's home page address."),
'type' => 'string_field',
);
$properties['hostname'] = array(
'label' => t('Hostname'),
'description' => t("The comment author's hostname."),
'type' => 'string_field',
);
$properties['created'] = array(
'label' => t('Created'),
'description' => t('The time that the comment was created.'),
'type' => 'integer_field',
);
$properties['changed'] = array(
'label' => t('Changed'),
'description' => t('The time that the comment was last edited.'),
'type' => 'integer_field',
);
$properties['status'] = array(
'label' => t('Publishing status'),
'description' => t('A boolean indicating whether the comment is published.'),
'type' => 'boolean_field',
);
$properties['thread'] = array(
'label' => t('Thread place'),
'description' => t("The alphadecimal representation of the comment's place in a thread, consisting of a base 36 string prefixed by an integer indicating its length."),
'type' => 'string_field',
);
$properties['node_type'] = array(
// @todo: The bundle property should be stored so it's queryable.
'label' => t('Node type'),
'description' => t("The comment node type."),
'type' => 'string_field',
'queryable' => FALSE,
);
$properties['new'] = array(
'label' => t('Comment new marker'),
'description' => t("The comment 'new' marker for the current user (0 read, 1 new, 2 updated)."),
'type' => 'integer_field',
'computed' => TRUE,
'class' => '\Drupal\comment\CommentNewItem',
);
return $properties;
}
/**
* {@inheritdoc}
*/
......
......@@ -354,4 +354,109 @@ public function permalink() {
return $url;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
$properties['cid'] = array(
'label' => t('ID'),
'description' => t('The comment ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['uuid'] = array(
'label' => t('UUID'),
'description' => t('The comment UUID.'),
'type' => 'uuid_field',
);
$properties['pid'] = array(
'label' => t('Parent ID'),
'description' => t('The parent comment ID if this is a reply to a comment.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'comment'),
);
$properties['nid'] = array(
'label' => t('Node ID'),
'description' => t('The ID of the node of which this comment is a reply.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'node'),
'required' => TRUE,
);
$properties['langcode'] = array(
'label' => t('Language code'),
'description' => t('The comment language code.'),
'type' => 'language_field',
);
$properties['subject'] = array(
'label' => t('Subject'),
'description' => t('The comment title or subject.'),
'type' => 'string_field',
);
$properties['uid'] = array(
'label' => t('User ID'),
'description' => t('The user ID of the comment author.'),
'type' => 'entity_reference_field',
'settings' => array(
'target_type' => 'user',
'default_value' => 0,
),
);
$properties['name'] = array(
'label' => t('Name'),
'description' => t("The comment author's name."),
'type' => 'string_field',
'settings' => array('default_value' => ''),
);
$properties['mail'] = array(
'label' => t('e-mail'),
'description' => t("The comment author's e-mail address."),
'type' => 'string_field',
);
$properties['homepage'] = array(
'label' => t('Homepage'),
'description' => t("The comment author's home page address."),
'type' => 'string_field',
);
$properties['hostname'] = array(
'label' => t('Hostname'),
'description' => t("The comment author's hostname."),
'type' => 'string_field',
);
$properties['created'] = array(
'label' => t('Created'),
'description' => t('The time that the comment was created.'),
'type' => 'integer_field',
);
$properties['changed'] = array(
'label' => t('Changed'),
'description' => t('The time that the comment was last edited.'),
'type' => 'integer_field',
);
$properties['status'] = array(
'label' => t('Publishing status'),
'description' => t('A boolean indicating whether the comment is published.'),
'type' => 'boolean_field',
);
$properties['thread'] = array(
'label' => t('Thread place'),
'description' => t("The alphadecimal representation of the comment's place in a thread, consisting of a base 36 string prefixed by an integer indicating its length."),
'type' => 'string_field',
);
$properties['node_type'] = array(
// @todo: The bundle property should be stored so it's queryable.
'label' => t('Node type'),
'description' => t("The comment node type."),
'type' => 'string_field',
'queryable' => FALSE,
);
$properties['new'] = array(
'label' => t('Comment new marker'),
'description' => t("The comment 'new' marker for the current user (0 read, 1 new, 2 updated)."),
'type' => 'integer_field',
'computed' => TRUE,
'class' => '\Drupal\comment\CommentNewItem',
);
return $properties;
}
}
......@@ -20,7 +20,7 @@
* label = @Translation("Contact message"),
* module = "contact",
* controllers = {
* "storage" = "Drupal\contact\MessageStorageController",
* "storage" = "Drupal\Core\Entity\DatabaseStorageControllerNG",
* "render" = "Drupal\contact\MessageRenderController",
* "form" = {
* "default" = "Drupal\contact\MessageFormController"
......@@ -138,4 +138,49 @@ public function getPersonalRecipient() {
}
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
$fields['category'] = array(
'label' => t('Category ID'),
'description' => t('The ID of the associated category.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'contact_category'),
'required' => TRUE,
);
$fields['name'] = array(
'label' => t("The sender's name"),
'description' => t('The name of the person that is sending the contact message.'),
'type' => 'string_field',
);
$fields['mail'] = array(
'label' => t("The sender's e-mail"),
'description' => t('The e-mail of the person that is sending the contact message.'),
'type' => 'email_field',
);
$fields['subject'] = array(
'label' => t('The message subject'),
'description' => t('The subject of the contact message.'),
'type' => 'string_field',
);
$fields['message'] = array(
'label' => t('The message text'),
'description' => t('The text of the contact message.'),
'type' => 'string_field',
);
$fields['copy'] = array(
'label' => t('Copy'),
'description' => t('Whether to send a copy of the message to the sender.'),
'type' => 'boolean_field',
);
$fields['recipient'] = array(
'label' => t('Recipient ID'),
'description' => t('The ID of the recipient user for personal contact messages.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'user'),
);
return $fields;
}
}
<?php
/**
* @file
* Contains \Drupal\contact\MessageStorageController.
*/
namespace Drupal\contact;
use Drupal\Core\Entity\DatabaseStorageControllerNG;
/**
* Defines the controller class for the contact message entity.
*/
class MessageStorageController extends DatabaseStorageControllerNG {
/**
* {@inheritdoc}
*/
public function baseFieldDefinitions() {
$fields['category'] = array(
'label' => t('Category ID'),
'description' => t('The ID of the associated category.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'contact_category'),
'required' => TRUE,
);
$fields['name'] = array(
'label' => t("The sender's name"),
'description' => t('The name of the person that is sending the contact message.'),
'type' => 'string_field',
);
$fields['mail'] = array(
'label' => t("The sender's e-mail"),
'description' => t('The e-mail of the person that is sending the contact message.'),
'type' => 'email_field',
);
$fields['subject'] = array(
'label' => t('The message subject'),
'description' => t('The subject of the contact message.'),
'type' => 'string_field',
);
$fields['message'] = array(
'label' => t('The message text'),
'description' => t('The text of the contact message.'),
'type' => 'string_field',
);
$fields['copy'] = array(
'label' => t('Copy'),
'description' => t('Whether to send a copy of the message to the sender.'),
'type' => 'boolean_field',
);
$fields['recipient'] = array(
'label' => t('Recipient ID'),
'description' => t('The ID of the recipient user for personal contact messages.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'user'),
);
return $fields;
}
}
......@@ -208,4 +208,64 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr
}
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
$properties['fid'] = array(
'label' => t('File ID'),
'description' => t('The file ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['uuid'] = array(
'label' => t('UUID'),
'description' => t('The file UUID.'),
'type' => 'uuid_field',
'read-only' => TRUE,
);
$properties['langcode'] = array(
'label' => t('Language code'),
'description' => t('The file language code.'),
'type' => 'language_field',
);
$properties['uid'] = array(
'label' => t('User ID'),
'description' => t('The user ID of the file.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'user'),
);
$properties['filename'] = array(
'label' => t('Filename'),
'description' => t('Name of the file with no path components.'),
'type' => 'string_field',
);
$properties['uri'] = array(
'label' => t('URI'),
'description' => t('The URI to access the file (either local or remote).'),
'type' => 'string_field',
);
$properties['filemime'] = array(
'label' => t('File MIME type'),
'description' => t("The file's MIME type."),
'type' => 'string_field',
);
$properties['filesize'] = array(
'label' => t('File size'),
'description' => t('The size of the file in bytes.'),
'type' => 'boolean_field',
);
$properties['status'] = array(
'label' => t('Status'),
'description' => t('The status of the file, temporary (0) and permanent (1)'),
'type' => 'integer_field',
);
$properties['timestamp'] = array(
'label' => t('Created'),
'description' => t('The time that the node was created.'),
'type' => 'integer_field',
);
return $properties;
}
}
......@@ -38,64 +38,4 @@ public function retrieveTemporaryFiles() {
':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
));
}
/**
* {@inheritdoc}
*/
public function baseFieldDefinitions() {
$properties['fid'] = array(
'label' => t('File ID'),
'description' => t('The file ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['uuid'] = array(
'label' => t('UUID'),
'description' => t('The file UUID.'),
'type' => 'uuid_field',
'read-only' => TRUE,
);
$properties['langcode'] = array(
'label' => t('Language code'),
'description' => t('The file language code.'),
'type' => 'language_field',
);
$properties['uid'] = array(
'label' => t('User ID'),
'description' => t('The user ID of the file.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'user'),
);
$properties['filename'] = array(
'label' => t('Filename'),
'description' => t('Name of the file with no path components.'),
'type' => 'string_field',
);
$properties['uri'] = array(
'label' => t('URI'),
'description' => t('The URI to access the file (either local or remote).'),
'type' => 'string_field',
);
$properties['filemime'] = array(
'label' => t('File MIME type'),
'description' => t("The file's MIME type."),
'type' => 'string_field',
);
$properties['filesize'] = array(
'label' => t('File size'),
'description' => t('The size of the file in bytes.'),
'type' => 'boolean_field',
);
$properties['status'] = array(
'label' => t('Status'),
'description' => t('The status of the file, temporary (0) and permanent (1)'),
'type' => 'integer_field',
);
$properties['timestamp'] = array(
'label' => t('Created'),
'description' => t('The time that the node was created.'),
'type' => 'integer_field',
);
return $properties;
}
}
......@@ -271,4 +271,122 @@ public function setRevisionAuthorId($uid) {
return $this;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions($entity_type) {
$properties['nid'] = array(
'label' => t('Node ID'),
'description' => t('The node ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['uuid'] = array(
'label' => t('UUID'),
'description' => t('The node UUID.'),
'type' => 'uuid_field',
'read-only' => TRUE,
);
$properties['vid'] = array(
'label' => t('Revision ID'),
'description' => t('The node revision ID.'),
'type' => 'integer_field',
'read-only' => TRUE,
);
$properties['type'] = array(
'label' => t('Type'),
'description' => t('The node type.'),
'type' => 'string_field',
'read-only' => TRUE,
);
$properties['langcode'] = array(
'label' => t('Language code'),
'description' => t('The node language code.'),
'type' => 'language_field',
);
$properties['title'] = array(
'label' => t('Title'),
'description' => t('The title of this node, always treated as non-markup plain text.'),
'type' => 'string_field',
'required' => TRUE,
'settings' => array(
'default_value' => '',
),
'property_constraints' => array(
'value' => array('Length' => array('max' => 255)),
),
);
$properties['uid'] = array(
'label' => t('User ID'),
'description' => t('The user ID of the node author.'),
'type' => 'entity_reference_field',
'settings' => array(
'target_type' => 'user',
'default_value' => 0,
),
);
$properties['status'] = array(
'label' => t('Publishing status'),
'description' => t('A boolean indicating whether the node is published.'),
'type' => 'boolean_field',
);
$properties['created'] = array(
'label' => t('Created'),
'description' => t('The time that the node was created.'),
'type' => 'integer_field',
);
$properties['changed'] = array(
'label' => t('Changed'),
'description' => t('The time that the node was last edited.'),
'type' => 'integer_field',
'property_constraints' => array(
'value' => array('NodeChanged' => array()),
),
);
$properties['comment'] = array(
'label' => t('Comment'),
'description' => t('Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).'),
'type' => 'integer_field',
);
$properties['promote'] = array(
'label' => t('Promote'),
'description' => t('A boolean indicating whether the node should be displayed on the front page.'),
'type' => 'boolean_field',
);
$properties['sticky'] = array(
'label' => t('Sticky'),
'description' => t('A boolean indicating whether the node should be displayed at the top of lists in which it appears.'),
'type' => 'boolean_field',
);
$properties['tnid'] = array(
'label' => t('Translation set ID'),
'description' => t('The translation set id for this node, which equals the node id of the source post in each set.'),
'type' => 'integer_field',
);
$properties['translate'] = array(
'label' => t('Translate'),
'description' => t('A boolean indicating whether this translation page needs to be updated.'),
'type' => 'boolean_field',
);
$properties['revision_timestamp'] = array(
'label' => t('Revision timestamp'),
'description' => t('The time that the current revision was created.'),
'type' => 'integer_field',
'queryable' => FALSE,
);
$properties['revision_uid'] = array(
'label' => t('Revision user ID'),
'description' => t('The user ID of the author of the current revision.'),
'type' => 'entity_reference_field',
'settings' => array('target_type' => 'user'),
'queryable' => FALSE,
);
$properties['log'] = array(
'label' => t('Log'),
'description' => t('The log entry explaining the changes in this version.'),
'type' => 'string_field',
);
return $properties;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment