function OliveroHooks::preprocessSearchResult

Same name and namespace in other branches
  1. main core/themes/olivero/src/Hook/OliveroHooks.php \Drupal\olivero\Hook\OliveroHooks::preprocessSearchResult()

Implements hook_preprocess_search_result().

Attributes

#[Hook('preprocess_search_result')]

File

core/themes/olivero/src/Hook/OliveroHooks.php, line 563

Class

OliveroHooks
Hook implementations for olivero.

Namespace

Drupal\olivero\Hook

Code

public function preprocessSearchResult(&$variables) : void {
  // Apply custom date formatter to "date" field.
  if (!empty($variables['result']['date'])) {
    $variables['info_date'] = \Drupal::service('date.formatter')->format($variables['result']['node']->getCreatedTime(), 'olivero_medium');
  }
}

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