EntityTypeInfo
class EntityTypeInfo implements ContainerInjectionInterface (View source)
| internal |
Manipulates entity type information.
This class contains primarily bridged hooks for compile-time or cache-clear-time hooks. Runtime hooks should be placed in EntityOperations.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected ModerationInformationInterface | $moderationInfo | The moderation information service. |
|
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected EntityTypeBundleInfoInterface | $bundleInfo | The bundle information service. |
|
| protected AccountInterface | $currentUser | The current user. |
|
| protected StateTransitionValidationInterface | $validator | The state transition validation service. |
|
| protected array | $moderationHandlers | A keyed array of custom moderation handlers for given entity types. |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
EntityTypeInfo constructor.
Instantiates a new instance of this class.
Adds Moderation configuration to appropriate entity types.
Modifies an entity definition to include moderation support.
Gets the "extra fields" for a bundle.
Returns an iterable list of entity names and bundle names under moderation.
Replaces the entity form entity object with a proper revision object.
Alters bundle forms to enforce revision handling.
Checks whether the specified form allows to edit a moderated entity.
Redirect content entity edit forms on save, if there is a pending revision.
Details
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__construct(TranslationInterface $translation, ModerationInformationInterface $moderation_information, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $bundle_info, AccountInterface $current_user, StateTransitionValidationInterface $validator)
EntityTypeInfo constructor.
static
create(ContainerInterface $container)
Instantiates a new instance of this class.
This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.
entityTypeAlter(array $entity_types)
Adds Moderation configuration to appropriate entity types.
protected ContentEntityTypeInterface
addModerationToEntityType(ContentEntityTypeInterface $type)
Modifies an entity definition to include moderation support.
This primarily just means an extra handler. A Generic one is provided, but individual entity types can provide their own as appropriate.
array
entityExtraFieldInfo()
Gets the "extra fields" for a bundle.
protected Generator
getModeratedBundles()
Returns an iterable list of entity names and bundle names under moderation.
That is, this method returns a list of bundles that have Content Moderation enabled on them.
BaseFieldDefinition[]
entityBaseFieldInfo(EntityTypeInterface $entity_type)
Adds base field info to an entity type.
entityPrepareForm(EntityInterface $entity, string $operation, FormStateInterface $form_state)
Replaces the entity form entity object with a proper revision object.
formAlter(array $form, FormStateInterface $form_state, string $form_id)
Alters bundle forms to enforce revision handling.
protected bool
isModeratedEntityEditForm(FormInterface $form_object)
Checks whether the specified form allows to edit a moderated entity.
static
bundleFormRedirect(array $form, FormStateInterface $form_state)
Redirect content entity edit forms on save, if there is a pending revision.
When saving their changes, editors should see those changes displayed on the next page.