12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace WebserviceBundle\Twig;
- use WebserviceBundle\Services\Webservice;
- class RemoteClientExtension extends \Twig_Extension
- {
-
- /**
- * @var Webservice
- */
- protected $webservice;
-
-
- /**
- * @param Webservice $webservice
- */
- public function __construct(Webservice $webservice)
- {
- $this->webservice = $webservice;
- }
- /**
- * @return array
- */
- public function getFunctions()
- {
- return array(
- new \Twig_SimpleFunction('remote_client', array($this, 'getClient')),
- );
- }
- /**
- * @param int $clientId
- * @return string
- */
- public function getClient($clientId)
- {
- $client = $this->webservice->getArray('client', array(
- 'id' => $clientId
- ));
-
- return isset($client[0]) ? "{$client[0]['id']} - {$client[0]['name']}" : $clientId;
- }
- /**
- * @return string
- */
- public function getName()
- {
- return 'remote_client_extension';
- }
- }
|