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

825 B

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