Exemplo n.º 1
0
 protected function createConfigValue($name, array $translation, $value = '')
 {
     $config = new Config();
     $config->setName($name)->setValue($value);
     foreach ($translation as $locale => $title) {
         $config->getTranslation($locale)->setTitle($title);
     }
     $config->save();
 }
Exemplo n.º 2
0
 public static function write($configName, $value, $secured = null, $hidden = null)
 {
     $config = self::create()->findOneByName($configName);
     if (null == $config) {
         $config = new Config();
         $config->setName($configName);
     }
     if ($secured !== null) {
         $config->setSecured($secured ? 1 : 0);
     }
     if ($hidden !== null) {
         $config->setHidden($hidden ? 1 : 0);
     }
     $config->setValue($value);
     $config->save();
     self::$cache[$configName] = $value;
 }
Exemplo n.º 3
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();
 }