* keywords im content mit Links ersetzen
* Links mit Klasse "show-modal" bei Klick in einen JS-Modal laden, statt dem Link zu folgen git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3296 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
20beca7c4d
commit
c924b4af15
15 changed files with 333 additions and 75 deletions
|
|
@ -7,14 +7,21 @@
|
|||
namespace AppBundle\Twig;
|
||||
|
||||
|
||||
use AppBundle\Service\KeywordService;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
class AppExtension extends \Twig_Extension
|
||||
{
|
||||
protected $environment;
|
||||
private $environment;
|
||||
private $keywordService;
|
||||
private $requestStack;
|
||||
private $template;
|
||||
|
||||
public function __construct(\Twig_Environment $env)
|
||||
public function __construct(\Twig_Environment $env, KeywordService $keywordService, RequestStack $requestStack)
|
||||
{
|
||||
$this->environment = $env;
|
||||
$this->keywordService = $keywordService;
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
|
|
@ -23,6 +30,9 @@ class AppExtension extends \Twig_Extension
|
|||
'stripslashes' => new \Twig_SimpleFilter('stripslashes', [$this, 'stripslashesFilter'], [
|
||||
'is_safe' => ['html']
|
||||
]),
|
||||
'keywords' => new \Twig_SimpleFilter('keywords', [$this, 'keywordsFilter'], [
|
||||
'is_safe' => ['html']
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +45,7 @@ class AppExtension extends \Twig_Extension
|
|||
'form_field_pho' => new \Twig_SimpleFunction('form_field_pho', [$this, 'formFieldPho'], [
|
||||
'is_safe' => ['html']
|
||||
]),
|
||||
'get_base_template' => new \Twig_SimpleFunction('get_base_template', [$this, 'getBaseTemplate']),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +54,16 @@ class AppExtension extends \Twig_Extension
|
|||
return stripslashes($v);
|
||||
}
|
||||
|
||||
public function keywordsFilter($v)
|
||||
{
|
||||
return $this->keywordService->addKeywordLinksToHtml($v, 'keyword-link');
|
||||
}
|
||||
|
||||
public function getBaseTemplate()
|
||||
{
|
||||
return ($this->requestStack->getCurrentRequest()->isXmlHttpRequest() ? 'ajax' : 'base') .'.html.twig';
|
||||
}
|
||||
|
||||
public function formField($form, $label = null, $opt = null)
|
||||
{
|
||||
$this->template = $this->environment->loadTemplate( '::default/form/helpers.html.twig' );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue