data; $processedData['context'] = []; $countryUid = (int) $data['tx_eptheme_context_country']; if ($countryUid > 0) { $processedData['context']['country'] = $this->getContextRecord($countryUid, 'tx_epproducts_domain_model_country'); } $regionUid = (int) $data['tx_eptheme_context_region']; if ($regionUid > 0) { $processedData['context']['region'] = $this->getContextRecord($regionUid, 'tx_epproducts_domain_model_region'); } if ($data['tx_eptheme_context_pacode'] ?? null) { $processedData['context']['paCode'] = $data['tx_eptheme_context_pacode']; } elseif ($paCode = $this->getPaCodeFromRequest()) { $processedData['context']['paCode'] = $paCode; } return $processedData; } /** * @return string */ private function getPaCodeFromRequest() { $currentUri = GeneralUtility::getIndpEnv('REQUEST_URI'); $query = parse_url($currentUri, \PHP_URL_QUERY); if (!$query) { return ''; } parse_str($query, $items); if (array_key_exists('pa', $items)) { return $items['pa']; } return ''; } /** * @param int $uid * @param string $table * @return array * @throws \Doctrine\DBAL\DBALException */ private function getContextRecord($uid, $table) { $qb = $this->getDbConnection()->createQueryBuilder(); $query = $qb ->select('*') ->from($table) ->where('uid = :uid') ->andWhere('deleted = 0') ->andWhere('hidden = 0') ->setParameter('uid', $uid) ; return $query->executeQuery()->fetchAssociative(); } }