Skip to content

Commit

Permalink
Merge pull request #108 from lukasniestroj/task/typo3-12
Browse files Browse the repository at this point in the history
[TASK] support TYPO3 12
  • Loading branch information
ulrichmathes authored Feb 16, 2024
2 parents ec573d0 + a16a79f commit 916a054
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 74 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ on:
jobs:
terUpload:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- uses: tomasnorre/typo3-upload-ter@v2
with:
api-token: ${{ secrets.TYPO3_API_TOKEN }}
36 changes: 20 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v3

-
name: Validate composer.json
run: Build/Scripts/runTests.sh -s composerValidate

-
name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: composer
Expand All @@ -40,25 +40,27 @@ jobs:
strategy:
max-parallel: 2
matrix:
php-versions: [7.4, '8.0']
typo3-versions: [10, 11]
php-versions: ['8.2', '8.1', '8.0']
typo3-versions: [12, 11]
exclude:
-
php-versions: '8.0'
typo3-versions: 10
- php-versions: '8.0'
typo3-versions: 12
include:
- php-versions: '7.4'
typo3-versions: 11

name: Unit (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v3

-
name: Validate composer.json
run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s composerValidate

-
name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php-${{ matrix.php-versions }}-typo3-${{ matrix.typo3-versions }}
Expand All @@ -78,25 +80,27 @@ jobs:
strategy:
max-parallel: 2
matrix:
php-versions: [7.4, '8.0']
typo3-versions: [10, 11]
php-versions: ['8.2', '8.1', '8.0']
typo3-versions: [12, 11]
exclude:
-
php-versions: '8.0'
typo3-versions: 10
- php-versions: '8.0'
typo3-versions: 12
include:
- php-versions: '7.4'
typo3-versions: 11

name: Functional (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v3

-
name: Validate composer.json
run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s composerValidate

-
name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php-${{ matrix.php-versions }}-typo3-${{ matrix.typo3-versions }}
Expand Down
12 changes: 7 additions & 5 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ Options:
- postgres: use postgres
- sqlite: use sqlite
-p <7.4|8.0>
-p <7.4|8.0|8.1|8.2>
Specifies the PHP minor version to be used
- 7.4 (default): use PHP 7.4
- 8.0: use PHP 8.0
- 8.1: use PHP 8.1
- 8.2: use PHP 8.2
-t <10|11>
-t <11|12>
Specifies the TYPO3 version to be used
- 10 (default): use TYPO3 10
- 11: use TYPO3 11
- 11 (default): use TYPO3 11
- 12: use TYPO3 12
-e "<phpunit options>"
Only with -s functional|unit
Expand Down Expand Up @@ -132,7 +134,7 @@ fi
TEST_SUITE="unit"
DBMS="mariadb"
PHP_VERSION="7.4"
TYPO3_VERSION="10"
TYPO3_VERSION="11"
PHP_XDEBUG_ON=0
PHP_XDEBUG_PORT=9003
EXTRA_TEST_OPTIONS=""
Expand Down
30 changes: 15 additions & 15 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ services:
typo3DatabaseUsername: root
typo3DatabasePassword: funcp
typo3DatabaseHost: mariadb10
working_dir: ${ROOT_DIR}/.Build
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
Expand All @@ -143,13 +143,13 @@ services:
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
fi
"
Expand All @@ -171,7 +171,7 @@ services:
typo3DatabasePort: 1433
typo3DatabaseCharset: utf-8
typo3DatabaseHost: mssql2019latest
working_dir: ${ROOT_DIR}/.Build
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
Expand All @@ -186,13 +186,13 @@ services:
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
fi
"
Expand All @@ -212,7 +212,7 @@ services:
typo3DatabaseUsername: ${HOST_USER}
typo3DatabaseHost: postgres10
typo3DatabasePassword: funcp
working_dir: ${ROOT_DIR}/.Build
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
Expand All @@ -226,13 +226,13 @@ services:
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
fi
"
Expand All @@ -248,7 +248,7 @@ services:
- ${ROOT_DIR}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/:rw,noexec,nosuid,uid=${HOST_UID}
environment:
typo3DatabaseDriver: pdo_sqlite
working_dir: ${ROOT_DIR}/.Build
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
Expand All @@ -257,13 +257,13 @@ services:
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
fi
"
Expand Down Expand Up @@ -312,7 +312,7 @@ services:
- ${HOST_HOME}:${HOST_HOME}
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
working_dir: ${ROOT_DIR}/.Build
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
Expand All @@ -321,12 +321,12 @@ services:
php -v | grep '^PHP'
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
.Build/bin/phpunit -c Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
bin/phpunit -c Web/typo3conf/ext/fluid_styleguide/Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
.Build/bin/phpunit -c Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
fi
"
7 changes: 1 addition & 6 deletions Classes/Domain/Repository/PackageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Psr\Container\ContainerInterface;
use Sitegeist\FluidStyleguide\Domain\Model\Package;
use SMS\FluidComponents\Utility\ComponentLoader;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver;
use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolverFactoryInterface;

Expand Down Expand Up @@ -86,10 +85,6 @@ public function findForComponentIdentifier(string $componentIdentifier): ?Packag

protected function getViewHelperResolver(): ViewHelperResolver
{
if (version_compare(TYPO3_version, '11.4', '>=')) {
return $this->container->get(ViewHelperResolverFactoryInterface::class)->create();
} else {
return GeneralUtility::makeInstance(ViewHelperResolver::class);
}
return $this->container->get(ViewHelperResolverFactoryInterface::class)->create();
}
}
51 changes: 29 additions & 22 deletions Classes/Middleware/StyleguideRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\TypoScript\AST\Node\RootNode;
use TYPO3\CMS\Core\TypoScript\FrontendTypoScript;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
Expand Down Expand Up @@ -133,9 +138,6 @@ public function process(
);

if ($styleguideLanguage) {
// Set language in TSFE object
$GLOBALS['TSFE']->lang = $styleguideLanguage['identifier'];

// Replace language in request
$request = $request->withAttribute('language', new SiteLanguage(
0,
Expand All @@ -149,13 +151,35 @@ public function process(
'twoLetterIsoCode' => $styleguideLanguage['twoLetterIsoCode']
]
));
$GLOBALS['TYPO3_REQUEST'] = $request;
}
}

// Create view
$view = $this->createView('fluidStyleguide', 'Styleguide', $actionName);
$view = $this->container->get(StandaloneView::class);

if ((new Typo3Version())->getMajorVersion() < 12) {
$view->getRenderingContext()->setControllerName('Styleguide');
$view->getRenderingContext()->setControllerAction($actionName);
}

$extbaseAttribute = new ExtbaseRequestParameters();
$extbaseAttribute->setControllerExtensionName('fluidStyleguide');
$extbaseAttribute->setControllerName('Styleguide');
$extbaseAttribute->setControllerActionName($actionName);
$request = new Request($request
->withAttribute('extbase', $extbaseAttribute)
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE)
->withAttribute('frontend.controller', $GLOBALS['TSFE']));

if ((new Typo3Version())->getMajorVersion() >= 12) {
$request = $request->withAttribute('frontend.typoscript', new FrontendTypoScript(new RootNode(), []));
$view->setRequest($request);
}

$controller->setRequest($request);

// set the global, since some ViewHelper still fallback to $GLOBALS['TYPO3_REQUEST']
$GLOBALS['TYPO3_REQUEST'] = $request;
$controller->initializeView($view);

// Call controller action
Expand All @@ -172,23 +196,6 @@ public function process(
return $response;
}

protected function createView(
string $extensionName,
string $controllerName,
string $actionName
): StandaloneView {
$view = $this->container->get(StandaloneView::class);
if (version_compare(TYPO3_version, '11.0', '>=')) {
$request = $view->getRenderingContext()->getControllerContext()->getRequest()
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE);
$request->setControllerExtensionName($extensionName);
$view->getRenderingContext()->getControllerContext()->setRequest($request);
}
$view->getRenderingContext()->setControllerName($controllerName);
$view->getRenderingContext()->setControllerAction($actionName);
return $view;
}

protected function callControllerAction(
object $controller,
string $actionMethod,
Expand Down
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/Component/ExampleViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ExampleViewHelper extends AbstractViewHelper
*/
protected $escapeOutput = false;

public function initializeArguments()
public function initializeArguments(): void
{
$this->registerArgument('component', Component::class, 'Component that should be rendered', true);
$this->registerArgument('fixtureName', 'string', 'Name of the fixture that should be used in the example');
Expand Down Expand Up @@ -169,9 +169,9 @@ function () {
*
* @param array $data
* @param RenderingContextInterface $renderingContext
* @return void
* @return array
*/
public static function renderFluidInExampleData(array $data, RenderingContextInterface $renderingContext)
public static function renderFluidInExampleData(array $data, RenderingContextInterface $renderingContext): array
{
return array_map(function ($value) use ($renderingContext) {
if (is_string($value)) {
Expand Down
Loading

0 comments on commit 916a054

Please sign in to comment.