コード例 #1
0
ファイル: ConfigTest.php プロジェクト: NandoKstroNet/thelia
 /**
  * @param ConfigModel $config
  * @depends testSetValue
  */
 public function testModify(ConfigModel $config)
 {
     $event = new ConfigUpdateEvent($config->getId());
     $event->setEventName('foo')->setValue('update baz')->setLocale('en_US')->setTitle('config title')->setDescription('config description')->setChapo('config chapo')->setPostscriptum('config postscriptum')->setHidden(0)->setSecured(0)->setDispatcher($this->dispatcher);
     $action = new Config();
     $action->modify($event);
     $updatedConfig = $event->getConfig();
     $this->assertInstanceOf('Thelia\\Model\\Config', $updatedConfig);
     $this->assertEquals('foo', $updatedConfig->getName());
     $this->assertEquals('update baz', $updatedConfig->getValue());
     $this->assertEquals('en_US', $updatedConfig->getLocale());
     $this->assertEquals('config title', $updatedConfig->getTitle());
     $this->assertEquals('config description', $updatedConfig->getDescription());
     $this->assertEquals('config chapo', $updatedConfig->getChapo());
     $this->assertEquals('config postscriptum', $updatedConfig->getPostscriptum());
     $this->assertEquals(0, $updatedConfig->getHidden());
     $this->assertEquals(0, $updatedConfig->getSecured());
     return $updatedConfig;
 }
コード例 #2
0
ファイル: ConfigController.php プロジェクト: alex63530/thelia
 /**
  * Change values modified directly from the variable list
  *
  * @return Thelia\Core\HttpFoundation\Response the response
  */
 public function changeValuesAction()
 {
     // Check current user authorization
     if (null !== ($response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE))) {
         return $response;
     }
     $variables = $this->getRequest()->get('variable', array());
     // Process all changed variables
     foreach ($variables as $id => $value) {
         $event = new ConfigUpdateEvent($id);
         $event->setValue($value);
         $this->dispatch(TheliaEvents::CONFIG_SETVALUE, $event);
     }
     return $this->generateRedirectFromRoute('admin.configuration.variables.default');
 }
コード例 #3
0
ファイル: Config.php プロジェクト: vigourouxjulien/thelia
 /**
  * Change a configuration entry
  *
  * @param \Thelia\Core\Event\Config\ConfigUpdateEvent $event
  * @param $eventName
  * @param EventDispatcherInterface $dispatcher
  */
 public function modify(ConfigUpdateEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
         $config->setDispatcher($dispatcher)->setName($event->getEventName())->setValue($event->getValue())->setHidden($event->getHidden())->setSecured($event->getSecured())->setLocale($event->getLocale())->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())->setPostscriptum($event->getPostscriptum())->save();
         $event->setConfig($config);
     }
 }