mirror of
https://github.com/flextype/flextype.git
synced 2025-08-12 08:04:05 +02:00
Flextype Core: Emitter Twig Extension - added
This commit is contained in:
32
flextype/twig/EmitterTwigExtension.php
Normal file
32
flextype/twig/EmitterTwigExtension.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
class EmitterTwigExtension extends \Twig_Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* Flextype Dependency Container
|
||||
*/
|
||||
private $flextype;
|
||||
|
||||
/**
|
||||
* __construct
|
||||
*/
|
||||
public function __construct($flextype)
|
||||
{
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new \Twig_SimpleFunction('emmiter_emmit', array($this, 'emit')),
|
||||
];
|
||||
}
|
||||
|
||||
public function emit(string $event)
|
||||
{
|
||||
return $this->flextype['emitter']->emit($event);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user