function RequestPath::validateConfigurationForm

Same name in other branches
  1. 10 core/modules/system/src/Plugin/Condition/RequestPath.php \Drupal\system\Plugin\Condition\RequestPath::validateConfigurationForm()

Overrides ConditionPluginBase::validateConfigurationForm

File

core/modules/system/src/Plugin/Condition/RequestPath.php, line 119

Class

RequestPath
Provides a 'Request Path' condition.

Namespace

Drupal\system\Plugin\Condition

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    $paths = array_map('trim', explode("\n", $form_state->getValue('pages')));
    foreach ($paths as $path) {
        if (empty($path) || $path === '<front>' || str_starts_with($path, '/')) {
            continue;
        }
        $form_state->setErrorByName('pages', $this->t("The path %path requires a leading forward slash when used with the Pages setting.", [
            '%path' => $path,
        ]));
    }
}

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