Skip to content
Snippets Groups Projects
Verified Commit 038902e6 authored by Kevin Ditscheid's avatar Kevin Ditscheid
Browse files

[TASK] ECS and phpstan fixes

parent ab36a723
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,6 @@ namespace SGalinski\SgYoutube\Controller;
use Exception;
use InvalidArgumentException;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface;
use SGalinski\SgYoutube\Event\AfterFilterVideosEvent;
use SGalinski\SgYoutube\Event\AfterMapCustomThumbnailsEvent;
......@@ -35,7 +34,6 @@ use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\FileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Service\ImageService;
......@@ -101,12 +99,7 @@ class YoutubeController extends ActionController {
}
}
$typo3Version = VersionNumberUtility::getCurrentTypo3Version();
if (version_compare($typo3Version, '13.0.0', '<')) {
$disableYoutubeCache = (bool) GeneralUtility::_GP('disableYoutubeCache');
} else {
$disableYoutubeCache = (bool) ($this->request->getParsedBody()['disableYoutubeCache'] ?? $this->request->getQueryParams()['disableYoutubeCache'] ?? NULL);
}
$disableYoutubeCache = (bool) ($this->request->getParsedBody()['disableYoutubeCache'] ?? $this->request->getQueryParams()['disableYoutubeCache'] ?? NULL);
// Add third-party filters
$filterInstances = $this->handleFrontendFilters($filterValues);
......
......@@ -133,7 +133,7 @@ class LicenceCheckService {
'8.1.0' => 1733341275, // Wed, 04 Dez 2024 20:57:50 GMT+3
'8.1.1' => 1737826502, // 2025-01-25T17:35:02Z
'8.1.2' => 1737826693, // 2025-01-25T17:38:13Z
'8.1.3' => 1737827527, // 2025-01-25T17:52:07Z
'8.1.3' => 1737827527, // 2025-01-25T17:52:07Z
];
/**
......
......@@ -26,15 +26,11 @@
namespace SGalinski\SgYoutube\ViewHelpers;
use Closure;
use InvalidArgumentException;
use RuntimeException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\FileReference;
......@@ -42,12 +38,9 @@ use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
use TYPO3\CMS\Extbase\Service\ImageService;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Exception;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic;
use UnexpectedValueException;
/**
......@@ -57,8 +50,6 @@ use UnexpectedValueException;
* @link https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Functions/Imgresource.html#width
*/
class PictureViewHelper extends AbstractViewHelper {
use CompileWithContentArgumentAndRenderStatic;
/** @var bool */
protected $escapeOutput = FALSE;
......@@ -154,21 +145,11 @@ class PictureViewHelper extends AbstractViewHelper {
/**
* Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function.
*
* @param array $arguments
* @param Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
* @throws InvalidConfigurationTypeException
* @throws ExtensionConfigurationExtensionNotConfiguredException
* @throws ExtensionConfigurationPathDoesNotExistException
*/
public static function renderStatic(
array $arguments,
Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
): string {
public function render(): string {
/** @var FileReference|string $image */
$image = $arguments['image'];
$image = $this->arguments['image'];
if (is_string($image)) {
$image = str_replace('/fileadmin', '1:', $image);
......@@ -191,33 +172,33 @@ class PictureViewHelper extends AbstractViewHelper {
)['plugin.']['tx_project_base.']['settings.']['responsiveImages.'];
}
$width = $arguments['width'];
$maxWidth = (int) $arguments['maxWidth'];
$minWidth = (int) $arguments['minWidth'];
$height = $arguments['height'];
$responsiveHeights = $arguments['responsiveHeights'] ?? [];
$responsiveImages = $arguments['responsiveImages'] ?? [];
$maxHeight = (int) $arguments['maxHeight'];
$minHeight = (int) $arguments['minHeight'];
$class = $arguments['class'];
$pictureClass = $arguments['pictureClass'] ?? '';
$id = $arguments['id'];
$title = $arguments['title'] ?? '';
$alt = $arguments['alt'] ?? '';
$disableWebp = $arguments['disableWebp'] ?? '';
$width = $this->arguments['width'];
$maxWidth = (int) $this->arguments['maxWidth'];
$minWidth = (int) $this->arguments['minWidth'];
$height = $this->arguments['height'];
$responsiveHeights = $this->arguments['responsiveHeights'] ?? [];
$responsiveImages = $this->arguments['responsiveImages'] ?? [];
$maxHeight = (int) $this->arguments['maxHeight'];
$minHeight = (int) $this->arguments['minHeight'];
$class = $this->arguments['class'];
$pictureClass = $this->arguments['pictureClass'] ?? '';
$id = $this->arguments['id'];
$title = $this->arguments['title'] ?? '';
$alt = $this->arguments['alt'] ?? '';
$disableWebp = $this->arguments['disableWebp'] ?? '';
try {
if ($arguments['treatIdAsReference']) {
if ($this->arguments['treatIdAsReference']) {
if ($image instanceof FileReference) {
/** @var FileReference $image */
$image = self::$imageService->getImage($image->getUid(), NULL, $arguments['treatIdAsReference']);
$image = self::$imageService->getImage($image->getUid(), NULL, $this->arguments['treatIdAsReference']);
} else {
// Hidden feature: the id used for treatIdAsReference can be an int or a string (e.g. "1:/someimage.png")
$image = self::$imageService->getImage($image, NULL, $arguments['treatIdAsReference']);
$image = self::$imageService->getImage($image, NULL, $this->arguments['treatIdAsReference']);
}
} else {
/** @var FileReference $image */
$image = self::$imageService->getImage('', $image, $arguments['treatIdAsReference']);
$image = self::$imageService->getImage('', $image, $this->arguments['treatIdAsReference']);
}
} catch (\Exception $exception) {
return '';
......@@ -253,7 +234,7 @@ class PictureViewHelper extends AbstractViewHelper {
|| $fileExtension === 'jpeg'
|| $fileExtension === 'webp'
);
$imageUrl = self::getImage($image, $sizes, 'default', $convertToWebp);
$imageUrl = $this->getImage($image, $sizes, 'default', $convertToWebp);
// Don't add a scaled version for SVG's. This is not necessary at all
$determinedWidth = (int) $width;
......@@ -286,7 +267,7 @@ class PictureViewHelper extends AbstractViewHelper {
$responsiveImage = $responsiveImages[$sizeKeyWithoutDot];
}
$sourceImageUrl = self::getImage($responsiveImage, $sizes, $sizeKeyWithoutDot, $convertToWebp);
$sourceImageUrl = $this->getImage($responsiveImage, $sizes, $sizeKeyWithoutDot, $convertToWebp);
$sources .= '<source media="(max-width: ' . $imageSizeMaxWidth . 'px)" srcset="' .
$sourceImageUrl . '" />' . "\n";
}
......@@ -325,10 +306,10 @@ class PictureViewHelper extends AbstractViewHelper {
$titleAsAttribute = $title ? ' title="' . htmlspecialchars($title) . '"' : '';
$loadingDirective = '';
if (isset($arguments['loadingDirective']) && $arguments['loadingDirective'] !== 'none') {
$arguments['loadingDirective'] = $arguments['loadingDirective'] !== '' ?
$arguments['loadingDirective'] : 'lazy';
$loadingDirective = ' loading="' . $arguments['loadingDirective'] . '"';
if (isset($this->arguments['loadingDirective']) && $this->arguments['loadingDirective'] !== 'none') {
$this->arguments['loadingDirective'] = $this->arguments['loadingDirective'] !== '' ?
$this->arguments['loadingDirective'] : 'lazy';
$loadingDirective = ' loading="' . $this->arguments['loadingDirective'] . '"';
}
return '<picture' . ($pictureClass ? ' class="' . $pictureClass . '"' : '') . '>' .
......@@ -348,7 +329,7 @@ class PictureViewHelper extends AbstractViewHelper {
* @param bool $convertToWebp
* @return string
*/
protected static function getImage(
protected function getImage(
FileInterface $image,
array $sizes = [],
string $cropVariant = 'default',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment