serviceContainer = $serviceContainer; } /** * @param string $webservice * @param array $params * @return array */ public function getChoices($webservice, $params = array()) { $choices = array(); $objectsJson = $this->getArray($webservice, $params); foreach ($objectsJson as $object) { $choices[$object['name']] = $object['id']; } return $choices; } /** * @param string $webservice * @param array $params * @return array */ public function getArray($webservice, $params = array()) { $objectsJson = array(); if ($this->serviceContainer->hasParameter($webservice)) { $url = $this->serviceContainer->getParameter($webservice); $url .= '?filters[qb-criteria]'; foreach ($params as $param => $value) { $url .= "&filters[{$param}]=$value"; } $objectsJson = json_decode(file_get_contents($url), true); } return $objectsJson; } }