RemoteClientExtension.php 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace WebserviceBundle\Twig;
  3. use WebserviceBundle\Services\Webservice;
  4. class RemoteClientExtension extends \Twig_Extension
  5. {
  6. /**
  7. * @var Webservice
  8. */
  9. protected $webservice;
  10. /**
  11. * @param Webservice $webservice
  12. */
  13. public function __construct(Webservice $webservice)
  14. {
  15. $this->webservice = $webservice;
  16. }
  17. /**
  18. * @return array
  19. */
  20. public function getFunctions()
  21. {
  22. return array(
  23. new \Twig_SimpleFunction('remote_client', array($this, 'getClient')),
  24. );
  25. }
  26. /**
  27. * @param int $clientId
  28. * @return string
  29. */
  30. public function getClient($clientId)
  31. {
  32. return $this->webservice->getById('client', $clientId);
  33. }
  34. /**
  35. * @return string
  36. */
  37. public function getName()
  38. {
  39. return 'remote_client_extension';
  40. }
  41. }