1 <?php
2
3 /*
4 * This file is part of the Brickrouge package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Brickrouge;
13
14 /**
15 * A `<BUTTON>` element.
16 */
17 class Button extends Element
18 {
19 /**
20 * The element is created with the type "button" and an union of the provided attributes and
21 * the following values:
22 *
23 * - `type`: "button"
24 * - {@link INNER_HTML}: The translated and escaped label. The label is translated with the "button" scope.
25 *
26 * @param string $label Label of the button (inner text).
27 * @param array $attributes Optional attributes used to create the element.
28 */
29 public function __construct($label, array $attributes=array())
30 {
31 parent::__construct
32 (
33 'button', $attributes + array
34 (
35 'type' => 'button',
36
37 self::INNER_HTML => escape(t($label, array(), array('scope' => 'button')))
38 )
39 );
40 }
41
42 /**
43 * Adds the `btn` class name.
44 *
45 * @see Brickrouge.Element::alter_class_names()
46 */
47 protected function alter_class_names(array $class_names)
48 {
49 return parent::alter_class_names($class_names) + array
50 (
51 'btn' => true
52 );
53 }
54 }