Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding some extension and new query builder

  • Loading branch information...
commit 31f8be3afa0083c8c61cebcbab2340d5c779288c 1 parent 07bf880
@renoirb authored
View
3  Controller/BlogController.php
@@ -90,7 +90,8 @@ public function postsByTagAction(Term $term)
}
return array(
- 'paginator' => $paginator
+ 'paginator' => $paginator,
+ 'term' => $term
);
}
View
61 Repository/PostRepository.php
@@ -69,6 +69,67 @@ public function getPublishedByTerm(Term $term=null)
}
/**
+ * Get three last hilighted
+ */
+ public function getHilighted()
+ {
+ $slugs = array('Favourites','Linux');
+
+ $this->qb = $this->getPublished()
+ ->innerJoin('p.termRelationships', 'tr')
+ ->innerJoin('tr.termTaxonomy', 'tt')
+ ->innerJoin('tt.term','t')
+ ->andWhere('tt.taxonomy = :taxonomy')
+ ->andWhere($this->qb->expr()->in('t.slug',$slugs))
+ ->orderBy('p.publishedAt','DESC');
+
+ $this->qb->setParameter('taxonomy', TermTaxonomy::POST_TAG);
+ $this->qb->setMaxResults(3);
+
+ return $this->qb;
+ }
+
+ /**
+ * Get a list of posts by Tag slug
+ *
+ * @param array $slugs List of slugs to search in
+ * @param int $max Limit Max results
+ *
+ * @return QueryBuilder
+ */
+ public function getByTagSlugs(array $slugs,$max=3)
+ {
+ $this->qb = $this->getPublished()
+ ->innerJoin('p.termRelationships', 'tr')
+ ->innerJoin('tr.termTaxonomy', 'tt')
+ ->innerJoin('tt.term','t')
+ ->andWhere('tt.taxonomy = :taxonomy')
+ ->andWhere($this->qb->expr()->in('t.slug',$slugs))
+ ->orderBy('p.publishedAt','DESC');
+
+ $this->qb->setParameter('taxonomy', TermTaxonomy::POST_TAG);
+ $this->qb->setMaxResults($max);
+
+ return $this->qb;
+ }
+
+ /**
+ * Get a list of posts by Category slug
+ *
+ * @param array $slugs List of slugs to search in
+ * @param int $max Limit Max results
+ *
+ * @return QueryBuilder
+ */
+ public function getByCategorySlugs(array $slugs,$max=3)
+ {
+ $this->qb = $this->getByTagSlugs($slugs,$max);
+ $this->qb->setParameter('taxonomy', TermTaxonomy::CATEGORY);
+
+ return $this->qb;
+ }
+
+ /**
* @return Doctrine\ORM\Query
*/
public function getPublishedPostsQuery()
View
3  Twig/Extension/ContentExtension.php
@@ -6,10 +6,13 @@ class ContentExtension extends \Twig_Extension
{
public function getFilters()
{
+ //$hilighter = new \PSS\Bundle\BlogBundle\Twig\Extension\Hilighter();
+
return array(
'autop' => new \Twig_Filter_Method($this, 'autop'),
'summarize' => new \Twig_Filter_Method($this, 'summarize'),
'more' => new \Twig_Filter_Method($this, 'cutToMoreTag')
+ //,'geshi', => new \Twig_Filter_Method($hilighter, 'main')
);
}
Please sign in to comment.
Something went wrong with that request. Please try again.