예제 #1
0
 /**
  * Lookup a entity based on it's 'primary key' or key column when passed a set.
  * This will always return a Container
  * @return Bond\Container
  */
 public function findBySet(Set $keySet)
 {
     // the simplest thing that possibly works
     // there're a lot of fairly easy performance gains to doing this differently.
     // this can be speeded up lots. Think interval intersection with value explosion.
     $multiton = $this->makeNewContainer();
     // persisted
     foreach ($this->instancesPersisted as $key => $entity) {
         if ($keySet->contains($key)) {
             $multiton->add($entity);
         }
     }
     // unpersisted
     foreach ($this->instancesUnpersisted as $entity) {
         if ($keySet->contains($entity->keyGet($entity))) {
             $multiton->add($entity);
         }
     }
     $persisted = parent::findBySet($keySet);
     return $this->makeNewContainer()->add($multiton, $persisted);
 }