|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace WebserviceBundle\Form\ChoiceList\Loader;
|
|
|
|
|
|
+use Base\AdminBundle\Controller\TenancyService;
|
|
|
use Symfony\Component\Form\ChoiceList\ArrayChoiceList;
|
|
|
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
@@ -10,24 +11,30 @@ use Symfony\Component\Form\FormEvents;
|
|
|
|
|
|
class ClientChoiceLoader implements ChoiceLoaderInterface
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @var Webservice
|
|
|
*/
|
|
|
protected $webservice;
|
|
|
+ /**
|
|
|
+ * @var TenancyService
|
|
|
+ */
|
|
|
+ protected $tenancyService;
|
|
|
|
|
|
// Currently selected choices
|
|
|
protected $selected = [];
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param Webservice $webservice
|
|
|
+ * @param TenancyService $tenancyService Contiene el servicio de tenencias.
|
|
|
*/
|
|
|
- public function __construct($webservice)
|
|
|
+ public function __construct($webservice, $tenancyService)
|
|
|
{
|
|
|
$this->webservice = $webservice;
|
|
|
+ $this->tenancyService = $tenancyService;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param FormBuilderInterface $builder
|
|
|
*/
|
|
@@ -93,7 +100,7 @@ class ClientChoiceLoader implements ChoiceLoaderInterface
|
|
|
|
|
|
$choices[$label] = $id;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return new ArrayChoiceList($choices);
|
|
|
}
|
|
|
|
|
@@ -119,7 +126,7 @@ class ClientChoiceLoader implements ChoiceLoaderInterface
|
|
|
|
|
|
/**
|
|
|
* Turn choices from other datatypes into strings (HTML option
|
|
|
- * values) if needed - we can simply return the choices as
|
|
|
+ * values) if needed - we can simply return the choices as
|
|
|
* they're strings already.
|
|
|
* Required by ChoiceLoaderInterface.
|
|
|
*/
|
|
@@ -137,16 +144,17 @@ class ClientChoiceLoader implements ChoiceLoaderInterface
|
|
|
|
|
|
/**
|
|
|
* Get first n choices
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $filter
|
|
|
- *
|
|
|
+ *
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getChoicesList($filter)
|
|
|
{
|
|
|
$params = array();
|
|
|
if ($filter !== false) {
|
|
|
- $params['name'] = $filter;
|
|
|
+ $params['name'] = urlencode($filter);
|
|
|
+ $params['tenancy_id'] = $this->tenancyService->getTenancyIdCurrent();
|
|
|
}
|
|
|
$choices = $this->webservice->getChoices('client', $params);
|
|
|
|