public function postActivation(ConnectionInterface $con = null) { if (null === ConfigQuery::read(static::RESOURCE_PATH_CONFIG_NAME)) { $config = new Config(); $config->setHidden(0)->setSecured(0)->setName(static::RESOURCE_PATH_CONFIG_NAME)->setValue(__DIR__ . DS . "Resources")->getTranslation("fr_FR")->setTitle("Chemin de templates pour Thelia studio")->getConfig()->getTranslation("en_US")->setTitle("Templates path for Thelia studio"); $config->save(); } }
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(); }
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; }
/** * 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(); }