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

[TASK] catch exception when no client id / secret is set

parent 46bc8788
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,10 @@ class VimeoController extends ActionController {
$maxResults = (int) $this->settings['maxResults'];
$clientId = $this->settings['clientId'];
$clientSecret = $this->settings['clientSecret'];
if (trim($clientId) === '' || trim($clientSecret) === '') {
$this->view->assign('error', 'Please configure a client id and a client secret for sg_vimeo.');
return;
}
$vimeoService = GeneralUtility::makeInstance(VimeoService::class, $clientId, $clientSecret);
$response = $vimeoService->getVimeoData($id, $maxResults);
$response = $this->mapVimeoApiResponseWithPossibleCustomThumbnails($response);
......@@ -50,10 +54,17 @@ class VimeoController extends ActionController {
return;
}
$showApiResult = (int) ($this->settings['showApiResult'] ?? 1);
$context = GeneralUtility::getApplicationContext();
// disable API debug output in production context
if ($context->isProduction()) {
$showApiResult = 0;
}
$this->view->assignMultiple(
[
'response' => $response,
'showApiResult' => (int) ($this->settings['showApiResult'] ?? 1),
'showApiResult' => $showApiResult,
'showTitle' => (int) ($this->settings['showTitle'] ?? 1),
'showDescription' => (int) ($this->settings['showDescription'] ?? 1),
]
......
<f:layout name="Default"/>
<f:section name="main">
<f:if condition="{showApiResult}">
<f:debug>{response}</f:debug>
</f:if>
<f:if condition="{error}">
<f:then>
<p>{error}</p>
</f:then>
<f:else>
<f:if condition="{showApiResult}">
<f:debug>{response}</f:debug>
</f:if>
<ul class="sg-vimeo sg-vimeo-default">
<f:for each="{response.items}" as="item" iteration="feedIterator">
<li class="sg-vimeo-item-container{f:if(condition: '{feedIterator.total} < 2', then: ' sg-vimeo-item-single')}">
<a class="sg-vimeo-item sg-card-shadow" href="{item.link}" data-video-id="{item.videoId}" target="_blank"
data-disable-lightbox="{settings.disableLightbox}"
data-disable-lightbox-mobile="{settings.disableLightboxMobile}">
<f:comment>
<!--Use the custom thumbnail (if available).
Use the last picture of the vimeo API response otherwise (the last one,
should always be the one with the highest resolution).-->
</f:comment>
<f:if condition="{item.thumbnail}">
<f:then>
<div class="sg-vimeo-image">
<img src="{item.thumbnail}" alt="{item.name}" loading="lazy"/>
</div>
</f:then>
<f:else>
<f:if condition="{item.pictures.sizes}">
<f:for each="{item.pictures.sizes}" as="picture" iteration="iterator">
<f:if condition="{iterator.isLast}">
<div class="sg-vimeo-image">
<img src="{picture.link}" alt="{item.name}" loading="lazy"/>
</div>
<ul class="sg-vimeo sg-vimeo-default">
<f:for each="{response.items}" as="item" iteration="feedIterator">
<li class="sg-vimeo-item-container{f:if(condition: '{feedIterator.total} < 2', then: ' sg-vimeo-item-single')}">
<a class="sg-vimeo-item sg-card-shadow" href="{item.link}" data-video-id="{item.videoId}" target="_blank"
data-disable-lightbox="{settings.disableLightbox}"
data-disable-lightbox-mobile="{settings.disableLightboxMobile}">
<f:comment>
<!--Use the custom thumbnail (if available).
Use the last picture of the vimeo API response otherwise (the last one,
should always be the one with the highest resolution).-->
</f:comment>
<f:if condition="{item.thumbnail}">
<f:then>
<div class="sg-vimeo-image">
<img src="{item.thumbnail}" alt="{item.name}" loading="lazy"/>
</div>
</f:then>
<f:else>
<f:if condition="{item.pictures.sizes}">
<f:for each="{item.pictures.sizes}" as="picture" iteration="iterator">
<f:if condition="{iterator.isLast}">
<div class="sg-vimeo-image">
<img src="{picture.link}" alt="{item.name}" loading="lazy"/>
</div>
</f:if>
</f:for>
</f:if>
</f:for>
</f:else>
</f:if>
<f:if condition="{showTitle} && {item.name}">
<div class="sg-vimeo-title">
<h3 class="h3">{item.name}</h3>
</div>
</f:if>
</f:else>
</f:if>
<f:if condition="{showTitle} && {item.name}">
<div class="sg-vimeo-title">
<h3 class="h3">{item.name}</h3>
</div>
</f:if>
<f:if condition="{showDescription} && {item.description}">
<div class="sg-vimeo-text">
<f:format.crop maxCharacters="200">{item.description}</f:format.crop>
</div>
</f:if>
</a>
</li>
</f:for>
</ul>
<f:if condition="{showDescription} && {item.description}">
<div class="sg-vimeo-text">
<f:format.crop maxCharacters="200">{item.description}</f:format.crop>
</div>
</f:if>
</a>
</li>
</f:for>
</ul>
</f:else>
</f:if>
</f:section>
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