Drupal 8  8.0.2
EntityType Class Reference
Inheritance diagram for EntityType:

Public Member Functions

 __construct ($definition)
 
 get ($property)
 
 set ($property, $value)
 
 isStaticallyCacheable ()
 
 isRenderCacheable ()
 
 isPersistentlyCacheable ()
 
 getKeys ()
 
 getKey ($key)
 
 hasKey ($key)
 
 id ()
 
 getProvider ()
 
 getClass ()
 
 getOriginalClass ()
 
 setClass ($class)
 
 isSubclassOf ($class)
 
 getHandlerClasses ()
 
 getHandlerClass ($handler_type, $nested=FALSE)
 
 setHandlerClass ($handler_type, $value)
 
 hasHandlerClass ($handler_type, $nested=FALSE)
 
 getStorageClass ()
 
 setStorageClass ($class)
 
 getFormClass ($operation)
 
 setFormClass ($operation, $class)
 
 hasFormClasses ()
 
 hasRouteProviders ()
 
 getListBuilderClass ()
 
 setListBuilderClass ($class)
 
 hasListBuilderClass ()
 
 getViewBuilderClass ()
 
 setViewBuilderClass ($class)
 
 hasViewBuilderClass ()
 
 getRouteProviderClasses ()
 
 getAccessControlClass ()
 
 setAccessClass ($class)
 
 getAdminPermission ()
 
 getPermissionGranularity ()
 
 getLinkTemplates ()
 
 getLinkTemplate ($key)
 
 hasLinkTemplate ($key)
 
 setLinkTemplate ($key, $path)
 
 getLabelCallback ()
 
 setLabelCallback ($callback)
 
 hasLabelCallback ()
 
 getBundleEntityType ()
 
 getBundleOf ()
 
 getBundleLabel ()
 
 getBaseTable ()
 
 isTranslatable ()
 
 isRevisionable ()
 
 getRevisionDataTable ()
 
 getRevisionTable ()
 
 getDataTable ()
 
 getLabel ()
 
 getLowercaseLabel ()
 
 getUriCallback ()
 
 setUriCallback ($callback)
 
 getGroup ()
 
 getGroupLabel ()
 
 getListCacheContexts ()
 
 getListCacheTags ()
 
 getConfigDependencyKey ()
 
 isCommonReferenceTarget ()
 
 getConstraints ()
 
 setConstraints (array $constraints)
 
 addConstraint ($constraint_name, $options=NULL)
 
 getBundleConfigDependency ($bundle)
 
- Public Member Functions inherited from EntityTypeInterface
 getHandlerClass ($handler_type)
 

Protected Member Functions

 checkStorageClass ($class)
 

Protected Attributes

 $static_cache = TRUE
 
 $render_cache = TRUE
 
 $persistent_cache = TRUE
 
 $entity_keys = array()
 
 $id
 
 $provider
 
 $class
 
 $originalClass
 
 $handlers = array()
 
 $admin_permission
 
 $permission_granularity = 'entity_type'
 
 $links = array()
 
 $label_callback = NULL
 
 $bundle_entity_type = NULL
 
 $bundle_of = NULL
 
 $bundle_label = NULL
 
 $base_table = NULL
 
 $revision_data_table = NULL
 
 $revision_table = NULL
 
 $data_table = NULL
 
 $translatable = FALSE
 
 $label = ''
 
 $uri_callback = NULL
 
 $group
 
 $group_label
 
 $field_ui_base_route
 
 $common_reference_target = FALSE
 
 $list_cache_contexts = []
 
 $list_cache_tags = []
 
 $constraints = array()
 
 $additional = []
 

Additional Inherited Members

- Data Fields inherited from EntityTypeInterface
const ID_MAX_LENGTH = 32
 
const BUNDLE_MAX_LENGTH = 32
 

Detailed Description

Provides an implementation of an entity type and its metadata.

Constructor & Destructor Documentation

__construct (   $definition)

Constructs a new EntityType.

Parameters
array$definitionAn array of values from the annotation.
Exceptions
\Drupal\Core\Entity\Exception\EntityTypeIdLengthExceptionThrown when attempting to instantiate an entity type with too long ID.

References EntityType\addConstraint(), EntityType\checkStorageClass(), EntityType\isSubclassOf(), EntityType\set(), and Unicode\strlen().

Here is the call graph for this function:

Member Function Documentation

addConstraint (   $constraint_name,
  $options = NULL 
)

{Adds a validation constraint.See ::getConstraints() for details on how constraints are defined.

Parameters
string$constraint_nameThe name of the constraint to add, i.e. its plugin id.
array | null$optionsThe constraint options as required by the constraint plugin, or NULL.
Returns
$this
}

Implements EntityTypeInterface.

Referenced by EntityType\__construct().

Here is the caller graph for this function:

checkStorageClass (   $class)
protected

Checks that the provided class is compatible with the current entity type.

Parameters
string$classThe class to check.

Referenced by EntityType\__construct(), and EntityType\setStorageClass().

Here is the caller graph for this function:

get (   $property)

{Gets any arbitrary property.

Parameters
string$propertyThe property to retrieve.
Returns
mixed The value for that property, or NULL if the property does not exist.
}

Implements EntityTypeInterface.

getAccessControlClass ( )

{Gets the access control class.

Returns
string The class for this entity type's access control.
}

Implements EntityTypeInterface.

References EntityType\getHandlerClass().

Here is the call graph for this function:

getAdminPermission ( )

{Gets the name of the default administrative permission.The default class checks this permission for all operations in its checkAccess() method. Entities with more complex permissions can extend this class to do their own access checks.

Returns
string|bool
}

Implements EntityTypeInterface.

getBaseTable ( )

{Gets the name of the entity's base table.

Todo:
Used by SqlContentEntityStorage only.
Returns
string|null The name of the entity's base table, or NULL if none exists.
}

Implements EntityTypeInterface.

getBundleConfigDependency (   $bundle)

{Gets the config dependency info for this entity, if any exists.

Parameters
string$bundleThe bundle name.
Returns
array An associative array containing the following keys:
  • 'type': The config dependency type (e.g. 'module', 'config').
  • 'name': The name of the config dependency.
}

Implements EntityTypeInterface.

References Drupal\entityManager(), EntityType\getBundleEntityType(), and EntityType\getProvider().

Here is the call graph for this function:

getBundleEntityType ( )

{Gets the name of the entity type which provides bundles.

Returns
string
}

Implements EntityTypeInterface.

Referenced by EntityType\getBundleConfigDependency().

Here is the caller graph for this function:

getBundleLabel ( )

{Gets the label for the bundle.

Returns
string|null The bundle label, or NULL if none exists.
}

Implements EntityTypeInterface.

getBundleOf ( )

{Gets the entity type for which this entity provides bundles.It can be used by other modules to act accordingly; for example, the Field UI module uses it to add operation links to manage fields and displays.

Returns
string|null The entity type for which this entity provides bundles, or NULL if does not provide bundles for another entity type.
}

Implements EntityTypeInterface.

getClass ( )

{Gets the class.

Returns
string A fully qualified class name.
}

Implements PluginDefinitionInterface.

Referenced by EntityType\isSubclassOf().

Here is the caller graph for this function:

getConfigDependencyKey ( )

{Gets the key that is used to store configuration dependencies.

Returns
string The key to be used in configuration dependencies when storing dependencies on entities of this type.
}

Implements EntityTypeInterface.

getConstraints ( )

{Gets an array of validation constraints.See ::getConstraints() for details on how constraints are defined.

Returns
array[] An array of validation constraint definitions, keyed by constraint name. Each constraint definition can be used for instantiating objects.
See Also
}

Implements EntityTypeInterface.

getDataTable ( )

{Gets the name of the entity's data table.

Todo:
Used by SqlContentEntityStorage only.
Returns
string|null The name of the entity type's data table, or NULL if none exists.
}

Implements EntityTypeInterface.

getFormClass (   $operation)

{Gets the form class for a specific operation.

Parameters
string$operationThe name of the operation to use, e.g., 'default'.
Returns
string The class for this operation's form for this entity type.
See Also
}

Implements EntityTypeInterface.

References EntityType\getHandlerClass().

Here is the call graph for this function:

getGroup ( )

{Gets the machine name of the entity type group.

Returns
string
}

Implements EntityTypeInterface.

References EntityType\$group.

getGroupLabel ( )

{Gets the human-readable name of the entity type group.

Returns
string
}

Implements EntityTypeInterface.

References t().

Here is the call graph for this function:

getHandlerClass (   $handler_type,
  $nested = FALSE 
)

{}

References EntityType\getHandlerClasses(), and EntityType\hasHandlerClass().

Referenced by EntityType\getAccessControlClass(), EntityType\getFormClass(), EntityType\getListBuilderClass(), EntityType\getStorageClass(), and EntityType\getViewBuilderClass().

Here is the call graph for this function:

Here is the caller graph for this function:

getHandlerClasses ( )

{Gets an array of handlers.

Returns
array An associative array where the keys are the names of different handler types (listed below) and the values are the names of the classes that implement that handler:
  • storage: The name of the class used to load the objects. The class must implement .
  • form: An associative array where the keys are the names of the different form operations (such as 'create', 'edit', or 'delete') and the values are the names of the handler classes for those operations. The name of the operation is passed also to the form handler's constructor, so that one class can be used for multiple entity forms when the forms are similar. The classes must implement .
  • list: The name of the class that provides listings of the entities. The class must implement .
  • render: The name of the class that is used to render the entities. The class must implement .
  • access: The name of the class that is used for access checks. The class must implement . Defaults to .
  • route_provider: (optional) A list of class names, keyed by a group string, which will be used to define routes related to this entity type. These classes must implement .
}

Implements EntityTypeInterface.

Referenced by EntityType\getHandlerClass(), and EntityType\hasHandlerClass().

Here is the caller graph for this function:

getKey (   $key)

{Gets a specific entity key.

Parameters
string$keyThe name of the entity key to return.
Returns
string|bool The entity key, or FALSE if it does not exist.
See Also
self::getKeys()
}

Implements EntityTypeInterface.

References EntityType\getKeys().

Here is the call graph for this function:

getKeys ( )

{Gets an array of entity keys.

Returns
array An array describing how the Field API can extract certain information from objects of this entity type:
  • id: The name of the property that contains the primary ID of the entity. Every entity object passed to the Field API must have this property and its value must be numeric.
  • revision: (optional) The name of the property that contains the revision ID of the entity. The Field API assumes that all revision IDs are unique across all entities of a type. If this entry is omitted the entities of this type are not revisionable.
  • bundle: (optional) The name of the property that contains the bundle name for the entity. The bundle name defines which set of fields are attached to the entity (e.g. what nodes call "content type"). This entry can be omitted if this entity type exposes a single bundle (such that all entities have the same collection of fields). The name of this single bundle will be the same as the entity type.
  • label: (optional) The name of the property that contains the entity label. For example, if the entity's label is located in $entity->subject, then 'subject' should be specified here. If complex logic is required to build the label, ::label() should be used.
  • langcode: (optional) The name of the property that contains the language code. For instance, if the entity's language is located in $entity->langcode, then 'langcode' should be specified here.
  • uuid: (optional) The name of the property that contains the universally unique identifier of the entity, which is used to distinctly identify an entity across different systems.
}

Implements EntityTypeInterface.

Referenced by EntityType\getKey(), and EntityType\hasKey().

Here is the caller graph for this function:

getLabel ( )

{Gets the human-readable name of the entity type.

Returns
string The human-readable name of the entity type.
}

Implements EntityTypeInterface.

Referenced by EntityType\getLowercaseLabel().

Here is the caller graph for this function:

getLabelCallback ( )

{Gets the callback for the label of the entity.The function takes an entity and returns the label of the entity. Use language() on the entity to get information on the requested language. The entity label is the main string associated with an entity; for example, the title of a node or the subject of a comment. If there is an entity object property that defines the label, use the 'label' element of the 'entity_keys' return value component to provide this information. If more complex logic is needed to determine the label of an entity, you can instead specify a callback function here, which will be called to determine the entity label.

Returns
callable|null The callback, or NULL if none exists.
Deprecated:
in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0. Use Drupal::label() for complex label generation as needed.
See Also
::label()
::setLabelCallback()
::hasLabelCallback()
Todo:
Remove usages of label_callback https://www.drupal.org/node/2450793.
}

Implements EntityTypeInterface.

getLinkTemplate (   $key)

{Gets the link template for a given key.

Parameters
string$keyThe link type.
Returns
string|bool The path for this link, or FALSE if it doesn't exist.
}

Implements EntityTypeInterface.

References EntityType\getLinkTemplates().

Here is the call graph for this function:

getLinkTemplates ( )

{Gets the link templates using the URI template syntax.Links are an array of standard link relations to the URI template that should be used for them. Where possible, link relationships should use established IANA relationships rather than custom relationships.Every entity type should, at minimum, define "canonical", which is the pattern for URIs to that entity. Even if the entity will have no HTML page exposed to users it should still have a canonical URI in order to be compatible with web services. Entities that will be user-editable via an HTML page must also define an "edit-form" relationship.By default, the following placeholders are supported:

  • [entityType]: The entity type itself will also be a valid token for the ID of the entity. For instance, a placeholder of {node} used on the Node class.
  • [bundleEntityType]: The bundle machine name itself. For instance, a placeholder of {node_type} used on the Node class.
Specific entity types may also expand upon this list by overriding the Entity::urlRouteParameters() method.http://www.iana.org/assignments/link-relations/link-relations.xml http://tools.ietf.org/html/rfc6570
Returns
array
}

Implements EntityTypeInterface.

Referenced by EntityType\getLinkTemplate(), and EntityType\hasLinkTemplate().

Here is the caller graph for this function:

getListBuilderClass ( )

{Gets the list class.

Returns
string The class for this entity type's list.
}

Implements EntityTypeInterface.

References EntityType\getHandlerClass().

Here is the call graph for this function:

getListCacheContexts ( )

{The list cache contexts associated with this entity type.Enables code listing entities of this type to ensure that rendered listings are varied as necessary, typically to ensure users of role A see other entities listed than users of role B.

Returns
string[]
}

Implements EntityTypeInterface.

getListCacheTags ( )

{The list cache tags associated with this entity type.Enables code listing entities of this type to ensure that newly created entities show up immediately.

Returns
string[]
}

Implements EntityTypeInterface.

getLowercaseLabel ( )

{Gets the lowercase form of the human-readable entity type name.

Returns
string The lowercase form of the human-readable entity type name.
}

Implements EntityTypeInterface.

References EntityType\getLabel(), and Unicode\strtolower().

Here is the call graph for this function:

getOriginalClass ( )

{Gets the name of the original entity type class.In case the class name was changed with setClass(), this will return the initial value. Useful when trying to identify the entity type ID based on the class.

Returns
string The name of the original entity type class.
}

Implements EntityTypeInterface.

getPermissionGranularity ( )

{Gets the permission granularity level.The allowed values are respectively "entity_type" or "bundle".

Returns
string Whether a module exposing permissions for the current entity type should use entity-type level granularity or bundle level granularity.
}

Implements EntityTypeInterface.

getProvider ( )

{Gets the name of the provider of this entity type.

Returns
string The name of the provider of this entity type.
}

Implements EntityTypeInterface.

Referenced by EntityType\getBundleConfigDependency().

Here is the caller graph for this function:

getRevisionDataTable ( )

{Gets the name of the entity's revision data table.

Todo:
Used by SqlContentEntityStorage only.
Returns
string|null The name of the entity type's revision data table, or NULL if none exists.
}

Implements EntityTypeInterface.

getRevisionTable ( )

{Gets the name of the entity's revision table.

Todo:
Used by SqlContentEntityStorage only.
Returns
string|null The name of the entity type's revision table, or NULL if none exists.
}

Implements EntityTypeInterface.

getRouteProviderClasses ( )

{Gets all the route provide handlers.Much like forms you can define multiple route provider handlers.

Returns
string[]
}

Implements EntityTypeInterface.

getStorageClass ( )

{Gets the storage class.

Returns
string The class for this entity type's storage.
}

Implements EntityTypeInterface.

References EntityType\getHandlerClass().

Here is the call graph for this function:

getUriCallback ( )

{Gets a callable that can be used to provide the entity URI.This is only called if there is no matching link template for the link relationship type, and there is no bundle-specific callback provided.

Returns
callable|null A valid callback that is passed the entity or NULL if none is specified.
}

Implements EntityTypeInterface.

getViewBuilderClass ( )

{Gets the view builder class.

Returns
string The class for this entity type's view builder.
}

Implements EntityTypeInterface.

References EntityType\getHandlerClass().

Here is the call graph for this function:

hasFormClasses ( )

{Indicates if this entity type has any forms.

Returns
bool TRUE if there are any forms for this entity type, FALSE otherwise.
}

Implements EntityTypeInterface.

hasHandlerClass (   $handler_type,
  $nested = FALSE 
)

{Determines if there is a handler for a given type.

Parameters
string$handler_typeThe type of handler to check.
bool$nested(optional) If this handler has a nested definition. Defaults to FALSE.
Returns
bool TRUE if a handler of this type exists, FALSE otherwise.
}

Implements EntityTypeInterface.

References EntityType\getHandlerClasses().

Referenced by EntityType\getHandlerClass(), EntityType\hasListBuilderClass(), and EntityType\hasViewBuilderClass().

Here is the call graph for this function:

Here is the caller graph for this function:

hasKey (   $key)

{Indicates if a given entity key exists.

Parameters
string$keyThe name of the entity key to check.
Returns
bool TRUE if a given entity key exists, FALSE otherwise.
}

Implements EntityTypeInterface.

References EntityType\getKeys().

Referenced by EntityType\isRevisionable().

Here is the call graph for this function:

Here is the caller graph for this function:

hasLabelCallback ( )

{Indicates if a label callback exists.

Returns
bool
Deprecated:
in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0. Use EntityInterface::label() for complex label generation as needed.
See Also
::label()
::getLabelCallback()
::setLabelCallback()
}

Implements EntityTypeInterface.

hasLinkTemplate (   $key)

{Indicates if a link template exists for a given key.

Parameters
string$keyThe link type.
Returns
bool TRUE if the link template exists, FALSE otherwise.
}

Implements EntityTypeInterface.

References EntityType\getLinkTemplates().

Here is the call graph for this function:

hasListBuilderClass ( )

{Indicates if this entity type has a list class.

Returns
bool TRUE if there is a list for this entity type, FALSE otherwise.
}

Implements EntityTypeInterface.

References EntityType\hasHandlerClass().

Here is the call graph for this function:

hasRouteProviders ( )

{Indicates if this entity type has any route provider.

Returns
bool
}

Implements EntityTypeInterface.

hasViewBuilderClass ( )

{Indicates if this entity type has a view builder.

Returns
bool TRUE if there is a view builder for this entity type, FALSE otherwise.
}

Implements EntityTypeInterface.

References EntityType\hasHandlerClass().

Here is the call graph for this function:

id ( )

{Gets the unique identifier of the entity type.

Returns
string The unique identifier of the entity type.
}

Implements EntityTypeInterface.

Referenced by ConfigEntityType\getConfigPrefix().

Here is the caller graph for this function:

isCommonReferenceTarget ( )

{Indicates whether this entity type is commonly used as a reference target.

Returns
bool TRUE if the entity type is a common reference; FALSE otherwise.
}

Implements EntityTypeInterface.

isPersistentlyCacheable ( )

{Indicates if the persistent cache of field data should be used.

Todo:
Used by ContentEntityStorageBase only.
The persistent cache should usually only be disabled if a higher level persistent cache is available for the entity type.
Returns
bool
}

Implements EntityTypeInterface.

isRenderCacheable ( )

{Indicates whether the rendered output of entities should be cached.

Returns
bool
}

Implements EntityTypeInterface.

isRevisionable ( )

{Indicates whether entities of this type have revision support.

Returns
bool
}

Implements EntityTypeInterface.

References EntityType\hasKey().

Here is the call graph for this function:

isStaticallyCacheable ( )

{Indicates whether entities should be statically cached.

Returns
bool TRUE if static caching should be used; FALSE otherwise.
}

Implements EntityTypeInterface.

isSubclassOf (   $class)

{Indicates if the entity type is a subclass of the given class or interface.

Parameters
string$classThe class or interface to check.
Returns
bool TRUE if the entity type is a subclass of the class or interface.
}

Implements EntityTypeInterface.

References EntityType\getClass().

Referenced by EntityType\__construct().

Here is the call graph for this function:

Here is the caller graph for this function:

isTranslatable ( )

{Indicates whether entities of this type have multilingual support.At an entity level, this indicates language support and at a bundle level this indicates translation support.

Returns
bool
}

Implements EntityTypeInterface.

set (   $property,
  $value 
)

{Sets a value to an arbitrary property.

Parameters
string$propertyThe property to use for the value.
mixed$valueThe value to set.
Returns
$this
}

Implements EntityTypeInterface.

Referenced by EntityType\__construct().

Here is the caller graph for this function:

setAccessClass (   $class)

{Gets the access class.

Parameters
string$classThe class for this entity type's access.
Returns
$this
}

Implements EntityTypeInterface.

setClass (   $class)

{Sets the class.

Parameters
string$classA fully qualified class name.
Returns
static
Exceptions
\InvalidArgumentExceptionIf the class is invalid.
}

Implements PluginDefinitionInterface.

setConstraints ( array  $constraints)

{Sets the array of validation constraints for the FieldItemList.NOTE: This will overwrite any previously set constraints. In most cases ContentEntityTypeInterface::addConstraint() should be used instead. See ::getConstraints() for details on how constraints are defined.

Parameters
array$constraintsAn array of validation constraint definitions, keyed by constraint name. Each constraint definition can be used for instantiating objects.
Returns
$this
See Also
}

Implements EntityTypeInterface.

setFormClass (   $operation,
  $class 
)

{Sets a form class for a specific operation.

Parameters
string$operationThe operation to use this form class for.
string$classThe form class implementing .
Returns
$this
See Also
}

Implements EntityTypeInterface.

setHandlerClass (   $handler_type,
  $value 
)

{Sets the handlers for a given type.

Parameters
string$handler_typeThe type of handler to set.
array | string$valueThe value for a handler type.
Returns
$this
}

Implements EntityTypeInterface.

setLabelCallback (   $callback)

{Sets the label callback.

Parameters
callable$callbackA callable that returns the label of the entity.
Returns
$this
Deprecated:
in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0. Use EntityInterface::label() for complex label generation as needed.
See Also
::label()
::getLabelCallback()
::hasLabelCallback()
}

Implements EntityTypeInterface.

setLinkTemplate (   $key,
  $path 
)

{Sets a single link template.

Parameters
string$keyThe name of a link.
string$pathThe route path to use for the link.
Returns
$this
Exceptions
\InvalidArgumentExceptionThrown when the path does not start with a leading slash.
}

Implements EntityTypeInterface.

setListBuilderClass (   $class)

{Sets the list class.

Parameters
string$classThe list class to use for the operation.
Returns
$this
}

Implements EntityTypeInterface.

setStorageClass (   $class)

{Sets the storage class.

Parameters
string$classThe class for this entity type's storage.
Returns
$this
}

Implements EntityTypeInterface.

References EntityType\checkStorageClass().

Here is the call graph for this function:

setUriCallback (   $callback)

{Sets a callable to use to provide the entity URI.

Parameters
callable$callbackA callback to use to provide a URI for the entity.
Returns
$this
}

Implements EntityTypeInterface.

setViewBuilderClass (   $class)

{Gets the view builder class.

Parameters
string$classThe class for this entity type's view builder.
Returns
$this
}

Implements EntityTypeInterface.

Field Documentation

$group
protected

The machine name of the entity type group.

Referenced by EntityType\getGroup().

$group_label
protected

The human-readable name of the entity type group.


The documentation for this class was generated from the following file: