CredentialCheck.php in CloudFlare 8
File
modules/cloudflarepurger/src/Plugin/Purge/DiagnosticCheck/CredentialCheck.php
View source
<?php
namespace Drupal\cloudflarepurger\Plugin\Purge\DiagnosticCheck;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckBase;
use Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CredentialCheck extends DiagnosticCheckBase implements DiagnosticCheckInterface {
protected $config;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->config = $config_factory
->get('cloudflare.settings');
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'));
}
public function run() {
$has_valid_credentials = $this->config
->get('valid_credentials');
if (!$has_valid_credentials) {
$this->recommendation = $this
->t("Invalid Api credentials.");
return SELF::SEVERITY_ERROR;
}
$this->recommendation = $this
->t('Valid Api credentials detected.');
return SELF::SEVERITY_OK;
}
}
Classes
Name |
Description |
CredentialCheck |
Checks if valid Api credentials have been entered for CloudFlare. |