Example #1
0
 /**
  * @return \Hynage\ORM\EntityCollection|\Hynage\ORM\Entity
  */
 public function load()
 {
     if ($this->data) {
         return $this->data;
     }
     $constraints = array($this->foreignFieldName => $this->entity->getValue($this->localFieldName));
     $type = $this->type;
     switch ($type) {
         case self::TYPE_ENTITY:
             $this->data = $this->em->findEntityBy($this->className, $constraints);
             break;
         case self::TYPE_COLLECTION:
             $this->data = $this->em->findEntitiesBy($this->className, $constraints);
             break;
         default:
             throw new \InvalidArgumentException("Invalid proxy type '{$type}'.");
     }
     return $this->data;
 }