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

[TASK] Run rector, ecs and phpstan

parent b4cf8ce5
No related branches found
No related tags found
1 merge request!3Feature upgrade to typo3 11
...@@ -32,7 +32,6 @@ use TYPO3\CMS\Extbase\Service\ImageService; ...@@ -32,7 +32,6 @@ use TYPO3\CMS\Extbase\Service\ImageService;
* The Vimeo Controller * The Vimeo Controller
*/ */
class VimeoController extends ActionController { class VimeoController extends ActionController {
/** /**
* Renders the Vimeo video view * Renders the Vimeo video view
* *
...@@ -51,7 +50,10 @@ class VimeoController extends ActionController { ...@@ -51,7 +50,10 @@ class VimeoController extends ActionController {
} }
/** @var VimeoService $vimeoService */ /** @var VimeoService $vimeoService */
$vimeoService = GeneralUtility::makeInstance( $vimeoService = GeneralUtility::makeInstance(
VimeoService::class, $clientId, $clientSecret, $personalAccessToken VimeoService::class,
$clientId,
$clientSecret,
$personalAccessToken
); );
$response = $vimeoService->getVimeoData($id, $maxResults); $response = $vimeoService->getVimeoData($id, $maxResults);
$response = $this->mapVimeoApiResponseWithPossibleCustomThumbnails($response); $response = $this->mapVimeoApiResponseWithPossibleCustomThumbnails($response);
...@@ -76,7 +78,7 @@ class VimeoController extends ActionController { ...@@ -76,7 +78,7 @@ class VimeoController extends ActionController {
} }
$showApiResult = (int) ($this->settings['showApiResult'] ?? 1); $showApiResult = (int) ($this->settings['showApiResult'] ?? 1);
$context = GeneralUtility::getApplicationContext(); $context = \TYPO3\CMS\Core\Core\Environment::getContext();
// disable API debug output in production context // disable API debug output in production context
if ($context->isProduction()) { if ($context->isProduction()) {
$showApiResult = 0; $showApiResult = 0;
...@@ -111,7 +113,9 @@ class VimeoController extends ActionController { ...@@ -111,7 +113,9 @@ class VimeoController extends ActionController {
/** @var FileRepository $fileRepository */ /** @var FileRepository $fileRepository */
$fileRepository = GeneralUtility::makeInstance(FileRepository::class); $fileRepository = GeneralUtility::makeInstance(FileRepository::class);
$fileObjects = $fileRepository->findByRelation( $fileObjects = $fileRepository->findByRelation(
'tt_content', 'tx_sgvimeo_thumbnail_image', $contentElementUid 'tt_content',
'tx_sgvimeo_thumbnail_image',
$contentElementUid
); );
if (count($fileObjects) <= 0) { if (count($fileObjects) <= 0) {
return $response; return $response;
......
...@@ -20,13 +20,12 @@ namespace SGalinski\SgVimeo\Hooks\PageLayoutView; ...@@ -20,13 +20,12 @@ namespace SGalinski\SgVimeo\Hooks\PageLayoutView;
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
use SGalinski\SgComments\Domain\Model\Language;
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\PageLayoutView; use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface; use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\View\StandaloneView;
use \TYPO3\CMS\Core\Localization\LanguageService;
/** /**
* Class PluginRenderer * Class PluginRenderer
...@@ -47,7 +46,11 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { ...@@ -47,7 +46,11 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
* @noinspection ReferencingObjectsInspection * @noinspection ReferencingObjectsInspection
*/ */
public function preProcess( public function preProcess(
PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row PageLayoutView &$parentObject,
&$drawItem,
&$headerContent,
&$itemContent,
array &$row
): void { ): void {
if ($row['list_type'] === 'sgvimeo_vimeo') { if ($row['list_type'] === 'sgvimeo_vimeo') {
$drawItem = FALSE; $drawItem = FALSE;
...@@ -62,7 +65,8 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { ...@@ -62,7 +65,8 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
// Get available plugin settings and their values from flexform // Get available plugin settings and their values from flexform
$pluginConfiguration = GeneralUtility::xml2array( $pluginConfiguration = GeneralUtility::xml2array(
$row['pi_flexform'], 'T3DataStructure' $row['pi_flexform'],
'T3DataStructure'
)['data']['sDEF']['lDEF']; )['data']['sDEF']['lDEF'];
$templateData = [ $templateData = [
...@@ -88,13 +92,14 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { ...@@ -88,13 +92,14 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
* Adapts the given $headerContent. * Adapts the given $headerContent.
* To be used in all plugin previews so the Header Contents appear similarly. * To be used in all plugin previews so the Header Contents appear similarly.
* *
* @param $headerContent * @param string $headerContent
* @param $row * @param array $row
*/ */
protected function adaptPluginHeaderContent(&$headerContent, $row): void { protected function adaptPluginHeaderContent(&$headerContent, $row): void {
$headerContent = '<h4>' . $this->getPluginNameForHeaderContent( $headerContent = '<h4>' . $this->getPluginNameForHeaderContent(
(int) $row['pid'], $row['list_type'] (int) $row['pid'],
) . $headerContent . '</h4>'; $row['list_type']
) . $headerContent . '</h4>';
} }
/** /**
...@@ -111,7 +116,10 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { ...@@ -111,7 +116,10 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
$pluginName = $languageService->sL( $pluginName = $languageService->sL(
BackendUtility::getLabelFromItemListMerged( BackendUtility::getLabelFromItemListMerged(
$pid, 'tt_content', 'list_type', $listType $pid,
'tt_content',
'list_type',
$listType
) )
); );
return '<span class="label label-primary">' . $pluginName . '</span>&nbsp;'; return '<span class="label label-primary">' . $pluginName . '</span>&nbsp;';
......
...@@ -96,6 +96,7 @@ class VimeoService implements LoggerAwareInterface { ...@@ -96,6 +96,7 @@ class VimeoService implements LoggerAwareInterface {
* @return array|null * @return array|null
*/ */
public function getVimeoData(string $vimeoId, int $maxResults): ?array { public function getVimeoData(string $vimeoId, int $maxResults): ?array {
$response = [];
$this->maxResultsPerPage = $maxResults; $this->maxResultsPerPage = $maxResults;
/** @var Registry $registry */ /** @var Registry $registry */
$registry = GeneralUtility::makeInstance(Registry::class); $registry = GeneralUtility::makeInstance(Registry::class);
...@@ -118,7 +119,7 @@ class VimeoService implements LoggerAwareInterface { ...@@ -118,7 +119,7 @@ class VimeoService implements LoggerAwareInterface {
$showcaseId = explode('/', $vimeoId)[1]; $showcaseId = explode('/', $vimeoId)[1];
$response['items'] = $this->addVideoIdsToResponse($this->getShowcaseVideos((int) $showcaseId)); $response['items'] = $this->addVideoIdsToResponse($this->getShowcaseVideos((int) $showcaseId));
$response['kind'] = 'showcase'; $response['kind'] = 'showcase';
} else if (strpos($vimeoId, 'channel') === 0) { } elseif (strpos($vimeoId, 'channel') === 0) {
$channelId = explode('/', $vimeoId)[1]; $channelId = explode('/', $vimeoId)[1];
$response['items'] = $this->addVideoIdsToResponse($this->getChannelVideos($channelId)); $response['items'] = $this->addVideoIdsToResponse($this->getChannelVideos($channelId));
$response['kind'] = 'channel'; $response['kind'] = 'channel';
...@@ -193,7 +194,7 @@ class VimeoService implements LoggerAwareInterface { ...@@ -193,7 +194,7 @@ class VimeoService implements LoggerAwareInterface {
// @TODO: we could check $response['headers‘]['X-RateLimit-Remaining'] here for remaining quota // @TODO: we could check $response['headers‘]['X-RateLimit-Remaining'] here for remaining quota
if (array_key_exists('paging', $response['body'])) { if (array_key_exists('paging', $response['body'])) {
$amountOfVideosInResponse = count($response['body']['data']); $amountOfVideosInResponse = is_countable($response['body']['data']) ? count($response['body']['data']) : 0;
$this->amountOfVideosFetched += $amountOfVideosInResponse; $this->amountOfVideosFetched += $amountOfVideosInResponse;
$this->paginatedResponseData[] = $response['body']['data']; $this->paginatedResponseData[] = $response['body']['data'];
$nextUrl = $response['body']['paging']['next']; $nextUrl = $response['body']['paging']['next'];
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['sgvimeo_vimeo'] = 'pi_flexform'; $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['sgvimeo_vimeo'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue( \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
'sgvimeo_vimeo', 'FILE:EXT:sg_vimeo/Configuration/FlexForms/flexform_sgvimeo_vimeo.xml' 'sgvimeo_vimeo',
'FILE:EXT:sg_vimeo/Configuration/FlexForms/flexform_sgvimeo_vimeo.xml'
); );
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin( \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'SGalinski.sg_vimeo', 'SgVimeo',
'Vimeo', 'Vimeo',
'Vimeo Videos' 'Vimeo Videos'
); );
Resources/Public/Icons/Extension.png

825 B

...@@ -24,15 +24,15 @@ ...@@ -24,15 +24,15 @@
* This copyright notice MUST APPEAR in all copies of the script! * This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/ ***************************************************************/
if (!defined('TYPO3_MODE')) { if (!defined('TYPO3')) {
die('Access denied.'); die('Access denied.');
} }
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SGalinski.sg_vimeo', 'SgVimeo',
'Vimeo', 'Vimeo',
[ [
'Vimeo' => 'index', \SGalinski\SgVimeo\Controller\VimeoController::class => 'index',
], ],
// non-cacheable actions // non-cacheable actions
......
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