Guillermo Espinoza 8 gadi atpakaļ
vecāks
revīzija
f594319cad
2 mainītis faili ar 15 papildinājumiem un 5 dzēšanām
  1. 14 0
      Services/Webservice.php
  2. 1 5
      Twig/RemoteClientExtension.php

+ 14 - 0
Services/Webservice.php

@@ -97,5 +97,19 @@ class Webservice
 
         return array();
     }
+    
+    /**
+     * @param string $webservice
+     * @param int $id
+     * @return string
+     */
+    public function getById($webservice, $id)
+    {
+        $result = $this->getArray($webservice, array(
+            'id' => $id
+        ));
+        
+        return isset($result[0]) ? "{$result[0]['id']} - {$result[0]['name']}" : $id;
+    }
 
 }

+ 1 - 5
Twig/RemoteClientExtension.php

@@ -37,11 +37,7 @@ class RemoteClientExtension extends \Twig_Extension
      */
     public function getClient($clientId)
     {
-        $client = $this->webservice->getArray('client', array(
-            'id' => $clientId
-        ));
-        
-        return isset($client[0]) ? "{$client[0]['id']} - {$client[0]['name']}" : $clientId;
+        return $this->webservice->getById('client', $clientId);
     }
 
     /**