/**
* Get a 16x16 pixel resized icon of the passed image if it exists, return the default icon otherwise.
*
* @param string $icon The icon to resize.
*
* @param string $defaultIcon The default icon.
*
* @return string
*/
public function getBackendIcon($icon, $defaultIcon = 'system/modules/metamodels/assets/images/icons/metamodels.png')
{
$dispatcher = $this->getDispatcher();
$realIcon = ToolboxFile::convertValueToPath($icon);
// Determine image to use.
if ($realIcon && file_exists(TL_ROOT . '/' . $realIcon)) {
$event = new ResizeImageEvent($realIcon, 16, 16);
$dispatcher->dispatch(ContaoEvents::IMAGE_RESIZE, $event);
return $event->getResultImage();
}
return $defaultIcon;
}