1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Chromabits\Nucleus\View\Composite;
13:
14: use Chromabits\Nucleus\Support\Html;
15: use Chromabits\Nucleus\View\Common\Button;
16: use Chromabits\Nucleus\View\Common\Italic;
17: use Chromabits\Nucleus\View\Interfaces\RenderableInterface;
18: use Chromabits\Nucleus\View\Interfaces\SafeHtmlProducerInterface;
19: use Chromabits\Nucleus\View\SafeHtmlWrapper;
20:
21: 22: 23: 24: 25: 26:
27: class IconButton implements RenderableInterface, SafeHtmlProducerInterface
28: {
29: 30: 31:
32: protected $attributes;
33:
34: 35: 36:
37: protected $content;
38:
39: 40: 41:
42: protected $icon;
43:
44: 45: 46: 47: 48:
49: public function __construct($icon, $content = '', $attributes = [])
50: {
51: $this->icon = $icon;
52: $this->content = $content;
53: $this->attributes = $attributes;
54: }
55:
56: 57: 58: 59: 60:
61: public function render()
62: {
63: return (new Button($this->attributes, [
64: new Italic(['class' => 'icon ' . $this->icon]),
65: $this->content,
66: ]))->render();
67: }
68:
69: 70: 71: 72: 73:
74: public function getSafeHtml()
75: {
76: return Html::safe($this->render());
77: }
78: }
79: