Use db connection trait
This commit is contained in:
@@ -27,8 +27,8 @@ namespace EP\EpTrack\Service;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Traits\DbConnectionTrait;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\TimeTracker\NullTimeTracker;
|
||||
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
@@ -40,11 +40,15 @@ use TYPO3\CMS\Frontend\Utility\EidUtility;
|
||||
|
||||
class RequestService
|
||||
{
|
||||
use DbConnectionTrait;
|
||||
|
||||
const COOKIE_NAME = 'ep_trk';
|
||||
const COOKIE_TTL = 30;
|
||||
const CODE_PATTERN = '([a-z]{4}|PA)\d{4}.*';
|
||||
|
||||
/**
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public function handleRequest()
|
||||
{
|
||||
$currentUri = GeneralUtility::getIndpEnv('REQUEST_URI');
|
||||
@@ -55,6 +59,7 @@ class RequestService
|
||||
/**
|
||||
* @param string $currentUri
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function matchRedirect($currentUri)
|
||||
{
|
||||
@@ -117,6 +122,7 @@ class RequestService
|
||||
|
||||
/**
|
||||
* @param string $currentUri
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function matchTrackingCodeInUri($currentUri)
|
||||
{
|
||||
@@ -139,6 +145,7 @@ class RequestService
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setCookie($code)
|
||||
{
|
||||
@@ -153,7 +160,7 @@ class RequestService
|
||||
*/
|
||||
protected function redirect($uri, $responseCode = '301')
|
||||
{
|
||||
HttpUtility::redirect($uri, constant('\TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_' . $responseCode));
|
||||
HttpUtility::redirect($uri, \constant('\TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_' . $responseCode));
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -191,16 +198,4 @@ class RequestService
|
||||
PageGenerator::pagegenInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \TYPO3\CMS\Core\Database\Connection
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
protected function getDbConnection()
|
||||
{
|
||||
/** @var ConnectionPool $connectionPool */
|
||||
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
|
||||
|
||||
return $connectionPool->getConnectionByName('Default');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user