コード例 #1
0
 /**
  * PHPDOC
  *
  * @param NelioABExperiment $exp  PHPDOC
  * @param object            $json PHPDOC
  *
  * @return NelioABAltExpGoal PHPDOC
  *
  * @since PHPDOC
  */
 public static function decode_from_appengine($exp, $json)
 {
     $result = new NelioABAltExpGoal($exp);
     $result->set_id($json->key->id);
     $result->set_name($json->name);
     $result->set_benefit($json->benefit);
     $result->set_as_main_goal($json->isMainGoal);
     $ae_actions = array();
     if (isset($json->pageAccessedActions)) {
         foreach ($json->pageAccessedActions as $action) {
             $action = (array) $action;
             $action['_type'] = 'page-accessed-action';
             $action = (object) $action;
             array_push($ae_actions, $action);
         }
     }
     if (isset($json->formActions)) {
         foreach ($json->formActions as $action) {
             $action = (array) $action;
             $action['_type'] = 'form-action';
             $action = (object) $action;
             array_push($ae_actions, $action);
         }
     }
     if (isset($json->clickActions)) {
         foreach ($json->clickActions as $action) {
             $action = (array) $action;
             $action['_type'] = 'click-element-action';
             $action = (object) $action;
             array_push($ae_actions, $action);
         }
     }
     if (isset($json->orderCompletedActions)) {
         foreach ($json->orderCompletedActions as $action) {
             $action = (array) $action;
             $action['_type'] = 'order-completed-action';
             $action = (object) $action;
             array_push($ae_actions, $action);
         }
     }
     usort($ae_actions, array('NelioABAltExpGoal', 'sort_goals'));
     foreach ($ae_actions as $action) {
         /** @var object $action */
         switch ($action->_type) {
             case 'page-accessed-action':
                 $result->add_action(NelioABPageAccessedAction::decode_from_appengine($action));
                 break;
             case 'form-action':
                 $result->add_action(NelioABFormSubmissionAction::decode_from_appengine($action));
                 break;
             case 'click-element-action':
                 $result->add_action(NelioABClickElementAction::decode_from_appengine($action));
                 break;
             case 'order-completed-action':
                 $result->add_action(NelioABWooCommerceOrderCompletedAction::decode_from_appengine($action));
                 break;
         }
     }
     return $result;
 }