Skip to content

Commit

Permalink
Merge pull request #124 from sitegeist/121-typo3-13-support
Browse files Browse the repository at this point in the history
TYPO3 13 support
  • Loading branch information
ulrichmathes authored Oct 11, 2024
2 parents 339970b + 4a1fd36 commit 36ee767
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 182 deletions.
132 changes: 66 additions & 66 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,69 +34,69 @@ jobs:
run: Build/Scripts/runTests.sh -s lintEditorconfig


unittest:
runs-on: ubuntu-latest

strategy:
max-parallel: 2
matrix:
php-versions: ['8.3', '8.2']
typo3-versions: [13, 12]

name: Unit (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
steps:
-
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@v3
with:
path: ~/.composer/cache
key: php-${{ matrix.php-versions }}-typo3-${{ matrix.typo3-versions }}

-
name: Install composer dependencies
run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s composerInstall

-
name: Automated Unit Testing
run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s unit


functionaltest:
runs-on: ubuntu-latest

strategy:
max-parallel: 2
matrix:
php-versions: ['8.3', '8.2']
typo3-versions: [13, 12]

name: Functional (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
steps:
-
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@v3
with:
path: ~/.composer/cache
key: php-${{ matrix.php-versions }}-typo3-${{ matrix.typo3-versions }}

-
name: Install composer dependencies
run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s composerInstall

-
name: Automated Functional Testing
run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s functional
# unittest:
# runs-on: ubuntu-latest

# strategy:
# max-parallel: 2
# matrix:
# php-versions: ['8.3', '8.2']
# typo3-versions: [13, 12]

# name: Unit (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
# steps:
# -
# 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@v3
# with:
# path: ~/.composer/cache
# key: php-${{ matrix.php-versions }}-typo3-${{ matrix.typo3-versions }}

# -
# name: Install composer dependencies
# run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s composerInstall

# -
# name: Automated Unit Testing
# run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s unit


# functionaltest:
# runs-on: ubuntu-latest

# strategy:
# max-parallel: 2
# matrix:
# php-versions: ['8.3', '8.2']
# typo3-versions: [13, 12]

# name: Functional (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
# steps:
# -
# 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@v3
# with:
# path: ~/.composer/cache
# key: php-${{ matrix.php-versions }}-typo3-${{ matrix.typo3-versions }}

# -
# name: Install composer dependencies
# run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s composerInstall

# -
# name: Automated Functional Testing
# run: Build/Scripts/runTests.sh -p ${{ matrix.php-versions }} -t ${{ matrix.typo3-versions }} -s functional
15 changes: 6 additions & 9 deletions Classes/Controller/StyleguideController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\View\FluidViewAdapter;
use TYPO3\CMS\Fluid\View\StandaloneView;

class StyleguideController
{
protected StandaloneView $view;
protected StandaloneView|FluidViewAdapter $view;
protected ServerRequestInterface $request;

public function __construct(
Expand All @@ -43,7 +44,7 @@ public function listAction(): ResponseInterface
'packages' => $componentPackages
]);

return new HtmlResponse($this->view->render());
return new HtmlResponse($this->view->render('Styleguide/List'));
}

public function showAction(array $arguments = []): ResponseInterface
Expand Down Expand Up @@ -87,7 +88,7 @@ public function showAction(array $arguments = []): ResponseInterface
'qualityIssues' => $qualityIssues
]);

return new HtmlResponse($this->view->render());
return new HtmlResponse($this->view->render('Styleguide/Show'));
}

/**
Expand Down Expand Up @@ -126,7 +127,7 @@ public function componentAction(array $arguments = [])
'fixtureData' => $formData
]);

$renderedView = $this->view->render();
$renderedView = $this->view->render('Styleguide/Component');

$event = new PostProcessComponentViewEvent($component, $fixture, $formData, $renderedView);
$eventDispatcher = $this->container->get(EventDispatcher::class);
Expand Down Expand Up @@ -175,14 +176,10 @@ protected function groupComponentsByPackage(array $components): array
return $componentPackages;
}

public function initializeView(StandaloneView $view): void
public function initializeView(StandaloneView|FluidViewAdapter $view): void
{
$this->view = $view;

$this->view->setTemplateRootPaths($this->styleguideConfigurationManager->getTemplateRootPaths());
$this->view->setPartialRootPaths($this->styleguideConfigurationManager->getPartialRootPaths());
$this->view->setLayoutRootPaths($this->styleguideConfigurationManager->getLayoutRootPaths());

$this->view->assignMultiple([
'styleguideConfiguration' => $this->styleguideConfigurationManager,
'styleguideLanguage' => $this->request->getAttribute('language'),
Expand Down
6 changes: 2 additions & 4 deletions Classes/Domain/Model/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@

use TYPO3\CMS\Core\Package\PackageInterface;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class Package
{
/**
* Associated TYPO3 extension
*/
protected PackageInterface $extension;
protected ?PackageInterface $extension = null;

public function __construct(
protected string $namespace, // PHP namespace for the component package
Expand Down Expand Up @@ -44,8 +43,7 @@ public function getExtension(): ?PackageInterface
return $this->extension;
}

$dependencyOrderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
$activeExtensions = GeneralUtility::makeInstance(PackageManager::class, $dependencyOrderingService)->getActivePackages();
$activeExtensions = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
foreach ($activeExtensions as $extension) {
if (str_starts_with($this->getPath(), (string) $extension->getPackagePath())) {
$this->extension = $extension;
Expand Down
26 changes: 21 additions & 5 deletions Classes/Middleware/StyleguideRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use TYPO3\CMS\Core\TypoScript\AST\Node\RootNode;
use TYPO3\CMS\Core\TypoScript\FrontendTypoScript;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\View\ViewFactoryData;
use TYPO3\CMS\Core\View\ViewFactoryInterface;
use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand All @@ -35,7 +37,8 @@ public function __construct(
protected Context $context,
protected ContainerInterface $container,
protected ExtensionConfiguration $extensionConfiguration,
protected FrontendUserAuthentication $frontendUserAuthentication
protected FrontendUserAuthentication $frontendUserAuthentication,
protected ?ViewFactoryInterface $viewFactory = null,
) {
}

Expand Down Expand Up @@ -133,9 +136,6 @@ public function process(
$request = $request->withAttribute('frontend.controller', $GLOBALS['TSFE']);
$GLOBALS['TYPO3_REQUEST'] = $request;

// Create view
$view = $this->container->get(StandaloneView::class);

$extbaseAttribute = new ExtbaseRequestParameters();
$extbaseAttribute->setControllerExtensionName('fluidStyleguide');
$extbaseAttribute->setControllerName('Styleguide');
Expand All @@ -152,7 +152,23 @@ public function process(
}

$request = $request->withAttribute('frontend.typoscript', $plainFrontendTypoScript);
$view->setRequest($request);

// Create view
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$view = $this->container->get(StandaloneView::class);
$view->setTemplateRootPaths($styleguideConfigurationManager->getTemplateRootPaths());
$view->setPartialRootPaths($styleguideConfigurationManager->getPartialRootPaths());
$view->setLayoutRootPaths($styleguideConfigurationManager->getLayoutRootPaths());
$view->setRequest($request);
} else {
$view = $this->viewFactory->create(new ViewFactoryData(
templateRootPaths: $styleguideConfigurationManager->getTemplateRootPaths(),
partialRootPaths: $styleguideConfigurationManager->getPartialRootPaths(),
layoutRootPaths: $styleguideConfigurationManager->getLayoutRootPaths(),
templatePathAndFilename: null,
request: $request,
));
}

$controller->setRequest($request);

Expand Down
Loading

0 comments on commit 36ee767

Please sign in to comment.