You are here

lagoon_varnish.module in Lagoon Varnish 8

File

lagoon_varnish.module
View source
<?php

/**
 * @file
 * Contains lagoon_varnish.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\lagoon_varnish\Plugin\Purge\Purger\LagoonVarnishPurger;

/**
 * Implements hook_help().
 */
function lagoon_varnish_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the lagoon_varnish module.
    case 'help.page.lagoon_varnish':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('A meta-module that bundles and configures Varnish cache clearing for the Lagoon platform') . '</p>';
      return $output;
    default:
  }
}

/**
 * Checks whether Lagoon varnish purger is enabled, if not, attempts to enable.
 */
function lagoon_varnish_add_purger() {
  $purger_service = \Drupal::service('purge.purgers');
  $purger_service
    ->reload();
  $enabled = $purger_service
    ->getPluginsEnabled();
  $plugin_id = LagoonVarnishPurger::LAGOON_VARNISH_PURGER_ID;
  if (in_array($plugin_id, $purger_service
    ->getPluginsAvailable())) {
    $enabled[$purger_service
      ->createId()] = $plugin_id;
    $purger_service
      ->setPluginsEnabled($enabled);
  }
}

Functions

Namesort descending Description
lagoon_varnish_add_purger Checks whether Lagoon varnish purger is enabled, if not, attempts to enable.
lagoon_varnish_help Implements hook_help().