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' => '