You are here

class Editoria11ySettings in Editoria11y Accessibility Checker 1.0.x

Class Editoria11ySettings.

Hierarchy

Expanded class hierarchy of Editoria11ySettings

1 string reference to 'Editoria11ySettings'
editoria11y.routing.yml in ./editoria11y.routing.yml
editoria11y.routing.yml

File

src/Form/Editoria11ySettings.php, line 11

Namespace

Drupal\editoria11y\Form
View source
class Editoria11ySettings extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'editoria11y_form_settings';
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'editoria11y.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this
      ->config('editoria11y.settings');
    $form['text'] = [
      '#markup' => '<h2>Getting started</h2><ol><li>Make sure <a href="/admin/people/permissions">user roles that edit content</a> have the "View Editoria11y" permission.</li><li>If the checker does not appear: make sure a z-indexed or overflow-hidden element in your front-end theme is not hiding or covering the <code>#ed11y-main-toggle</code> button, make sure that any custom selectors in the "Disable the scanner if these elements are detected" field are not present, and make sure that no JavaScript errors are appearing in the <a href="https://developer.mozilla.org/en-US/docs/Tools/Browser_Console">browser console</a>.</li><li>If the checker is present but never reporting errors: check that your inclusions & exclusion settings below are not missing or ignoring all content.</li></ol><p><a href="https://www.drupal.org/project/editoria11y">Project overview</a> | <a href="https://itmaybejj.github.io/editoria11y/demo/">Demo</a> | <a href="https://www.drupal.org/project/issues/editoria11y?categories=All">Issue queue</a></p><h2>Basic Configuration</h2>',
    ];
    $form['setup'] = [
      '#type' => 'fieldset',
      '#title' => t('Inclusions &amp; exclusions'),
    ];
    $form['setup']['content_root'] = [
      '#title' => $this
        ->t("Check content in this container"),
      '#type' => 'textfield',
      '#placeholder' => 'body',
      '#description' => $this
        ->t('If all editorial content is in <strong>one</strong> element (e.g., <code>main</code> or <code>#content</code>), provide that single <a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors">selector</a>.'),
      '#default_value' => $config
        ->get('content_root'),
    ];
    $form['setup']['ignore_containers'] = [
      '#title' => $this
        ->t("Skip over these elements"),
      '#type' => 'textarea',
      '#placeholder' => '#toolbar-administration, .contextual-region > nav, .search-results',
      '#description' => $this
        ->t('Provide a comma-separated list of selectors for elements to ignore, such as <code>.my-embedded-social-media-feed, #sidebar-menu</code>.'),
      '#default_value' => $config
        ->get('ignore_containers'),
    ];
    $form['setup']['no_load'] = [
      '#title' => $this
        ->t("Disable the scanner if these elements are detected"),
      '#type' => 'textarea',
      '#placeholder' => '#quickedit-entity-toolbar, #layout-builder',
      '#description' => $this
        ->t('Provided a comma-separated list of selectors unique to pages or states that should not be scanned; e.g, during inline editing  (<code>#inline-editor-open</code>) or on pages without user-editable content (<code>.node-261, .front</code>).'),
      '#default_value' => $config
        ->get('no_load'),
    ];
    $form['subhead2'] = [
      '#markup' => '<h2>Customization</h2>',
    ];
    $form['results'] = [
      '#type' => 'fieldset',
      '#title' => t('Tests'),
    ];
    $form['results']['assertiveness'] = [
      '#title' => $this
        ->t("Open the issue details panel automatically when new issues are detected"),
      '#type' => 'radios',
      '#options' => [
        'smart' => $this
          ->t('When nodes are created or changed'),
        'assertive' => $this
          ->t('Always'),
        'polite' => $this
          ->t('Never'),
      ],
      '#description' => $this
        ->t('"Always" is not recommended for sites with multiple editors.'),
      '#default_value' => $config
        ->get('assertiveness'),
    ];
    $form['results']['download_links'] = [
      '#title' => $this
        ->t("Warn that these links need manual review"),
      '#type' => 'textarea',
      '#placeholder' => "a[href\$='.pdf'], a[href*='.doc']",
      '#description' => $this
        ->t('Provide a comma-separated list of selectors for links that should have a "this file download needs a manual check" warning, e.g.: <code>[href^="/download"], .a[data-entity-substitution^="media"]</code>.'),
      '#default_value' => $config
        ->get('download_links'),
    ];
    $form['results']['embedded_content_warning'] = [
      '#title' => $this
        ->t("Warn that these embedded elements need manual review"),
      '#type' => 'textarea',
      '#description' => $this
        ->t('Provide a comma-separated list of selectors for elements with potentially complex issues, e.g.: <code>.my-embedded-feed, #my-social-link-block</code>.<br> Note that this <strong>ignores the ignore list</strong>: you are specifying that you want his element flagged.'),
      '#default_value' => $config
        ->get('embedded_content_warning'),
    ];
    $form['theme'] = [
      '#type' => 'fieldset',
      '#title' => t('Theme compatibility'),
    ];
    $form['theme']['allow_overflow'] = [
      '#title' => $this
        ->t("Force these containers to allow overflow when tips are open"),
      '#type' => 'textarea',
      '#placeholder' => 'automatic',
      '#description' => $this
        ->t('Editoria11y detects elements themed with overflow:hidden and automatically forces them to allow overflow when there is an open tip inside them. If this comma-separated list of selectors is not empty, only elements on this list will receive this override.'),
      '#default_value' => $config
        ->get('allow_overflow'),
    ];
    $form['theme']['hidden_handlers'] = [
      '#title' => $this
        ->t("Theme JS will handle revealing hidden tooltips inside these containers"),
      '#type' => 'textarea',
      '#description' => $this
        ->t('Editoria11y detects hidden tooltips and warns the user when they try to jump to them from the panel. For elements on this list, Editoria11y will <a href="https://itmaybejj.github.io/editoria11y/#dealing-with-alerts-on-hidden-or-size-constrained-content">dispatch a JS event</a> instead of a warning, so custom JS in your theme can first reveal the hidden tip (e.g., open an accordion or tab panel).'),
      '#default_value' => $config
        ->get('hidden_handlers'),
    ];
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this
      ->config('editoria11y.settings')
      ->set('ignore_containers', $form_state
      ->getValue('ignore_containers'))
      ->set('assertiveness', $form_state
      ->getValue('assertiveness'))
      ->set('no_load', $form_state
      ->getValue('no_load'))
      ->set('content_root', $form_state
      ->getValue('content_root'))
      ->set('allow_overflow', $form_state
      ->getValue('allow_overflow'))
      ->set('download_links', $form_state
      ->getValue('download_links'))
      ->set('embedded_content_warning', $form_state
      ->getValue('embedded_content_warning'))
      ->set('hidden_handlers', $form_state
      ->getValue('hidden_handlers'))
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBase::create public static function Instantiates a new instance of this class. Overrides FormBase::create 18
ConfigFormBase::__construct public function Constructs a \Drupal\system\ConfigFormBase object. 16
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
Editoria11ySettings::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
Editoria11ySettings::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
Editoria11ySettings::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
Editoria11ySettings::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
FormBase::$configFactory protected property The config factory. 3
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 3
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route.
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 72
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.