Exemple #1
0
 /**
  * Loads a list of model by a list of field criteria.
  *
  * @param array   $criteria
  * @param array   $orderBy
  * @param integer $limit    (optional)
  * @param integer $offset   (optional)
  *
  * @return array
  */
 public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null)
 {
     $pool = $this->manager->getPool();
     $manager_id = $this->class->getManagerIdentifier();
     $models = array();
     foreach ($this->class->getFieldManagerNames() as $manager) {
         $models[$manager] = $this->class->getFieldMapping($manager)->getName();
     }
     $data = $pool->getManager($manager_id)->getRepository($models[$manager_id])->findBy($criteria, $orderBy, $limit, $offset);
     if (empty($data)) {
         return array();
     }
     $builder = new ModelBuilder($this->manager, $this->uow, $this->class);
     return $builder->buildAll($data, $manager_id);
 }
Exemple #2
0
 /**
  * Multiple hydration model.
  *
  * @param array $objects
  * @param array $fields  List of fields prime (optional)
  *
  * @return array
  */
 public function hydrate(array $objects, array $fields = array())
 {
     return $this->modelBuilder->buildAll($objects, $this->class->getManagerIdentifier(), $fields);
 }