Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ajout des mappers et repository

  • Loading branch information...
commit 4a603c62ee4a145734635377cc2b16d3a15c88de 1 parent c67a548
@Orkin authored
View
52 src/ZfrForum/Mapper/CategoryTrackingMapperInterface.php
@@ -0,0 +1,52 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license.
+ */
+
+namespace ZfrForum\Mapper;
+
+use Doctrine\Common\Persistence\ObjectRepository;
+use ZfrForum\Entity\CategoryTracking;
+use ZfrForum\Entity\Category;
+use ZfcUser\Entity\UserInterface;
+
+interface CategoryTrackingMapperInterface extends ObjectRepository
+{
+ /**
+ * @param CategoryTracking $categoryTracking
+ * @return CategoryTracking
+ */
+ public function add(CategoryTracking $categoryTracking);
+
+ /**
+ * @param CategoryTracking $categoryTracking
+ * @return CategoryTracking
+ */
+ public function update(CategoryTracking $categoryTracking);
+
+ /**
+ * @param CategoryTracking $categoryTracking
+ * @return void
+ */
+ public function remove(CategoryTracking $categoryTracking);
+
+ /**
+ * @param Category $category
+ * @param UserInterface $user
+ * @return CategoryTracking
+ */
+ public function findByCategoryAndUser(Category $category, UserInterface $user);
+}
View
60 src/ZfrForum/Mapper/ThreadTrackingMapperInterface.php
@@ -0,0 +1,60 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license.
+ */
+
+namespace ZfrForum\Mapper;
+
+use Doctrine\Common\Persistence\ObjectRepository;
+use ZfrForum\Entity\ThreadTracking;
+use ZfrForum\Entity\Thread;
+use ZfrForum\Entity\Category;
+use ZfcUser\Entity\UserInterface;
+
+interface ThreadTrackingMapperInterface extends ObjectRepository
+{
+ /**
+ * @param ThreadTracking $threadTracking
+ * @return ThreadTracking
+ */
+ public function add(ThreadTracking $threadTracking);
+
+ /**
+ * @param ThreadTracking $threadTracking
+ * @return ThreadTracking
+ */
+ public function update(ThreadTracking $threadTracking);
+
+ /**
+ * @param ThreadTracking $threadTracking
+ * @return void
+ */
+ public function remove(ThreadTracking $threadTracking);
+
+ /**
+ * @param Thread $thread
+ * @param UserInterface $user
+ * @return ThreadTracking
+ */
+ public function findByThreadAndUser(Thread $thread, UserInterface $user);
+
+ /**
+ * @param Category $category
+ * @param UserInterface $user
+ * @return array
+ */
+ public function findByCategoryAndUser(Category $category, UserInterface $user);
+}
View
80 src/ZfrForum/Repository/CategoryTrackingRepository.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license.
+ */
+
+namespace ZfrForum\Repository;
+
+use Doctrine\ORM\EntityRepository;
+use ZfrForum\Entity\Thread;
+use ZfrForum\Entity\CategoryTracking;
+use ZfrForum\Mapper\CategoryTrackingMapperInterface;
+use ZfrForum\Entity\Category;
+use ZfcUser\Entity\UserInterface;
+
+class CategoryTrackingRepository extends EntityRepository implements CategoryTrackingMapperInterface
+{
+
+ /**
+ * @param CategoryTracking $categoryTracking
+ * @return CategoryTracking
+ */
+ public function add(CategoryTracking $categoryTracking)
+ {
+ // TODO: Implement add() method.
+ }
+
+ /**
+ * @param CategoryTracking $categoryTracking
+ * @return CategoryTracking
+ */
+ public function update(CategoryTracking $categoryTracking)
+ {
+ $this->getEntityManager()->flush($categoryTracking);
+ return $categoryTracking;
+ }
+
+ /**
+ * @param CategoryTracking $categoryTracking
+ * @return void
+ */
+ public function remove(CategoryTracking $categoryTracking)
+ {
+ // TODO: Implement remove() method.
+ }
+
+ /**
+ * @param Category $category
+ * @param UserInterface $user
+ * @return CategoryTracking
+ */
+ public function findByCategoryAndUser(Category $category, UserInterface $user)
+ {
+ $queryBuilder = $this->getEntityManager()->createQueryBuilder();
+ $queryBuilder->select('ct')
+ ->from('ZfrForum\Entity\CategoryTracking', 'ct')
+ ->where('ct.category = :category')
+ ->andWhere('ct.user = :user')
+ ->setParameter('category', $category)
+ ->setParameter('user', $user);
+
+ $categoryTracking = $queryBuilder->getQuery()->getOneOrNullResult();
+
+ return $categoryTracking;
+ }
+
+
+}
View
100 src/ZfrForum/Repository/ThreadTrackingRepository.php
@@ -0,0 +1,100 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license.
+ */
+
+namespace ZfrForum\Repository;
+
+use Doctrine\ORM\EntityRepository;
+use ZfrForum\Entity\Thread;
+use ZfrForum\Entity\ThreadTracking;
+use ZfrForum\Mapper\ThreadTrackingMapperInterface;
+use ZfrForum\Entity\Category;
+use ZfcUser\Entity\UserInterface;
+
+class ThreadTrackingRepository extends EntityRepository implements ThreadTrackingMapperInterface
+{
+ /**
+ * @param ThreadTracking $threadTracking
+ * @return ThreadTracking
+ */
+ public function add(ThreadTracking $threadTracking)
+ {
+
+ }
+
+ /**
+ * @param ThreadTracking $threadTracking
+ * @return ThreadTracking
+ */
+ public function update(ThreadTracking $threadTracking)
+ {
+ $this->getEntityManager()->flush($threadTracking);
+ return $threadTracking;
+ }
+
+ /**
+ * @param ThreadTracking $threadTracking
+ * @return void
+ */
+ public function remove(ThreadTracking $threadTracking)
+ {
+ // TODO: Implement remove() method.
+ }
+
+ /**
+ * @param Thread $thread
+ * @param UserInterface $user
+ * @return ThreadTracking
+ */
+ public function findByThreadAndUser(Thread $thread, UserInterface $user)
+ {
+ $queryBuilder = $this->getEntityManager()->createQueryBuilder();
+ $queryBuilder->select('tt')
+ ->from('ZfrForum\Entity\ThreadTracking', 'tt')
+ ->where('tt.thread = :thread')
+ ->andWhere('tt.category = :category')
+ ->andWhere('tt.user = :user')
+ ->setParameter('thread', $thread)
+ ->setParameter('user', $user);
+
+ $threadTracking = $queryBuilder->getQuery()->getOneOrNullResult();
+
+ return $threadTracking;
+ }
+
+ /**
+ * @param Category $category
+ * @param UserInterface $user
+ * @return array
+ */
+ public function findByCategoryAndUser(Category $category, UserInterface $user)
+ {
+ $queryBuilder = $this->getEntityManager()->createQueryBuilder();
+ $queryBuilder->select('tt')
+ ->from('ZfrForum\Entity\ThreadTracking', 'tt')
+ ->where('ct.category = :category')
+ ->andWhere('ct.user = :user')
+ ->setParameter('category', $category)
+ ->setParameter('user', $user);
+
+ $categoryTracking = $queryBuilder->getQuery()->getResult();
+
+ return $categoryTracking;
+ }
+
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.