Debian Codegraph @

vendor/ipl/web/src/Widget/ActionBar.php

raw
1 <?php
2
3 namespace ipl\Web\Widget;
4
5 use ipl\Html\Attributes;
6 use ipl\Html\BaseHtmlElement;
7 use ipl\Web\Common\BaseTarget;
8 use ipl\Web\Url;
9
10 /**
11 * Action bar element for displaying a list of links
12 */
13 class ActionBar extends BaseHtmlElement
14 {
15 use BaseTarget;
16
17 protected $contentSeparator = ' ';
18
19 protected $defaultAttributes = [
20 'class' => 'action-bar',
21 'data-base-target' => '_self'
22 ];
23
24 protected $tag = 'div';
25
26 /**
27 * Create a action bar
28 *
29 * @param Attributes|array $attributes
30 */
31 public function __construct($attributes = null)
32 {
33 $this->getAttributes()->add($attributes);
34 }
35
36 /**
37 * Add a link to the action bar
38 *
39 * @param mixed $content
40 * @param Url|string $url
41 * @param string $icon
42 *
43 * @return $this
44 */
45 public function addLink($content, $url, $icon = null)
46 {
47 $this->add(new ActionLink($content, $url, $icon));
48
49 return $this;
50 }
51 }