Skip to content
Snippets Groups Projects
Icon.php 596 B
Newer Older
  • Learn to ignore specific revisions
  • use ViewComponents\Component;
    
    class Icon extends Component
    {
        public string $glyph = '';
    
        public function render(): string
        {
    
            try {
                $svgContents = file_get_contents('assets/icons/' . $this->glyph . '.svg');
            } catch (Exception) {
                return '□';
            }
    
            if ($this->attributes['class'] !== '') {
                $svgContents = str_replace('<svg', '<svg class="' . $this->attributes['class'] . '"', $svgContents);