mirror of
https://code.castopod.org/adaures/castopod
synced 2025-05-13 01:35:47 +00:00

- 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
28 lines
573 B
PHP
28 lines
573 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\View\Components;
|
|
|
|
use ViewComponents\Component;
|
|
|
|
class Icon extends Component
|
|
{
|
|
public string $glyph = '';
|
|
|
|
public function render(): string
|
|
{
|
|
$svgContents = file_get_contents('assets/icons/' . $this->glyph . '.svg');
|
|
|
|
if ($svgContents) {
|
|
if ($this->attributes['class'] !== '') {
|
|
$svgContents = str_replace('<svg', '<svg class="' . $this->attributes['class'] . '"', $svgContents);
|
|
}
|
|
|
|
return $svgContents;
|
|
}
|
|
|
|
return '□';
|
|
}
|
|
}
|