You are here

class PagererCache in Pagerer 8.2

Same name and namespace in other branches
  1. 8 src/PagererCache.php \Drupal\pagerer\PagererCache

Pagerer cache callback.

Hierarchy

Expanded class hierarchy of PagererCache

File

src/PagererCache.php, line 11

Namespace

Drupal\pagerer
View source
class PagererCache implements TrustedCallbackInterface {

  /**
   * {@inheritdoc}
   */
  public static function trustedCallbacks() {
    return [
      'preRenderPager',
    ];
  }

  /**
   * A #pre_render callback for type #pager.
   *
   * Used to associate the config:pagerer.settings cache tag to the #pager
   * type, since Pagerer makes the rendered pager dependent on its
   * configuration.
   *
   * @param array $pager
   *   A renderable array of #type => pager.
   *
   * @return array
   *   The altered renderable array.
   */
  public static function preRenderPager(array $pager) {
    CacheableMetadata::createFromRenderArray($pager)
      ->merge(CacheableMetadata::createFromObject(\Drupal::config('pagerer.settings')))
      ->applyTo($pager);
    return $pager;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PagererCache::preRenderPager public static function A #pre_render callback for type #pager.
PagererCache::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.