Skip to content
Snippets Groups Projects
Commit a0effa58 authored by Kevin von Spiczak's avatar Kevin von Spiczak
Browse files

[TASK] clean up/optimizations

parent bd1bbec7
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,10 @@ class VimeoController extends ActionController { ...@@ -50,7 +50,10 @@ class VimeoController extends ActionController {
$this->view->assign('error', 'Please configure a client id and a client secret for sg_vimeo.'); $this->view->assign('error', 'Please configure a client id and a client secret for sg_vimeo.');
return; return;
} }
$vimeoService = GeneralUtility::makeInstance(VimeoService::class, $clientId, $clientSecret, $personalAccessToken); /** @var VimeoService $vimeoService */
$vimeoService = GeneralUtility::makeInstance(
VimeoService::class, $clientId, $clientSecret, $personalAccessToken
);
$response = $vimeoService->getVimeoData($id, $maxResults, $isPrivate); $response = $vimeoService->getVimeoData($id, $maxResults, $isPrivate);
$response = $this->mapVimeoApiResponseWithPossibleCustomThumbnails($response); $response = $this->mapVimeoApiResponseWithPossibleCustomThumbnails($response);
if ($response === NULL) { if ($response === NULL) {
...@@ -70,6 +73,7 @@ class VimeoController extends ActionController { ...@@ -70,6 +73,7 @@ class VimeoController extends ActionController {
$item['link'] = strstr($item['link'], '.com/', TRUE) . '.com/' . $item['videoId']; $item['link'] = strstr($item['link'], '.com/', TRUE) . '.com/' . $item['videoId'];
} }
} }
unset($item);
} }
$showApiResult = (int) ($this->settings['showApiResult'] ?? 1); $showApiResult = (int) ($this->settings['showApiResult'] ?? 1);
...@@ -96,7 +100,7 @@ class VimeoController extends ActionController { ...@@ -96,7 +100,7 @@ class VimeoController extends ActionController {
* @return array|null * @return array|null
*/ */
protected function mapVimeoApiResponseWithPossibleCustomThumbnails(?array $response): ?array { protected function mapVimeoApiResponseWithPossibleCustomThumbnails(?array $response): ?array {
if ($response === NULL || !is_array($response) || !array_key_exists('items', $response)) { if (!is_array($response) || !array_key_exists('items', $response)) {
return NULL; return NULL;
} }
...@@ -105,6 +109,7 @@ class VimeoController extends ActionController { ...@@ -105,6 +109,7 @@ class VimeoController extends ActionController {
return $response; return $response;
} }
/** @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
...@@ -129,6 +134,7 @@ class VimeoController extends ActionController { ...@@ -129,6 +134,7 @@ class VimeoController extends ActionController {
$processingInstructions = [ $processingInstructions = [
'crop' => $cropArea->isEmpty() ? NULL : $cropArea->makeAbsoluteBasedOnFile($fileObject), 'crop' => $cropArea->isEmpty() ? NULL : $cropArea->makeAbsoluteBasedOnFile($fileObject),
]; ];
/** @var ImageService $imageService */
$imageService = GeneralUtility::makeInstance(ImageService::class); $imageService = GeneralUtility::makeInstance(ImageService::class);
$processedImage = $imageService->applyProcessingInstructions($fileObject, $processingInstructions); $processedImage = $imageService->applyProcessingInstructions($fileObject, $processingInstructions);
$response['items'][$index]['thumbnail'] = $imageService->getImageUri($processedImage); $response['items'][$index]['thumbnail'] = $imageService->getImageUri($processedImage);
......
...@@ -20,6 +20,7 @@ namespace SGalinski\SgVimeo\Hooks\PageLayoutView; ...@@ -20,6 +20,7 @@ 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;
...@@ -52,7 +53,7 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { ...@@ -52,7 +53,7 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
$drawItem = FALSE; $drawItem = FALSE;
$this->adaptPluginHeaderContent($headerContent, $row); $this->adaptPluginHeaderContent($headerContent, $row);
/** @var StandaloneView $view */
$view = GeneralUtility::makeInstance(StandaloneView::class); $view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setPartialRootPaths(['EXT:sg_vimeo/Resources/Private/Partials/Backend']); $view->setPartialRootPaths(['EXT:sg_vimeo/Resources/Private/Partials/Backend']);
$view->setTemplateRootPaths(['EXT:sg_vimeo/Resources/Private/Templates/Vimeo']); $view->setTemplateRootPaths(['EXT:sg_vimeo/Resources/Private/Templates/Vimeo']);
...@@ -106,6 +107,7 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { ...@@ -106,6 +107,7 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
* @return string * @return string
*/ */
protected function getPluginNameForHeaderContent(int $pid, string $listType): string { protected function getPluginNameForHeaderContent(int $pid, string $listType): string {
/** @var LanguageService $languageService */
$languageService = GeneralUtility::makeInstance(LanguageService::class); $languageService = GeneralUtility::makeInstance(LanguageService::class);
$pluginName = $languageService->sL( $pluginName = $languageService->sL(
......
...@@ -93,6 +93,7 @@ class VimeoService implements LoggerAwareInterface { ...@@ -93,6 +93,7 @@ class VimeoService implements LoggerAwareInterface {
*/ */
public function getVimeoData(string $vimeoId, int $maxResults, bool $isPrivate): ?array { public function getVimeoData(string $vimeoId, int $maxResults, bool $isPrivate): ?array {
$this->maxResultsPerPage = $maxResults; $this->maxResultsPerPage = $maxResults;
/** @var Registry $registry */
$registry = GeneralUtility::makeInstance(Registry::class); $registry = GeneralUtility::makeInstance(Registry::class);
$currentDay = date('Y-m-d', $GLOBALS['EXEC_TIME']); $currentDay = date('Y-m-d', $GLOBALS['EXEC_TIME']);
$cacheKey = sha1($vimeoId . $maxResults); $cacheKey = sha1($vimeoId . $maxResults);
...@@ -110,11 +111,11 @@ class VimeoService implements LoggerAwareInterface { ...@@ -110,11 +111,11 @@ class VimeoService implements LoggerAwareInterface {
} }
if (strpos($vimeoId, 'showcase') === 0) { if (strpos($vimeoId, 'showcase') === 0) {
$showcaseId = preg_split('/\//', $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) { } else if (strpos($vimeoId, 'channel') === 0) {
$channelId = preg_split('/\//', $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';
} else { } else {
...@@ -122,7 +123,6 @@ class VimeoService implements LoggerAwareInterface { ...@@ -122,7 +123,6 @@ class VimeoService implements LoggerAwareInterface {
$response['kind'] = 'video'; $response['kind'] = 'video';
} }
if (!$disableVimeoCache) { if (!$disableVimeoCache) {
$response['CACHE_DATE'] = $currentDay; $response['CACHE_DATE'] = $currentDay;
$registry->set('sg_vimeo', $cacheKey, $response); $registry->set('sg_vimeo', $cacheKey, $response);
...@@ -138,7 +138,7 @@ class VimeoService implements LoggerAwareInterface { ...@@ -138,7 +138,7 @@ class VimeoService implements LoggerAwareInterface {
* @return array|null * @return array|null
*/ */
protected function addVideoIdsToResponse(?array $response): ?array { protected function addVideoIdsToResponse(?array $response): ?array {
if ($response === NULL || !is_array($response)) { if (!is_array($response)) {
return NULL; return NULL;
} }
...@@ -176,7 +176,7 @@ class VimeoService implements LoggerAwareInterface { ...@@ -176,7 +176,7 @@ class VimeoService implements LoggerAwareInterface {
* @return array|null * @return array|null
*/ */
protected function preprocessApiResponse(?array $response): ?array { protected function preprocessApiResponse(?array $response): ?array {
if ($response === NULL || !is_array($response)) { if (!is_array($response)) {
return NULL; return NULL;
} }
......
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