/** * Wrapper for \Cx\Core\Routing\Url::fromApi() * This ensures correct param order * @param string $adapterName (Json)Data adapter name * @param string $adapterMethod (Json)Data method name * @param array $params (optional) params for (Json)Data method call * @return \Cx\Core\Routing\Url URL for (Json)Data call */ protected function getUrlFromApi($adapterName, $adapterMethod, $params) { if (isset($_GET['preview'])) { $params['theme'] = intval($_GET['preview']); } $url = \Cx\Core\Routing\Url::fromApi('Data', array('Plain', $adapterName, $adapterMethod), $params); // make sure params are in correct order: $correctIndexOrder = array('page', 'lang', 'user', 'theme', 'country', 'currency'); $params = $url->getParamArray(); uksort($params, function ($a, $b) use($correctIndexOrder) { return array_search($a, $correctIndexOrder) - array_search($b, $correctIndexOrder); }); $url->setParams($params); $url->setParam('EOU', ''); return $url; }
/** * End caching functions. Check for a sessionId: if not set, write pagecontent to a file. */ public function endContrexxCaching($page, $endcode) { // TODO: $dynVars needs to be built dynamically $this->dynVars = array('GEO' => array('country_code' => \Cx\Core\Routing\Url::fromApi('Data', array('Plain', 'GeoIp', 'getCountryCode'))->toString())); // back-replace ESI variables that are url encoded foreach ($this->dynVars as $groupName => $vars) { foreach ($vars as $varName => $url) { $esiPlaceholder = '$(' . $groupName . '{\'' . $varName . '\'})'; $endcode = str_replace(urlencode($esiPlaceholder), $esiPlaceholder, $endcode); } } $cx = \Cx\Core\Core\Controller\Cx::instanciate(); if ($page && $page->getModule() == 'Error' || !$this->boolIsEnabled || session_id() != '' && \FWUser::getFWUserObject()->objUser->login() || $cx->getComponent('Uploader')->isActive()) { return $this->internalEsiParsing($endcode); } // write header cache file $resolver = \Env::get('Resolver'); $headers = $resolver->getHeaders(); $this->writeCacheFileForRequest($page, $headers, $endcode); return $this->internalEsiParsing($endcode); }