Example #1
0
 /**
  * Get an object by it's named id (customer_id, invoice_id)
  * 
  * @param string $classname
  * @param string $name
  * @param string $id
  * @return Domainmodel_Abstract
  * @throws InvalidNamedIdExeption
  * @throws InvalidIdException 
  */
 public function getByNamedId($classname, $name, $id)
 {
     if (!isset($this->namedId[$classname]) || !in_array($name, $this->namedId[$classname])) {
         throw new InvalidNamedIdExeption('NamedId ' . $name . ' is not a valid type');
     }
     if (!preg_match('/^[a-zA-Z0-9\\- _]+$/D', $id)) {
         throw new InvalidIdException('Invalid id: ' . $id);
     }
     $classname = __NAMESPACE__ . '\\' . $classname;
     $response = $this->request($this->buildUrl(new $classname(), null, '/' . $name . '/' . $id), 'GET');
     return $this->mapper->mapFromStorage($response);
 }