From 1a1f4b3a412cdfa20bb206b8759fb861ae7678a0 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 8 Feb 2024 08:04:56 +0100 Subject: [PATCH] Add cs fixer --- Classes/Backend/PreviewRenderer/Video.php | 5 +--- .../AddFurtherMetadataToFile.php | 30 ++++++++----------- Classes/EventListener/PageLayoutHeader.php | 28 ++++++++--------- .../DataProcessing/CategoriesCounts.php | 14 ++++----- .../NaturalSortingProcessor.php | 14 +++++---- .../RssFeed/BlogPostsDataProvider.php | 5 ++-- Classes/UserFunction/CodeHighlighting.php | 8 ++--- Classes/ViewHelpers/Format/IdViewHelper.php | 8 +++-- .../Backend/DashboardWidgetGroups.php | 2 ++ Configuration/TCA/Overrides/pages.php | 16 ++++++---- Configuration/TCA/Overrides/sys_category.php | 13 +++++--- .../TCA/Overrides/sys_file_metadata.php | 14 +++++---- Configuration/TCA/Overrides/sys_template.php | 8 +++-- Configuration/TCA/Overrides/tt_content.php | 28 +++++++++-------- .../TCA/Overrides/tt_content_admonition.php | 19 +++++++----- .../TCA/Overrides/tt_content_image.php | 28 +++++++++-------- .../TCA/Overrides/tt_content_menupages.php | 8 +++-- .../TCA/Overrides/tt_content_video.php | 20 ++++++++----- ext_localconf.php | 8 +++-- 19 files changed, 157 insertions(+), 119 deletions(-) diff --git a/Classes/Backend/PreviewRenderer/Video.php b/Classes/Backend/PreviewRenderer/Video.php index 60fdc1a..9eab276 100644 --- a/Classes/Backend/PreviewRenderer/Video.php +++ b/Classes/Backend/PreviewRenderer/Video.php @@ -31,12 +31,9 @@ use TYPO3\CMS\Frontend\DataProcessing\FilesProcessor; class Video extends StandardContentPreviewRenderer { - private ContentDataProcessor $contentDataProcessor; - public function __construct( - ContentDataProcessor $contentDataProcessor + private ContentDataProcessor $contentDataProcessor ) { - $this->contentDataProcessor = $contentDataProcessor; } public function renderPageModulePreviewContent(GridColumnItem $item): string diff --git a/Classes/EventListener/AddFurtherMetadataToFile.php b/Classes/EventListener/AddFurtherMetadataToFile.php index 849d325..d2859ce 100644 --- a/Classes/EventListener/AddFurtherMetadataToFile.php +++ b/Classes/EventListener/AddFurtherMetadataToFile.php @@ -29,23 +29,9 @@ use TYPO3\CMS\Frontend\Resource\FileCollector; class AddFurtherMetadataToFile { - /** - * @var FileCollector - */ - private $fileCollector; - - public function __construct(FileCollector $fileCollector) - { - $this->fileCollector = $fileCollector; - } - - public function __invoke(EnrichFileMetaDataEvent $event): void - { - $record = $event->getRecord(); - - $record['poster'] = $this->resolvePoster($record); - - $event->setRecord($record); + public function __construct( + private FileCollector $fileCollector + ) { } private function resolvePoster(array $record): ?FileReference @@ -57,6 +43,16 @@ class AddFurtherMetadataToFile ); $files = $this->fileCollector->getFiles(); + return $files[0] ?? null; } + + public function __invoke(EnrichFileMetaDataEvent $event): void + { + $record = $event->getRecord(); + + $record['poster'] = $this->resolvePoster($record); + + $event->setRecord($record); + } } diff --git a/Classes/EventListener/PageLayoutHeader.php b/Classes/EventListener/PageLayoutHeader.php index e565bf6..ad0bab5 100644 --- a/Classes/EventListener/PageLayoutHeader.php +++ b/Classes/EventListener/PageLayoutHeader.php @@ -31,11 +31,24 @@ use TYPO3\CMS\Frontend\Resource\FileCollector; class PageLayoutHeader { + private function getView(): StandaloneView + { + return GeneralUtility::makeInstance(StandaloneView::class); + } + + private function resolvePageMedia(int $pageUid): array + { + $files = GeneralUtility::makeInstance(FileCollector::class); + $files->addFilesFromRelation('pages', 'media', ['uid' => $pageUid]); + + return $files->getFiles(); + } + public function __invoke(ModifyPageLayoutContentEvent $event): void { $request = $event->getRequest(); $pageinfo = BackendUtility::readPageAccess( - (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0), + (int) ($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0), '' ); @@ -83,17 +96,4 @@ class PageLayoutHeader $event->addHeaderContent($view->render()); } - - private function getView(): StandaloneView - { - return GeneralUtility::makeInstance(StandaloneView::class); - } - - private function resolvePageMedia(int $pageUid): array - { - $files = GeneralUtility::makeInstance(FileCollector::class); - $files->addFilesFromRelation('pages', 'media', ['uid' => $pageUid]); - - return $files->getFiles(); - } } diff --git a/Classes/Frontend/DataProcessing/CategoriesCounts.php b/Classes/Frontend/DataProcessing/CategoriesCounts.php index 969ad9f..3cb46ef 100644 --- a/Classes/Frontend/DataProcessing/CategoriesCounts.php +++ b/Classes/Frontend/DataProcessing/CategoriesCounts.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace DanielSiepmann\DsSite\Frontend\DataProcessing; +use InvalidArgumentException; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Database\Query\QueryHelper; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; @@ -30,14 +31,9 @@ use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; class CategoriesCounts implements DataProcessorInterface { - /** - * @var QueryBuilder - */ - private $queryBuilder; - - public function __construct(QueryBuilder $queryBuilder) - { - $this->queryBuilder = $queryBuilder; + public function __construct( + private QueryBuilder $queryBuilder + ) { } public function process( @@ -51,7 +47,7 @@ class CategoriesCounts implements DataProcessorInterface $orderBy = $cObj->stdWrapValue('orderBy', $processorConfiguration, 'count desc'); if ($parent === '') { - throw new \InvalidArgumentException('No "parent" given.', 1600988668); + throw new InvalidArgumentException('No "parent" given.', 1600988668); } $processedData[$as] = $this->getCategoriesCount( diff --git a/Classes/Frontend/DataProcessing/NaturalSortingProcessor.php b/Classes/Frontend/DataProcessing/NaturalSortingProcessor.php index 061ef52..230e5e3 100644 --- a/Classes/Frontend/DataProcessing/NaturalSortingProcessor.php +++ b/Classes/Frontend/DataProcessing/NaturalSortingProcessor.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace DanielSiepmann\DsSite\Frontend\DataProcessing; +use Exception; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; @@ -43,16 +44,16 @@ class NaturalSortingProcessor implements DataProcessorInterface ) { $variablePath = $cObj->stdWrapValue('variablePath', $processorConfiguration, ''); if (is_string($variablePath) === false) { - throw new \Exception('Variable path needs to be string.', 1663760889); + throw new Exception('Variable path needs to be string.', 1663760889); } $variableSubPath = $cObj->stdWrapValue('variableSubPath', $processorConfiguration, ''); if (is_string($variableSubPath) === false) { - throw new \Exception('Variable Sub Path needs to be string.', 1663760908); + throw new Exception('Variable Sub Path needs to be string.', 1663760908); } if ($variablePath === '' || $variableSubPath === '') { - throw new \Exception('Provide variablePath as well as variableSubPath.', 1638373263); + throw new Exception('Provide variablePath as well as variableSubPath.', 1638373263); } if (ArrayUtility::isValidPath($processedData, $variablePath) === false) { @@ -61,16 +62,17 @@ class NaturalSortingProcessor implements DataProcessorInterface $valuesToSort = ArrayUtility::getValueByPath($processedData, $variablePath); if (is_array($valuesToSort) === false) { - throw new \Exception('Variable at "' . $variablePath . '" was not of type array.', 1667911071); + throw new Exception('Variable at "' . $variablePath . '" was not of type array.', 1667911071); } - $valuesToSort = array_filter($valuesToSort, function (array $value) use ($variableSubPath): bool { + $valuesToSort = array_filter($valuesToSort, static function (array $value) use ($variableSubPath): bool { return ArrayUtility::getValueByPath($value, $variableSubPath) == true; }); - usort($valuesToSort, function (array $variable1, array $variable2) use ($variableSubPath) { + usort($valuesToSort, static function (array $variable1, array $variable2) use ($variableSubPath) { $value1 = ArrayUtility::getValueByPath($variable1, $variableSubPath); $value2 = ArrayUtility::getValueByPath($variable2, $variableSubPath); + return strnatcasecmp($value2, $value1); }); $processedData = ArrayUtility::setValueByPath($processedData, $variablePath, $valuesToSort); diff --git a/Classes/Frontend/RssFeed/BlogPostsDataProvider.php b/Classes/Frontend/RssFeed/BlogPostsDataProvider.php index 84249d7..3508509 100644 --- a/Classes/Frontend/RssFeed/BlogPostsDataProvider.php +++ b/Classes/Frontend/RssFeed/BlogPostsDataProvider.php @@ -66,7 +66,7 @@ final class BlogPostsDataProvider implements DataProcessorInterface private function getAdditionalWhere(ServerRequestInterface $request): string { - $categoryUid = intval($request->getQueryParams()['category_uid'] ?? 0); + $categoryUid = (int) ($request->getQueryParams()['category_uid'] ?? 0); if ($categoryUid === 0) { return ''; } @@ -77,6 +77,7 @@ final class BlogPostsDataProvider implements DataProcessorInterface if ($where !== '') { return ''; } + return ' ' . $where; } @@ -107,7 +108,7 @@ final class BlogPostsDataProvider implements DataProcessorInterface ) ); - return array_map(function (array $row) { + return array_map(static function (array $row) { if (is_numeric($row['uid'])) { return (int) $row['uid']; } diff --git a/Classes/UserFunction/CodeHighlighting.php b/Classes/UserFunction/CodeHighlighting.php index dbdfeb8..c861e82 100644 --- a/Classes/UserFunction/CodeHighlighting.php +++ b/Classes/UserFunction/CodeHighlighting.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace DanielSiepmann\DsSite\UserFunction; +use DomainException; use Highlight\Highlighter; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; @@ -32,10 +33,7 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; */ class CodeHighlighting { - /** - * @var ContentObjectRenderer - */ - private $contentObjectRenderer; + private ContentObjectRenderer $contentObjectRenderer; public function setContentObjectRenderer(ContentObjectRenderer $contentObjectRenderer): void { @@ -53,7 +51,7 @@ class CodeHighlighting // Highlight some code. $highlighted = $highlighter->highlightAuto($code); $content = '
' . $highlighted->value . '
'; - } catch (\DomainException $e) { + } catch (DomainException $e) { $content = '
' . $code . '
'; } diff --git a/Classes/ViewHelpers/Format/IdViewHelper.php b/Classes/ViewHelpers/Format/IdViewHelper.php index 0deeeab..aa0bb30 100644 --- a/Classes/ViewHelpers/Format/IdViewHelper.php +++ b/Classes/ViewHelpers/Format/IdViewHelper.php @@ -23,10 +23,11 @@ declare(strict_types=1); namespace DanielSiepmann\DsSite\ViewHelpers\Format; +use Closure; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic; -use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Formats a given string to be a valid HTML id attribute value. @@ -42,18 +43,19 @@ class IdViewHelper extends AbstractViewHelper public static function renderStatic( array $arguments, - \Closure $renderChildrenClosure, + Closure $renderChildrenClosure, RenderingContextInterface $renderingContext ) { $value = $renderChildrenClosure(); if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) { return $value; } - $value = (string)$value; + $value = (string) $value; $value = str_replace(' ', '_', $value); $value = preg_replace('#\W#', '', $value) ?? ''; $value = GeneralUtility::underscoredToUpperCamelCase($value); $value = lcfirst($value); + return $value; } } diff --git a/Configuration/Backend/DashboardWidgetGroups.php b/Configuration/Backend/DashboardWidgetGroups.php index cafbbe3..40dcf67 100644 --- a/Configuration/Backend/DashboardWidgetGroups.php +++ b/Configuration/Backend/DashboardWidgetGroups.php @@ -1,4 +1,6 @@ [ 'title' => 'Own widgets', diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index 52f2887..e47a1b9 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -1,7 +1,13 @@ [ 'rel' => [ 'label' => 'rel Attribute of generated a Tag', @@ -36,10 +42,10 @@ ], ]); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( + ExtensionManagementUtility::addToAllTCAtypes( $tableName, 'rel', - (string) \TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_LINK, + (string) PageRepository::DOKTYPE_LINK, 'after:url' ); diff --git a/Configuration/TCA/Overrides/sys_category.php b/Configuration/TCA/Overrides/sys_category.php index 23aa6fd..ce3ffc5 100644 --- a/Configuration/TCA/Overrides/sys_category.php +++ b/Configuration/TCA/Overrides/sys_category.php @@ -1,7 +1,12 @@ [ 'slug' => [ 'label' => '.slug', @@ -17,13 +22,13 @@ ], 'fallbackCharacter' => '-', 'eval' => 'uniqueInSite', - 'default' => '' + 'default' => '', ], ], ], ]); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( + ExtensionManagementUtility::addToAllTCAtypes( $tableName, 'slug', '', diff --git a/Configuration/TCA/Overrides/sys_file_metadata.php b/Configuration/TCA/Overrides/sys_file_metadata.php index 8e92c26..0447ddd 100644 --- a/Configuration/TCA/Overrides/sys_file_metadata.php +++ b/Configuration/TCA/Overrides/sys_file_metadata.php @@ -1,10 +1,14 @@ - [ 'youtube' => [ 'label' => $languagePath . 'youtube', @@ -18,13 +22,13 @@ 'config' => [ 'type' => 'file', 'maxitems' => 1, - 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], + 'allowed' => 'common-image-types', ], ], ], ]); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( + ExtensionManagementUtility::addToAllTCAtypes( $tableName, 'youtube, poster', '', diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 48f4d99..1c5fb9a 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -1,7 +1,11 @@ [ $ctype => [ 'showitem' => implode(',', [ '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general', - '--palette--;;general', - '--palette--;;headers', - 'image', + '--palette--;;general', + '--palette--;;headers', + 'image', '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance', - '--palette--;;frames', - '--palette--;;appearanceLinks', + '--palette--;;frames', + '--palette--;;appearanceLinks', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language', - '--palette--;;language', + '--palette--;;language', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access', - '--palette--;;hidden', - '--palette--;;access', + '--palette--;;hidden', + '--palette--;;access', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories', - 'categories', + 'categories', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes', - 'rowDescription', + 'rowDescription', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended', ]), ], diff --git a/Configuration/TCA/Overrides/tt_content_admonition.php b/Configuration/TCA/Overrides/tt_content_admonition.php index 39c70d7..47555dc 100644 --- a/Configuration/TCA/Overrides/tt_content_admonition.php +++ b/Configuration/TCA/Overrides/tt_content_admonition.php @@ -1,9 +1,14 @@ [ 'typeicon_classes' => [ $contentType => 'content-idea', @@ -42,14 +47,14 @@ ], ]); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( + ExtensionManagementUtility::addTcaSelectItem( $tableName, 'CType', [ - $languagePath . $contentType, - $contentType, - 'content-idea', - 'default' + 'label' => $languagePath . $contentType, + 'value' => $contentType, + 'icon' => 'content-idea', + 'group' => 'default', ], 'image', 'after' diff --git a/Configuration/TCA/Overrides/tt_content_image.php b/Configuration/TCA/Overrides/tt_content_image.php index 89af2a0..e7ddceb 100644 --- a/Configuration/TCA/Overrides/tt_content_image.php +++ b/Configuration/TCA/Overrides/tt_content_image.php @@ -1,26 +1,30 @@ [ $ctype => [ 'showitem' => implode(',', [ '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general', - '--palette--;;general', - '--palette--;;headers', - 'image', + '--palette--;;general', + '--palette--;;headers', + 'image', '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance', - '--palette--;;frames', - '--palette--;;appearanceLinks', + '--palette--;;frames', + '--palette--;;appearanceLinks', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language', - '--palette--;;language', + '--palette--;;language', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access', - '--palette--;;hidden', - '--palette--;;access', + '--palette--;;hidden', + '--palette--;;access', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories', - 'categories', + 'categories', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes', - 'rowDescription', + 'rowDescription', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended', ]), ], diff --git a/Configuration/TCA/Overrides/tt_content_menupages.php b/Configuration/TCA/Overrides/tt_content_menupages.php index e520c37..1aaa69f 100644 --- a/Configuration/TCA/Overrides/tt_content_menupages.php +++ b/Configuration/TCA/Overrides/tt_content_menupages.php @@ -1,9 +1,13 @@ [ $contentType => [ 'showitem' => implode(',', [ diff --git a/Configuration/TCA/Overrides/tt_content_video.php b/Configuration/TCA/Overrides/tt_content_video.php index ccc609c..fbae0f6 100644 --- a/Configuration/TCA/Overrides/tt_content_video.php +++ b/Configuration/TCA/Overrides/tt_content_video.php @@ -1,11 +1,15 @@ [ 'typeicon_classes' => [ $contentType => 'content-media', @@ -37,14 +41,14 @@ use DanielSiepmann\DsSite\Backend\PreviewRenderer\Video; ], ]); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( + ExtensionManagementUtility::addTcaSelectItem( $tableName, 'CType', [ - $languagePath . $contentType, - $contentType, - 'content-media', - 'default' + 'label' => $languagePath . $contentType, + 'value' => $contentType, + 'icon' => 'content-media', + 'group' => 'default', ], 'image', 'after' diff --git a/ext_localconf.php b/ext_localconf.php index 7b5f17c..6c6a1bd 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,7 +1,11 @@ [ 'stylesheets' => [ $extKey => 'EXT:' . $extKey . '/Resources/Public/Backend/Css/',