You are here

BlockEnabled.php in Site Audit 8.3

File

src/Plugin/SiteAuditCheck/BlockEnabled.php
View source
<?php

namespace Drupal\site_audit\Plugin\SiteAuditCheck;

use Drupal\site_audit\Plugin\SiteAuditCheckBase;

/**
 * Provides the BlockEnabled Check.
 *
 * @SiteAuditCheck(
 *  id = "block_enabled",
 *  name = @Translation("Block status"),
 *  description = @Translation("Check to see if enabled"),
 *  report = "block"
 * )
 */
class BlockEnabled extends SiteAuditCheckBase {

  /**
   * {@inheritdoc}.
   */
  public function getResultFail() {
    return $this
      ->t('Block caching is not enabled!');
  }

  /**
   * {@inheritdoc}.
   */
  public function getResultInfo() {
    return $this
      ->t('Block is not enabled.');
  }

  /**
   * {@inheritdoc}.
   */
  public function getResultPass() {
    return $this
      ->t('Block is enabled.');
  }

  /**
   * {@inheritdoc}.
   */
  public function getResultWarn() {
    return $this
      ->t("Block is enabled, but there is no default theme. Consider disabling block if you don't need it.");
  }

  /**
   * {@inheritdoc}.
   */
  public function getAction() {
  }

  /**
   * {@inheritdoc}.
   */
  public function calculateScore() {
    if (!\Drupal::service('module_handler')
      ->moduleExists('block')) {
      $this->abort = TRUE;
      return SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO;
    }
    $this->registry->theme_default = \Drupal::config('system.theme')
      ->get('default');
    if (!$this->registry->theme_default) {
      return SiteAuditCheckBase::AUDIT_CHECK_SCORE_WARN;
    }
    return SiteAuditCheckBase::AUDIT_CHECK_SCORE_PASS;
  }

}

Classes

Namesort descending Description
BlockEnabled Provides the BlockEnabled Check.