You are here

class BlockAriaLandmarkRoles in Block ARIA Landmark Roles 8

Helper class for ARIA landmark roles.

Hierarchy

Expanded class hierarchy of BlockAriaLandmarkRoles

2 files declare their use of BlockAriaLandmarkRoles
BlockAriaLandmarkRolesTest.php in tests/src/Unit/BlockAriaLandmarkRolesTest.php
block_aria_landmark_roles.module in ./block_aria_landmark_roles.module
Add ARIA landmark roles to Drupal blocks.

File

src/BlockAriaLandmarkRoles.php, line 8

Namespace

Drupal\block_aria_landmark_roles
View source
class BlockAriaLandmarkRoles {

  /**
   * An array of ARIA landmark roles.
   *
   * @var array
   */
  private $roles = [
    'application',
    'banner',
    'complementary',
    'contentinfo',
    'form',
    'main',
    'navigation',
    'search',
  ];

  /**
   * Get the defined ARIA roles.
   *
   * @return array
   *   An indexed array of roles.
   */
  public static function get() {
    return (new static())->roles;
  }

  /**
   * Get the defined ARIA roles as an associative array.
   *
   * @return array
   *   An associative array of roles.
   */
  public static function getAssociative() {
    $self = new static();
    return array_combine($self->roles, $self->roles);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlockAriaLandmarkRoles::$roles private property An array of ARIA landmark roles.
BlockAriaLandmarkRoles::get public static function Get the defined ARIA roles.
BlockAriaLandmarkRoles::getAssociative public static function Get the defined ARIA roles as an associative array.