Add cs fixer

This commit is contained in:
Daniel Siepmann 2024-02-08 08:04:56 +01:00
parent f57b8831d4
commit 1a1f4b3a41
19 changed files with 157 additions and 119 deletions

View file

@ -31,12 +31,9 @@ use TYPO3\CMS\Frontend\DataProcessing\FilesProcessor;
class Video extends StandardContentPreviewRenderer class Video extends StandardContentPreviewRenderer
{ {
private ContentDataProcessor $contentDataProcessor;
public function __construct( public function __construct(
ContentDataProcessor $contentDataProcessor private ContentDataProcessor $contentDataProcessor
) { ) {
$this->contentDataProcessor = $contentDataProcessor;
} }
public function renderPageModulePreviewContent(GridColumnItem $item): string public function renderPageModulePreviewContent(GridColumnItem $item): string

View file

@ -29,23 +29,9 @@ use TYPO3\CMS\Frontend\Resource\FileCollector;
class AddFurtherMetadataToFile class AddFurtherMetadataToFile
{ {
/** public function __construct(
* @var FileCollector private FileCollector $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);
} }
private function resolvePoster(array $record): ?FileReference private function resolvePoster(array $record): ?FileReference
@ -57,6 +43,16 @@ class AddFurtherMetadataToFile
); );
$files = $this->fileCollector->getFiles(); $files = $this->fileCollector->getFiles();
return $files[0] ?? null; return $files[0] ?? null;
} }
public function __invoke(EnrichFileMetaDataEvent $event): void
{
$record = $event->getRecord();
$record['poster'] = $this->resolvePoster($record);
$event->setRecord($record);
}
} }

View file

@ -31,6 +31,19 @@ use TYPO3\CMS\Frontend\Resource\FileCollector;
class PageLayoutHeader 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 public function __invoke(ModifyPageLayoutContentEvent $event): void
{ {
$request = $event->getRequest(); $request = $event->getRequest();
@ -83,17 +96,4 @@ class PageLayoutHeader
$event->addHeaderContent($view->render()); $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();
}
} }

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\DsSite\Frontend\DataProcessing; namespace DanielSiepmann\DsSite\Frontend\DataProcessing;
use InvalidArgumentException;
use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\QueryHelper; use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@ -30,14 +31,9 @@ use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class CategoriesCounts implements DataProcessorInterface class CategoriesCounts implements DataProcessorInterface
{ {
/** public function __construct(
* @var QueryBuilder private QueryBuilder $queryBuilder
*/ ) {
private $queryBuilder;
public function __construct(QueryBuilder $queryBuilder)
{
$this->queryBuilder = $queryBuilder;
} }
public function process( public function process(
@ -51,7 +47,7 @@ class CategoriesCounts implements DataProcessorInterface
$orderBy = $cObj->stdWrapValue('orderBy', $processorConfiguration, 'count desc'); $orderBy = $cObj->stdWrapValue('orderBy', $processorConfiguration, 'count desc');
if ($parent === '') { if ($parent === '') {
throw new \InvalidArgumentException('No "parent" given.', 1600988668); throw new InvalidArgumentException('No "parent" given.', 1600988668);
} }
$processedData[$as] = $this->getCategoriesCount( $processedData[$as] = $this->getCategoriesCount(

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\DsSite\Frontend\DataProcessing; namespace DanielSiepmann\DsSite\Frontend\DataProcessing;
use Exception;
use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
@ -43,16 +44,16 @@ class NaturalSortingProcessor implements DataProcessorInterface
) { ) {
$variablePath = $cObj->stdWrapValue('variablePath', $processorConfiguration, ''); $variablePath = $cObj->stdWrapValue('variablePath', $processorConfiguration, '');
if (is_string($variablePath) === false) { 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, ''); $variableSubPath = $cObj->stdWrapValue('variableSubPath', $processorConfiguration, '');
if (is_string($variableSubPath) === false) { 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 === '') { 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) { if (ArrayUtility::isValidPath($processedData, $variablePath) === false) {
@ -61,16 +62,17 @@ class NaturalSortingProcessor implements DataProcessorInterface
$valuesToSort = ArrayUtility::getValueByPath($processedData, $variablePath); $valuesToSort = ArrayUtility::getValueByPath($processedData, $variablePath);
if (is_array($valuesToSort) === false) { 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; 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); $value1 = ArrayUtility::getValueByPath($variable1, $variableSubPath);
$value2 = ArrayUtility::getValueByPath($variable2, $variableSubPath); $value2 = ArrayUtility::getValueByPath($variable2, $variableSubPath);
return strnatcasecmp($value2, $value1); return strnatcasecmp($value2, $value1);
}); });
$processedData = ArrayUtility::setValueByPath($processedData, $variablePath, $valuesToSort); $processedData = ArrayUtility::setValueByPath($processedData, $variablePath, $valuesToSort);

View file

@ -66,7 +66,7 @@ final class BlogPostsDataProvider implements DataProcessorInterface
private function getAdditionalWhere(ServerRequestInterface $request): string private function getAdditionalWhere(ServerRequestInterface $request): string
{ {
$categoryUid = intval($request->getQueryParams()['category_uid'] ?? 0); $categoryUid = (int) ($request->getQueryParams()['category_uid'] ?? 0);
if ($categoryUid === 0) { if ($categoryUid === 0) {
return ''; return '';
} }
@ -77,6 +77,7 @@ final class BlogPostsDataProvider implements DataProcessorInterface
if ($where !== '') { if ($where !== '') {
return ''; return '';
} }
return ' ' . $where; 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'])) { if (is_numeric($row['uid'])) {
return (int) $row['uid']; return (int) $row['uid'];
} }

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace DanielSiepmann\DsSite\UserFunction; namespace DanielSiepmann\DsSite\UserFunction;
use DomainException;
use Highlight\Highlighter; use Highlight\Highlighter;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@ -32,10 +33,7 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
*/ */
class CodeHighlighting class CodeHighlighting
{ {
/** private ContentObjectRenderer $contentObjectRenderer;
* @var ContentObjectRenderer
*/
private $contentObjectRenderer;
public function setContentObjectRenderer(ContentObjectRenderer $contentObjectRenderer): void public function setContentObjectRenderer(ContentObjectRenderer $contentObjectRenderer): void
{ {
@ -53,7 +51,7 @@ class CodeHighlighting
// Highlight some code. // Highlight some code.
$highlighted = $highlighter->highlightAuto($code); $highlighted = $highlighter->highlightAuto($code);
$content = '<pre><code>' . $highlighted->value . '</code></pre>'; $content = '<pre><code>' . $highlighted->value . '</code></pre>';
} catch (\DomainException $e) { } catch (DomainException $e) {
$content = '<pre><code>' . $code . '</code></pre>'; $content = '<pre><code>' . $code . '</code></pre>';
} }

View file

@ -23,10 +23,11 @@ declare(strict_types=1);
namespace DanielSiepmann\DsSite\ViewHelpers\Format; namespace DanielSiepmann\DsSite\ViewHelpers\Format;
use Closure;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic; 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. * Formats a given string to be a valid HTML id attribute value.
@ -42,7 +43,7 @@ class IdViewHelper extends AbstractViewHelper
public static function renderStatic( public static function renderStatic(
array $arguments, array $arguments,
\Closure $renderChildrenClosure, Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext RenderingContextInterface $renderingContext
) { ) {
$value = $renderChildrenClosure(); $value = $renderChildrenClosure();
@ -54,6 +55,7 @@ class IdViewHelper extends AbstractViewHelper
$value = preg_replace('#\W#', '', $value) ?? ''; $value = preg_replace('#\W#', '', $value) ?? '';
$value = GeneralUtility::underscoredToUpperCamelCase($value); $value = GeneralUtility::underscoredToUpperCamelCase($value);
$value = lcfirst($value); $value = lcfirst($value);
return $value; return $value;
} }
} }

View file

@ -1,4 +1,6 @@
<?php <?php
declare(strict_types=1);
return [ return [
'own' => [ 'own' => [
'title' => 'Own widgets', 'title' => 'Own widgets',

View file

@ -1,7 +1,13 @@
<?php <?php
(function (string $extensionKey, string $tableName) { declare(strict_types=1);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
(static function (string $extensionKey, string $tableName) {
ExtensionManagementUtility::registerPageTSConfigFile(
$extensionKey, $extensionKey,
'Configuration/PageTSconfig/Index.tsconfig', 'Configuration/PageTSconfig/Index.tsconfig',
$extensionKey $extensionKey
@ -9,7 +15,7 @@
$languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.'; $languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [ ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'columns' => [ 'columns' => [
'rel' => [ 'rel' => [
'label' => 'rel Attribute of generated a Tag', 'label' => 'rel Attribute of generated a Tag',
@ -36,10 +42,10 @@
], ],
]); ]);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( ExtensionManagementUtility::addToAllTCAtypes(
$tableName, $tableName,
'rel', 'rel',
(string) \TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_LINK, (string) PageRepository::DOKTYPE_LINK,
'after:url' 'after:url'
); );

View file

@ -1,7 +1,12 @@
<?php <?php
(function (string $tableName) { declare(strict_types=1);
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
(static function (string $tableName) {
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'columns' => [ 'columns' => [
'slug' => [ 'slug' => [
'label' => '<path-to-locallang-file>.slug', 'label' => '<path-to-locallang-file>.slug',
@ -17,13 +22,13 @@
], ],
'fallbackCharacter' => '-', 'fallbackCharacter' => '-',
'eval' => 'uniqueInSite', 'eval' => 'uniqueInSite',
'default' => '' 'default' => '',
], ],
], ],
], ],
]); ]);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( ExtensionManagementUtility::addToAllTCAtypes(
$tableName, $tableName,
'slug', 'slug',
'', '',

View file

@ -1,10 +1,14 @@
<?php <?php
(function (string $extensionKey, string $tableName) { declare(strict_types=1);
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
(static function (string $extensionKey, string $tableName) {
$languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.'; $languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [ ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'columns' => [ 'columns' => [
'youtube' => [ 'youtube' => [
'label' => $languagePath . 'youtube', 'label' => $languagePath . 'youtube',
@ -18,13 +22,13 @@
'config' => [ 'config' => [
'type' => 'file', 'type' => 'file',
'maxitems' => 1, 'maxitems' => 1,
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], 'allowed' => 'common-image-types',
], ],
], ],
], ],
]); ]);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( ExtensionManagementUtility::addToAllTCAtypes(
$tableName, $tableName,
'youtube, poster', 'youtube, poster',
'', '',

View file

@ -1,7 +1,11 @@
<?php <?php
(function (string $extensionKey) { declare(strict_types=1);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
(static function (string $extensionKey) {
ExtensionManagementUtility::addStaticFile(
$extensionKey, $extensionKey,
'Configuration/TypoScript/', 'Configuration/TypoScript/',
$extensionKey $extensionKey

View file

@ -1,7 +1,11 @@
<?php <?php
(function (string $extensionKey, string $tableName, string $ctype) { declare(strict_types=1);
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
use TYPO3\CMS\Core\Utility\ArrayUtility;
(static function (string $extensionKey, string $tableName, string $ctype) {
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'types' => [ 'types' => [
$ctype => [ $ctype => [
'showitem' => implode(',', [ 'showitem' => implode(',', [

View file

@ -1,9 +1,14 @@
<?php <?php
(function (string $extensionKey, string $tableName, string $contentType) { declare(strict_types=1);
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
(static function (string $extensionKey, string $tableName, string $contentType) {
$languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.'; $languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [ ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'ctrl' => [ 'ctrl' => [
'typeicon_classes' => [ 'typeicon_classes' => [
$contentType => 'content-idea', $contentType => 'content-idea',
@ -42,14 +47,14 @@
], ],
]); ]);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( ExtensionManagementUtility::addTcaSelectItem(
$tableName, $tableName,
'CType', 'CType',
[ [
$languagePath . $contentType, 'label' => $languagePath . $contentType,
$contentType, 'value' => $contentType,
'content-idea', 'icon' => 'content-idea',
'default' 'group' => 'default',
], ],
'image', 'image',
'after' 'after'

View file

@ -1,7 +1,11 @@
<?php <?php
(function (string $extensionKey, string $tableName, string $ctype) { declare(strict_types=1);
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
use TYPO3\CMS\Core\Utility\ArrayUtility;
(static function (string $extensionKey, string $tableName, string $ctype) {
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'types' => [ 'types' => [
$ctype => [ $ctype => [
'showitem' => implode(',', [ 'showitem' => implode(',', [

View file

@ -1,9 +1,13 @@
<?php <?php
(function (string $extensionKey, string $tableName, string $contentType) { declare(strict_types=1);
use TYPO3\CMS\Core\Utility\ArrayUtility;
(static function (string $extensionKey, string $tableName, string $contentType) {
$languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.'; $languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [ ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'types' => [ 'types' => [
$contentType => [ $contentType => [
'showitem' => implode(',', [ 'showitem' => implode(',', [

View file

@ -1,11 +1,15 @@
<?php <?php
use DanielSiepmann\DsSite\Backend\PreviewRenderer\Video; declare(strict_types=1);
(function (string $extensionKey, string $tableName, string $contentType) { use DanielSiepmann\DsSite\Backend\PreviewRenderer\Video;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
(static function (string $extensionKey, string $tableName, string $contentType) {
$languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.'; $languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [ ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'ctrl' => [ 'ctrl' => [
'typeicon_classes' => [ 'typeicon_classes' => [
$contentType => 'content-media', $contentType => 'content-media',
@ -37,14 +41,14 @@ use DanielSiepmann\DsSite\Backend\PreviewRenderer\Video;
], ],
]); ]);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( ExtensionManagementUtility::addTcaSelectItem(
$tableName, $tableName,
'CType', 'CType',
[ [
$languagePath . $contentType, 'label' => $languagePath . $contentType,
$contentType, 'value' => $contentType,
'content-media', 'icon' => 'content-media',
'default' 'group' => 'default',
], ],
'image', 'image',
'after' 'after'

View file

@ -1,7 +1,11 @@
<?php <?php
(function (string $extKey) { declare(strict_types=1);
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TYPO3_CONF_VARS'], [
use TYPO3\CMS\Core\Utility\ArrayUtility;
(static function (string $extKey) {
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TYPO3_CONF_VARS'], [
'BE' => [ 'BE' => [
'stylesheets' => [ 'stylesheets' => [
$extKey => 'EXT:' . $extKey . '/Resources/Public/Backend/Css/', $extKey => 'EXT:' . $extKey . '/Resources/Public/Backend/Css/',