PartKeepr\MimetypeIconsBundle\Services\MimetypeIconService::getMimetypeIcon PHP Method

getMimetypeIcon() public method

Returns the file path to an image file which represents the passed mimetype.
public getMimetypeIcon ( string $mimetype ) : string
$mimetype string The mimetype
return string A path to the mimetype icon
    public function getMimetypeIcon($mimetype)
    {
        $file = str_replace('/', '-', $mimetype) . '.svg';
        $iconDirectory = $this->container->getParameter('partkeepr.directories.mimetype_icons');
        $fileLocator = new FileLocator($iconDirectory);
        try {
            $iconFile = $fileLocator->locate($file);
        } catch (\InvalidArgumentException $e) {
            $file = 'empty.svg';
            $iconFile = $fileLocator->locate($file);
        }
        return $iconFile;
    }