/**
  * Update a Journey
  * @trigger updateJourney.pre, updateJourney.post
  * @param JourneyEntity $objJourney
  * @return \FrontCommsAdmin\Entities\FrontJourneysEntity
  */
 public function updateJourney(FrontJourneysEntity $objJourney)
 {
     //trigger the pre event
     $result = $this->getEventManager()->trigger(__FUNCTION__ . ".pre", $this, array("objJourney" => $objJourney));
     //create the request object
     $objApiRequest = $this->getApiRequestModel();
     //setup the object and specify the action
     $objApiRequest->setApiAction($objJourney->getHyperMedia("edit-journey")->url);
     $objApiRequest->setApiModule(NULL);
     //extract data
     $arr_data = $objJourney->getArrayCopy();
     //manipulate date to valid format
     if ($arr_data["date_expiry"] != "") {
         $objDate = \DateTime::createFromFormat('d M Y', $arr_data["date_expiry"]);
         $arr_data["date_expiry"] = $objDate->format('c');
     }
     //end if
     //execute
     $objJourney = $objApiRequest->performPUTRequest($arr_data)->getBody();
     //recreate the journey entity
     $objJourney = $this->createJourneyEntity($objJourney->data);
     //trigger the post event
     $result = $this->getEventManager()->trigger(__FUNCTION__ . ".post", $this, array("objJourney" => $objJourney));
     //clear cache
     $this->getJourneysCacheManager()->clearCacheItem("journeys");
     return $objJourney;
 }
 /**
  * Update a Journey
  * @trigger updateJourney.pre, updateJourney.post
  * @param JourneyEntity $objJourney
  * @return \FrontCommsAdmin\Entities\FrontJourneysEntity
  */
 public function updateJourney(FrontJourneysEntity $objJourney)
 {
     //trigger the pre event
     $result = $this->getEventManager()->trigger(__FUNCTION__ . ".pre", $this, array("objJourney" => $objJourney));
     //create the request object
     $objApiRequest = $this->getApiRequestModel();
     //setup the object and specify the action
     $objApiRequest->setApiAction($objJourney->getHyperMedia("edit-journey")->url);
     $objApiRequest->setApiModule(NULL);
     //extract data
     $arr_data = $objJourney->getArrayCopy();
     if ($arr_data['date_expiry'] == '0000-00-00') {
         $arr_data['date_expiry'] = '';
     }
     //end if
     //manipulate date to valid format
     if ($arr_data["date_expiry"] != "") {
         $objDate = \DateTime::createFromFormat('d M Y', $arr_data["date_expiry"]);
         if (!$objDate || !is_object($objDate)) {
             throw new \Exception(__CLASS__ . " : Line " . __LINE__ . " : An error occurred setting the expiry date", 500);
         }
         //end if
         $arr_data["date_expiry"] = $objDate->format('c');
     }
     //end if
     //interim work around for campaigns not being available on forms or status journey statuses
     if (!isset($arr_data['fk_campaign_id'])) {
         $arr_data['fk_campaign_id'] = '';
     }
     //end if
     //execute
     $objJourney = $objApiRequest->performPUTRequest($arr_data)->getBody();
     //recreate the journey entity
     $objJourney = $this->createJourneyEntity($objJourney->data);
     //trigger the post event
     $result = $this->getEventManager()->trigger(__FUNCTION__ . ".post", $this, array("objJourney" => $objJourney));
     //clear cache
     $this->getJourneysCacheManager()->clearCacheItem("journeys");
     return $objJourney;
 }