Beispiel #1
0
 /**
  * Create and save the id of the pop-in images folder if necessary.
  *
  * @throws \Exception
  * @throws PropelException
  */
 protected function createPopInImageFolder()
 {
     $imageFolderIdConfig = ConfigQuery::create()->findOneByName(static::CONF_KEY_IMAGE_FOLDER_ID);
     if (null !== $imageFolderIdConfig && null !== FolderQuery::create()->findPk($imageFolderIdConfig->getValue())) {
         // we already have and know our images folder
         return;
     }
     Propel::getConnection()->beginTransaction();
     try {
         // create the folder
         $folder = new Folder();
         $folder->setVisible(true);
         /** @var Lang $lang */
         foreach (LangQuery::create()->find() as $lang) {
             $localizedTitle = Translator::getInstance()->trans("Pop-in images", [], static::MESSAGE_DOMAIN_BO, $lang->getLocale(), false);
             if ($localizedTitle == "") {
                 continue;
             }
             $folder->setLocale($lang->getLocale())->setTitle($localizedTitle);
         }
         $folder->save();
         // save the folder id in configuration
         if ($folder->getId() !== null) {
             $config = new Config();
             $config->setName(static::CONF_KEY_IMAGE_FOLDER_ID)->setValue($folder->getId())->setHidden(false);
             /** @var Lang $lang */
             foreach (LangQuery::create()->find() as $lang) {
                 $localizedTitle = Translator::getInstance()->trans("Pop-in images folder id", [], static::MESSAGE_DOMAIN_BO, $lang->getLocale(), false);
                 if ($localizedTitle == "") {
                     continue;
                 }
                 $config->setLocale($lang->getLocale())->setTitle($localizedTitle);
             }
             $config->save();
         }
     } catch (\Exception $e) {
         Propel::getConnection()->rollBack();
         throw $e;
     }
     Propel::getConnection()->commit();
 }
Beispiel #2
0
 /**
  * generates a folder and its contents to be used in Position tests
  *
  * @return Folder the parent folder
  */
 protected function getFolderForPositionTest()
 {
     if (null === self::$folderForPositionTest) {
         $folder = new Folder();
         $folder->setParent(0);
         $folder->setVisible(1);
         $folder->setPosition(1);
         $this->setI18n($folder);
         $folder->save();
         for ($i = 0; $i < 4; $i++) {
             $content = new \Thelia\Model\Content();
             $content->addFolder($folder);
             $content->setVisible(1);
             $content->setPosition($i + 1);
             $this->setI18n($content);
             $contentFolders = $content->getContentFolders();
             $collection = new Collection();
             $collection->prepend($contentFolders[0]->setDefaultFolder(1));
             $content->setContentFolders($collection);
             $content->save();
         }
         self::$folderForPositionTest = $folder;
     }
     return self::$folderForPositionTest;
 }
Beispiel #3
0
 /**
  * generates a folder and its sub folders to be used in Position tests
  *
  * @return int the parent folder id
  */
 protected function getFolderIdForPositionTest()
 {
     if (null === self::$folderIdForPositionTest) {
         $folder = new FolderModel();
         $folder->setParent(0);
         $folder->setVisible(1);
         $folder->setPosition(1);
         $this->setI18n($folder);
         $folder->save();
         for ($i = 0; $i < 4; $i++) {
             $subFolder = new FolderModel();
             $subFolder->setParent($folder->getId());
             $subFolder->setVisible(1);
             $subFolder->setPosition($i + 1);
             $this->setI18n($subFolder);
             $subFolder->save();
         }
         self::$folderIdForPositionTest = $folder->getId();
     }
     return self::$folderIdForPositionTest;
 }
Beispiel #4
0
 /**
  * generates a folder and its contents to be used in Position tests
  *
  * @return Folder the parent folder
  */
 protected function getFolderForPositionTest()
 {
     if (null === self::$folderForPositionTest) {
         $folder = new Folder();
         $folder->setParent(0);
         $folder->setVisible(1);
         $folder->setPosition(1);
         $this->setI18n($folder);
         $folder->save();
         for ($i = 0; $i < 4; $i++) {
             $content = new ContentModel();
             $content->setVisible(1);
             $content->addFolder($folder);
             $this->setI18n($content);
             $content->save();
         }
         self::$folderForPositionTest = $folder;
     }
     return self::$folderForPositionTest;
 }