sitemap_status-1.0.0-alpha4/sitemap_status.install

sitemap_status.install
<?php

/**
 * @file
 * Install, update, and uninstall functions for the Sitemap status module.
 */

use Drupal\sitemap_status\SitemapStatusInterface;

/**
 * Implements hook_requirements().
 *
 * @return array
 *   An array describing the sitemap status.
 */
function sitemap_status_requirements($phase) {
  $requirements = [];
  if ($phase === 'runtime') {
    /** @var \Drupal\sitemap_status\SitemapStatusInterface $sitemapStatus */
    $sitemapStatus = \Drupal::service('sitemap_status');
    $sitemapStatusLevel = $sitemapStatus->getStatusLevel();
    $requirements['sitemap_status']['title'] = t('Sitemap status');
    $requirements['sitemap_status']['severity'] = $sitemapStatusLevel;
    $requirements['sitemap_status']['description'] = $sitemapStatus->getStatusSummary();
    switch ($sitemapStatusLevel) {
      case SitemapStatusInterface::REQUIREMENT_ERROR:
        $requirements['sitemap_status']['value'] = t('Some 5xx errors were met.');
        break;

      case SitemapStatusInterface::REQUIREMENT_WARNING:
        $requirements['sitemap_status']['value'] = t('Some 4xx errors were met.');
        break;

      case SitemapStatusInterface::REQUIREMENT_OK:
      case SitemapStatusInterface::REQUIREMENT_INFO:
        $requirements['sitemap_status']['value'] = t('Locations status check valid. All locations are returning either 2xx or 3xx.');
        break;

      case SitemapStatusInterface::REQUIREMENT_UNKNOWN:
      default:
        $requirements['sitemap_status']['value'] = t('No locations status data available.');
        $requirements['sitemap_status']['severity'] = SitemapStatusInterface::REQUIREMENT_WARNING;
        break;
    }
  }
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function sitemap_status_uninstall() {
  /** @var \Drupal\Core\Cache\CacheBackendInterface $cacheBackend */
  $cacheBackend = \Drupal::service('cache.backend.sitemap_status');
  if ($cacheBackend->get(SitemapStatusInterface::CACHE_ID)) {
    $cacheBackend->delete(SitemapStatusInterface::CACHE_ID);
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc