Advertisement
djuro95

twig extension

Apr 9th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. Twig extension
  2.  
  3. class EventLogExtension extends \Twig_Extension
  4. {
  5.  
  6. /**
  7. * @var RegistryInterface
  8. */
  9. private $doctrine;
  10.  
  11. public function __construct(RegistryInterface $doctrine)
  12. {
  13. $this->doctrine = $doctrine;
  14. }
  15.  
  16. public function getFunctions()
  17. {
  18. return [
  19. new \Twig_Function('get_event_log_count', \Closure::bind(function (User $user, $status) {
  20. return $this->getEventLogCount($user, $status);
  21. }, $this))
  22. ];
  23. }
  24.  
  25. private function getEventLogCount(User $user, $status)
  26. {
  27. ...................
  28. }
  29.  
  30. }
  31.  
  32. ----------------------------
  33. view
  34.  
  35. app/capmaign/partials/_menu_influencer.html.twig
  36.  
  37. <a href="{{ path('influence_campaign_list', {'preset': 'accepted'}) }}"
  38. class="nav-link {% if app.request.get('preset') == 'accepted' %}active{% endif %}">
  39. {{ 'tab.offer.accepted'|trans({}, 'campaign') }} ({{ count_offers_by_status(app.user, 'accepted') }})
  40. </a>
  41.  
  42. ////////////////////////////////////////////////////////////
  43. ({{ count_offers_by_status(app.user, 'accepted') }})
  44. ///////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement