public function AcquiaPlatformCdnCheck::run in Acquia Purge 8
Perform the check and determine the severity level.
Diagnostic checks determine whether something you are checking for is in shape, for instance CMI settings on which your plugin depends. Any check reporting self::SEVERITY_ERROR in their run() methods, will cause purge to stop working. Any other severity level will let the purgers proceed operating but you may report any warning through getRecommendation() to be shown on Drupal's status report, purge_ui or any other diagnostic listing.
public function run() {
if (...check..) {
return self::SEVERITY_OK;
}
return self::SEVERITY_WARNING;
}
@warning As diagnostic checks can be expensive, this method is called as rarely as possible. Checks derived from DiagnosticCheckBase will only see the check getting executed when any of the getter methods are called.
Return value
int Integer, matching either of the following constants:
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_INFO
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_OK
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_WARNING
- \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticCheckInterface::SEVERITY_ERROR
Throws
\Drupal\purge\Plugin\Purge\DiagnosticCheck\Exception\CheckNotImplementedCorrectly Thrown when the return value is incorrect.
Overrides DiagnosticCheckInterface::run
File
- src/
Plugin/ Purge/ DiagnosticCheck/ AcquiaPlatformCdnCheck.php, line 63
Class
- AcquiaPlatformCdnCheck
- Acquia Purge CDN.
Namespace
Drupal\acquia_purge\Plugin\Purge\DiagnosticCheckCode
public function run() {
// Verify if we're able to fetch the Platform CDN configuration array.
if (!($backend_config = BackendFactory::getConfig($this->platformInfo))) {
$this->recommendation = $this
->t("Platform CDN isn't yet configured, please contact Acquia Support to do this for you.");
return self::SEVERITY_ERROR;
}
// Lookup a backend class for the Platform CDN vendor.
if (!($backend_class = BackendFactory::getClassFromConfig($backend_config))) {
$this->recommendation = $this
->t("Please upgrade Acquia Purge to a newer version.");
return self::SEVERITY_ERROR;
}
// Ask the backend plugin to validate the Platform CDN configuration array.
if (!$backend_class::validateConfiguration($backend_config)) {
$this->recommendation = $this
->t("Configuration malformed, please contact Acquia Support.");
return self::SEVERITY_ERROR;
}
// Check for temporary runtime errors and suspend operations if present.
if ($error = $backend_class::getTemporaryRuntimeError()) {
$this->recommendation = $error;
return self::SEVERITY_ERROR;
}
$this->recommendation = $this
->t("Acquia Platform CDN is enabled.");
return self::SEVERITY_OK;
}