ContentModerationStateInterface
interface ContentModerationStateInterface implements ContentEntityInterface, EntityOwnerInterface (View source)
| internal |
An interface for Content moderation state entity.
Content moderation state entities track the moderation state of other content entities.
Methods
Checks data value access.
The cache contexts associated with this object.
The cache tags associated with this object.
The maximum age for which this object may be cached.
Adds cache contexts.
Merges the maximum age (in seconds) with the existing maximum age.
Adds a dependency on an object: merges its cacheability metadata.
Gets the URL object for the entity.
Generates the HTML for a link to this entity.
Indicates if a link template exists for a given key.
Gets a list of URI relationships supported by this entity.
Loads one or more entities.
Constructs a new entity object, without permanently saving it.
Acts on a saved entity before the insert or update hook is invoked.
Changes the values of an entity before it is created.
Acts on entities before they are deleted and before hooks are invoked.
Acts on deleted entities before the delete hook is invoked.
Gets a list of entities referenced by this entity.
Returns the cache tags that should be used to invalidate caches.
Gets a typed data object for this entity object.
Gets the key that is used to store configuration dependencies.
Gets the configuration target identifier for the entity.
Provides base field definitions for an entity type.
Provides field definitions for a specific bundle.
Determines whether the entity has a field with the given name.
Gets the definition of a contained field.
Gets an array of field definitions of all contained fields.
Gets a field item list.
Sets a field value.
Gets an array of all field item lists.
Gets an array of field item lists for translatable fields.
Validates the currently set values.
Checks whether entity validation is required before saving the entity.
Sets whether entity validation is required before saving the entity.
Checks whether the translation is the default one.
Returns the languages the data is translated to.
Returns the translatable object referring to the original language.
Checks there is a translation for the given language code.
Adds a new translation to the translatable object.
Removes the translation identified by the given language code.
Determines if the current translation of the entity has unsaved changes.
Determines whether a new revision should be created on save.
Enforces an entity to be saved as a new revision.
Updates the loaded Revision ID with the revision ID.
Checks if this entity is the default revision.
Checks whether the entity object was a default revision when it was saved.
Acts on a revision before it gets saved.
Checks whether this is the latest revision affecting this translation.
Marks the current revision translation as affected.
Checks whether the current translation is affected by the current revision.
Checks if the revision translation affected flag value has been enforced.
Enforces the revision translation affected flag value.
Checks if untranslatable fields should affect only the default translation.
Sets the status of the synchronization flag.
Returns whether this entity is being changed as part of a synchronization.
Details
bool|AccessResultInterface
access(string $operation, AccountInterface $account = NULL, bool $return_as_object = FALSE)
Checks data value access.
string[]
getCacheContexts()
The cache contexts associated with this object.
These identify a specific variation/representation of the object.
Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.
string[]
getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
int
getCacheMaxAge()
The maximum age for which this object may be cached.
$this
addCacheContexts(array $cache_contexts)
Adds cache contexts.
$this
addCacheTags(array $cache_tags)
Adds cache tags.
$this
mergeCacheMaxAge(int $max_age)
Merges the maximum age (in seconds) with the existing maximum age.
The max age will be set to the given value if it is lower than the existing value.
$this
addCacheableDependency(CacheableDependencyInterface|object $other_object)
Adds a dependency on an object: merges its cacheability metadata.
string|null
uuid()
Gets the entity UUID (Universally Unique Identifier).
The UUID is guaranteed to be unique and can be used to identify an entity across multiple systems.
string|int|null
id()
Gets the identifier.
LanguageInterface
language()
Gets the language of the entity.
bool
isNew()
Determines whether the entity is new.
Usually an entity is new if no ID exists for it yet. However, entities may be enforced to be new with existing IDs too.
$this
enforceIsNew(bool $value = TRUE)
Enforces an entity to be new.
Allows migrations to create entities with pre-defined IDs by forcing the entity to be new before saving.
string
getEntityTypeId()
Gets the ID of the type of the entity.
string
bundle()
Gets the bundle of the entity.
string|TranslatableMarkup|null
label()
Gets the label of the entity.
Url
toUrl(string $rel = 'canonical', array $options = [])
Gets the URL object for the entity.
The entity must have an id already. Content entities usually get their IDs by saving them.
URI templates might be set in the links array in an annotation, for example:
Link
toLink(string|null $text = NULL, string $rel = 'canonical', array $options = [])
Generates the HTML for a link to this entity.
bool
hasLinkTemplate(string $key)
Indicates if a link template exists for a given key.
string[]
uriRelationships()
Gets a list of URI relationships supported by this entity.
static EntityInterface|null
load(mixed $id)
Loads an entity.
static EntityInterface[]
loadMultiple(array $ids = NULL)
Loads one or more entities.
static EntityInterface
create(array $values = [])
Constructs a new entity object, without permanently saving it.
int
save()
Saves an entity permanently.
When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.
delete()
Deletes an entity permanently.
preSave(EntityStorageInterface $storage)
Acts on an entity before the presave hook is invoked.
Used before the entity is saved and before invoking the presave hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed. This is different from its counterpart in the Field API, FieldItemListInterface::preSave(), which is fired on all field translations automatically.
postSave(EntityStorageInterface $storage, bool $update = TRUE)
Acts on a saved entity before the insert or update hook is invoked.
Used after the entity is saved, but before invoking the insert or update hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed.
static
preCreate(EntityStorageInterface $storage, array $values)
Changes the values of an entity before it is created.
Load defaults for example.
postCreate(EntityStorageInterface $storage)
Acts on a created entity before hooks are invoked.
Used after the entity is created, but before saving the entity and before any of the presave hooks are invoked.
See the @link entity_crud Entity CRUD topic @endlink for more information.
static
preDelete(EntityStorageInterface $storage, array $entities)
Acts on entities before they are deleted and before hooks are invoked.
Used before the entities are deleted and before invoking the delete hook.
static
postDelete(EntityStorageInterface $storage, array $entities)
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but before invoking the delete hook.
static
postLoad(EntityStorageInterface $storage, array $entities)
Acts on loaded entities.
EntityInterface
createDuplicate()
Creates a duplicate of the entity.
EntityTypeInterface
getEntityType()
Gets the entity type definition.
EntityInterface[]
referencedEntities()
Gets a list of entities referenced by this entity.
int|string|null
getOriginalId()
Gets the original ID.
string[]
getCacheTagsToInvalidate()
Returns the cache tags that should be used to invalidate caches.
This will not return additional cache tags added through addCacheTags().
$this
setOriginalId(int|string|null $id)
Sets the original ID.
array
toArray()
Gets an array of all property values.
ComplexDataInterface
getTypedData()
Gets a typed data object for this entity object.
The returned typed data object wraps this entity and allows dealing with entities based on the generic typed data API.
string
getConfigDependencyKey()
Gets the key that is used to store configuration dependencies.
string
getConfigDependencyName()
Gets the configuration dependency name.
Configuration entities can depend on content and configuration entities. They store an array of content and config dependency names in their "dependencies" key.
string
getConfigTarget()
Gets the configuration target identifier for the entity.
Used to supply the correct format for storing a reference targeting this entity in configuration.
static FieldDefinitionInterface[]
baseFieldDefinitions(EntityTypeInterface $entity_type)
Provides base field definitions for an entity type.
Implementations typically use the class \Drupal\Core\Field\BaseFieldDefinition for creating the field definitions; for example a 'name' field could be defined as the following:
static FieldDefinitionInterface[]
bundleFieldDefinitions(EntityTypeInterface $entity_type, string $bundle, array $base_field_definitions)
Provides field definitions for a specific bundle.
This function can return definitions both for bundle fields (fields that are not defined in $base_field_definitions, and therefore might not exist on some bundles) as well as bundle-specific overrides of base fields (fields that are defined in $base_field_definitions, and therefore exist for all bundles). However, bundle-specific base field overrides can also be provided by 'base_field_override' configuration entities, and that is the recommended approach except in cases where an entity type needs to provide a bundle-specific base field override that is decoupled from configuration. Note that for most entity types, the bundles themselves are derived from configuration (e.g., 'node' bundles are managed via 'node_type' configuration entities), so decoupling bundle-specific base field overrides from configuration only makes sense for entity types that also decouple their bundles from configuration. In cases where both this function returns a bundle-specific override of a base field and a 'base_field_override' configuration entity exists, the latter takes precedence.
bool
hasField(string $field_name)
Determines whether the entity has a field with the given name.
FieldDefinitionInterface|null
getFieldDefinition(string $name)
Gets the definition of a contained field.
FieldDefinitionInterface[]
getFieldDefinitions()
Gets an array of field definitions of all contained fields.
FieldItemListInterface
get(string $field_name)
Gets a field item list.
$this
set(string $field_name, mixed $value, bool $notify = TRUE)
Sets a field value.
FieldItemListInterface[]
getFields(bool $include_computed = TRUE)
Gets an array of all field item lists.
FieldItemListInterface[]
getTranslatableFields(bool $include_computed = TRUE)
Gets an array of field item lists for translatable fields.
onChange(string $field_name)
Reacts to changes to a field.
Note that this is invoked after any changes have been applied.
EntityConstraintViolationListInterface
validate()
Validates the currently set values.
bool
isValidationRequired()
Checks whether entity validation is required before saving the entity.
$this
setValidationRequired(bool $required)
Sets whether entity validation is required before saving the entity.
bool
isDefaultTranslation()
Checks whether the translation is the default one.
bool
isNewTranslation()
Checks whether the translation is new.
LanguageInterface[]
getTranslationLanguages(bool $include_default = TRUE)
Returns the languages the data is translated to.
$this
getTranslation($langcode)
Gets a translation of the data.
The returned translation has to be of the same type than this typed data object.
$this
getUntranslated()
Returns the translatable object referring to the original language.
bool
hasTranslation(string $langcode)
Checks there is a translation for the given language code.
$this
addTranslation(string $langcode, array $values = [])
Adds a new translation to the translatable object.
To create a translation of an entity prefilled with the original data:
removeTranslation(string $langcode)
Removes the translation identified by the given language code.
bool
isTranslatable()
Returns the translation support status.
bool
hasTranslationChanges()
Determines if the current translation of the entity has unsaved changes.
bool
isNewRevision()
Determines whether a new revision should be created on save.
setNewRevision(bool $value = TRUE)
Enforces an entity to be saved as a new revision.
The
getRevisionId()
Gets the revision identifier of the entity.
int
getLoadedRevisionId()
Gets the loaded Revision ID of the entity.
$this
updateLoadedRevisionId()
| internal |
Updates the loaded Revision ID with the revision ID.
This method should not be used, it could unintentionally cause the original revision ID property value to be lost.
bool
isDefaultRevision(bool $new_value = NULL)
Checks if this entity is the default revision.
bool
wasDefaultRevision()
Checks whether the entity object was a default revision when it was saved.
bool
isLatestRevision()
Checks if this entity is the latest revision.
preSaveRevision(EntityStorageInterface $storage, stdClass $record)
Acts on a revision before it gets saved.
bool
isLatestTranslationAffectedRevision()
Checks whether this is the latest revision affecting this translation.
$this
setRevisionTranslationAffected(bool|null $affected)
Marks the current revision translation as affected.
Setting the revision translation affected flag through the setter or through the field directly will always enforce it, which will be used by the entity storage to determine if the flag should be recomputed or the set value should be used instead.
bool
isRevisionTranslationAffected()
Checks whether the current translation is affected by the current revision.
bool
isRevisionTranslationAffectedEnforced()
| internal |
Checks if the revision translation affected flag value has been enforced.
$this
setRevisionTranslationAffectedEnforced(bool $enforced)
| internal |
Enforces the revision translation affected flag value.
Note that this method call will not have any influence on the storage if the value of the revision translation affected flag is NULL which is used as an indication for the storage to recompute the flag.
bool
isDefaultTranslationAffectedOnly()
Checks if untranslatable fields should affect only the default translation.
$this
setSyncing(bool $status)
Sets the status of the synchronization flag.
bool
isSyncing()
Returns whether this entity is being changed as part of a synchronization.
If you are writing code that responds to a change in this entity (insert, update, delete, presave, etc.), and your code would result in a change to this entity itself, a configuration change (whether related to this entity, another entity, or non-entity configuration), you need to check and see if this entity change is part of a synchronization process, and skip executing your code if that is the case.
For example, \Drupal\node\Entity\NodeType::postSave() adds the default body field to newly created node type configuration entities, which is a configuration change. You would not want this code to run during an import, because imported entities were already given the body field when they were originally created, and the imported configuration includes all of their currently-configured fields. On the other hand, \Drupal\field\Entity\FieldStorageConfig::preSave() and the methods it calls make sure that the storage tables are created or updated for the field storage configuration entity, which is not a configuration change, and it must be done whether due to an import or not. So, the first method should check $entity->isSyncing() and skip executing if it returns TRUE, and the second should not perform this check.
UserInterface
getOwner()
Returns the entity owner's user entity.
$this
setOwner(UserInterface $account)
Sets the entity owner's user entity.
int|null
getOwnerId()
Returns the entity owner's user ID.
$this
setOwnerId(int $uid)
Sets the entity owner's user ID.