Skip to content

Commit

Permalink
fix generating element in be
Browse files Browse the repository at this point in the history
  • Loading branch information
vvohh committed May 8, 2023
1 parent 10493a1 commit 8d2fbf4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,9 @@

All notable changes to this project will be documented in this file.

## [1.3.1] - 2023-05-08
- Fixed: generate content element in backend

## [1.3.0] - 2023-01-23
- Added: encore contracts support ([#16])

Expand Down
12 changes: 12 additions & 0 deletions src/Generator/VideoGenerator.php
Expand Up @@ -8,10 +8,12 @@

namespace HeimrichHannot\VideoBundle\Generator;

use Contao\BackendTemplate;
use Contao\Config;
use Contao\FilesModel;
use Contao\Frontend;
use Contao\PageModel;
use Contao\System;
use HeimrichHannot\UtilsBundle\Image\ImageUtil;
use HeimrichHannot\UtilsBundle\Model\ModelUtil;
use HeimrichHannot\UtilsBundle\Template\TemplateUtil;
Expand Down Expand Up @@ -87,6 +89,16 @@ public function __construct(Environment $twig, ModelUtil $modelUtil, ImageUtil $
*/
public function generate(VideoInterface $video, $parent, array $options = []): string
{
$request = System::getContainer()->get('request_stack')->getCurrentRequest();

if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
{
$objTemplate = new BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . $GLOBALS['TL_LANG']['CTE'][\HeimrichHannot\VideoBundle\ContentElement\VideoElement::TYPE][0] . ' ###';

return $objTemplate->parse();
}

if (isset($options['rootPage'])) {
if (!$options['rootPage'] instanceof PageModel) {
throw new \InvalidArgumentException("Option rootPage only allows \Contao\PageModel instances. Input was ".\get_class($options['rootPage']));
Expand Down

0 comments on commit 8d2fbf4

Please sign in to comment.