EntityController
class EntityController implements ContainerInjectionInterface (View source)
Provides the add-page and title callbacks for entities.
It provides:
- The add-page callback.
- An add title callback for entity types.
- An add title callback for entity types with bundles.
- A view title callback.
- An edit title callback.
- A delete title callback.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected EntityTypeManagerInterface | $entityTypeManager | The entity type manager. |
|
| protected EntityTypeBundleInfoInterface | $entityTypeBundleInfo | The entity type bundle info. |
|
| protected EntityRepositoryInterface | $entityRepository | The entity repository. |
|
| protected RendererInterface | $renderer | The renderer. |
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.
Constructs a new EntityController.
Instantiates a new instance of this class.
Returns a redirect response object for the specified route.
Displays add links for the available bundles.
Provides a generic add title callback for an entity type.
Provides a generic add title callback for entities with bundles.
Provides a generic title callback for a single entity.
Provides a generic edit title callback.
Provides a generic delete title callback.
Determines the entity.
Expands the bundle information with descriptions, if known.
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(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityRepositoryInterface $entity_repository, RendererInterface $renderer, TranslationInterface $string_translation, UrlGeneratorInterface $url_generator)
Constructs a new EntityController.
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.
protected RedirectResponse
redirect(string $route_name, array $route_parameters = [], array $options = [], int $status = 302)
Returns a redirect response object for the specified route.
RedirectResponse|array
addPage(string $entity_type_id)
Displays add links for the available bundles.
Redirects to the add form if there's only one bundle available.
string
addTitle(string $entity_type_id)
Provides a generic add title callback for an entity type.
string
addBundleTitle(RouteMatchInterface $route_match, string $entity_type_id, string $bundle_parameter)
Provides a generic add title callback for entities with bundles.
string|null
title(RouteMatchInterface $route_match, EntityInterface $_entity = NULL)
Provides a generic title callback for a single entity.
string|null
editTitle(RouteMatchInterface $route_match, EntityInterface $_entity = NULL)
Provides a generic edit title callback.
string
deleteTitle(RouteMatchInterface $route_match, EntityInterface $_entity = NULL)
Provides a generic delete title callback.
protected EntityInterface|null
doGetEntity(RouteMatchInterface $route_match, EntityInterface $_entity = NULL)
Determines the entity.
protected array
loadBundleDescriptions(array $bundles, EntityTypeInterface $bundle_entity_type)
Expands the bundle information with descriptions, if known.