Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ResponseStatus.php

function ResponseStatus::buildConfigurationForm

Overrides ConditionPluginBase::buildConfigurationForm

File

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

Class

ResponseStatus
Provides a 'Response status' condition.

Namespace

Drupal\system\Plugin\Condition

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) : array {
    $status_codes = [
        Response::HTTP_OK => $this->t('Success (@status_code)', [
            '@status_code' => Response::HTTP_OK,
        ]),
        Response::HTTP_FORBIDDEN => $this->t('Access denied (@status_code)', [
            '@status_code' => Response::HTTP_FORBIDDEN,
        ]),
        Response::HTTP_NOT_FOUND => $this->t('Page not found (@status_code)', [
            '@status_code' => Response::HTTP_NOT_FOUND,
        ]),
    ];
    $form['status_codes'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('Response status'),
        '#options' => $status_codes,
        '#default_value' => $this->configuration['status_codes'],
        '#description' => $this->t('Shows the block on pages with any matching response status. If nothing is checked, the block is shown on all pages. Other response statuses are not used.'),
    ];
    return parent::buildConfigurationForm($form, $form_state);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal