コード例 #1
0
 protected function getUpdateEvent($formData)
 {
     $changeEvent = new FeatureUpdateEvent($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;
 }
コード例 #2
0
ファイル: Feature.php プロジェクト: alex63530/thelia
 /**
  * Change a product feature
  *
  * @param \Thelia\Core\Event\Feature\FeatureUpdateEvent $event
  */
 public function update(FeatureUpdateEvent $event)
 {
     if (null !== ($feature = FeatureQuery::create()->findPk($event->getFeatureId()))) {
         $feature->setDispatcher($event->getDispatcher())->setLocale($event->getLocale())->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())->setPostscriptum($event->getPostscriptum())->save();
         $event->setFeature($feature);
     }
 }
コード例 #3
0
ファイル: FeatureTest.php プロジェクト: NandoKstroNet/thelia
 /**
  * @param FeatureModel $feature
  * @depends testCreate
  */
 public function testUpdate(FeatureModel $feature)
 {
     $event = new FeatureUpdateEvent($feature->getId());
     $event->setLocale('en_US')->setTitle('test update')->setChapo('test chapo')->setDescription('test description')->setPostscriptum('test postscriptum')->setDispatcher($this->dispatcher);
     $action = new Feature();
     $action->update($event);
     $updatedFeature = $event->getFeature();
     $this->assertInstanceOf('Thelia\\Model\\Feature', $updatedFeature);
     $this->assertEquals('test update', $updatedFeature->getTitle());
     $this->assertEquals('test chapo', $updatedFeature->getChapo());
     $this->assertEquals('test description', $updatedFeature->getDescription());
     $this->assertEquals('test postscriptum', $updatedFeature->getPostscriptum());
     $this->assertEquals('en_US', $updatedFeature->getLocale());
     return $updatedFeature;
 }
コード例 #4
0
ファイル: FeaturesImport.php プロジェクト: JumBay/ImportT1
 public function importFeatures()
 {
     $count = $errors = 0;
     $hdl = $this->t1db->query("select * from caracteristique order by classement");
     while ($hdl && ($caracteristique = $this->t1db->fetch_object($hdl))) {
         $descs = $this->t1db->query_list("select * from caracteristiquedesc where caracteristique = ? order by lang asc", array($caracteristique->id));
         $idx = 0;
         $event = new FeatureCreateEvent();
         foreach ($descs as $desc) {
             try {
                 $lang = $this->getT2Lang($desc->lang);
                 if ($idx == 0) {
                     $event->setLocale($lang->getLocale())->setTitle($desc->titre);
                     $this->dispatcher->dispatch(TheliaEvents::FEATURE_CREATE, $event);
                     // Updater position
                     $update_position_event = new UpdatePositionEvent($event->getFeature()->getId(), UpdatePositionEvent::POSITION_ABSOLUTE, $caracteristique->classement);
                     $this->dispatcher->dispatch(TheliaEvents::FEATURE_UPDATE_POSITION, $update_position_event);
                     Tlog::getInstance()->info("Created feature " . $event->getFeature()->getId() . " from {$desc->titre} ({$caracteristique->id})");
                     $this->feat_corresp->addEntry($caracteristique->id, $event->getFeature()->getId());
                 }
                 $update_event = new FeatureUpdateEvent($event->getFeature()->getId());
                 $update_event->setLocale($lang->getLocale())->setTitle($desc->titre)->setChapo($desc->chapo)->setDescription($desc->description)->setPostscriptum('');
                 $this->dispatcher->dispatch(TheliaEvents::FEATURE_UPDATE, $update_event);
                 $idx++;
             } catch (ImportException $ex) {
                 Tlog::getInstance()->addError("Failed to create Feature from {$desc->titre} ({$caracteristique->id}): ", $ex->getMessage());
                 $errors++;
             }
         }
         $count++;
     }
     return new ImportChunkResult($count, $errors);
 }