Commit c57c7e41 authored by arnaudbey's avatar arnaudbey
Browse files

add twig extension to get definitions

parent c93dd573
services:
# innova_wiktionary.example:
# class: Innova\WiktionaryBundle\Example
# arguments: ["@service_id", "plain_value", "%parameter%"]
innovalangues_wiktionary:
class: Innova\WiktionaryBundle\Manager\WiktionaryManager
twig.extension.wiktionary:
class: Innova\WiktionaryBundle\Twig\WiktionaryExtension
arguments:
"wiktionaryManager": "@innovalangues_wiktionary"
tags:
- { name: twig.extension }
<?php
namespace Innova\WiktionaryBundle\Twig;
class WiktionaryExtension extends \Twig_Extension
{
protected $wiktionaryManager;
public function __construct($wiktionaryManager)
{
$this->wiktionaryManager = $wiktionaryManager;
}
public function getDefinitions($form, $language)
{
$definitions = $this->wiktionaryManager->getDefinitions($form, $language);
return $definitions;
}
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('getDefinitions', array($this, 'getDefinitions')),
);
}
public function getName()
{
return 'getDefinitions';
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment