public function getInitcmsAdminIconPath(\Sonata\AdminBundle\Admin\AdminInterface $admin, $size = 'small', $active = false)
{
$state = $active ? '_active' : '';
$imagePath = '/bundles/networkinginitcms/img/icons/icon_blank_' . $size . $state . '.png';
$bundleGuesser = $this->getService('networking_init_cms.helper.bundle_guesser');
$bundleGuesser->initialize($admin);
$bundleName = $bundleGuesser->getBundleShortName();
/** @var $kernel \AppKernel */
$kernel = $this->getService('kernel');
$bundles = $kernel->getBundle($bundleName, false);
$bundle = end($bundles);
$path = $bundle->getPath();
$slug = self::slugify($admin->getLabel());
$iconName = 'icon_' . $slug . '_' . $size . $state;
$folders = array('img/icons', 'image/icons', 'img', 'image');
$imageType = array('gif', 'png', 'jpg', 'jpeg');
foreach ($folders as $folder) {
foreach ($imageType as $type) {
$icon = $folder . DIRECTORY_SEPARATOR . $iconName . '.' . $type;
if (file_exists($path . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . $icon)) {
$imagePath = 'bundles' . DIRECTORY_SEPARATOR . str_replace('bundle', '', strtolower($bundleName)) . DIRECTORY_SEPARATOR . $icon;
}
}
}
return $imagePath;
}