Added:
- toolbar refactor
This commit is contained in:
37
src/Manager/Toolbar/Element/AbstractToolbarElement.php
Normal file
37
src/Manager/Toolbar/Element/AbstractToolbarElement.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Manager\Toolbar\Element;
|
||||
|
||||
abstract class AbstractToolbarElement implements ToolbarElement
|
||||
{
|
||||
protected string $icon;
|
||||
protected string|array $text;
|
||||
protected string $action;
|
||||
|
||||
public function __construct(string $icon, string|array $text, string $action)
|
||||
{
|
||||
$this->icon = $icon;
|
||||
$this->text = $text;
|
||||
$this->action = $action;
|
||||
}
|
||||
|
||||
public function getIcon(): string
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
public function getText(): string|array
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function getAction(): string
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function getAdditionalProperties(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
14
src/Manager/Toolbar/Element/ToolbarButton.php
Normal file
14
src/Manager/Toolbar/Element/ToolbarButton.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Manager\Toolbar\Element;
|
||||
|
||||
use App\Manager\Toolbar\Element\AbstractToolbarElement;
|
||||
|
||||
class ToolbarButton extends AbstractToolbarElement
|
||||
{
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return 'button';
|
||||
}
|
||||
}
|
||||
15
src/Manager/Toolbar/Element/ToolbarDivider.php
Normal file
15
src/Manager/Toolbar/Element/ToolbarDivider.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Manager\Toolbar\Element;
|
||||
|
||||
class ToolbarDivider extends AbstractToolbarElement
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('divider', '', '');
|
||||
}
|
||||
public function getType(): string
|
||||
{
|
||||
return 'divider';
|
||||
}
|
||||
}
|
||||
24
src/Manager/Toolbar/Element/ToolbarDropdown.php
Normal file
24
src/Manager/Toolbar/Element/ToolbarDropdown.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Manager\Toolbar\Element;
|
||||
|
||||
class ToolbarDropdown extends AbstractToolbarElement
|
||||
{
|
||||
private array $items;
|
||||
|
||||
public function __construct(string $icon, string $text, string $action, array $items)
|
||||
{
|
||||
parent::__construct($icon, $text, $action);
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
public function getType(): string
|
||||
{
|
||||
return 'dropdown';
|
||||
}
|
||||
|
||||
public function getAdditionalProperties(): array
|
||||
{
|
||||
return ['items' => $this->items];
|
||||
}
|
||||
}
|
||||
12
src/Manager/Toolbar/Element/ToolbarElement.php
Normal file
12
src/Manager/Toolbar/Element/ToolbarElement.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Manager\Toolbar\Element;
|
||||
|
||||
interface ToolbarElement
|
||||
{
|
||||
public function getIcon(): string;
|
||||
public function getText(): string|array;
|
||||
public function getAction(): string;
|
||||
public function getType(): string;
|
||||
public function getAdditionalProperties(): array;
|
||||
}
|
||||
Reference in New Issue
Block a user