mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 22:43:19 +00:00
64 lines
1.2 KiB
PHP
64 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Repositories;
|
|
|
|
use Doctrine\ORM\EntityRepository;
|
|
|
|
/**
|
|
* StoryWZRepository
|
|
*
|
|
* This class was generated by the Doctrine ORM. Add your own custom
|
|
* repository methods below.
|
|
*/
|
|
class StoryWZRepository extends EntityRepository
|
|
{
|
|
|
|
public function findByUser(\User_Adapter $user)
|
|
{
|
|
$stories = $this->findBy(array('usr_id' => $user->get_id()));
|
|
|
|
foreach ($stories as $key => $story)
|
|
{
|
|
try
|
|
{
|
|
$record = $story->getRecord();
|
|
}
|
|
catch (\Exception_Record_AdapterNotFound $e)
|
|
{
|
|
$this->getEntityManager()->remove($story);
|
|
}
|
|
|
|
unset($stories[$key]);
|
|
}
|
|
|
|
$this->getEntityManager()->flush();
|
|
|
|
return $stories;
|
|
}
|
|
|
|
public function findUserStory(\User_Adapter $user, \record_adapter $Story)
|
|
{
|
|
$story = $this->findOneBy(
|
|
array(
|
|
'usr_id' => $user->get_id(),
|
|
'sbas_id' => $Story->get_sbas_id(),
|
|
'record_id' => $Story->get_record_id(),
|
|
)
|
|
);
|
|
|
|
try
|
|
{
|
|
$record = $story->getRecord();
|
|
}
|
|
catch (\Exception_Record_AdapterNotFound $e)
|
|
{
|
|
$this->getEntityManager()->remove($story);
|
|
$this->getEntityManager()->flush();
|
|
$story = null;
|
|
}
|
|
|
|
return $story;
|
|
}
|
|
|
|
}
|