summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/web/src/Widget/ActionBar.php
blob: bf3184507d794a58b1f9433cb34be2a2dea0cc39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

namespace ipl\Web\Widget;

use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Web\Common\BaseTarget;
use ipl\Web\Url;

/**
 * Action bar element for displaying a list of links
 */
class ActionBar extends BaseHtmlElement
{
    use BaseTarget;

    protected $contentSeparator = ' ';

    protected $defaultAttributes = [
        'class'            => 'action-bar',
        'data-base-target' => '_self'
    ];

    protected $tag = 'div';

    /**
     * Create a action bar
     *
     * @param Attributes|array $attributes
     */
    public function __construct($attributes = null)
    {
        $this->getAttributes()->add($attributes);
    }

    /**
     * Add a link to the action bar
     *
     * @param mixed      $content
     * @param Url|string $url
     * @param string     $icon
     *
     * @return $this
     */
    public function addLink($content, $url, $icon = null)
    {
        $this->add(new ActionLink($content, $url, $icon));

        return $this;
    }
}