You are here

public function AgreementForm::validatePath in Agreement 8.2

Same name and namespace in other branches
  1. 3.0.x src/Entity/AgreementForm.php \Drupal\agreement\Entity\AgreementForm::validatePath()

Validate the provided path.

Parameters

array $element: The form array element.

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

File

src/Entity/AgreementForm.php, line 262

Class

AgreementForm
Add or edit agreements.

Namespace

Drupal\agreement\Entity

Code

public function validatePath(array $element, FormStateInterface $form_state) {
  $new = $form_state
    ->getValue('path');
  $url = $this->pathValidator
    ->getUrlIfValidWithoutAccessCheck($new);
  if ($new !== $this->entity
    ->get('path') && (!$url || $url
    ->isExternal() || $url
    ->isRouted())) {
    $form_state
      ->setErrorByName('path', $this
      ->t('The path must be an internal and unused relative URL.'));
  }
}