/** * Loads the experiment from AppEngine. * * @param int $id the ID of the experiment we want to retrieve. * @param int $type the type of the experiment we want to retrieve. * * @return NelioABExperiment the experiment whose ID is `$id` and whose type is `$type`. * Note that the result will be an instance of * a concrete subclass of `NelioABExperiment`. * * @throws Exception `EXPERIMENT_ID_NOT_FOUND` * This exception is thrown if the experiment was not * found in AppEngine. * * @see NelioABExperiment::load * * @since 3.4.0 */ private static function load_experiment_by_id($id, $type) { require_once NELIOAB_MODELS_DIR . '/goals/goals-manager.php'; /** @var NelioABExperiment $exp */ switch ($type) { case NelioABExperiment::POST_ALT_EXP: case NelioABExperiment::PAGE_ALT_EXP: case NelioABExperiment::PAGE_OR_POST_ALT_EXP: case NelioABExperiment::CPT_ALT_EXP: $exp = NelioABPostAlternativeExperiment::load($id); break; case NelioABExperiment::HEADLINE_ALT_EXP: $exp = NelioABHeadlineAlternativeExperiment::load($id); break; case NelioABExperiment::WC_PRODUCT_SUMMARY_ALT_EXP: $exp = NelioABProductSummaryAlternativeExperiment::load($id); break; case NelioABExperiment::THEME_ALT_EXP: $exp = NelioABThemeAlternativeExperiment::load($id); break; case NelioABExperiment::CSS_ALT_EXP: $exp = NelioABCssAlternativeExperiment::load($id); break; case NelioABExperiment::WIDGET_ALT_EXP: $exp = NelioABWidgetAlternativeExperiment::load($id); break; case NelioABExperiment::MENU_ALT_EXP: $exp = NelioABMenuAlternativeExperiment::load($id); break; case NelioABExperiment::HEATMAP_EXP: $exp = NelioABHeatmapExperiment::load($id); break; default: $err = NelioABErrCodes::EXPERIMENT_ID_NOT_FOUND; throw new Exception(NelioABErrCodes::to_string($err), $err); } $exp->mark_as_fully_loaded(); return $exp; }