class UnapprovedComments extends LocalTaskDefault implements ContainerFactoryPluginInterface (View source)

Provides a local task that shows the amount of unapproved comments.

Traits

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

Provides dependency injection friendly methods for serialization.

Constants

DERIVATIVE_SEPARATOR

A string which is used to separate base plugin IDs from the derivative ID.

Properties

protected string $pluginId

The plugin_id.

from  PluginBase
protected array $pluginDefinition

The plugin implementation definition.

from  PluginBase
protected array $configuration

Configuration information passed into the plugin.

from  PluginBase
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 RouteProviderInterface $routeProvider

The route provider to load routes by name.

from  LocalTaskDefault
protected bool $active

TRUE if this plugin is forced active for options attributes.

from  LocalTaskDefault
protected TranslationInterface $stringTranslation

The string translation service.

from  StringTranslationTrait
protected CommentStorageInterface $commentStorage

The comment storage service.

Methods

__construct(array $configuration, string $plugin_id, mixed $plugin_definition, CommentStorageInterface $comment_storage)

Construct the UnapprovedComments object.

string
getPluginId()

Gets the plugin_id of the plugin instance.

string
getBaseId()

Gets the base_plugin_id of the plugin instance.

string|null
getDerivativeId()

Gets the derivative_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

bool
isConfigurable()

Determines if the plugin is configurable.

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

string
getRouteName()

Get the route name from the settings.

array
getRouteParameters(RouteMatchInterface $route_match)

Returns the route parameters needed to render a link for the local task.

string
getTitle(Request $request = NULL)

Returns the localized title to be shown for this tab.

int|null
getWeight()

Returns the weight of the local task.

array
getOptions(RouteMatchInterface $route_match)

Returns options for rendering a link to the local task.

$this
setActive(bool $active = TRUE)

Sets the active status.

bool
getActive()

Gets the active status.

routeProvider()

Returns the route provider.

string[]
getCacheTags()

The cache tags associated with this object.

string[]
getCacheContexts()

The cache contexts associated with this object.

int
getCacheMaxAge()

The maximum age for which this object may be cached.

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.

create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

Details

__construct(array $configuration, string $plugin_id, mixed $plugin_definition, CommentStorageInterface $comment_storage)

Construct the UnapprovedComments object.

Parameters

array $configuration

A configuration array containing information about the plugin instance.

string $plugin_id

The plugin_id for the plugin instance.

mixed $plugin_definition

The plugin implementation definition.

CommentStorageInterface $comment_storage

The comment storage service.

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

string getBaseId()

Gets the base_plugin_id of the plugin instance.

Return Value

string

The base_plugin_id of the plugin instance.

string|null getDerivativeId()

Gets the derivative_id of the plugin instance.

Return Value

string|null

The derivative_id of the plugin instance NULL otherwise.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

bool isConfigurable()

Determines if the plugin is configurable.

Return Value

bool

A boolean indicating whether the plugin is configurable.

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

string getRouteName()

Get the route name from the settings.

Return Value

string

The name of the route this local task links to.

array getRouteParameters(RouteMatchInterface $route_match)

Returns the route parameters needed to render a link for the local task.

Parameters

RouteMatchInterface $route_match

The current route match.

Return Value

array

An array of parameter names and values.

string getTitle(Request $request = NULL)

Returns the localized title to be shown for this tab.

Subclasses may add optional arguments like NodeInterface $node = NULL that will be supplied by the ControllerResolver.

Parameters

Request $request

Return Value

string

The title of the local task.

int|null getWeight()

Returns the weight of the local task.

Return Value

int|null

The weight of the task or NULL.

array getOptions(RouteMatchInterface $route_match)

Returns options for rendering a link to the local task.

Parameters

RouteMatchInterface $route_match

The current route match.

Return Value

array

An associative array of options.

$this setActive(bool $active = TRUE)

Sets the active status.

Parameters

bool $active

Sets whether this tab is active (e.g. a parent of the current tab).

Return Value

$this

The called object for chaining.

bool getActive()

Gets the active status.

Return Value

bool

TRUE if the local task is active, FALSE otherwise.

protected RouteProviderInterface routeProvider()

Returns the route provider.

Return Value

RouteProviderInterface

The route provider.

string[] getCacheTags()

The cache tags associated with this object.

When this object is modified, these cache tags will be invalidated.

Return Value

string[]

A set of cache tags.

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.

Return Value

string[]

An array of cache context tokens, used to generate a cache ID.

int getCacheMaxAge()

The maximum age for which this object may be cached.

Return Value

int

The maximum time in seconds that this object may be cached.

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

static ContainerFactoryPluginInterface create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

Parameters

ContainerInterface $container

The container to pull out services used in the plugin.

array $configuration

A configuration array containing information about the plugin instance.

string $plugin_id

The plugin ID for the plugin instance.

mixed $plugin_definition

The plugin implementation definition.

Return Value

ContainerFactoryPluginInterface

Returns an instance of this plugin.