mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Add \Entities\UsrList::has method
This commit is contained in:
@@ -45,7 +45,7 @@ class UsrList
|
|||||||
private $owners;
|
private $owners;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Entities\UsrListEntry
|
* @var \Doctrine\Common\Collections\Collection
|
||||||
*/
|
*/
|
||||||
private $entries;
|
private $entries;
|
||||||
|
|
||||||
@@ -150,8 +150,9 @@ class UsrList
|
|||||||
foreach ($this->getOwners() as $owner)
|
foreach ($this->getOwners() as $owner)
|
||||||
{
|
{
|
||||||
if ($owner->getUser()->get_id() == $user->get_id())
|
if ($owner->getUser()->get_id() == $user->get_id())
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -167,8 +168,9 @@ class UsrList
|
|||||||
foreach ($this->getOwners() as $owner)
|
foreach ($this->getOwners() as $owner)
|
||||||
{
|
{
|
||||||
if ($owner->getUser()->get_id() == $user->get_id())
|
if ($owner->getUser()->get_id() == $user->get_id())
|
||||||
|
{
|
||||||
return $owner;
|
return $owner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception('This user is not an owner of the list');
|
throw new \Exception('This user is not an owner of the list');
|
||||||
@@ -187,11 +189,27 @@ class UsrList
|
|||||||
/**
|
/**
|
||||||
* Get entries
|
* Get entries
|
||||||
*
|
*
|
||||||
* @return Doctrine\Common\Collections\Collection
|
* @return \Doctrine\Common\Collections\Collection
|
||||||
*/
|
*/
|
||||||
public function getEntries()
|
public function getEntries()
|
||||||
{
|
{
|
||||||
return $this->entries;
|
return $this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if one of the entry is related to the given user
|
||||||
|
*
|
||||||
|
* @param \User_Adapter $user
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function has(\User_Adapter $user)
|
||||||
|
{
|
||||||
|
return $this->entries->exists(
|
||||||
|
function($key, $entry) use ($user)
|
||||||
|
{
|
||||||
|
return $entry->getUser()->get_id() === $user->get_id();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user