Yassine Doghri 94872f2338 feat(ui): create ViewComponents library to enable building class and view files components
- replace some helper components and forms with class components in the ui
- create viewcomponents
service and load the component function to be used in views
2021-12-29 11:54:22 +00:00

37 lines
781 B
PHP

<?php
declare(strict_types=1);
namespace ViewComponents;
class Component implements ComponentInterface
{
/**
* @var array<string, string>
*/
protected array $attributes = [
'class' => '',
];
/**
* @param array<string, mixed> $properties
* @param array<string, string> $attributes
*/
public function __construct(
protected array $properties,
array $attributes
) {
// overwrite default properties if set
foreach ($properties as $key => $value) {
$this->{$key} = $value;
}
$this->attributes = array_merge($this->attributes, $attributes);
}
public function render(): string
{
return static::class . ': RENDER METHOD NOT IMPLEMENTED';
}
}