public function deleteEntryAction(Request $request, Entries $entry)
{
$em = $this->getDoctrine()->getManager();
- $em->remove($entry);
+ $entry->setDeleted(1);
+ $em->persist($entry);
$em->flush();
$this->get('session')->getFlashBag()->add(
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Wallabag\CoreBundle\Entity\Entries;
use Wallabag\CoreBundle\Entity\Tags;
use Wallabag\CoreBundle\Service\Extractor;
*/
public function getEntriesAction(Request $request)
{
+ // TODO isArchived, isStarred et isDeleted ne doivent pas avoir de valeur par défaut
+ // TODO Si on ne passe rien, on ne filtre pas sur le statut.
$isArchived = $request->query->get('archive', 0);
$isStarred = $request->query->get('star', 0);
$isDeleted = $request->query->get('delete', 0);
*/
public function deleteEntriesAction(Entries $entry)
{
+ if ($entry->isDeleted()) {
+ throw new NotFoundHttpException('This entry is already deleted');
+ }
+
+ $em = $this->getDoctrine()->getManager();
+ $entry->setDeleted(1);
+ $em->persist($entry);
+ $em->flush();
+
+ return $entry;
}
/**
*/
private $userId;
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="is_deleted", type="decimal", precision=10, scale=0, nullable=true)
+ */
+ private $isDeleted = '0';
+
/**
* Get id
*
{
return $this->userId;
}
+
+ /**
+ * @return string
+ */
+ public function isDeleted()
+ {
+ return $this->isDeleted;
+ }
+
+ /**
+ * @param string $isDeleted
+ */
+ public function setDeleted($isDeleted)
+ {
+ $this->isDeleted = $isDeleted;
+ }
}
->setMaxResults($maxResults)
->where('e.isRead = 0')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
+ ->andWhere('e.isDeleted=0')
->getQuery();
$paginator = new Paginator($qb);
->setMaxResults($maxResults)
->where('e.isRead = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
+ ->andWhere('e.isDeleted=0')
->getQuery();
$paginator = new Paginator($qb);
->setMaxResults($maxResults)
->where('e.isFav = 1')
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
+ ->andWhere('e.isDeleted=0')
->getQuery();
$paginator = new Paginator($qb);
->where('e.isFav =:isStarred')->setParameter('isStarred', $isStarred)
->andWhere('e.isRead =:isArchived')->setParameter('isArchived', $isArchived)
->andWhere('e.userId =:userId')->setParameter('userId', $userId)
+ ->andWhere('e.isDeleted=0')
->getQuery()
->getResult(Query::HYDRATE_ARRAY);