function ResponseStatus::summary

Same name in other branches
  1. 11.x core/modules/system/src/Plugin/Condition/ResponseStatus.php \Drupal\system\Plugin\Condition\ResponseStatus::summary()

Overrides ConditionInterface::summary

File

core/modules/system/src/Plugin/Condition/ResponseStatus.php, line 89

Class

ResponseStatus
Provides a 'Response status' condition.

Namespace

Drupal\system\Plugin\Condition

Code

public function summary() : PluralTranslatableMarkup {
    $allowed_codes = $this->configuration['status_codes'];
    $status_codes = [
        Response::HTTP_OK,
        Response::HTTP_FORBIDDEN,
        Response::HTTP_NOT_FOUND,
    ];
    $result = empty($allowed_codes) ? $status_codes : $allowed_codes;
    $count = count($result);
    $codes = implode(', ', $result);
    if (!empty($this->configuration['negate'])) {
        return $this->formatPlural($count, 'Request response code is not: @codes', 'Request response code is not one of the following: @codes', [
            '@codes' => $codes,
        ]);
    }
    return $this->formatPlural($count, 'Request response code is: @codes', 'Request response code is one of the following: @codes', [
        '@codes' => $codes,
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.