class LinkGenerationTestHooks

Hook implementations for link_generation_test.

Hierarchy

Expanded class hierarchy of LinkGenerationTestHooks

File

core/modules/system/tests/modules/link_generation_test/src/Hook/LinkGenerationTestHooks.php, line 13

Namespace

Drupal\link_generation_test\Hook
View source
class LinkGenerationTestHooks {
    use StringTranslationTrait;
    
    /**
     * Implements hook_link_alter().
     */
    public function linkAlter(&$variables) : void {
        if (\Drupal::state()->get('link_generation_test_link_alter', FALSE)) {
            // Add a text to the end of links.
            if (\Drupal::state()->get('link_generation_test_link_alter_safe', FALSE)) {
                $variables['text'] = $this->t('@text <strong>Test!</strong>', [
                    '@text' => $variables['text'],
                ]);
            }
            else {
                $variables['text'] .= ' <strong>Test!</strong>';
            }
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
LinkGenerationTestHooks::linkAlter public function Implements hook_link_alter().
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language. 1

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.