class SearchPageListBuilder extends DraggableListBuilder implements FormInterface (View source)

Defines a class to build a listing of search page entities.

Traits

Provides access to configuration for forms.

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.

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
protected string $entitiesKey

The key to use for the form element containing the entities.

from  DraggableListBuilder
protected SearchPageInterface[] $entities

The entities being listed.

protected string|bool $weightKey

Name of the entity's weight field or FALSE if no field is provided.

from  DraggableListBuilder
protected FormBuilderInterface $formBuilder

The form builder.

from  DraggableListBuilder
protected ConfigFactoryInterface $configFactory

Stores the configuration factory.

protected SearchPluginManager $searchManager

The search manager.

protected SearchIndexInterface $searchIndex

The search index.

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, SearchPluginManager $search_manager, ConfigFactoryInterface $config_factory, MessengerInterface $messenger, SearchIndexInterface $search_index)

Constructs a new SearchPageListBuilder 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.

array
buildForm(array $form, FormStateInterface $form_state)

Form constructor.

validateForm(array $form, FormStateInterface $form_state)

Form validation handler.

submitForm(array $form, FormStateInterface $form_state)

Form submission handler.

formBuilder()

Returns the form builder.

config(string $name)

Retrieves a configuration object.

getEditableConfigNames()

{@inheritdoc}

string
getFormId()

Returns a unique string identifying the form.

searchAdminReindexSubmit(array $form, FormStateInterface $form_state)

Form submission handler for the reindex button on the search admin settings form.

validateAddSearchPage(array $form, FormStateInterface $form_state)

Form validation handler for adding a new search page.

submitAddSearchPage(array $form, FormStateInterface $form_state)

Form submission handler for adding a new search page.

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, SearchPluginManager $search_manager, ConfigFactoryInterface $config_factory, MessengerInterface $messenger, SearchIndexInterface $search_index)

Constructs a new SearchPageListBuilder object.

Parameters

EntityTypeInterface $entity_type

The entity type definition.

EntityStorageInterface $storage

The entity storage class.

SearchPluginManager $search_manager

The search plugin manager.

ConfigFactoryInterface $config_factory

The factory for configuration objects.

MessengerInterface $messenger

The messenger.

SearchIndexInterface $search_index

The search index.

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.

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.

array buildForm(array $form, FormStateInterface $form_state)

Form constructor.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

Return Value

array

The form structure.

validateForm(array $form, FormStateInterface $form_state)

Form validation handler.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

submitForm(array $form, FormStateInterface $form_state)

Form submission handler.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

protected FormBuilderInterface formBuilder()

Returns the form builder.

Return Value

FormBuilderInterface

The form builder.

protected Config|ImmutableConfig config(string $name)

Retrieves a configuration object.

Parameters

string $name

The name of the configuration object to retrieve. The name corresponds to a configuration file. For @code \Drupal::config('book.admin') @endcode, the config object returned will contain the contents of book.admin configuration file.

Return Value

Config|ImmutableConfig

An editable configuration object if the given name is listed in the getEditableConfigNames() method or an immutable configuration object if not.

protected getEditableConfigNames()

{@inheritdoc}

string getFormId()

Returns a unique string identifying the form.

The returned ID should be a unique string that can be a valid PHP function name, since it's used in hook implementation names such as hook_form_FORM_ID_alter().

Return Value

string

The unique string identifying the form.

searchAdminReindexSubmit(array $form, FormStateInterface $form_state)

Form submission handler for the reindex button on the search admin settings form.

Parameters

array $form
FormStateInterface $form_state

validateAddSearchPage(array $form, FormStateInterface $form_state)

Form validation handler for adding a new search page.

Parameters

array $form
FormStateInterface $form_state

submitAddSearchPage(array $form, FormStateInterface $form_state)

Form submission handler for adding a new search page.

Parameters

array $form
FormStateInterface $form_state