public function findByPost(Post $post, $taxonomy = null, $hydrationMode = AbstractQuery::HYDRATE_SIMPLEOBJECT)
 {
     $queryBuilder = $this->getQueryBuilder()->join('t.taxonomy', 'taxonomy')->join('taxonomy.posts', 'post')->andWhere('post.id = :postId')->setParameter('postId', $post->getId());
     if (null !== $taxonomy) {
         $queryBuilder->andWhere('taxonomy.name = :taxonomyName')->setParameter('taxonomyName', is_string($taxonomy) ? $taxonomy : $taxonomy->getName());
     }
     return $queryBuilder->getQuery()->getResult($hydrationMode);
 }
 protected function getValidComments(Post $post)
 {
     $comments = array();
     $allComments = $post->getComments();
     /** @var Comment $comment */
     foreach ($allComments as $comment) {
         if ($comment->getApproved() === "1") {
             $comments[] = $comment;
         }
     }
     return $comments;
 }
 public function getMetaByPost(Post $post, $key, $hydrationMode = AbstractQuery::HYDRATE_SIMPLEOBJECT)
 {
     return $this->getQueryBuilder()->join('pm.post', 'post')->andWhere('post.id = :postId')->andWhere('pm.key = :key')->setMaxResults(1)->setParameter('postId', $post->getId())->setParameter('key', $key)->getQuery()->getOneOrNullResult($hydrationMode);
 }
示例#4
0
 /**
  * Set parent
  *
  * @param Post $child
  */
 public function addChild(Post $child)
 {
     $child->setParent($this);
     $this->children[] = $child;
 }