Skip to content

Commit

Permalink
Merge branch 'stable' into franz/changelogs_20211115
Browse files Browse the repository at this point in the history
  • Loading branch information
stentrop authored Nov 16, 2021
2 parents 67dda88 + 5d44fa4 commit 846d37c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Extensions/TwigTemplateContextExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use IO\Helper\EventDispatcher;
use IO\Helper\TemplateContainer;
use IO\Services\TemplateService;
use Plenty\Modules\ContentCache\Contracts\ContentCacheRepositoryContract;
use Plenty\Plugin\Templates\Extensions\Twig_Extension;

class TwigTemplateContextExtension extends Twig_Extension
Expand Down Expand Up @@ -64,7 +65,14 @@ public function getGlobals(): array
$context->init(TemplateService::$currentTemplateData);
}

return ArrayHelper::toArray($context);
$contextArray = ArrayHelper::toArray($context);
if(is_null($contextArray)) {
/** @var ContentCacheRepositoryContract $contentCacheRepository */
$contentCacheRepository = pluginApp(ContentCacheRepositoryContract::class);
$contentCacheRepository->disableCacheForResponse('Twig context could not be initialized');
return [];
}
return $contextArray;
}

return [];
Expand Down

0 comments on commit 846d37c

Please sign in to comment.