Skip to content

Commit

Permalink
[WIP] Compatibility with TYPO3 v13
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Jan 22, 2025
1 parent cf49f7a commit 19b4169
Show file tree
Hide file tree
Showing 95 changed files with 854 additions and 396 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ jobs:
typo3: "^12.4"
- php: "8.3"
typo3: "^12.4"
- php: "8.3"
typo3: "^13.4"

runs-on: ubuntu-latest

Expand Down Expand Up @@ -107,6 +109,8 @@ jobs:
typo3: "^12.4"
- php: "8.3"
typo3: "^12.4"
- php: "8.3"
typo3: "^13.4"

runs-on: ubuntu-latest

Expand All @@ -132,7 +136,9 @@ jobs:
run: vendor/bin/phpunit --coverage-clover=build/logs/clover.xml

- name: Upload test coverage
run: vendor/bin/php-coveralls -vvv
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
env:
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: typo3-${{ matrix.typo3 }}-php-${{ matrix.php }}
Expand Down
7 changes: 5 additions & 2 deletions Classes/Backend/BackendLayoutDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
use FluidTYPO3\Flux\Provider\PageProvider;
use FluidTYPO3\Flux\Provider\ProviderInterface;
use FluidTYPO3\Flux\Provider\ProviderResolver;
use FluidTYPO3\Flux\Proxy\DataProviderContextProxy;
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService;
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayout;
use TYPO3\CMS\Backend\View\BackendLayout\BackendLayoutCollection;
use TYPO3\CMS\Backend\View\BackendLayout\DataProviderContext;
use TYPO3\CMS\Backend\View\BackendLayout\DataProviderInterface;
use TYPO3\CMS\Backend\View\BackendLayout\DefaultDataProvider;

class BackendLayoutDataProvider implements DataProviderInterface
{
Expand All @@ -34,7 +34,10 @@ public function addBackendLayouts(
DataProviderContext $dataProviderContext,
BackendLayoutCollection $backendLayoutCollection
): void {
$backendLayout = $this->getBackendLayout('grid', $dataProviderContext->getPageId());
$backendLayout = $this->getBackendLayout(
'grid',
DataProviderContextProxy::readPageUidFromObject($dataProviderContext)
);
if ($backendLayout) {
$backendLayoutCollection->add($backendLayout);
}
Expand Down
6 changes: 3 additions & 3 deletions Classes/Backend/PageLayoutDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

use FluidTYPO3\Flux\Enum\FormOption;
use FluidTYPO3\Flux\Form;
use FluidTYPO3\Flux\Proxy\SiteFinderProxy;
use FluidTYPO3\Flux\Service\PageService;
use FluidTYPO3\Flux\Utility\ExtensionNamingUtility;
use FluidTYPO3\Flux\Utility\MiscellaneousUtility;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand All @@ -24,12 +24,12 @@ class PageLayoutDataProvider
{
private ConfigurationManagerInterface $configurationManager;
private PageService $pageService;
private SiteFinder $siteFinder;
private SiteFinderProxy $siteFinder;

public function __construct(
ConfigurationManagerInterface $configurationManager,
PageService $pageService,
SiteFinder $siteFinder
SiteFinderProxy $siteFinder
) {
$this->configurationManager = $configurationManager;
$this->pageService = $pageService;
Expand Down
10 changes: 4 additions & 6 deletions Classes/Builder/ContentTypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ protected function addPageTsConfig(Form $form, string $contentType, string $icon

// Registration for "new content element" wizard to show our new CType
// (otherwise, only selectable via "Content type" drop-down)
ExtensionManagementUtility::addPageTSConfig(
$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] .= PHP_EOL .
sprintf(
'mod.wizards.newContentElement.wizardItems.%s.elements.%s {
iconIdentifier = %s
Expand All @@ -316,8 +316,7 @@ protected function addPageTsConfig(Form $form, string $contentType, string $icon
$contentType,
$groupName,
$formId
)
);
);
}

protected function sanitizeString(string $string): string
Expand All @@ -339,7 +338,7 @@ protected function initializeNewContentWizardGroup(string $groupName, string $gr
return;
}

ExtensionManagementUtility::addPageTSConfig(
$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] .= PHP_EOL .
sprintf(
'mod.wizards.newContentElement.wizardItems.%s {
%s
Expand All @@ -348,8 +347,7 @@ protected function initializeNewContentWizardGroup(string $groupName, string $gr
}',
$groupName,
'header = ' . $groupLabel
)
);
);
$groups[$groupName] = true;
}

Expand Down
2 changes: 2 additions & 0 deletions Classes/Builder/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function getServerRequest(): ServerRequestInterface
$frontendTypoScript = GeneralUtility::makeInstance(
FrontendTypoScript::class,
GeneralUtility::makeInstance(RootNode::class),
[],
[],
[]
);
$frontendTypoScript->setSetupArray([]);
Expand Down
6 changes: 3 additions & 3 deletions Classes/Content/ContentTypeValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public function validateContentTypeRecord(array $parameters): string
$view->assign('recordIsNew', $recordIsNew);

if ($recordIsNew) {
return $view->render();
return is_string($output = $view->render()) ? $output : '';
}

$contentType = $this->contentTypeManager->determineContentTypeForTypeString($record['content_type']);
if (!$contentType) {
$view->assign('recordIsNew', true);
return $view->render();
return is_string($output = $view->render()) ? $output : '';
}

$usesTemplateFile = true;
Expand All @@ -91,7 +91,7 @@ public function validateContentTypeRecord(array $parameters): string
],
]);

return $view->render();
return is_string($output = $view->render()) ? $output : '';
}

protected function validateContextMatchesSignature(ContentTypeDefinitionInterface $definition): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,22 @@ public function getContentTypeName(): string

public function getIconReference(): string
{
return '';
$extensionKey = ExtensionNamingUtility::getExtensionKey($this->extensionIdentity);
$contentType = $this->getContentTypeName();
$files = [
'EXT:' . $extensionKey . '/Resources/Public/Icons/Content/' . $contentType . '.svg',
'EXT:' . $extensionKey . '/Resources/Public/Icons/Content/' . $contentType . '.png',
'EXT:' . $extensionKey . '/Resources/Public/Icons/Content/' . $contentType . '.gif',
];

foreach ($files as $potentialIconFile) {
$absoluteFileName = GeneralUtility::getFileAbsFileName($potentialIconFile);
if (file_exists($absoluteFileName)) {
return $potentialIconFile;
}
}

return 'EXT:flux/Resources/Public/Icons/Extension.svg';
}

public function getExtensionIdentity(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RecordBasedContentTypeDefinition implements FluidRenderingContentTypeDefin
public function __construct(array $record)
{
$this->record = $record;
$this->contentTypeName = $record['content_type'];
$this->contentTypeName = $record['content_type'] ?? 'undefined';
}

/**
Expand Down
11 changes: 7 additions & 4 deletions Classes/Controller/AbstractFluxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ protected function createHtmlResponse(string $html = null)
* vanilla Provider instances when registering them for
* content object types or other ad-hoc registrations.
*
* @return \Psr\Http\Message\ResponseInterface|Response
* @return \Psr\Http\Message\ResponseInterface|Response|ResponseInterface
*/
public function defaultAction()
{
Expand All @@ -317,7 +317,7 @@ public function defaultAction()
/**
* Render content
*
* @return \Psr\Http\Message\ResponseInterface|Response
* @return \Psr\Http\Message\ResponseInterface|Response|ResponseInterface
*/
public function renderAction()
{
Expand Down Expand Up @@ -353,7 +353,7 @@ protected function resolveOverriddenFluxControllerActionNameFromRequestParameter
}

/**
* @return \Psr\Http\Message\ResponseInterface|Response
* @return \Psr\Http\Message\ResponseInterface|Response|ResponseInterface
*/
protected function performSubRendering(
string $extensionName,
Expand All @@ -365,6 +365,7 @@ protected function performSubRendering(
if (property_exists($this, 'responseFactory') && $this->responseFactory instanceof ResponseFactoryInterface) {
$response = $this->responseFactory->createResponse();
} else {
/** @var ResponseInterface\ $response */
$response = GeneralUtility::makeInstance(Response::class);
}

Expand Down Expand Up @@ -435,7 +436,9 @@ protected function performSubRendering(
]
)['content'];

return $content instanceof \Psr\Http\Message\ResponseInterface ? $content : $this->createHtmlResponse($content);
return $content instanceof \Psr\Http\Message\ResponseInterface || $content instanceof ResponseInterface
? $content
: $this->createHtmlResponse($content);
}

protected function hasSubControllerActionOnForeignController(
Expand Down
2 changes: 1 addition & 1 deletion Classes/Form/AbstractMultiValueFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function getItems(): array
$items = $this->addOptionsFromResults($this->items);
} elseif (true === is_string($this->items)) {
if (false !== strpos($this->items, '..')) {
list ($low, $high) = explode('..', $this->items);
[$low, $high] = explode('..', $this->items);
$itemNames = range($low, $high, 1);
} else {
$itemNames = GeneralUtility::trimExplode(',', $this->items);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Form/Transformation/FormDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
use FluidTYPO3\Flux\Form;
use FluidTYPO3\Flux\Form\ContainerInterface;
use FluidTYPO3\Flux\Form\Field;
use FluidTYPO3\Flux\Form\FieldInterface;
use FluidTYPO3\Flux\Form\Field\Inline\Fal;
use FluidTYPO3\Flux\Form\FieldInterface;
use FluidTYPO3\Flux\Hooks\HookHandler;
use FluidTYPO3\Flux\Utility\ExtensionConfigurationUtility;
use TYPO3\CMS\Core\Service\FlexFormService;
Expand Down
6 changes: 3 additions & 3 deletions Classes/Form/Transformation/Transformer/FileTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
use FluidTYPO3\Flux\Form\FormInterface;
use FluidTYPO3\Flux\Form\OptionCarryingInterface;
use FluidTYPO3\Flux\Form\Transformation\DataTransformerInterface;
use FluidTYPO3\Flux\Proxy\ResourceFactoryProxy;
use FluidTYPO3\Flux\Utility\DoctrineQueryProxy;
use FluidTYPO3\Flux\Utility\ExtensionConfigurationUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\ResourceFactory;

/**
* File Transformer
Expand All @@ -30,9 +30,9 @@
class FileTransformer implements DataTransformerInterface
{
private ConnectionPool $connectionPool;
private ResourceFactory $resourceFactory;
private ResourceFactoryProxy $resourceFactory;

public function __construct(ConnectionPool $connectionPool, ResourceFactory $resourceFactory)
public function __construct(ConnectionPool $connectionPool, ResourceFactoryProxy $resourceFactory)
{
$this->connectionPool = $connectionPool;
$this->resourceFactory = $resourceFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public function __construct(
public function processData(): void
{
// Initialize the TCA needed by "template as CType" integrations
$this->spoolQueuedContentTypeTableConfigurations(Core::getQueuedContentTypeRegistrations());
$registrations = Core::getQueuedContentTypeRegistrations();
$this->spoolQueuedContentTypeTableConfigurations($registrations);

foreach ($this->contentTypeManager->fetchContentTypes() as $contentType) {
if (!$contentType instanceof FluidRenderingContentTypeDefinitionInterface) {
Expand Down
1 change: 0 additions & 1 deletion Classes/Integration/FormEngine/ClearValueWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class ClearValueWizard extends AbstractNode
public function render(): array
{
$result = $this->initializeResultArray();

$fieldName = 'data' . $this->data['elementBaseName'];
$nameSegments = explode('][', $fieldName);
$nameSegments[count($nameSegments) - 2] .= '_clear';
Expand Down
10 changes: 1 addition & 9 deletions Classes/Integration/FormEngine/ColumnPositionNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@
*/

use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Backend\Form\NodeInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ColumnPositionNode extends AbstractNode implements NodeInterface
{
private array $parameters = [];

public function __construct(NodeFactory $nodeFactory, array $data = [])
{
$this->parameters = $data;
}

public function render(): array
{
$return = $this->initializeResultArray();
/** @var UserFunctions $userFunctions */
$userFunctions = GeneralUtility::makeInstance(UserFunctions::class);
$return['html'] = $userFunctions->renderColumnPositionField($this->parameters);
$return['html'] = $userFunctions->renderColumnPositionField($this->data);
return $return;
}
}
10 changes: 1 addition & 9 deletions Classes/Integration/FormEngine/ContentTypeValidatorNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@

use FluidTYPO3\Flux\Content\ContentTypeValidator;
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Backend\Form\NodeInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ContentTypeValidatorNode extends AbstractNode implements NodeInterface
{
private array $parameters = [];

public function __construct(NodeFactory $nodeFactory, array $data = [])
{
$this->parameters = $data;
}

public function render(): array
{
$return = $this->initializeResultArray();
/** @var ContentTypeValidator $validator */
$validator = GeneralUtility::makeInstance(ContentTypeValidator::class);
$return['html'] = $validator->validateContentTypeRecord(
$this->parameters['parameterArray'] + ['row' => $this->parameters['databaseRow']]
$this->data['parameterArray'] + ['row' => $this->data['databaseRow']]
);
return $return;
}
Expand Down
10 changes: 1 addition & 9 deletions Classes/Integration/FormEngine/HtmlOutputNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@
*/

use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Backend\Form\NodeInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class HtmlOutputNode extends AbstractNode implements NodeInterface
{
private array $parameters = [];

public function __construct(NodeFactory $nodeFactory, array $data = [])
{
$this->parameters = $data;
}

public function render(): array
{
$return = $this->initializeResultArray();
/** @var UserFunctions $userFunctions */
$userFunctions = GeneralUtility::makeInstance(UserFunctions::class);
$return['html'] = $userFunctions->renderHtmlOutputField($this->parameters['parameterArray']);
$return['html'] = $userFunctions->renderHtmlOutputField($this->data['parameterArray']);
return $return;
}
}
4 changes: 3 additions & 1 deletion Classes/Integration/FormEngine/PageLayoutSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class PageLayoutSelector extends AbstractNode

public function __construct(?NodeFactory $nodeFactory = null, array $data = [])
{
$this->nodeFactory = $nodeFactory ?? GeneralUtility::makeInstance(NodeFactory::class);
if (property_exists($this, 'nodeFactory')) {
$this->nodeFactory = $nodeFactory ?? GeneralUtility::makeInstance(NodeFactory::class);
}
$this->data = $data;
$this->pageService = GeneralUtility::makeInstance(PageService::class);
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
Expand Down
Loading

0 comments on commit 19b4169

Please sign in to comment.