You are here

public function InstallableLibrary::getStatus in Markdown 8.2

Retrieves the current status of the library.

Parameters

bool $long: Flag indicating whether to use longer explanations as indicated by the individual property values.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The human readable status.

File

src/Annotation/InstallableLibrary.php, line 192

Class

InstallableLibrary

Namespace

Drupal\markdown\Annotation

Code

public function getStatus($long = FALSE) {

  // Immediately return if there are requirement violations (not installed).
  if ($this->requirementViolations) {
    return t('Not Installed');
  }

  // Determine the library status.
  if ($this
    ->hasRequestFailure()) {
    if ($long) {
      return t('Request Failure. @explanation', [
        '@explanation' => $this->requestException
          ->getMessage(),
      ]);
    }
    return t('Request Failure');
  }
  if ($this
    ->getNewerVersions()) {
    if ($this->deprecated) {
      return t('Deprecated');
    }
    if ($this->preferred) {
      return t('Update Available');
    }
    return t('Upgrade Available');
  }
  if ($this
    ->isKnownVersion()) {
    if ($this->deprecated && !$this->preferred) {
      if ($long && $this->deprecated !== TRUE) {
        return t('Upgrade Available. @explanation', [
          '@explanation' => $this->deprecated,
        ]);
      }
      return t('Upgrade Available');
    }
    if ($this->deprecated && $this->preferred) {
      if ($long && $this->deprecated !== TRUE) {
        return t('Deprecated. @explanation', [
          '@explanation' => $this->deprecated,
        ]);
      }
      return t('Deprecated');
    }
    if ($this->experimental) {
      if ($long && $this->experimental !== TRUE) {
        return t('Experimental. @explanation', [
          '@explanation' => $this->experimental,
        ]);
      }
      return t('Experimental');
    }
    if ($this
      ->isPrerelease()) {
      return t('Prerelease');
    }
    if ($this
      ->isDev()) {
      return t('Development Release');
    }
    return t('Up to date');
  }
  return t('Unknown');
}