Esempio n. 1
0
 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();
     }
 }
Esempio n. 2
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();
 }
Esempio 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();
 }
Esempio n. 4
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;
 }
 /**
  * @param Config $object
  * @return int
  */
 protected function getObjectId($object)
 {
     return $object->getId();
 }
Esempio n. 6
0
 /**
  * @param ConfigModel $config
  * @depends testModify
  */
 public function testDelete(ConfigModel $config)
 {
     $event = new ConfigDeleteEvent($config->getId());
     $event->setDispatcher($this->dispatcher);
     $action = new Config();
     $action->delete($event);
     $deletedConfig = $event->getConfig();
     $this->assertInstanceOf('Thelia\\Model\\Config', $deletedConfig);
     $this->assertTrue($deletedConfig->isDeleted());
 }
Esempio n. 7
0
 /**
  * Create a new configuration entry
  *
  * @param \Thelia\Core\Event\Config\ConfigCreateEvent $event
  * @param $eventName
  * @param EventDispatcherInterface $dispatcher
  */
 public function create(ConfigCreateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $config = new ConfigModel();
     $config->setDispatcher($dispatcher)->setName($event->getEventName())->setValue($event->getValue())->setLocale($event->getLocale())->setTitle($event->getTitle())->setHidden($event->getHidden())->setSecured($event->getSecured())->save();
     $event->setConfig($config);
 }
Esempio n. 8
0
 /**
  * Declares an association between this object and a ChildConfig object.
  *
  * @param                  ChildConfig $v
  * @return                 \Thelia\Model\ConfigI18n The current object (for fluent API support)
  * @throws PropelException
  */
 public function setConfig(ChildConfig $v = null)
 {
     if ($v === null) {
         $this->setId(NULL);
     } else {
         $this->setId($v->getId());
     }
     $this->aConfig = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ChildConfig object, it will not be re-added.
     if ($v !== null) {
         $v->addConfigI18n($this);
     }
     return $this;
 }
Esempio n. 9
0
 /**
  * Exclude object from result
  *
  * @param   ChildConfig $config Object to remove from the list of results
  *
  * @return ChildConfigQuery The current query, for fluid interface
  */
 public function prune($config = null)
 {
     if ($config) {
         $this->addUsingAlias(ConfigTableMap::ID, $config->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Esempio n. 10
0
 /**
  * Filter the query by a related \Thelia\Model\Config object
  *
  * @param \Thelia\Model\Config|ObjectCollection $config The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildConfigI18nQuery The current query, for fluid interface
  */
 public function filterByConfig($config, $comparison = null)
 {
     if ($config instanceof \Thelia\Model\Config) {
         return $this->addUsingAlias(ConfigI18nTableMap::ID, $config->getId(), $comparison);
     } elseif ($config instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(ConfigI18nTableMap::ID, $config->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByConfig() only accepts arguments of type \\Thelia\\Model\\Config or Collection');
     }
 }