You are here

class RenameAdminPathsCallbacks in Rename Admin Paths 8

RenameAdminPathsCallbacks class.

Hierarchy

Expanded class hierarchy of RenameAdminPathsCallbacks

File

src/Form/RenameAdminPathsCallbacks.php, line 10

Namespace

Drupal\rename_admin_paths\Form
View source
class RenameAdminPathsCallbacks {

  /**
   * Form element validation handler for 'name' in form_test_validate_form().
   *
   * @param string $element
   *   The field element.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state object.
   */
  public function validatePath(&$element, FormStateInterface $form_state) {

    // Force path replacement values to contain only lowercase letters, numbers and underscores.
    if (!empty($element['#value']) && !preg_match('!^[a-z0-9_]+$!i', $element['#value'])) {
      $form_state
        ->setError($element, t('Path replacement value must contain only lowercase letters, numbers and underscores.'));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RenameAdminPathsCallbacks::validatePath public function Form element validation handler for 'name' in form_test_validate_form().