You are here

public function ExtlinkExtraController::getTitle in External Links Extra 8

Title callback.

Return value

string

1 string reference to 'ExtlinkExtraController::getTitle'
extlink_extra.routing.yml in ./extlink_extra.routing.yml
extlink_extra.routing.yml

File

src/Controller/ExtlinkExtraController.php, line 71

Class

ExtlinkExtraController

Namespace

Drupal\extlink_extra\Controller

Code

public function getTitle() {

  // Get configuration.
  $config = $this->configFactory
    ->get('extlink_extra.settings');

  // Prepare token replacement values.
  $extlink_token_data = [
    'extlink' => [
      'external_url' => isset($_COOKIE['external_url']) ? $_COOKIE['external_url'] : NULL,
      'back_url' => isset($_COOKIE['back_url']) ? $_COOKIE['back_url'] : NULL,
    ],
  ];

  // Fetch the page title and return it after replacing the tokens.
  $page_title = $config
    ->get('extlink_page_title') ?: NULL;
  return $this->token
    ->replace($page_title, $extlink_token_data);
}