Skip to content

Commit f80a5ba

Browse files
authored
Merge pull request #53 from comwrap/update-9.5
2 parents 18d6971 + dca7760 commit f80a5ba

23 files changed

Lines changed: 303 additions & 211 deletions

.php_cs.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ return PhpCsFixer\Config::create()
44
->setRules([
55
'@PSR2' => true,
66
'array_syntax' => [
7-
'syntax' => 'long',
7+
'syntax' => 'short',
88
],
99
'binary_operator_spaces' => true,
1010
'concat_space' => [

.styleci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ enabled:
77
- function_typehint_space
88
- hash_to_slash_comment
99
- linebreak_after_opening_tag
10-
- long_array_syntax
1110
- lowercase_cast
1211
- method_separation
1312
- native_function_casing
@@ -43,6 +42,7 @@ enabled:
4342
- phpdoc_scalar
4443
- phpdoc_types
4544
- self_accessor
45+
- short_array_syntax
4646
- short_scalar_cast
4747
- single_quote
4848
- standardize_not_equals

.travis.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ before_install:
2323
- phpenv config-rm xdebug.ini
2424

2525
install:
26-
- composer require typo3/cms=$TYPO3_VERSION
26+
- composer require typo3/minimal=$TYPO3_VERSION
2727
- export TYPO3_PATH_WEB="$PWD/.Build/Web"
2828

2929
script:
@@ -48,6 +48,9 @@ script:
4848
jobs:
4949
fast_finish: true
5050
include:
51+
- stage: test
52+
php: 7.2
53+
env: TYPO3_VERSION=^9.5
5154
- stage: test
5255
php: 7.2
5356
env: TYPO3_VERSION=^8.7
@@ -57,27 +60,6 @@ jobs:
5760
- stage: test
5861
php: 7.0
5962
env: TYPO3_VERSION=^8.7
60-
- stage: test
61-
php: 7.2
62-
env: TYPO3_VERSION="^7.6"
63-
- stage: test
64-
php: 7.1
65-
env: TYPO3_VERSION="^7.6"
66-
- stage: test
67-
php: 7.0
68-
env: TYPO3_VERSION="^7.6"
69-
- stage: test
70-
php: 5.6
71-
env: TYPO3_VERSION=^7.6
72-
- stage: test
73-
php: 5.5
74-
env: TYPO3_VERSION=^7.6
75-
- stage: test
76-
php: 5.6
77-
env: TYPO3_VERSION=^6.2
78-
- stage: test
79-
php: 5.5
80-
env: TYPO3_VERSION=^6.2
8163

8264
- stage: 🚢 to TER
8365
if: tag IS present

Classes/Configuration/RecordRenderingConfigurationBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ public function configurationFor($extensionName, $pluginName, $contextRecord = '
4545
list($tableName, $uid) = $this->resolveTableNameAndUidFromContextString($contextRecord);
4646
$pluginSignature = $this->buildPluginSignature($extensionName, $pluginName);
4747
$renderingPath = $this->resolveRenderingPath($pluginSignature);
48-
return array(
48+
return [
4949
'record' => $tableName . '_' . $uid,
5050
'path' => $renderingPath,
51-
);
51+
];
5252
}
5353

5454
/**
@@ -68,11 +68,11 @@ protected function resolveTableNameAndUidFromContextString($contextRecord)
6868
}
6969

7070
if ($contextRecord === 'currentPage') {
71-
$tableNameAndUid = array('pages', $this->renderingContext->getFrontendController()->id);
71+
$tableNameAndUid = ['pages', $this->renderingContext->getFrontendController()->id];
7272
} else {
7373
$tableNameAndUid = explode(':', $contextRecord);
7474
if (count($tableNameAndUid) !== 2 || empty($tableNameAndUid[0]) || empty($tableNameAndUid[1]) || !MathUtility::canBeInterpretedAsInteger($tableNameAndUid[1])) {
75-
$tableNameAndUid = array('pages', $this->renderingContext->getFrontendController()->id);
75+
$tableNameAndUid = ['pages', $this->renderingContext->getFrontendController()->id];
7676
}
7777
}
7878
// TODO: maybe check if the record is available
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
namespace Helhum\TyposcriptRendering\Middleware;
3+
4+
/*
5+
* This file is part of the TypoScript Rendering TYPO3 extension.
6+
*
7+
* It is free software; you can redistribute it and/or modify it under
8+
* the terms of the GNU General Public License, either version 2
9+
* of the License, or any later version.
10+
*
11+
* For the full copyright and license information, please read
12+
* LICENSE file that was distributed with this source code.
13+
*
14+
*/
15+
16+
use Psr\Http\Message\ResponseInterface;
17+
use Psr\Http\Message\ServerRequestInterface;
18+
use Psr\Http\Server\MiddlewareInterface;
19+
use Psr\Http\Server\RequestHandlerInterface;
20+
use TYPO3\CMS\Core\Exception;
21+
use TYPO3\CMS\Core\Http\Response;
22+
use TYPO3\CMS\Core\Utility\GeneralUtility;
23+
24+
/**
25+
* Lightweight alternative to regular frontend requests based at typoscript_rendering extensions; used when $_GET[tx_typoscriptrendering] is set.
26+
*/
27+
class TypoScriptRenderingHandler implements MiddlewareInterface
28+
{
29+
/**
30+
* Dispatches the request to the corresponding typoscript_rendering configuration
31+
*
32+
* @param ServerRequestInterface $request
33+
* @param RequestHandlerInterface $handler
34+
* @throws Exception
35+
* @return ResponseInterface
36+
*/
37+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
38+
{
39+
$TsRendering = $request->getParsedBody()['tx_typoscriptrendering'] ?? $request->getQueryParams()['tx_typoscriptrendering'] ?? null;
40+
41+
if ($TsRendering === null) {
42+
return $handler->handle($request);
43+
}
44+
45+
// Remove any output produced until now
46+
ob_clean();
47+
48+
//prepare and return final output
49+
if ($GLOBALS['TSFE']->isINTincScript()) {
50+
$GLOBALS['TSFE']->INTincScript();
51+
}
52+
53+
$response = GeneralUtility::makeInstance(Response::class);
54+
55+
$response->getBody()->write($GLOBALS['TSFE']->content);
56+
57+
return $response;
58+
}
59+
}

Classes/Mvc/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Request
1818
/**
1919
* @var array
2020
*/
21-
protected $arguments = array();
21+
protected $arguments = [];
2222

2323
/**
2424
* @param array $arguments

Classes/Renderer/RecordRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function canRender(Request $request)
5757
*/
5858
protected function resolveRenderingConfiguration(Request $request, RenderingContext $renderingContext)
5959
{
60-
$configuration = array();
60+
$configuration = [];
6161

6262
if ($request->hasArgument('path')) {
6363
$renderingPath = $request->getArgument('path');

Classes/RenderingDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class RenderingDispatcher
4040
/**
4141
* @var string[]
4242
*/
43-
protected $renderer = array();
43+
protected $renderer = [];
4444

4545
/**
4646
* @param RequestBuilder $requestBuilder

Classes/ViewHelpers/Uri/AjaxActionViewHelper.php

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,51 @@ class AjaxActionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractView
3838
protected $configurationManager;
3939

4040
/**
41-
* @param string $action Target action
42-
* @param array $arguments Arguments
43-
* @param string $controller Target controller in UpperCamelCase. If null, current controllerName is used.
44-
* @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
45-
* @param string $pluginName Target plugin. If empty, the current plugin name is used
46-
* @param int $pageUid target page. See TypoLink destination
47-
* @param string $section the anchor to be added to the URI
48-
* @param string $format The requested format, e.g. ".html
49-
* @param bool $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
50-
* @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
51-
* @param bool $absolute If set, an absolute URI is rendered
52-
* @param bool $addQueryString If set, the current query parameters will be kept in the URI
53-
* @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
54-
* @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE
55-
* @param string $contextRecord The record that the rendering should depend upon. e.g. current (default: record is fetched from current Extbase plugin), tt_content:12 (tt_content record with uid 12), pages:15 (pages record with uid 15), 'currentPage' record of current page
41+
* Initialize arguments
42+
*
43+
* @api
44+
*/
45+
public function initializeArguments()
46+
{
47+
$this->registerArgument('action', 'string', 'Target action');
48+
$this->registerArgument('arguments', 'array', 'Arguments', false, []);
49+
$this->registerArgument('controller', 'string', 'Target controller. If NULL current controllerName is used');
50+
$this->registerArgument('extensionName', 'string', 'Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used');
51+
$this->registerArgument('pluginName', 'string', 'Target plugin. If empty, the current plugin name is used');
52+
$this->registerArgument('pageUid', 'int', 'Target page. See TypoLink destination');
53+
$this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, '');
54+
$this->registerArgument('format', 'string', 'The requested format, e.g. ".html', false, '');
55+
$this->registerArgument('linkAccessRestrictedPages', 'bool', 'If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.', false, false);
56+
$this->registerArgument('additionalParams', 'array', 'additional query parameters that won\'t be prefixed like $arguments (overrule $arguments)', false, []);
57+
$this->registerArgument('absolute', 'bool', 'If set, an absolute URI is rendered', false, false);
58+
$this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URI', false, false);
59+
$this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = TRUE', false, []);
60+
$this->registerArgument('addQueryStringMethod', 'string', 'Set which parameters will be kept. Only active if $addQueryString = TRUE');
61+
$this->registerArgument('contextRecord', 'string', 'The record that the rendering should depend upon. e.g. current (default: record is fetched from current Extbase plugin), tt_content:12 (tt_content record with uid 12), pages:15 (pages record with uid 15), \'currentPage\' record of current page', false, 'current');
62+
}
63+
64+
/**
5665
*
5766
* @throws \Helhum\TyposcriptRendering\Configuration\ConfigurationBuildingException
5867
* @return string Rendered link
5968
*
6069
*/
61-
public function render($action = null, array $arguments = array(), $controller = null, $extensionName = null, $pluginName = null, $pageUid = null, $section = '', $format = '', $linkAccessRestrictedPages = false, array $additionalParams = array(), $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array(), $addQueryStringMethod = null, $contextRecord = 'current')
70+
public function render()
6271
{
72+
$pluginName = $this->arguments['pluginName'];
73+
$extensionName = $this->arguments['extensionName'];
74+
$contextRecord = $this->arguments['contextRecord'];
75+
6376
if ($pluginName === null) {
64-
$pluginName = $this->controllerContext->getRequest()->getPluginName();
77+
$pluginName = $this->renderingContext->getControllerContext()->getRequest()->getPluginName();
6578
}
6679
if ($extensionName === null) {
67-
$extensionName = $this->controllerContext->getRequest()->getControllerExtensionName();
80+
$extensionName = $this->renderingContext->getControllerContext()->getRequest()->getControllerExtensionName();
6881
}
6982
if ($contextRecord === 'current') {
7083
if (
71-
$pluginName !== $this->controllerContext->getRequest()->getPluginName()
72-
|| $extensionName !== $this->controllerContext->getRequest()->getControllerExtensionName()
84+
$pluginName !== $this->renderingContext->getControllerContext()->getRequest()->getPluginName()
85+
|| $extensionName !== $this->renderingContext->getControllerContext()->getRequest()->getControllerExtensionName()
7386
) {
7487
$contextRecord = 'currentPage';
7588
} else {
@@ -79,20 +92,20 @@ public function render($action = null, array $arguments = array(), $controller =
7992
$renderingConfiguration = $this->buildTypoScriptRenderingConfiguration($extensionName, $pluginName, $contextRecord);
8093
$additionalParams['tx_typoscriptrendering']['context'] = json_encode($renderingConfiguration);
8194

82-
$uriBuilder = $this->controllerContext->getUriBuilder();
95+
$uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
8396
$uriBuilder->reset()
84-
->setTargetPageUid($pageUid)
97+
->setTargetPageUid($this->arguments['pageUid'])
8598
->setUseCacheHash(true)
86-
->setSection($section)
87-
->setFormat($format)
88-
->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
99+
->setSection($this->arguments['section'])
100+
->setFormat($this->arguments['format'])
101+
->setLinkAccessRestrictedPages($this->arguments['linkAccessRestrictedPages'])
89102
->setArguments($additionalParams)
90-
->setCreateAbsoluteUri($absolute)
91-
->setAddQueryString($addQueryString)
92-
->setAddQueryStringMethod($addQueryStringMethod)
93-
->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString);
103+
->setCreateAbsoluteUri($this->arguments['absolute'])
104+
->setAddQueryString($this->arguments['addQueryString'])
105+
->setAddQueryStringMethod($this->arguments['addQueryStringMethod'])
106+
->setArgumentsToBeExcludedFromQueryString($this->arguments['argumentsToBeExcludedFromQueryString']);
94107

95-
return $uriBuilder->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
108+
return $uriBuilder->uriFor($this->arguments['action'], $this->arguments['arguments'], $this->arguments['controller'], $extensionName, $pluginName);
96109
}
97110

98111
/**

Classes/ViewHelpers/Widget/LinkViewHelper.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function initializeArguments()
6262
* @return string The rendered link
6363
*
6464
*/
65-
public function render($pluginName, $extensionName, $action = null, array $arguments = array(), $section = '', $format = '', $ajax = true, $contextRecord = 'current')
65+
public function render($pluginName, $extensionName, $action = null, array $arguments = [], $section = '', $format = '', $ajax = true, $contextRecord = 'current')
6666
{
6767
if ($ajax === true) {
6868
$uri = $this->getAjaxUri();
@@ -86,7 +86,7 @@ protected function getAjaxUri()
8686
$pluginName = $this->arguments['pluginName'];
8787
$extensionName = $this->arguments['extensionName'];
8888
$contextRecord = $this->arguments['contextRecord'];
89-
$arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : array();
89+
$arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : [];
9090
if ($contextRecord === 'current') {
9191
if (
9292
$pluginName !== $this->controllerContext->getRequest()->getPluginName()
@@ -104,10 +104,10 @@ protected function getAjaxUri()
104104
$argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
105105

106106
$uriBuilder->reset()
107-
->setArguments(array_merge(array($argumentPrefix => $arguments), $additionalParams))
107+
->setArguments(array_merge([$argumentPrefix => $arguments], $additionalParams))
108108
->setSection($this->arguments['section'])
109109
->setAddQueryString(true)
110-
->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))
110+
->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
111111
->setFormat($this->arguments['format'])
112112
->setUseCacheHash(true);
113113

@@ -128,7 +128,7 @@ protected function getWidgetUri()
128128
{
129129
$uriBuilder = $this->controllerContext->getUriBuilder();
130130
$argumentPrefix = $this->controllerContext->getRequest()->getArgumentPrefix();
131-
$arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : array();
131+
$arguments = $this->hasArgument('arguments') ? $this->arguments['arguments'] : [];
132132
if ($this->hasArgument('action')) {
133133
$arguments['action'] = $this->arguments['action'];
134134
}
@@ -139,10 +139,10 @@ protected function getWidgetUri()
139139
$arguments['addQueryStringMethod'] = $this->arguments['addQueryStringMethod'];
140140
}
141141
$uriBuilder->reset()
142-
->setArguments(array($argumentPrefix => $arguments))
142+
->setArguments([$argumentPrefix => $arguments])
143143
->setSection($this->arguments['section'])
144144
->setAddQueryString(true)
145-
->setArgumentsToBeExcludedFromQueryString(array($argumentPrefix, 'cHash'))
145+
->setArgumentsToBeExcludedFromQueryString([$argumentPrefix, 'cHash'])
146146
->setFormat($this->arguments['format']);
147147

148148
// TYPO3 6.0 compatibility check:

0 commit comments

Comments
 (0)