Example #1
0
 /**
  * @param string $styleMapId
  * @param string $styleId
  * @return bool
  * @throws \Symfony\Component\Config\Definition\Exception\Exception
  */
 public function removeStyle($styleMapId, $styleId)
 {
     $styleMap = $this->getById($styleMapId);
     if ($styleMap) {
         $style = $this->styleManager->getById($styleId);
         if (!$style) {
             throw new Exception('Der Style kann nicht gelöscht werden. Er gehört nicht zu der Stylemap.');
         }
         $style->removeStyleMapById($styleMapId);
         $styleMap->removeStyleById($styleId);
         $this->styleManager->save($style);
         return $this->save($styleMap) ? true : false;
     }
     return false;
 }
Example #2
0
 public function testSaveStyleWorkflow()
 {
     /**@var StyleMap $styleMap */
     /**@var Style $style */
     list($style, $styleMap) = $this->getMockUpStyleMap();
     $this->styleMapManager->save($styleMap);
     try {
         $this->styleMapManager->addStyle($styleMap->getId(), $style->getId());
     } catch (Exception $exception) {
         self::assertNotNull($exception);
     }
     $style = $this->styleManager->save($style);
     $wasSaved = $this->styleMapManager->addStyle($styleMap->getId(), $style->getId());
     self::assertTrue($wasSaved);
     $wasRemoved = $this->styleMapManager->removeStyle($styleMap->getId(), $style->getId());
     self::assertTrue($wasRemoved);
     try {
         $this->styleMapManager->removeStyle($styleMap->getId(), $style->getId());
     } catch (Exception $exception) {
         self::assertNotNull($exception);
     }
 }