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
{
private ContentDataProcessor $contentDataProcessor;
public function __construct(
ContentDataProcessor $contentDataProcessor
private ContentDataProcessor $contentDataProcessor
) {
$this->contentDataProcessor = $contentDataProcessor;
}
public function renderPageModulePreviewContent(GridColumnItem $item): string

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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(

View file

@ -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);

View file

@ -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'];
}

View file

@ -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 = '<pre><code>' . $highlighted->value . '</code></pre>';
} catch (\DomainException $e) {
} catch (DomainException $e) {
$content = '<pre><code>' . $code . '</code></pre>';
}

View file

@ -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;
}
}

View file

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

View file

@ -1,7 +1,13 @@
<?php
(function (string $extensionKey, string $tableName) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile(
declare(strict_types=1);
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,
'Configuration/PageTSconfig/Index.tsconfig',
$extensionKey
@ -9,7 +15,7 @@
$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' => [
'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'
);

View file

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

View file

@ -1,10 +1,14 @@
<?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 . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'columns' => [
'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',
'',

View file

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

View file

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

View file

@ -1,9 +1,14 @@
<?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 . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'ctrl' => [
'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'

View file

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

View file

@ -1,9 +1,13 @@
<?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 . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'types' => [
$contentType => [
'showitem' => implode(',', [

View file

@ -1,11 +1,15 @@
<?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 . '.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [
'ctrl' => [
'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'

View file

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