Files
Phraseanet/lib/Doctrine/Repositories/UsrListOwnerRepository.php
2012-01-04 12:31:35 +01:00

40 lines
800 B
PHP

<?php
namespace Repositories;
use Doctrine\ORM\EntityRepository;
/**
* UsrListOwnerRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class UsrListOwnerRepository extends EntityRepository
{
/**
*
*
* @param \Entities\UsrList $list
* @param type $owner_id
* @return \Entities\UsrList
*/
public function findByListAndOwner(\Entities\UsrList $list, $owner_id)
{
$owner = $this->find($owner_id);
/* @var $owner \Entities\UsrListOwner */
if (null === $owner)
{
throw new \Exception_NotFound(_('Owner is not found'));
}
if (!$owner->getList()->getid() != $list->getId())
{
throw new \Exception_Forbidden(_('Owner and list mismatch'));
}
return $owner;
}
}