Refactor basket_adapter

This commit is contained in:
Romain Neutron
2011-12-26 10:50:55 +01:00
parent 6a815c91da
commit 0e6757e2db
11 changed files with 107 additions and 133 deletions

View File

@@ -45,5 +45,29 @@ class BasketElementRepository extends EntityRepository
return $query->getResult();
}
/**
*
* @param type $element_id
* @param \User_Adapter $user
* @return \Entities\BasketELement
*/
public function findUserElement($element_id, \User_Adapter $user)
{
$element = $this->find($element_id);
/* @var $element \Entities\BasketElement */
if (null === $element)
{
throw new \Exception_NotFound(_('Element is not found'));
}
if ($element->getBasket()->getowner()->get_id() != $user->get_id())
{
throw new \Exception_Forbidden(_('You have not access to this basket element'));
}
return $element;
}
}