Beispiel #1
0
 protected function createOrUpdate(CustomerTitleEvent $event, CustomerTitleModel $customerTitle)
 {
     $con = Propel::getConnection(CustomerTitleTableMap::DATABASE_NAME);
     $con->beginTransaction();
     $i18n = $customerTitle->getTranslation($event->getLocale(), $con);
     try {
         $i18n->setShort($event->getShort())->setLong($event->getLong());
         $customerTitle->save($con);
         if ($event->isDefault()) {
             $customerTitle->toggleDefault($con);
             $event->setDefault(false);
         }
         $con->commit();
     } catch (\Exception $e) {
         $con->rollBack();
         throw $e;
     }
     $event->setCustomerTitle($customerTitle);
 }
Beispiel #2
0
 /**
  * @param array $data
  * @return CustomerTitleEvent
  *
  * Handler to create the customer title event
  */
 protected function createEvent(array &$data)
 {
     $event = new CustomerTitleEvent();
     if (isset($data["default"])) {
         $event->setDefault($data["default"]);
     }
     if (isset($data["title_id"])) {
         $event->setCustomerTitle(CustomerTitleQuery::create()->findPk($data["title_id"]));
     }
     if (isset($data["i18n"]) && !empty($data["i18n"])) {
         $row = array_shift($data["i18n"]);
         $this->hydrateEvent($row, $event);
     }
     return $event;
 }