Exemple #1
0
 /**
  * Creates the shortcut icon for an existing icon.
  *
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceIcon $icon
  *
  * @return \Claroline\CoreBundle\Entity\Resource\ResourceIcon
  *
  * @throws \RuntimeException
  */
 public function createShortcutIcon(ResourceIcon $icon, Workspace $workspace = null)
 {
     $this->om->startFlushSuite();
     $ds = DIRECTORY_SEPARATOR;
     try {
         $originalIconLocation = "{$this->rootDir}{$ds}..{$ds}web{$ds}{$icon->getRelativeUrl()}";
         $shortcutLocation = $this->creator->shortcutThumbnail($originalIconLocation, $workspace);
     } catch (\Exception $e) {
         $shortcutLocation = "{$this->rootDir}{$ds}.." . "{$ds}web{$ds}bundles{$ds}clarolinecore{$ds}images{$ds}resources{$ds}icons{$ds}shortcut-default.png";
     }
     $shortcutIcon = $this->om->factory('Claroline\\CoreBundle\\Entity\\Resource\\ResourceIcon');
     if (strstr($shortcutLocation, "bundles")) {
         $tmpRelativeUrl = strstr($shortcutLocation, "bundles");
     } else {
         $tmpRelativeUrl = strstr($shortcutLocation, $this->basepath);
     }
     $relativeUrl = str_replace('\\', '/', $tmpRelativeUrl);
     $shortcutIcon->setRelativeUrl($relativeUrl);
     $shortcutIcon->setMimeType($icon->getMimeType());
     $shortcutIcon->setShortcut(true);
     $icon->setShortcutIcon($shortcutIcon);
     $shortcutIcon->setShortcutIcon($shortcutIcon);
     $this->om->persist($icon);
     $this->om->persist($shortcutIcon);
     $this->om->endFlushSuite();
     return $shortcutIcon;
 }
Exemple #2
0
 /**
  * Creates the shortcut icon for an existing icon.
  *
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceIcon $icon
  *
  * @return \Claroline\CoreBundle\Entity\Resource\ResourceIcon
  *
  * @throws \RuntimeException
  */
 public function createShortcutIcon(ResourceIcon $icon, Workspace $workspace = null)
 {
     $this->om->startFlushSuite();
     $relativeUrl = $this->createShortcutFromRelativeUrl($icon->getRelativeUrl(), $workspace);
     $shortcutIcon = new ResourceIcon();
     $shortcutIcon->setRelativeUrl($relativeUrl);
     $shortcutIcon->setMimeType($icon->getMimeType());
     $shortcutIcon->setShortcut(true);
     $icon->setShortcutIcon($shortcutIcon);
     $shortcutIcon->setShortcutIcon($shortcutIcon);
     $this->om->persist($icon);
     $this->om->persist($shortcutIcon);
     $this->om->endFlushSuite();
     return $shortcutIcon;
 }