Exemple #1
0
 /**
  * Replace a node icon.
  *
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $resource
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceIcon $icon
  *
  * @return \Claroline\CoreBundle\Entity\Resource\ResourceNode
  */
 public function replace(ResourceNode $resource, ResourceIcon $icon)
 {
     $this->om->startFlushSuite();
     $oldIcon = $resource->getIcon();
     if (!$oldIcon->isShortcut()) {
         $oldShortcutIcon = $oldIcon->getShortcutIcon();
         $shortcutIcon = $icon->getShortcutIcon();
         if (!is_null($oldShortcutIcon) && !is_null($shortcutIcon)) {
             $nodes = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findBy(array('icon' => $oldShortcutIcon));
             foreach ($nodes as $node) {
                 $node->setIcon($shortcutIcon);
                 $this->om->persist($node);
             }
         }
     }
     $this->delete($oldIcon);
     $resource->setIcon($icon);
     $this->om->persist($resource);
     $this->om->endFlushSuite();
     return $resource;
 }
Exemple #2
0
 public function refresh(ResourceIcon $icon)
 {
     $shortcut = $icon->getShortcutIcon();
     $newUrl = $this->createShortcutFromRelativeUrl($icon->getRelativeUrl());
     $shortcut->setRelativeUrl($newUrl);
     $this->om->persist($shortcut);
     $this->om->flush();
 }