protected function getUpdateEvent($formData)
 {
     $changeEvent = new FeatureAvUpdateEvent($formData['id']);
     // Create and dispatch the change event
     $changeEvent->setLocale($formData["locale"])->setTitle($formData['title'])->setChapo($formData['chapo'])->setDescription($formData['description'])->setPostscriptum($formData['postscriptum']);
     return $changeEvent;
 }
Exemple #2
0
 /**
  * Change a product feature
  *
  * @param FeatureAvUpdateEvent $event
  */
 public function update(FeatureAvUpdateEvent $event)
 {
     if (null !== ($feature = FeatureAvQuery::create()->findPk($event->getFeatureAvId()))) {
         $feature->setDispatcher($event->getDispatcher())->setLocale($event->getLocale())->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())->setPostscriptum($event->getPostscriptum())->save();
         $event->setFeatureAv($feature);
     }
 }
 /**
  * Process the features values (fix it in future version to integrate it in the feature form as a collection)
  *
  * @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction()
  */
 protected function performAdditionalUpdateAction($updateEvent)
 {
     $attr_values = $this->getRequest()->get('feature_values', null);
     if ($attr_values !== null) {
         foreach ($attr_values as $id => $value) {
             $event = new FeatureAvUpdateEvent($id);
             $event->setTitle($value);
             $event->setLocale($this->getCurrentEditionLocale());
             $this->dispatch(TheliaEvents::FEATURE_AV_UPDATE, $event);
         }
     }
     return null;
 }
Exemple #4
0
 /**
  * @param FeatureAvModel $featureAv
  * @depends testCreate
  */
 public function testUpdate(FeatureAvModel $featureAv)
 {
     $event = new FeatureAvUpdateEvent($featureAv->getId());
     $event->setLocale('en_uS')->setTitle('test update')->setDescription('test description')->setChapo('test chapo')->setPostscriptum('test postscriptum')->setDispatcher($this->dispatcher);
     $action = new FeatureAv();
     $action->update($event);
     $updatedFeatureAv = $event->getFeatureAv();
     $this->assertInstanceOf('Thelia\\Model\\FeatureAv', $updatedFeatureAv);
     $this->assertEquals('en_US', $updatedFeatureAv->getLocale());
     $this->assertEquals('test update', $updatedFeatureAv->getTitle());
     $this->assertEquals('test chapo', $updatedFeatureAv->getChapo());
     $this->assertEquals('test description', $updatedFeatureAv->getDescription());
     $this->assertEquals('test postscriptum', $updatedFeatureAv->getPostscriptum());
     return $updatedFeatureAv;
 }
Exemple #5
0
 public function importFeaturesAv()
 {
     $count = $errors = 0;
     $hdl = $this->t1db->query("select * from caracdisp");
     while ($hdl && ($caracdisp = $this->t1db->fetch_object($hdl))) {
         $descs = $this->t1db->query_list("select * from caracdispdesc where caracdisp = ? order by lang asc", array($caracdisp->id));
         $idx = 0;
         $event = new FeatureAvCreateEvent();
         foreach ($descs as $desc) {
             try {
                 $lang = $this->getT2Lang($desc->lang);
                 $feature_id = $this->feat_corresp->getT2($caracdisp->caracteristique);
                 if ($idx == 0) {
                     $event->setFeatureId($feature_id)->setLocale($lang->getLocale())->setTitle($desc->titre);
                     $this->dispatcher->dispatch(TheliaEvents::FEATURE_AV_CREATE, $event);
                     // Updater position
                     $update_position_event = new UpdatePositionEvent($event->getFeatureAv()->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, $desc->classement);
                     $this->dispatcher->dispatch(TheliaEvents::FEATURE_AV_UPDATE_POSITION, $update_position_event);
                     $this->feat_av_corresp->addEntry($caracdisp->id, $event->getFeatureAv()->getId());
                 }
                 $update_event = new FeatureAvUpdateEvent($event->getFeatureAv()->getId());
                 $update_event->setFeatureId($feature_id)->setLocale($lang->getLocale())->setTitle($desc->titre)->setChapo('')->setDescription('')->setPostscriptum('');
                 $this->dispatcher->dispatch(TheliaEvents::FEATURE_AV_UPDATE, $update_event);
                 $idx++;
             } catch (\Exception $ex) {
                 Tlog::getInstance()->addError("Failed to import Feature Av: ", $ex->getMessage());
                 $errors++;
             }
             $count++;
         }
     }
     return new ImportChunkResult($count, $errors);
 }