class ShortcutSetListBuilder extends ConfigEntityListBuilder (View source)

Defines a class to build a listing of shortcut set entities.

Traits

Provides a trait for the messenger service.

Wrapper methods for the Redirect Destination.

Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.

Provides dependency injection friendly methods for serialization.

Properties

protected TranslationInterface $stringTranslation

The string translation service.

from  StringTranslationTrait
protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected ModuleHandlerInterface $moduleHandler

The module handler to invoke hooks on.

from  EntityHandlerBase
protected MessengerInterface $messenger

The messenger.

from  MessengerTrait
protected RedirectDestinationInterface $redirectDestination

The redirect destination service.

from  RedirectDestinationTrait
protected EntityStorageInterface $storage

The entity storage class.

from  EntityListBuilder
protected string $entityTypeId

The entity type ID.

from  EntityListBuilder
protected EntityTypeInterface $entityType

Information about the entity type.

from  EntityListBuilder
protected int|false $limit

The number of entities to list per page, or FALSE to list all entities.

from  EntityListBuilder

Methods

t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

getStringTranslation()

Gets the string translation service.

$this
setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

moduleHandler()

Gets the module handler.

$this
setModuleHandler(ModuleHandlerInterface $module_handler)

Sets the module handler for this handler.

setMessenger(MessengerInterface $messenger)

Sets the messenger.

messenger()

Gets the messenger.

array
getDestinationArray()

Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.

getRedirectDestination()

Returns the redirect destination service.

$this
setRedirectDestination(RedirectDestinationInterface $redirect_destination)

Sets the redirect destination service.

createInstance(ContainerInterface $container, EntityTypeInterface $entity_type)

Instantiates a new instance of this entity handler.

__construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage)

Constructs a new EntityListBuilder object.

getStorage()

Gets the entity storage.

load()

Loads entities of this type from storage for listing.

array
getEntityIds()

Loads entity IDs using a pager sorted by the entity id.

array
getOperations(EntityInterface $entity)

Provides an array of information to build a list of operation links.

array
getDefaultOperations(EntityInterface $entity)

Gets this list's default operations.

array
buildHeader()

Builds the header row for the entity listing.

array
buildRow(EntityInterface $entity)

Builds a row for an entity in the entity listing.

array
buildOperations(EntityInterface $entity)

Builds a renderable list of operation links for the entity.

array
render()

Builds a listing of entities for the given entity type.

getTitle()

Gets the title of the page.

Url
ensureDestination(Url $url)

Ensures that a destination is present on the given URL.

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

Parameters

string $string

A string containing the English text to translate.

array $args

(optional) An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for details.

array $options

(optional) An associative array of additional options, with the following elements:

  • 'langcode' (defaults to the current language): A language code, to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to. See the @link i18n Internationalization topic @endlink for more information about string contexts.

Return Value

TranslatableMarkup

An object that, when cast to a string, returns the translated string.

See also

FormattableMarkup::placeholderFormat
TranslatableMarkup::__construct

protected formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

Parameters

$count
$singular
$plural
array $args
array $options

See also

TranslationInterface::formatPlural

protected getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

Parameters

$langcode

See also

PluralFormulaInterface::getNumberOfPlurals

protected TranslationInterface getStringTranslation()

Gets the string translation service.

Return Value

TranslationInterface

The string translation service.

$this setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

Parameters

TranslationInterface $translation

The string translation service.

Return Value

$this

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

protected ModuleHandlerInterface moduleHandler()

Gets the module handler.

Return Value

ModuleHandlerInterface

The module handler.

$this setModuleHandler(ModuleHandlerInterface $module_handler)

Sets the module handler for this handler.

Parameters

ModuleHandlerInterface $module_handler

The module handler.

Return Value

$this

setMessenger(MessengerInterface $messenger)

Sets the messenger.

Parameters

MessengerInterface $messenger

The messenger.

MessengerInterface messenger()

Gets the messenger.

Return Value

MessengerInterface

The messenger.

protected array getDestinationArray()

Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.

Return Value

array

An associative array containing the key:

  • destination: The value of the current request's 'destination' query parameter, if present. This can be either a relative or absolute URL. However, for security, redirection to external URLs is not performed. If the query parameter isn't present, then the URL of the current request is returned.

See also

RedirectDestinationInterface::getAsArray

protected RedirectDestinationInterface getRedirectDestination()

Returns the redirect destination service.

Return Value

RedirectDestinationInterface

The redirect destination helper.

$this setRedirectDestination(RedirectDestinationInterface $redirect_destination)

Sets the redirect destination service.

Parameters

RedirectDestinationInterface $redirect_destination

The redirect destination service.

Return Value

$this

static EntityHandlerInterface createInstance(ContainerInterface $container, EntityTypeInterface $entity_type)

Instantiates a new instance of this entity handler.

This is a factory method that returns a new instance of this object. The factory should pass any needed dependencies into the constructor of this object, but not the container itself. Every call to this method must return a new instance of this object; that is, it may not implement a singleton.

Parameters

ContainerInterface $container

The service container this object should use.

EntityTypeInterface $entity_type

The entity type definition.

Return Value

EntityHandlerInterface

A new instance of the entity handler.

__construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage)

Constructs a new EntityListBuilder object.

Parameters

EntityTypeInterface $entity_type

The entity type definition.

EntityStorageInterface $storage

The entity storage class.

EntityStorageInterface getStorage()

Gets the entity storage.

Return Value

EntityStorageInterface

The storage used by this list builder.

EntityInterface[] load()

Loads entities of this type from storage for listing.

This allows the implementation to manipulate the listing, like filtering or sorting the loaded entities.

Return Value

EntityInterface[]

An array of entities implementing \Drupal\Core\Entity\EntityInterface indexed by their IDs. Returns an empty array if no matching entities are found.

protected array getEntityIds()

Loads entity IDs using a pager sorted by the entity id.

Return Value

array

An array of entity IDs.

array getOperations(EntityInterface $entity)

Provides an array of information to build a list of operation links.

Parameters

EntityInterface $entity

The entity the operations are for.

Return Value

array

An associative array of operation link data for this list, keyed by operation name, containing the following key-value pairs:

  • title: The localized title of the operation.
  • url: An instance of \Drupal\Core\Url for the operation URL.
  • weight: The weight of this operation.

array getDefaultOperations(EntityInterface $entity)

Gets this list's default operations.

Parameters

EntityInterface $entity

The entity the operations are for.

Return Value

array

The array structure is identical to the return value of self::getOperations().

array buildHeader()

Builds the header row for the entity listing.

Return Value

array

A render array structure of header strings.

array buildRow(EntityInterface $entity)

Builds a row for an entity in the entity listing.

Parameters

EntityInterface $entity

The entity for this row of the list.

Return Value

array

A render array structure of fields for this entity.

array buildOperations(EntityInterface $entity)

Builds a renderable list of operation links for the entity.

Parameters

EntityInterface $entity

The entity on which the linked operations will be performed.

Return Value

array

A renderable array of operation links.

See also

EntityListBuilder::buildRow

array render()

Builds a listing of entities for the given entity type.

Add a link to add a new item to the #empty text.

Return Value

array

A render array as expected by \Drupal\Core\Render\RendererInterface::render().

protected getTitle()

Gets the title of the page.

protected Url ensureDestination(Url $url)

Ensures that a destination is present on the given URL.

Parameters

Url $url

The URL object to which the destination should be added.

Return Value

Url

The updated URL object.