コード例 #1
0
ファイル: SelectTest.php プロジェクト: rajanlamic/IntTest
 public function testSetOptionsOptions()
 {
     $element = new SelectElement();
     $element->setOptions(array('value_options' => array('bar' => 'baz'), 'options' => array('foo' => 'bar'), 'empty_option' => array('baz' => 'foo')));
     $this->assertEquals(array('bar' => 'baz'), $element->getOption('value_options'));
     $this->assertEquals(array('foo' => 'bar'), $element->getOption('options'));
     $this->assertEquals(array('baz' => 'foo'), $element->getOption('empty_option'));
 }
コード例 #2
0
ファイル: Controller.php プロジェクト: augustoalvess/dataware
 /**
  * Retorna todos os registros para serem populados em campos de tipo select,
  * conforme registros padrões 'id' e 'title'.
  * 
  * @param Select $element
  * @return array
  */
 public function getListValuesToSelectElement(Select $element)
 {
     $entityName = $element->getOption('entity');
     $entity = new $entityName();
     $repository = $this->getEntityManager()->getRepository($entityName);
     if (method_exists($entity, "getTitle")) {
         $query = $repository->createQueryBuilder("list")->select("list.id, list.title")->orderBy("list.title")->getQuery();
     } else {
         if (method_exists($entity, "getNome")) {
             $query = $repository->createQueryBuilder("list")->select("list.id, list.nome")->orderBy("list.nome")->getQuery();
         } else {
             exit("Atributo de descriçao nao definido para a entidade " . $entityName);
         }
     }
     $result = $query->getResult();
     return $result;
 }