Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
294
Merge Requests
294
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
371e7624
Commit
371e7624
authored
Jun 16, 2014
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2216533
by jhodgdon: Fill in topic/@defgroup docs for Entity API overview.
parent
359936bc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
25 deletions
+83
-25
core/lib/Drupal/Core/Entity/ContentEntityBase.php
core/lib/Drupal/Core/Entity/ContentEntityBase.php
+2
-0
core/lib/Drupal/Core/Entity/ContentEntityInterface.php
core/lib/Drupal/Core/Entity/ContentEntityInterface.php
+2
-0
core/lib/Drupal/Core/Entity/EntityListBuilder.php
core/lib/Drupal/Core/Entity/EntityListBuilder.php
+2
-0
core/lib/Drupal/Core/Entity/EntityType.php
core/lib/Drupal/Core/Entity/EntityType.php
+2
-0
core/lib/Drupal/Core/Entity/EntityViewBuilder.php
core/lib/Drupal/Core/Entity/EntityViewBuilder.php
+2
-0
core/modules/content_translation/src/ContentTranslationHandler.php
...les/content_translation/src/ContentTranslationHandler.php
+2
-0
core/modules/system/core.api.php
core/modules/system/core.api.php
+71
-25
No files found.
core/lib/Drupal/Core/Entity/ContentEntityBase.php
View file @
371e7624
...
...
@@ -16,6 +16,8 @@
/**
* Implements Entity Field API specific enhancements to the Entity class.
*
* @ingroup entity_api
*/
abstract
class
ContentEntityBase
extends
Entity
implements
\
IteratorAggregate
,
ContentEntityInterface
{
...
...
core/lib/Drupal/Core/Entity/ContentEntityInterface.php
View file @
371e7624
...
...
@@ -25,6 +25,8 @@
*
* @see \Drupal\Core\TypedData\TypedDataManager
* @see \Drupal\Core\Field\FieldItemListInterface
*
* @ingroup entity_api
*/
interface
ContentEntityInterface
extends
EntityInterface
,
RevisionableInterface
,
TranslatableInterface
,
ComplexDataInterface
{
...
...
core/lib/Drupal/Core/Entity/EntityListBuilder.php
View file @
371e7624
...
...
@@ -13,6 +13,8 @@
/**
* Defines a generic implementation to build a listing of entities.
*
* @ingroup entity_api
*/
class
EntityListBuilder
extends
EntityControllerBase
implements
EntityListBuilderInterface
,
EntityControllerInterface
{
...
...
core/lib/Drupal/Core/Entity/EntityType.php
View file @
371e7624
...
...
@@ -14,6 +14,8 @@
/**
* Provides an implementation of an entity type and its metadata.
*
* @ingroup entity_api
*/
class
EntityType
implements
EntityTypeInterface
{
...
...
core/lib/Drupal/Core/Entity/EntityViewBuilder.php
View file @
371e7624
...
...
@@ -22,6 +22,8 @@
/**
* Base class for entity view controllers.
*
* @ingroup entity_api
*/
class
EntityViewBuilder
extends
EntityControllerBase
implements
EntityControllerInterface
,
EntityViewBuilderInterface
{
...
...
core/modules/content_translation/src/ContentTranslationHandler.php
View file @
371e7624
...
...
@@ -14,6 +14,8 @@
/**
* Base class for content translation handlers.
*
* @ingroup entity_api
*/
class
ContentTranslationHandler
implements
ContentTranslationHandlerInterface
{
...
...
core/modules/system/core.api.php
View file @
371e7624
...
...
@@ -268,53 +268,100 @@
* @{
* Describes how to define and manipulate content and configuration entities.
*
* @todo Add an overview here, describing what an entity is, bundles, entity
* types, etc. at an overview level. And link to more detailed documentation:
* https://drupal.org/developing/api/entity
*
* @section types Types of entities
* Entities can be used to store content or configuration information. See the
* Entities, in Drupal, are objects that are used for persistent storage of
* content and configuration information. See the
* @link architecture Drupal's architecture topic @endlink for an overview of
* the different types of information, and the
* @link config_api Configuration API topic @endlink for more about the
* configuration API. Defining and manipulating content and configuration
* entities is very similar, and this is described in the sections below.
* configuration API.
*
* @section define Defining an entity type
* Each entity is an instance of a particular "entity type". Some content entity
* types have sub-types, which are known as "bundles", while for other entity
* types, there is only a single bundle. For example, the Node content entity
* type, which is used for the main content pages in Drupal, has bundles that
* are known as "content types", while the User content type, which is used for
* user accounts, has only one bundle.
*
* @todo This section was written for Config entities. Add information about
* content entities to each item, and add additional items that are relevant
* to content entities, making sure to say they are not needed for config
* entities, such as view page controllers, etc.
* The sections below have more information about entities and the Entity API;
* for more detailed information, see https://drupal.org/developing/api/entity
*
* Here are the steps to follow to define a new entity type:
* @section define Defining an entity type
* Entity types are defined by modules, using Drupal's Plugin API (see the
* @link plugins Plugin API topic @endlink for more information about plugins
* in general). Here are the steps to follow to define a new entity type:
* - Choose a unique machine name, or ID, for your entity type. This normally
* starts with (or is the same as) your module's machine name. It should be
* as short as possible, and may not exceed 32 characters.
* - Define an interface for your entity's get/set methods, extending either
* \Drupal\Core\Config\Entity\ConfigEntityInterface or
[content entity
*
interface]
.
* \Drupal\Core\Config\Entity\ConfigEntityInterface or
*
\Drupal\Core\Entity\ContentEntityInterface
.
* - Define a class for your entity, implementing your interface and extending
* either \Drupal\Core\Config\Entity\ConfigEntityBase or
[content entity
*
class] , with annotation for \@ConfigEntityType or [content entity
*
annotation]
in its documentation block.
* either \Drupal\Core\Config\Entity\ConfigEntityBase or
*
\Drupal\Core\Entity\ContentEntityBase, with annotation for
*
\@ConfigEntityType or \@ContentEntityType
in its documentation block.
* - The 'id' annotation gives the entity type ID, and the 'label' annotation
* gives the human-readable name of the entity type.
* gives the human-readable name of the entity type. If you are defining a
* content entity type that uses bundles, the 'bundle_label' annotation gives
* the human-readable name to use for a bundle of this entity type (for
* example, "Content type" for the Node entity).
* - The annotation will refer to several controller classes, which you will
* also need to define:
* - list_builder: Define a class that extends
* \Drupal\Core\Config\Entity\ConfigEntityListBuilder or [content entity
list builder], to provide an administrative overview for your entities.
* \Drupal\Core\Config\Entity\ConfigEntityListBuilder (for configuration
* entities) or \Drupal\Core\Entity\EntityListBuilder (for content
* entities), to provide an administrative overview for your entities.
* - add and edit forms, or default form: Define a class (or two) that
* extend(s) \Drupal\Core\Entity\EntityForm to provide add and edit forms
* for your entities.
* - delete form: Define a class that extends
* \Drupal\Core\Entity\EntityConfirmFormBase to provide a delete
* confirmation form for your entities.
* - view_buider: For content entities, define a class that extends
* \Drupal\Core\Entity\EntityViewBuilder, to display a single entity.
* - translation: For translatable content entities (if the 'translatable'
* annotation has value TRUE), define a class that extends
* \Drupal\content_translation\ContentTranslationHandler, to translate
* the content. Configuration translation is handled automatically by the
* Configuration Translation module, without the need of a controller class.
* - access: If your configuration entity has complex permissions, you might
* need an access controller, implementing
* \Drupal\Core\Entity\EntityAccessControllerInterface, but most entities
* can just use the 'admin_permission' annotation instead.
* - For content entities, the annotation will refer to a number of database
* tables and their fields. These annotation properties, such as 'base_table',
* 'data_table', 'entity_keys', etc., are documented on
* \Drupal\Core\Entity\EntityType. Your module will also need to set up its
* database tables using hook_schema().
* - For content entities that are displayed on their own pages, the annotation
* will refer to a 'uri_callback' function, which takes an object of the
* entity interface you have defined as its parameter, and returns routing
* information for the entity page; see node_uri() for an example. You will
* also need to add a corresponding route to your module's routing.yml file;
* see the node.view route in node.routing.yml for an example, and see the
* @link menu Menu and routing @endlink topic for more information about
* routing.
* - Define routing and links for the various URLs associated with the entity.
* These go into the 'links' annotation, with the link type as the key, and
* the route machine name (defined in your module's routing.yml file) as the
* value. Typical link types are:
* - canonical: Default link, either to view (if entities are viewed on their
* own pages) or edit the entity.
* - delete-form: Confirmation form to delete the entity.
* - edit-form: Editing form.
* - admin-form: Form for editing bundle or entity type settings.
* - Other link types specific to your entity type can also be defined.
* - If your content entity has bundles, you will also need to define a second
* plugin to handle the bundles. This plugin is itself a configuration entity
* type, so follow the steps here to define it. The machine name ('id'
* annotation) of this configuration entity class goes into the
* 'bundle_entity_type' annotation on the entity type class. For example, for
* the Node entity, the bundle class is \Drupal\node\Entity\NodeType, whose
* machine name is 'node_type'. This is the annotation value for
* 'bundle_entity_type' on the \Drupal\node\Entity\Node class.
* - Additional annotations can be seen on entity class examples such as
* \Drupal\node\Entity\Node (content) and \Drupal\user\Entity\Role
* (configuration). These annotations are documented on
* \Drupal\Core\Entity\EntityType.
*
* @section load_query Loading and querying entities
* To load entities, use the entity storage manager, which is a class
...
...
@@ -323,6 +370,8 @@
* @code
* $storage = \Drupal::entityManager()->getStorage('your_entity_type');
* @endcode
* Here, 'your_entity_type' is the machine name of your entity type ('id'
* annotation on the entity class).
*
* To query to find entities to load, use an entity query, which is a class
* implementing \Drupal\Core\Entity\Query\QueryInterface that you can retrieve
...
...
@@ -330,9 +379,6 @@
* @code
* $storage = \Drupal::entityQuery('your_entity_type');
* @endcode
*
* @todo Add additional relevant classes and interfaces to this topic using
* ingroup.
* @}
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment