ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
Bulky.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
4 /* Copyright (c) 2017 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
5 
7 
8 use ILIAS\UI\Component as C;
10 
14 class Bulky extends Button implements C\Button\Bulky
15 {
16  // allowed ARIA roles
17  public const MENUITEM = 'menuitem';
18 
22  protected $icon_or_glyph;
23 
27  protected $aria_role;
28 
32  protected static $allowed_aria_roles = array(
33  self::MENUITEM
34  );
35 
36  public function __construct(Symbol $icon_or_glyph, string $label, string $action)
37  {
38  $this->icon_or_glyph = $icon_or_glyph;
39  $this->label = $label;
40  $this->action = $action;
41  }
42 
46  public function getIconOrGlyph()
47  {
48  return $this->icon_or_glyph;
49  }
50 
54  public function withAriaRole(string $aria_role) : Button
55  {
56  $this->checkArgIsElement(
57  "role",
58  $aria_role,
59  self::$allowed_aria_roles,
60  implode('/', self::$allowed_aria_roles)
61  );
62  $clone = clone $this;
63  $clone->aria_role = $aria_role;
64  return $clone;
65  }
66 
70  public function getAriaRole() : ?string
71  {
72  return $this->aria_role;
73  }
74 }
This describes a symbol.
Definition: Symbol.php:11
checkArgIsElement($which, $value, $array, $name)
Throw an InvalidArgumentException if $value is not an element of array.
__construct(Symbol $icon_or_glyph, string $label, string $action)
Definition: Bulky.php:36
getAriaRole()
Get the ARIA role on the button.
Definition: Bulky.php:70
withAriaRole(string $aria_role)
Get a button like this, but with an additional ARIA role.
Definition: Bulky.php:54