コード例 #1
0
 public function testPopulation()
 {
     $model = new NewModel();
     $array = ['elemento' => 2, 'notIgnored' => 321];
     Populator::populate($model, $array);
     $this->assertEquals($array['elemento'], $model->getElement());
     $this->assertEquals($array['notIgnored'], $model->getNotIgnored());
 }
コード例 #2
0
 /**
  * Seleciona uma coleção de objetos do tipo do objeto que fora
  * chamado. O método irá identificar qual a classe filho dessa
  * classe atual, e instanciar um objeto do tipo da classe filho
  * e em seguida popular ele e adicioná-lo na lista de dados.
  *
  * @param $where
  * @return ArrayList
  * @throws NoDataFoundException
  */
 public static function select($where)
 {
     $table = new TableGateway(self::getInstance());
     $resultSet = $table->select($where);
     if ($resultSet->count() == 0) {
         throw new NoDataFoundException();
     }
     $list = new ArrayList();
     foreach ($resultSet->toArray() as $array) {
         $obj = self::getInstance();
         Populator::populate($obj, $array);
         $list->add($obj);
     }
     return $list;
 }