]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
remove dumb code
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 20 Feb 2015 16:20:12 +0000 (17:20 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 6 Mar 2015 19:50:30 +0000 (20:50 +0100)
src/Wallabag/CoreBundle/Controller/WallabagRestController.php
src/Wallabag/CoreBundle/Entity/Tag.php
src/Wallabag/CoreBundle/Repository/TagRepository.php

index cb68784d55d02080d5262ae3bdac5b61d4d8474c..2384325f49d5eb57ab965aee11cc52dae5d5ea80 100644 (file)
@@ -232,37 +232,13 @@ class WallabagRestController extends Controller
      * Retrieve all tags
      *
      * @ApiDoc(
+     *          {"name"="user", "dataType"="integer", "requirement"="\w+", "description"="The user ID"}
      * )
      */
-    public function getTagsAction()
+    public function getTagsUserAction()
     {
     }
 
-    /**
-     * Retrieve a single tag
-     *
-     * @ApiDoc(
-     *       requirements={
-     *          {"name"="label", "dataType"="string", "requirement"="\w+", "description"="Label of the tag"}
-     *       }
-     * )
-     */
-    public function getTagAction($label)
-    {
-        $tag = $this
-            ->getDoctrine()
-            ->getRepository('WallabagCoreBundle:Tag')
-            ->findOneByLabel($label);
-
-        if (is_null($tag)) {
-            throw $this->createNotFoundException();
-        }
-
-        $json = $this->get('serializer')->serialize($tag, 'json');
-
-        return new Response($json, 200, array('application/json'));
-    }
-
     /**
      * Permanently remove one tag from **every** entry
      *
index 963f32b1ef20df88b334a3c6a658c55ea926d97e..0d7f8c2b26201850f1cf133e51ad510a1dc1f57d 100644 (file)
@@ -3,12 +3,14 @@
 namespace Wallabag\CoreBundle\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
+use JMS\Serializer\Annotation\XmlRoot;
 
 /**
  * Tag
  *
+ * @XmlRoot("tag")
  * @ORM\Table(name="tag")
- * @ORM\Entity
+ * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository")
  */
 class Tag
 {
index 005142fc568707a9b2e807f390dbf2cca8814fb2..903a99cda3804bddfa61751cdf611a3c6a209e75 100644 (file)
@@ -3,119 +3,8 @@
 namespace Wallabag\CoreBundle\Repository;
 
 use Doctrine\ORM\EntityRepository;
-use Doctrine\ORM\Tools\Pagination\Paginator;
 
-class EntryRepository extends EntityRepository
+class TagRepository extends EntityRepository
 {
-    /**
-     * Retrieves unread entries for a user
-     *
-     * @param int $userId
-     * @param int $firstResult
-     * @param int $maxResults
-     *
-     * @return Paginator
-     */
-    public function findUnreadByUser($userId, $firstResult, $maxResults = 12)
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->setFirstResult($firstResult)
-            ->setMaxResults($maxResults)
-            ->leftJoin('e.user', 'u')
-            ->where('e.isArchived = false')
-            ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->orderBy('e.createdAt', 'desc')
-            ->getQuery();
 
-        $paginator = new Paginator($qb);
-
-        return $paginator;
-    }
-
-    /**
-     * Retrieves read entries for a user
-     *
-     * @param int $userId
-     * @param int $firstResult
-     * @param int $maxResults
-     *
-     * @return Paginator
-     */
-    public function findArchiveByUser($userId, $firstResult, $maxResults = 12)
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->select('e')
-            ->setFirstResult($firstResult)
-            ->setMaxResults($maxResults)
-            ->leftJoin('e.user', 'u')
-            ->where('e.isArchived = true')
-            ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->orderBy('e.createdAt', 'desc')
-            ->getQuery();
-
-        $paginator = new Paginator($qb);
-
-        return $paginator;
-    }
-
-    /**
-     * Retrieves starred entries for a user
-     *
-     * @param int $userId
-     * @param int $firstResult
-     * @param int $maxResults
-     *
-     * @return Paginator
-     */
-    public function findStarredByUser($userId, $firstResult, $maxResults = 12)
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->select('e')
-            ->setFirstResult($firstResult)
-            ->setMaxResults($maxResults)
-            ->leftJoin('e.user', 'u')
-            ->where('e.isStarred = true')
-            ->andWhere('u.id =:userId')->setParameter('userId', $userId)
-            ->orderBy('e.createdAt', 'desc')
-            ->getQuery();
-
-        $paginator = new Paginator($qb);
-
-        return $paginator;
-    }
-
-    /**
-     * Find Entries
-     *
-     * @param int    $userId
-     * @param bool   $isArchived
-     * @param bool   $isStarred
-     * @param string $sort
-     * @param string $order
-     *
-     * @return array
-     */
-    public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC')
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->where('e.user =:userId')->setParameter('userId', $userId);
-
-        if (null !== $isArchived) {
-            $qb->andWhere('e.isArchived =:isArchived')->setParameter('isArchived', (bool) $isArchived);
-        }
-
-        if (null !== $isStarred) {
-            $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred);
-        }
-
-        if ('created' === $sort) {
-            $qb->orderBy('e.createdAt', $order);
-        } elseif ('updated' === $sort) {
-            $qb->orderBy('e.updatedAt', $order);
-        }
-
-        return $qb
-            ->getQuery()
-            ->getResult();
-    }
 }