Flarum\Extension\Extension::getIcon PHP Method

getIcon() public method

Loads the icon information from the composer.json.
public getIcon ( ) : array | null
return array | null
    public function getIcon()
    {
        if ($icon = $this->composerJsonAttribute('extra.flarum-extension.icon')) {
            if ($file = Arr::get($icon, 'image')) {
                $file = $this->path . '/' . $file;
                if (file_exists($file)) {
                    $mimetype = pathinfo($file, PATHINFO_EXTENSION) === 'svg' ? 'image/svg+xml' : finfo_file(finfo_open(FILEINFO_MIME_TYPE), $file);
                    $data = file_get_contents($file);
                    $icon['backgroundImage'] = 'url(\'data:' . $mimetype . ';base64,' . base64_encode($data) . '\')';
                }
            }
            return $icon;
        }
    }