Commit 90410114 authored by Stefan Galinski's avatar Stefan Galinski

Merge branch 'feature_UpgradeTo9LTS' into 'master'

Feature upgrade to9 lts

See merge request !8
parents 64ce687f 3e31f528
......@@ -29,13 +29,21 @@ namespace SGalinski\SgRoutes\Controller;
use SGalinski\SgRoutes\Domain\Model\Category;
use SGalinski\SgRoutes\Domain\Model\PageNotFoundHandling;
use SGalinski\SgRoutes\Domain\Model\Route;
use SGalinski\SgRoutes\Domain\Repository\CategoryRepository;
use SGalinski\SgRoutes\Domain\Repository\LogRepository;
use SGalinski\SgRoutes\Domain\Repository\PageNotFoundHandlingRepository;
use SGalinski\SgRoutes\Domain\Repository\RouteRepository;
use SGalinski\SgRoutes\Service\LicensingService;
use SGalinski\SgRoutes\Service\RoutingService;
use TYPO3\CMS\Backend\Clipboard\Clipboard;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -84,29 +92,64 @@ class RouteController extends ActionController {
private $docHeaderComponent;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\RouteRepository
* @inject
* @var RouteRepository
*/
private $routeRepository;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\CategoryRepository
* @inject
* Inject the RouteRepository
*
* @param RouteRepository $routeRepository
*/
public function injectRouteRepository(RouteRepository $routeRepository) {
$this->routeRepository = $routeRepository;
}
/**
* @var CategoryRepository
*/
private $categoryRepository;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\LogRepository
* @inject
* Inject the CategoryRepository
*
* @param CategoryRepository $categoryRepository
*/
public function injectCategoryRepository(CategoryRepository $categoryRepository) {
$this->categoryRepository = $categoryRepository;
}
/**
* @var LogRepository
*
*/
private $logRepository;
/**
* @var \SGalinski\SgRoutes\Domain\Repository\PageNotFoundHandlingRepository
* @inject
* Inject the LogRepository
*
* @param LogRepository $logRepository
*/
public function injectLogRepository(LogRepository $logRepository) {
$this->logRepository = $logRepository;
}
/**
* @var PageNotFoundHandlingRepository
*
*/
private $pageNotFoundHandlingRepository;
/**
* Inject the PageNotFoundHandlingRepository
*
* @param PageNotFoundHandlingRepository $pageNotFoundHandlingRepository
*/
public function injectPageNotFoundHandlingRepository(PageNotFoundHandlingRepository $pageNotFoundHandlingRepository
) {
$this->pageNotFoundHandlingRepository = $pageNotFoundHandlingRepository;
}
/**
* Initialize action for all actions
*
......@@ -150,20 +193,37 @@ class RouteController extends ActionController {
$this->view->assign('typo3Version', VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version));
if (!$this->rootPageUid) {
$rootOptionRows = (array) BackendUtility::getRecordsByField('pages', 'is_siteroot', 1, '', '', 'sorting');
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class))
->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$rootOptionRows = $queryBuilder->select('*')
->from('pages')
->where(
$queryBuilder->expr()->andX(
$queryBuilder->expr()->eq(
'sys_language_uid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
),
$queryBuilder->expr()->eq(
'is_siteroot', $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT)
)
)
)->orderBy('sorting')->execute()->fetchAll();
$rootOptions = [];
foreach ($rootOptionRows as $row) {
$pageInfo = BackendUtility::readPageAccess($row['uid'], $GLOBALS['BE_USER']->getPagePermsClause(1));
if ($pageInfo) {
$rootline = BackendUtility::BEgetRootLine($pageInfo['uid'], '', TRUE);
ksort($rootline);
\ksort($rootline);
$path = '/root';
foreach ($rootline as $page) {
$path .= '/p' . dechex($page['uid']);
$path .= '/p' . \dechex($page['uid']);
}
$pageInfo['path'] = $path;
$pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 1);
$pageInfo['_thePathFull'] = substr($pageInfo['_thePathFull'], 0, -1);
$pageInfo['_thePathFull'] = \substr($pageInfo['_thePathFull'], 1);
$pageInfo['_thePathFull'] = \substr($pageInfo['_thePathFull'], 0, -1);
$rootOptions[] = $pageInfo;
}
}
......@@ -254,7 +314,11 @@ class RouteController extends ActionController {
// Refresh
$refreshButton = $buttonBar->makeLinkButton()
->setHref(GeneralUtility::getIndpEnv('REQUEST_URI'))
->setTitle(LocalizationUtility::translate('LLL:EXT:lang/locallang_core.xlf:labels.reload', ''))
->setTitle(
LocalizationUtility::translate(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'
)
)
->setIcon($iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
$buttonBar->addButton($refreshButton, ButtonBar::BUTTON_POSITION_RIGHT);
......@@ -306,15 +370,17 @@ class RouteController extends ActionController {
*
* @param array $filters
* @return void
* @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Core\Exception
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
*/
public function htaccessAction(array $filters = []) {
if (LicensingService::checkKey()) {
/** @var array $routes */
$routes = $this->routeRepository->findRoutes($this->rootPageUid, $filters, TRUE);
$data = RoutingService::getHtaccessEntries($routes);
$routingService = GeneralUtility::makeInstance(RoutingService::class);
$data = $routingService->getHtaccessEntries($routes);
$this->view->assign('data', $data);
}
......@@ -342,6 +408,7 @@ class RouteController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
public function pageNotFoundHandlingAction() {
if ($this->rootPageUid) {
......@@ -350,16 +417,32 @@ class RouteController extends ActionController {
/** @var PageNotFoundHandling $handling */
$handling = $this->pageNotFoundHandlingRepository->findOneByPid($this->rootPageUid);
$tableName = 'tx_sgroutes_domain_model_pagenotfoundhandling';
$returnUrl = BackendUtility::getModuleUrl('web_SgRoutesRoute', ['id' => $pageUid]);
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$returnUrl = $uriBuilder->buildUriFromRoute('web_SgRoutesRoute', ['id' => $pageUid]);
if ($handling) {
$editUri = BackendUtility::getModuleUrl('record_edit') .
'&edit[' . $tableName . '][' . $handling->getUid() . ']=edit';
$editUri = $uriBuilder->buildUriFromRoute(
'record_edit', [
'edit' => [
$tableName => [
$handling->getUid() => 'edit'
]
],
'returnUrl' => (string) $returnUrl
]
);
} else {
$editUri = BackendUtility::getModuleUrl('record_edit') .
'&edit[' . $tableName . '][' . $this->rootPageUid . ']=new';
$editUri = $uriBuilder->buildUriFromRoute(
'record_edit', [
'edit' => [
$tableName => [
$this->rootPageUid => 'new'
]
],
'returnUrl' => (string) $returnUrl
]
);
}
$editUri .= '&returnUrl=' . rawurlencode($returnUrl);
header('Location: ' . $editUri, TRUE);
\header('Location: ' . $editUri, TRUE);
exit();
}
}
......@@ -394,7 +477,7 @@ class RouteController extends ActionController {
foreach ($propertyColumns as $propertyName => $columnName) {
$label = isset($GLOBALS['TCA']['tx_sgroutes_domain_model_route']['columns'][$columnName]) ?
$GLOBALS['TCA']['tx_sgroutes_domain_model_route']['columns'][$columnName]['label'] : '';
if (strpos($label, 'LLL:') === 0) {
if (\strpos($label, 'LLL:') === 0) {
$label = $GLOBALS['LANG']->sL($label);
}
$export[0][] = $label ?: $propertyName;
......@@ -405,8 +488,8 @@ class RouteController extends ActionController {
foreach ($routes as $route) {
foreach ($propertyColumns as $propertyName => $columnName) {
$value = $route->_getProperty($propertyName);
if (in_array($propertyName, $dateFields, TRUE)) {
$export[$line][] = $value ? date('d.m.Y', $value) : '';
if (\in_array($propertyName, $dateFields, TRUE)) {
$export[$line][] = $value ? \date('d.m.Y', $value) : '';
} elseif ($propertyName === 'categories') {
$categoryString = '';
if ($value) {
......@@ -433,13 +516,13 @@ class RouteController extends ActionController {
foreach ($line as $field) {
$fields[] = '"' . $field . '"';
}
$exportString .= implode(',', $fields) . ';' . LF;
$exportString .= \implode(',', $fields) . ';' . LF;
}
}
header('Content-Type: application/force-download');
header('Content-Transfer-Encoding: Binary');
header('Content-Disposition: attachment; filename="export.csv"');
header('Content-Length: ' . strlen($exportString));
\header('Content-Type: application/force-download');
\header('Content-Transfer-Encoding: Binary');
\header('Content-Disposition: attachment; filename="export.csv"');
\header('Content-Length: ' . \strlen($exportString));
echo $exportString;
exit(0);
}
......@@ -450,7 +533,7 @@ class RouteController extends ActionController {
* @throws \InvalidArgumentException
*/
public function initClipboard() {
if (is_array($this->clipboardCommandArray)) {
if (\is_array($this->clipboardCommandArray)) {
$clipObj = GeneralUtility::makeInstance(Clipboard::class);
$clipObj->initializeClipboard();
if ($this->clipboardCommandArray['paste']) {
......
......@@ -69,14 +69,14 @@ class RouteRepository extends Repository {
$constraints = [];
if (isset($filters['categories']) && is_array($filters['categories']) && count($filters['categories'])) {
if (isset($filters['categories']) && \is_array($filters['categories']) && \count($filters['categories'])) {
$categoryConstraints = [];
foreach ($filters['categories'] as $category) {
if ((int) $category) {
$categoryConstraints[] = $query->contains('categories', $category);
}
}
if (count($categoryConstraints)) {
if (\count($categoryConstraints)) {
$constraints[] = $query->logicalOr($categoryConstraints);
}
}
......@@ -91,9 +91,9 @@ class RouteRepository extends Repository {
$constraints[] = $query->logicalOr($searchConstraints);
}
if (count($constraints) > 1) {
if (\count($constraints) > 1) {
$query->matching($query->logicalAnd($constraints));
} elseif (count($constraints)) {
} elseif (\count($constraints)) {
$query->matching($constraints[0]);
}
......
<?php
namespace SGalinski\SgRoutes\Middleware;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* Resolver for generating frontend links
*
* @package SGalinski\SgRoutes\Middleware
* @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
*/
class FrontendLinkResolver implements MiddlewareInterface {
/**
* Process an incoming server request.
*
* Processes an incoming server request in order to produce a response.
* If unable to produce the response itself, it may delegate to the provided
* request handler to do so.
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
$queryParams = $request->getQueryParams();
if (!isset($queryParams['tx_sgroutes_frontendlink'])) {
return $handler->handle($request);
}
$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$response = new Response();
$response->getBody()
->write(
$contentObjectRenderer->typoLink(
'',
[
'parameter' => $queryParams['tx_sgroutes_frontendlink']['destination_url'],
'returnLast' => 'url'
]
)
);
return $response;
}
}
<?php
namespace SGalinski\SgRoutes\Middleware;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use SGalinski\SgRoutes\Service\LicensingService;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\ErrorController;
use TYPO3\CMS\Frontend\Page\PageAccessFailureReasons;
use TYPO3\CMS\Frontend\Page\PageRepository;
/**
* Middleware resolver class for the sg_routes
*
* @package SGalinski\SgRoutes\Middleware
* @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
*/
class RedirectResolver implements MiddlewareInterface {
const URL_WIZARD_ID = 't3://page?uid=';
/**
* Process an incoming server request.
*
* Processes an incoming server request in order to produce a response.
* If unable to produce the response itself, it may delegate to the provided
* request handler to do so.
*
* @param ServerRequestInterface $request
* @param RequestHandlerInterface $handler
* @return ResponseInterface
* @throws \TYPO3\CMS\Core\Error\Http\PageNotFoundException
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
$start = \microtime(TRUE);
$uri = $request->getUri();
$requestParameters = $request->getQueryParams();
$requestParameterPageId = NULL;
$filteredRequestParameters = [];
foreach ($requestParameters as $key => $splittedParameter) {
if ($key === 'id') {
continue;
}
$filteredRequestParameters[$key] = $splittedParameter;
}
$requestParameters = $filteredRequestParameters;
$uri = $uri->withQuery('');
$rootUid = $request->getAttribute('site')->getRootPageId();
if ($rootUid) {
if ($GLOBALS['TYPO3_CONF_VARS']['FE']['tx_routes_executed'][$rootUid]) {
// already redirected the route to $rootUid, proceed with page loading
return $handler->handle($request);
}
$GLOBALS['TYPO3_CONF_VARS']['FE']['tx_routes_executed'][$rootUid] = TRUE;
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_sgroutes_domain_model_route');
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
$resultArray = $queryBuilder->select(
'uid',
'pid',
'use_regular_expression',
'source_url',
'source_url_case_sensitive',
'destination_url',
'redirect_url_parameters',
'redirect_code',
'description')
->from('tx_sgroutes_domain_model_route')
->where(
$queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($rootUid, \PDO::PARAM_INT))
)
->orderBy('sorting')
->execute()->fetchAll();
if ($resultArray) {
foreach ($resultArray as $redirect) {
if ($redirect['source_url'] === '' || $redirect['destination_url'] === '') {
continue;
}
if ($redirect['use_regular_expression'] && LicensingService::checkKey()) {
$pattern = '/' . \str_replace('/', '\\/', $redirect['source_url']) . '/is';
if ($redirect['redirect_url_parameters']) {
$uri = $uri->withQuery($request->getUri()->getQuery());
} elseif (!empty($requestParameters)) {
$uri = $uri->withQuery(GeneralUtility::implodeArrayForUrl('', $requestParameters));
}
if (\preg_match($pattern, \rawurldecode($uri))) {
$redirectUri = \preg_replace(
$pattern, $redirect['destination_url'], \rawurldecode($uri)
);
$this->logRedirect(
$redirect, \rawurldecode($uri), $redirectUri, $start, \microtime(TRUE)
);
return new RedirectResponse($redirectUri, $redirect['redirect_code']);
}
} else {
$sourceUrl = new Uri($redirect['source_url']);
$uri = $uri->withPath(\trim($uri->getPath(), '/'));
$sourceUrl = $sourceUrl->withPath(\trim($sourceUrl->getPath()));
if ($sourceUrl->getHost() === '') {
$uri = $uri->withHost('')->withScheme(NULL);
}
if (
(
(bool)$redirect['source_url_case_sensitive'] &&
(string) $uri === (string) $sourceUrl
) ||
(
!(bool)$redirect['source_url_case_sensitive'] &&
\mb_strtolower($uri) === \mb_strtolower($sourceUrl)
)
) {
$destinationUrl = $redirect['destination_url'];
if (\strpos($destinationUrl, self::URL_WIZARD_ID) === 0) {
$destinationUrl = (int) \substr($destinationUrl, 14);
}
if (\is_numeric($destinationUrl)) {
$GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance(PageRepository::class);
$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class, $GLOBALS['TSFE']);
$redirectUri = $contentObjectRenderer->typoLink_URL([
'parameter' => $destinationUrl,
'additionalParams' => '&' . \implode('&', $requestParameters)
]);
if ($redirectUri === '') {
// the page either does not exist or isn't accessible, drop out
return GeneralUtility::makeInstance(ErrorController::class)->pageNotFoundAction(
$request,
'The page with id #' . $destinationUrl . ' could not be found!',
['code' => PageAccessFailureReasons::PAGE_NOT_FOUND]
);
} else {
$this->logRedirect(
$redirect, \rawurldecode($uri), $redirectUri, $start, \microtime(TRUE)
);
return new RedirectResponse($redirectUri, $redirect['redirect_code']);
}
}
}
}
}
}
}
return $handler->handle($request);
}
/**
* @param array $routeRow
* @param string $requestUri
* @param string $redirectUri
* @param float $start
* @param float $end
* @return void
* @throws \InvalidArgumentException
*/
private function logRedirect($routeRow, $requestUri, $redirectUri, $start, $end): void {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_sgroutes_domain_model_log');
$queryBuilder->getRestrictions()->removeAll();
$categories = $queryBuilder->select('c.title')
->from('tx_sgroutes_domain_model_category', 'c')
->innerJoin('c', 'tx_sgroutes_domain_model_route_category', 'mm', 'c.uid = mm.uid_foreign')
->where(
$queryBuilder->expr()->eq('mm.uid_local', $queryBuilder->createNamedParameter($routeRow['uid'], \PDO::PARAM_INT))
)
->orderBy('mm.sorting')
->execute()->fetchAll();
$insertRow = [
'pid' => $routeRow['pid'],
'use_regular_expression' => $routeRow['use_regular_expression'],
'source_url' => $routeRow['source_url'],
'destination_url' => $routeRow['destination_url'],
'redirect_url_parameters' => $routeRow['redirect_url_parameters'],
'redirect_code' => $routeRow['redirect_code'],
'description' => $routeRow['description'],
'categories' => '',
'request_url' => $requestUri,
'redirect_url' => $redirectUri,
'execution_duration' => 1000 * ($end - $start),
'crdate' => $GLOBALS['EXEC_TIME'],
];
if ($categories) {
/** @var array $category */
foreach ($categories as $i => $category) {
if ($insertRow['categories'] !== '') {
$insertRow['categories'] .= ', ';
}
$insertRow['categories'] .= $category['category_title'];
}
}
$queryBuilder->resetQueryParts();
$queryBuilder->insert('tx_sgroutes_domain_model_log')
->values($insertRow)
->execute();
}
}
......@@ -28,7 +28,9 @@ namespace SGalinski\SgRoutes\Service;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SGalinski\SgRoutes\Utility\ExtensionUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Http\NullResponse;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -54,9 +56,9 @@ class LicensingService {
public static function checkKey(): bool {
if (static::$isLicenseKeyValid === NULL) {
static::$isLicenseKeyValid = FALSE;
$configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]);
if (isset($configuration['key']) && $key = trim($configuration['key'])) {
static::$isLicenseKeyValid = (bool) preg_match('/^([A-Z\d]{6}-?){4}$/', $key);
$configuration = ExtensionUtility::getExtensionConfiguration();
if (isset($configuration['key']) && $key = \trim($configuration['key'])) {
static::$isLicenseKeyValid = (bool) \preg_match('/^([A-Z\d]{6}-?){4}$/', $key);
}
}
......@@ -71,19 +73,19 @@ class LicensingService {
*/
public static function ping($returnUrl = FALSE): string {
try {
$configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::EXTENSION_KEY], [FALSE]);
$configuration = ExtensionUtility::getExtensionConfiguration();
$key = '';
if (isset($configuration['key'])) {
$key = trim($configuration['key']);
$key = \trim($configuration['key']);
}
$params = [
'extension' => self::EXTENSION_KEY,
'host' => GeneralUtility::getIndpEnv('HTTP_HOST'),
'key' => $key
];
$params = http_build_query($params);
$params = \http_build_query($params);
$pingUrl = self::URL;
$pingUrl .= $params !== '' ? (strpos($pingUrl, '?') === FALSE ? '?' : '&') . $params : '';
$pingUrl .= $params !== '' ? (\strpos($pingUrl, '?') === FALSE ? '?' : '&') . $params : '';
if ($returnUrl) {
return $pingUrl;
}
......@@ -103,13 +105,16 @@ class LicensingService {
* @return ResponseInterface
* @throws \InvalidArgumentException
*/
public function ajaxPing(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface {
public function ajaxPing(ServerRequestInterface $request, ResponseInterface $response = NULL): ResponseInterface {
/** @var BackendUserAuthentication $backendUser */
$backendUser = $GLOBALS['BE_USER'];
if ($backendUser && !$backendUser->getModuleData('tools_beuser/index.php/web_SgRoutesRoute_pinged', 'ses')) {
$backendUser->pushModuleData('tools_beuser/index.php/web_SgRoutesRoute_pinged', TRUE);
self::ping();
}
if ($response === NULL) {
$response = new NullResponse();
}
return $response;
}
}
This diff is collapsed.
<?php
namespace SGalinski\SgRoutes\Utility;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
/**
* Class ExtensionUtility
*
* @package SGalinski\SgRoutes\Utility