| 1 | <?php |
||
| 8 | class NotifierExtension extends \Twig_Extension |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var \Twig_Environment |
||
| 12 | */ |
||
| 13 | protected $twig; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $host; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $apiKey; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Class constructor |
||
| 27 | * |
||
| 28 | * @param \Twig_Environment $twig |
||
| 29 | * @param string $host |
||
| 30 | * @param string $apiKey |
||
| 31 | */ |
||
| 32 | 4 | public function __construct(\Twig_Environment $twig, $host, $apiKey) |
|
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritDoc} |
||
| 41 | */ |
||
| 42 | 2 | public function getFunctions() |
|
| 43 | { |
||
| 44 | return array( |
||
| 45 | 2 | new \Twig_SimpleFunction( |
|
| 46 | 2 | 'errbit_notifier', |
|
| 47 | 2 | array($this, 'getErrbitNotifier'), |
|
| 48 | array( |
||
| 49 | 2 | 'is_safe' => array('html'), |
|
| 50 | ) |
||
| 51 | 2 | ) |
|
| 52 | 2 | ); |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Returns the HTML that will be inserted by rendering the template |
||
| 57 | * |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | public function getErrbitNotifier() |
||
| 61 | { |
||
| 62 | return $this->twig->render( |
||
| 63 | 'SumoCodersFrameworkErrorBundle:Extension:notifier.html.twig', |
||
| 64 | array( |
||
| 65 | 'host' => $this->host, |
||
| 66 | 'api_key' => $this->apiKey, |
||
| 67 | ) |
||
| 68 | ); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @return string |
||
| 73 | */ |
||
| 74 | 3 | public function getName() |
|
| 78 | } |
||
| 79 |