Implement passing of tracking codes across domains
This commit is contained in:
@@ -27,7 +27,10 @@ namespace EP\EpTheme\DataProcessing;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Service\ResellerDataService;
|
||||
use EP\EpProducts\Traits\DbConnectionTrait;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
|
||||
|
||||
@@ -59,9 +62,69 @@ class ContextProcessor implements DataProcessorInterface
|
||||
if ($regionUid > 0) {
|
||||
$processedData['context']['region'] = $this->getContextRecord($regionUid, 'tx_epproducts_domain_model_region');
|
||||
}
|
||||
$resellerData = $this->getResellerData();
|
||||
if ($resellerData) {
|
||||
$processedData['context']['paCode'] = $resellerData['paCode'];
|
||||
} elseif ($paCode = $this->getPaCodeFromRequest()) {
|
||||
$processedData['context']['paCode'] = $paCode;
|
||||
} elseif ($cookieData = $this->getCookieData()) {
|
||||
$processedData['context']['paCode'] = $cookieData;
|
||||
}
|
||||
|
||||
return $processedData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|bool
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
private function getResellerData()
|
||||
{
|
||||
/** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
|
||||
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
|
||||
/** @var ResellerDataService $resellerService */
|
||||
$resellerService = $objectManager->get(ResellerDataService::class);
|
||||
return $resellerService->getResellerForCurrentDomain();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)) {
|
||||
$paCode = $items['pa'];
|
||||
$expiratonDate = new \DateTime('now');
|
||||
$expiratonDate->add(new \DateInterval('P' . '30D'));
|
||||
setcookie('ep_trk', $paCode, $expiratonDate->getTimestamp(), '/');
|
||||
|
||||
return $paCode;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getCookieData()
|
||||
{
|
||||
if ($_COOKIE['ep_trk']) {
|
||||
return $_COOKIE['ep_trk'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid
|
||||
* @param string $table
|
||||
|
||||
Reference in New Issue
Block a user