diff --git a/Controller/BlogController.php b/Controller/BlogController.php index c79a978..c77a2b5 100755 --- a/Controller/BlogController.php +++ b/Controller/BlogController.php @@ -2,63 +2,97 @@ namespace PSS\Bundle\BlogBundle\Controller; + +# Symfony/Doctrine internal use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Component\HttpFoundation\Request; + + +# Specific + + +# Domain objects + + +# Entities +use PSS\Bundle\BlogBundle\Entity\Post; +use PSS\Bundle\BlogBundle\Entity\Term; + + +/** + * Base Controller + * + * Basic views available here, to override you can + * use the PostManager service. The idea of this controller + * is that you can extend as a Base, and alter the returned array() + * that each method returns using parent::methodName(); + * + * Cookbook in PSSBlogBundle/Resources/doc/recipe-extending-blog-controller.md + * + * @Route("/blog") + */ class BlogController extends Controller { /** - * @Route("/blog", name="blog_index") + * Generate a comment form and process */ - public function indexAction() + protected function comment(Request $request, Post $post) { - $entityManager = $this->get('doctrine.orm.entity_manager'); - - $query = $entityManager - ->getRepository('PSS\Bundle\BlogBundle\Entity\Post') - ->getPublishedPostsQuery(); - - $paginator = $this->createPaginator($query); - - return $this->render('PSSBlogBundle:Blog:index.html.twig', array('paginator' => $paginator)); +# try { +# $cmtMgr = $this->get('pss.blogbundle.manager.comment'); +# $entity = $cmtMgr->entityFactory($request); // Setting the "always required" stuff } /** - * @Route("/tag/{tag}", name="blog_posts_by_tag") + * @Route("/{year}/{month}/{slug}", name="blog_show") + * @Template() */ - public function postsByTagAction($tag) + public function showAction(Post $post, Request $request) { - $entityManager = $this->get('doctrine.orm.entity_manager'); - - $query = $entityManager - ->getRepository('PSS\Bundle\BlogBundle\Entity\Post') - ->getPublishedPostsByTagQuery($tag); - - $paginator = $this->createPaginator($query); + return array( + 'post' => $post->onlyIfPublished(), + 'comment_form' => $this->comment($request,$post) + ); + } - if ($paginator->getTotalItemCount() == 0) { - throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException('Page Not Found'); - } + /** + * @Route("/", name="blog_index") + * @Template() + */ + public function indexAction() + { + $pm = $this->getPostManager(); + $paginator = $this->createPaginator($pm->getRepository()->getPublishedPostsQuery()); - return $this->render('PSSBlogBundle:Blog:postsByTag.html.twig', array('paginator' => $paginator)); + return array( + 'paginator' => $paginator + ); } /** - * @Route("/{slug}", name="blog_show") + * @Route("/tag/{slug}", name="blog_posts_by_tag") + * @Template() */ - public function showAction($slug) + public function postsByTagAction(Term $term) { - $entityManager = $this->get('doctrine.orm.entity_manager'); + $pm = $this->getPostManager(); + $repository = $pm->getRepository(); + $query = $repository + ->getPublishedByTerm($term); + + $paginator = $this->createPaginator($query->getQuery()); - try { - $post = $entityManager - ->getRepository('PSS\Bundle\BlogBundle\Entity\Post') - ->findPublishedPostOrPage($slug); - } catch (\Doctrine\ORM\NoResultException $exception) { + if ($paginator->getTotalItemCount() == 0) { throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException('Page Not Found'); } - return $this->render('PSSBlogBundle:Blog:show.html.twig', array('post' => $post)); + return array( + 'paginator' => $paginator, + 'term' => $term + ); } public function recentPostsAction($max) @@ -86,11 +120,23 @@ public function tagCloudAction() } /** + * Access to Post Manager service + * + * @return \PSS\Bundle\BlogBundle\Manager\PostManager + */ + protected function getPostManager() + { + return $this->get('pss.blog.manager.post'); + } + + /** + * Create a paginator from a Query + * * @param \Doctrine\ORM\Query $query * * @return \Knp\Component\Pager\Pagination\PaginationInterface */ - private function createPaginator(\Doctrine\ORM\Query $query) + protected function createPaginator(\Doctrine\ORM\Query $query) { $paginator = $this->get('knp_paginator'); $request = $this->get('request'); diff --git a/Entity/Comment.php b/Entity/Comment.php index 1c7c826..c1e6f27 100755 --- a/Entity/Comment.php +++ b/Entity/Comment.php @@ -2,11 +2,35 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; +use Symfony\Component\Validator\Constraints as Assert; +use Doctrine\Common\Collections\ArrayCollection; + + +// Specific + + +// Domain objects + + +// Entities + + + /** + * A Comment represent a note left by a visitor from the web. + * + * Comment can be attached to either a Post or an other Comment. + * + * Comment needs to be validated by blog owner. + * + * @ORM\HasLifecycleCallbacks() * @ORM\Table(name="wp_comments") - * @ORM\Entity + * @ORM\Entity(repositoryClass="PSS\Bundle\BlogBundle\Repository\CommentRepository") */ class Comment { @@ -58,6 +82,8 @@ class Comment /** * @var datetime $createdAt * + * @Gedmo\Timestampable(on="create") + * @Assert\Type(type="\DateTime") * @ORM\Column(name="comment_date", type="datetime", nullable=false) */ private $createdAt; @@ -65,6 +91,8 @@ class Comment /** * @var datetime $createdAtAsGmt * + * @Gedmo\Timestampable(on="create") + * @Assert\Type(type="\DateTime") * @ORM\Column(name="comment_date_gmt", type="datetime", nullable=false) */ private $createdAtAsGmt; @@ -126,4 +154,322 @@ class Comment * @ORM\JoinColumn(name="comment_ID", referencedColumnName="comment_id") */ private $meta; -} + + + + public function __construct() + { + $this->meta = new ArrayCollection(); + } + + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set authorName + * + * @param text $authorName + */ + public function setAuthorName($authorName) + { + $this->authorName = $authorName; + } + + /** + * Get authorName + * + * @return text + */ + public function getAuthorName() + { + return $this->authorName; + } + + /** + * Set authorEmail + * + * @param string $authorEmail + */ + public function setAuthorEmail($authorEmail) + { + $this->authorEmail = $authorEmail; + } + + /** + * Get authorEmail + * + * @return string + */ + public function getAuthorEmail() + { + return $this->authorEmail; + } + + /** + * Set authorUrl + * + * @param string $authorUrl + */ + public function setAuthorUrl($authorUrl) + { + $this->authorUrl = $authorUrl; + } + + /** + * Get authorUrl + * + * @return string + */ + public function getAuthorUrl() + { + return $this->authorUrl; + } + + /** + * Set authorIp + * + * @param string $authorIp + */ + public function setAuthorIp($authorIp) + { + $this->authorIp = $authorIp; + } + + /** + * Get authorIp + * + * @return string + */ + public function getAuthorIp() + { + return $this->authorIp; + } + + /** + * Set createdAt + * + * @param datetime $createdAt + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * Get createdAt + * + * @return datetime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set createdAtAsGmt + * + * @param datetime $createdAtAsGmt + */ + public function setCreatedAtAsGmt($createdAtAsGmt) + { + $this->createdAtAsGmt = $createdAtAsGmt; + } + + /** + * Get createdAtAsGmt + * + * @return datetime + */ + public function getCreatedAtAsGmt() + { + return $this->createdAtAsGmt; + } + + /** + * Set content + * + * @param text $content + */ + public function setContent($content) + { + $this->content = $content; + } + + /** + * Get content + * + * @return text + */ + public function getContent() + { + return $this->content; + } + + /** + * Set karma + * + * @param integer $karma + */ + public function setKarma($karma) + { + $this->karma = $karma; + } + + /** + * Get karma + * + * @return integer + */ + public function getKarma() + { + return $this->karma; + } + + /** + * Set approved + * + * @param boolean $approved + */ + public function setApproved($approved) + { + $this->approved = !! $approved; + } + + /** + * Get approved + * + * @return boolean + */ + public function getApproved() + { + return !! $this->approved; + } + + /** + * Set agent + * + * @param string $agent + */ + public function setAgent($agent) + { + $this->agent = $agent; + } + + /** + * Get agent + * + * @return string + */ + public function getAgent() + { + return $this->agent; + } + + /** + * Set type + * + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set parentId + * + * @param bigint $parentId + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + } + + /** + * Get parentId + * + * @return bigint + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set post + * + * @param PSS\Bundle\BlogBundle\Entity\Post $post + */ + public function setPost(\PSS\Bundle\BlogBundle\Entity\Post $post) + { + $this->post = $post; + } + + /** + * Get post + * + * @return PSS\Bundle\BlogBundle\Entity\Post + */ + public function getPost() + { + return $this->post; + } + + /** + * Set user + * + * @param PSS\Bundle\BlogBundle\Entity\User $user + */ + public function setUser(\PSS\Bundle\BlogBundle\Entity\User $user) + { + $this->user = $user; + } + + /** + * Get user + * + * @return PSS\Bundle\BlogBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } + + /** + * Add meta + * + * @param PSS\Bundle\BlogBundle\Entity\CommentMeta $meta + */ + public function addCommentMeta(\PSS\Bundle\BlogBundle\Entity\CommentMeta $meta) + { + $this->meta[] = $meta; + } + + /** + * Get meta + * + * @return Doctrine\Common\Collections\Collection + */ + public function getMeta() + { + return $this->meta; + } +} \ No newline at end of file diff --git a/Entity/CommentMeta.php b/Entity/CommentMeta.php index b16441b..4b1a739 100755 --- a/Entity/CommentMeta.php +++ b/Entity/CommentMeta.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_commentmeta") * @ORM\Entity @@ -40,4 +54,74 @@ class CommentMeta * @ORM\Column(name="meta_value", type="text", nullable=true) */ private $value; -} + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set key + * + * @param string $key + */ + public function setKey($key) + { + $this->key = $key; + } + + /** + * Get key + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Set value + * + * @param text $value + */ + public function setValue($value) + { + $this->value = $value; + } + + /** + * Get value + * + * @return text + */ + public function getValue() + { + return $this->value; + } + + /** + * Set comment + * + * @param PSS\Bundle\BlogBundle\Entity\Comment $comment + */ + public function setComment(\PSS\Bundle\BlogBundle\Entity\Comment $comment) + { + $this->comment = $comment; + } + + /** + * Get comment + * + * @return PSS\Bundle\BlogBundle\Entity\Comment + */ + public function getComment() + { + return $this->comment; + } +} \ No newline at end of file diff --git a/Entity/Link.php b/Entity/Link.php index 074564d..19bd55f 100755 --- a/Entity/Link.php +++ b/Entity/Link.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_links") * @ORM\Entity @@ -117,4 +131,298 @@ class Link * @ORM\JoinColumn(name="link_id", referencedColumnName="object_id") */ private $termRelationships; -} + public function __construct() + { + $this->termRelationships = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set url + * + * @param string $url + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set name + * + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set image + * + * @param string $image + */ + public function setImage($image) + { + $this->image = $image; + } + + /** + * Get image + * + * @return string + */ + public function getImage() + { + return $this->image; + } + + /** + * Set target + * + * @param string $target + */ + public function setTarget($target) + { + $this->target = $target; + } + + /** + * Get target + * + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * Set category + * + * @param bigint $category + */ + public function setCategory($category) + { + $this->category = $category; + } + + /** + * Get category + * + * @return bigint + */ + public function getCategory() + { + return $this->category; + } + + /** + * Set description + * + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * Get description + * + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set visible + * + * @param string $visible + */ + public function setVisible($visible) + { + $this->visible = $visible; + } + + /** + * Get visible + * + * @return string + */ + public function getVisible() + { + return $this->visible; + } + + /** + * Set owner + * + * @param bigint $owner + */ + public function setOwner($owner) + { + $this->owner = $owner; + } + + /** + * Get owner + * + * @return bigint + */ + public function getOwner() + { + return $this->owner; + } + + /** + * Set rating + * + * @param integer $rating + */ + public function setRating($rating) + { + $this->rating = $rating; + } + + /** + * Get rating + * + * @return integer + */ + public function getRating() + { + return $this->rating; + } + + /** + * Set updatedAt + * + * @param datetime $updatedAt + */ + public function setUpdatedAt($updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * Get updatedAt + * + * @return datetime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Set rel + * + * @param string $rel + */ + public function setRel($rel) + { + $this->rel = $rel; + } + + /** + * Get rel + * + * @return string + */ + public function getRel() + { + return $this->rel; + } + + /** + * Set notes + * + * @param text $notes + */ + public function setNotes($notes) + { + $this->notes = $notes; + } + + /** + * Get notes + * + * @return text + */ + public function getNotes() + { + return $this->notes; + } + + /** + * Set rss + * + * @param string $rss + */ + public function setRss($rss) + { + $this->rss = $rss; + } + + /** + * Get rss + * + * @return string + */ + public function getRss() + { + return $this->rss; + } + + /** + * Add termRelationships + * + * @param PSS\Bundle\BlogBundle\Entity\TermRelationship $termRelationships + */ + public function addTermRelationship(\PSS\Bundle\BlogBundle\Entity\TermRelationship $termRelationships) + { + $this->termRelationships[] = $termRelationships; + } + + /** + * Get termRelationships + * + * @return Doctrine\Common\Collections\Collection + */ + public function getTermRelationships() + { + return $this->termRelationships; + } +} \ No newline at end of file diff --git a/Entity/Option.php b/Entity/Option.php index 5fd9c06..17e3efb 100755 --- a/Entity/Option.php +++ b/Entity/Option.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_options") * @ORM\Entity @@ -46,4 +60,94 @@ class Option * @ORM\Column(name="autoload", type="string", length=20, nullable=false) */ private $autoload; -} + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set blogId + * + * @param integer $blogId + */ + public function setBlogId($blogId) + { + $this->blogId = $blogId; + } + + /** + * Get blogId + * + * @return integer + */ + public function getBlogId() + { + return $this->blogId; + } + + /** + * Set name + * + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Set value + * + * @param text $value + */ + public function setValue($value) + { + $this->value = $value; + } + + /** + * Get value + * + * @return text + */ + public function getValue() + { + return $this->value; + } + + /** + * Set autoload + * + * @param string $autoload + */ + public function setAutoload($autoload) + { + $this->autoload = $autoload; + } + + /** + * Get autoload + * + * @return string + */ + public function getAutoload() + { + return $this->autoload; + } +} \ No newline at end of file diff --git a/Entity/Post.php b/Entity/Post.php index 63d280c..46f24a3 100755 --- a/Entity/Post.php +++ b/Entity/Post.php @@ -2,7 +2,26 @@ namespace PSS\Bundle\BlogBundle\Entity; -use Doctrine\ORM\Mapping as ORM; + +// Symfony/Doctrine internal +use \Doctrine\ORM\Mapping as ORM; +use \Doctrine\Common\Collections\ArrayCollection; + + +// Specific + + +// Domain objects + + +// Entities + + +// Exceptions +use \Symfony\Component\HttpKernel\Exception\NotFoundHttpException; + + + /** * @ORM\Table(name="wp_posts") @@ -256,4 +275,517 @@ public function getTitle() { return $this->title; } -} + + + /** + * @return integer + */ + public function getYear() + { + $date = $this->getPublishedAt(); + return $date->format('Y'); + } + + + /** + * @return integer + */ + public function getMonth() + { + $date = $this->getPublishedAt(); + return $date->format('m'); + } + + + + /** + * Validate if post is set as published + * + * @return Post The post + * @throws NotFoundHttpException If post status is NOT to "publish" + */ + public function onlyIfPublished(){ + if($this->status != static::STATUS_PUBLISH) + { + throw new NotFoundHttpException('Page Not Found'); + } + return $this; + } + + + public function __construct() + { + $this->comments = new ArrayCollection(); + $this->meta = new ArrayCollection(); + $this->termRelationships = new ArrayCollection(); + } + + + /** + * Get moderated comments + * + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function getModeratedComments() + { + $approved = new ArrayCollection(); + foreach ($this->comments as $comment) { + if ($comment->getApproved() === true) { + $approved[] = $comment; + } + } + return $approved; + } + + + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set publishedAt + * + * @param datetime $publishedAt + */ + public function setPublishedAt($publishedAt) + { + $this->publishedAt = $publishedAt; + } + + /** + * Set publishedAtAsGmt + * + * @param datetime $publishedAtAsGmt + */ + public function setPublishedAtAsGmt($publishedAtAsGmt) + { + $this->publishedAtAsGmt = $publishedAtAsGmt; + } + + /** + * Get publishedAtAsGmt + * + * @return datetime + */ + public function getPublishedAtAsGmt() + { + return $this->publishedAtAsGmt; + } + + /** + * Set content + * + * @param text $content + */ + public function setContent($content) + { + $this->content = $content; + } + + /** + * Set title + * + * @param text $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * Set excerpt + * + * @param text $excerpt + */ + public function setExcerpt($excerpt) + { + $this->excerpt = $excerpt; + } + + /** + * Set status + * + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * Get status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set commentStatus + * + * @param string $commentStatus + */ + public function setCommentStatus($commentStatus) + { + $this->commentStatus = $commentStatus; + } + + /** + * Get commentStatus + * + * @return string + */ + public function getCommentStatus() + { + return $this->commentStatus; + } + + /** + * Set pingStatus + * + * @param string $pingStatus + */ + public function setPingStatus($pingStatus) + { + $this->pingStatus = $pingStatus; + } + + /** + * Get pingStatus + * + * @return string + */ + public function getPingStatus() + { + return $this->pingStatus; + } + + /** + * Set password + * + * @param string $password + */ + public function setPassword($password) + { + $this->password = $password; + } + + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set slug + * + * @param string $slug + */ + public function setSlug($slug) + { + $this->slug = $slug; + } + + /** + * Set toPing + * + * @param text $toPing + */ + public function setToPing($toPing) + { + $this->toPing = $toPing; + } + + /** + * Get toPing + * + * @return text + */ + public function getToPing() + { + return $this->toPing; + } + + /** + * Set pinged + * + * @param text $pinged + */ + public function setPinged($pinged) + { + $this->pinged = $pinged; + } + + /** + * Get pinged + * + * @return text + */ + public function getPinged() + { + return $this->pinged; + } + + /** + * Set modifiedAt + * + * @param datetime $modifiedAt + */ + public function setModifiedAt($modifiedAt) + { + $this->modifiedAt = $modifiedAt; + } + + /** + * Get modifiedAt + * + * @return datetime + */ + public function getModifiedAt() + { + return $this->modifiedAt; + } + + /** + * Set modifiedAtAsGmt + * + * @param datetime $modifiedAtAsGmt + */ + public function setModifiedAtAsGmt($modifiedAtAsGmt) + { + $this->modifiedAtAsGmt = $modifiedAtAsGmt; + } + + /** + * Get modifiedAtAsGmt + * + * @return datetime + */ + public function getModifiedAtAsGmt() + { + return $this->modifiedAtAsGmt; + } + + /** + * Set contentFiltered + * + * @param text $contentFiltered + */ + public function setContentFiltered($contentFiltered) + { + $this->contentFiltered = $contentFiltered; + } + + /** + * Get contentFiltered + * + * @return text + */ + public function getContentFiltered() + { + return $this->contentFiltered; + } + + /** + * Set parentId + * + * @param bigint $parentId + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + } + + /** + * Get parentId + * + * @return bigint + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set guid + * + * @param string $guid + */ + public function setGuid($guid) + { + $this->guid = $guid; + } + + /** + * Get guid + * + * @return string + */ + public function getGuid() + { + return $this->guid; + } + + /** + * Set menuOrder + * + * @param integer $menuOrder + */ + public function setMenuOrder($menuOrder) + { + $this->menuOrder = $menuOrder; + } + + /** + * Get menuOrder + * + * @return integer + */ + public function getMenuOrder() + { + return $this->menuOrder; + } + + /** + * Set type + * + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * Get type + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Set mimeType + * + * @param string $mimeType + */ + public function setMimeType($mimeType) + { + $this->mimeType = $mimeType; + } + + /** + * Get mimeType + * + * @return string + */ + public function getMimeType() + { + return $this->mimeType; + } + + /** + * Set commentCount + * + * @param bigint $commentCount + */ + public function setCommentCount($commentCount) + { + $this->commentCount = $commentCount; + } + + /** + * Get commentCount + * + * @return bigint + */ + public function getCommentCount() + { + return $this->commentCount; + } + + /** + * Set author + * + * @param PSS\Bundle\BlogBundle\Entity\User $author + */ + public function setAuthor(\PSS\Bundle\BlogBundle\Entity\User $author) + { + $this->author = $author; + } + + /** + * Add comments + * + * @param PSS\Bundle\BlogBundle\Entity\Comment $comments + */ + public function addComment(\PSS\Bundle\BlogBundle\Entity\Comment $comments) + { + $this->comments[] = $comments; + } + + /** + * Get comments + * + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function getComments() + { + return $this->comments; + } + + /** + * Add meta + * + * @param PSS\Bundle\BlogBundle\Entity\PostMeta $meta + */ + public function addPostMeta(\PSS\Bundle\BlogBundle\Entity\PostMeta $meta) + { + $this->meta[] = $meta; + } + + /** + * Get meta + * + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function getMeta() + { + return $this->meta; + } + + /** + * Add termRelationships + * + * @param PSS\Bundle\BlogBundle\Entity\TermRelationship $termRelationships + */ + public function addTermRelationship(\PSS\Bundle\BlogBundle\Entity\TermRelationship $termRelationships) + { + $this->termRelationships[] = $termRelationships; + } + + /** + * Get termRelationships + * + * @return \Doctrine\Common\Collections\ArrayCollection + */ + public function getTermRelationships() + { + return $this->termRelationships; + } +} \ No newline at end of file diff --git a/Entity/PostMeta.php b/Entity/PostMeta.php index 0df0166..a24c42c 100755 --- a/Entity/PostMeta.php +++ b/Entity/PostMeta.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_postmeta") * @ORM\Entity @@ -40,4 +54,74 @@ class PostMeta * @ORM\Column(name="meta_value", type="text", nullable=true) */ private $value; -} + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set key + * + * @param string $key + */ + public function setKey($key) + { + $this->key = $key; + } + + /** + * Get key + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Set value + * + * @param text $value + */ + public function setValue($value) + { + $this->value = $value; + } + + /** + * Get value + * + * @return text + */ + public function getValue() + { + return $this->value; + } + + /** + * Set post + * + * @param PSS\Bundle\BlogBundle\Entity\Post $post + */ + public function setPost(\PSS\Bundle\BlogBundle\Entity\Post $post) + { + $this->post = $post; + } + + /** + * Get post + * + * @return PSS\Bundle\BlogBundle\Entity\Post + */ + public function getPost() + { + return $this->post; + } +} \ No newline at end of file diff --git a/Entity/Term.php b/Entity/Term.php index acb8787..290b0bf 100755 --- a/Entity/Term.php +++ b/Entity/Term.php @@ -2,9 +2,23 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + + +// Specific + + +// Domain objects + + +// Entities use PSS\Bundle\BlogBundle\Entity\TermTaxonomy; + + + /** * @ORM\Table(name="wp_terms") * @ORM\Entity(repositoryClass="PSS\Bundle\BlogBundle\Repository\TermRepository") @@ -49,6 +63,7 @@ class Term implements \PSS\Bundle\BlogBundle\TagCloud\TagInterface */ private $termTaxonomies; + /** * @return string */ @@ -57,6 +72,7 @@ public function getName() return $this->name; } + /** * @return string */ @@ -65,6 +81,7 @@ public function getSlug() return $this->slug; } + /** * @return integer */ @@ -73,6 +90,7 @@ public function getFrequency() return $this->getPostCount(); } + /** * @return integer */ @@ -83,6 +101,7 @@ public function getPostCount() return is_null($termTaxonomy) ? 0 : $termTaxonomy->getPostCount(); } + /** * @return PSS\Bundle\BlogBundle\Entity\TermTaxonomy */ @@ -98,4 +117,87 @@ private function getPostTagTaxonomy() return null; } -} + + + public function __construct() + { + $this->termTaxonomies = new \Doctrine\Common\Collections\ArrayCollection(); + } + + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + + /** + * Set name + * + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + + /** + * Set slug + * + * @param string $slug + */ + public function setSlug($slug) + { + $this->slug = $slug; + } + + + /** + * Set group + * + * @param bigint $group + */ + public function setGroup($group) + { + $this->group = $group; + } + + + /** + * Get group + * + * @return bigint + */ + public function getGroup() + { + return $this->group; + } + + + /** + * Add termTaxonomies + * + * @param PSS\Bundle\BlogBundle\Entity\TermTaxonomy $termTaxonomies + */ + public function addTermTaxonomy(\PSS\Bundle\BlogBundle\Entity\TermTaxonomy $termTaxonomies) + { + $this->termTaxonomies[] = $termTaxonomies; + } + + + /** + * Get termTaxonomies + * + * @return Doctrine\Common\Collections\Collection + */ + public function getTermTaxonomies() + { + return $this->termTaxonomies; + } +} \ No newline at end of file diff --git a/Entity/TermRelationship.php b/Entity/TermRelationship.php index 6ddf27c..836ed96 100755 --- a/Entity/TermRelationship.php +++ b/Entity/TermRelationship.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_term_relationships") * @ORM\Entity @@ -58,4 +72,134 @@ class TermRelationship * @ORM\Column(name="term_order", type="integer", nullable=false) */ private $termOrder; -} + + + /** + * Set objectId + * + * @param bigint $objectId + */ + public function setObjectId($objectId) + { + $this->objectId = $objectId; + } + + + /** + * Get objectId + * + * @return bigint + */ + public function getObjectId() + { + return $this->objectId; + } + + + /** + * Set termTaxonomyId + * + * @param bigint $termTaxonomyId + */ + public function setTermTaxonomyId($termTaxonomyId) + { + $this->termTaxonomyId = $termTaxonomyId; + } + + + /** + * Get termTaxonomyId + * + * @return bigint + */ + public function getTermTaxonomyId() + { + return $this->termTaxonomyId; + } + + + /** + * Set termOrder + * + * @param integer $termOrder + */ + public function setTermOrder($termOrder) + { + $this->termOrder = $termOrder; + } + + + /** + * Get termOrder + * + * @return integer + */ + public function getTermOrder() + { + return $this->termOrder; + } + + + /** + * Set link + * + * @param PSS\Bundle\BlogBundle\Entity\Link $link + */ + public function setLink(\PSS\Bundle\BlogBundle\Entity\Link $link) + { + $this->link = $link; + } + + + /** + * Get link + * + * @return PSS\Bundle\BlogBundle\Entity\Link + */ + public function getLink() + { + return $this->link; + } + + + /** + * Set post + * + * @param PSS\Bundle\BlogBundle\Entity\Post $post + */ + public function setPost(\PSS\Bundle\BlogBundle\Entity\Post $post) + { + $this->post = $post; + } + + + /** + * Get post + * + * @return PSS\Bundle\BlogBundle\Entity\Post + */ + public function getPost() + { + return $this->post; + } + + /** + * Set termTaxonomy + * + * @param PSS\Bundle\BlogBundle\Entity\TermTaxonomy $termTaxonomy + */ + public function setTermTaxonomy(\PSS\Bundle\BlogBundle\Entity\TermTaxonomy $termTaxonomy) + { + $this->termTaxonomy = $termTaxonomy; + } + + /** + * Get termTaxonomy + * + * @return PSS\Bundle\BlogBundle\Entity\TermTaxonomy + */ + public function getTermTaxonomy() + { + return $this->termTaxonomy; + } +} \ No newline at end of file diff --git a/Entity/TermTaxonomy.php b/Entity/TermTaxonomy.php index df6a0b7..cae11e9 100755 --- a/Entity/TermTaxonomy.php +++ b/Entity/TermTaxonomy.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_term_taxonomy") * @ORM\Entity @@ -89,4 +103,151 @@ public function getPostCount() { return $this->count; } -} + + + public function __construct() + { + $this->termRelationships = new \Doctrine\Common\Collections\ArrayCollection(); + } + + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set termId + * + * @param bigint $termId + */ + public function setTermId($termId) + { + $this->termId = $termId; + } + + /** + * Get termId + * + * @return bigint + */ + public function getTermId() + { + return $this->termId; + } + + /** + * Set taxonomy + * + * @param string $taxonomy + */ + public function setTaxonomy($taxonomy) + { + $this->taxonomy = $taxonomy; + } + + /** + * Set description + * + * @param text $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * Get description + * + * @return text + */ + public function getDescription() + { + return $this->description; + } + + /** + * Set parentId + * + * @param bigint $parentId + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + } + + /** + * Get parentId + * + * @return bigint + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * Set count + * + * @param bigint $count + */ + public function setCount($count) + { + $this->count = $count; + } + + /** + * Get count + * + * @return bigint + */ + public function getCount() + { + return $this->count; + } + + /** + * Set term + * + * @param PSS\Bundle\BlogBundle\Entity\Term $term + */ + public function setTerm(\PSS\Bundle\BlogBundle\Entity\Term $term) + { + $this->term = $term; + } + + /** + * Get term + * + * @return PSS\Bundle\BlogBundle\Entity\Term + */ + public function getTerm() + { + return $this->term; + } + + /** + * Add termRelationships + * + * @param PSS\Bundle\BlogBundle\Entity\TermRelationship $termRelationships + */ + public function addTermRelationship(\PSS\Bundle\BlogBundle\Entity\TermRelationship $termRelationships) + { + $this->termRelationships[] = $termRelationships; + } + + /** + * Get termRelationships + * + * @return Doctrine\Common\Collections\Collection + */ + public function getTermRelationships() + { + return $this->termRelationships; + } +} \ No newline at end of file diff --git a/Entity/User.php b/Entity/User.php index f38d987..c773788 100755 --- a/Entity/User.php +++ b/Entity/User.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_users") * @ORM\Entity @@ -113,4 +127,250 @@ public function getDisplayName() { return $this->displayName; } -} + public function __construct() + { + $this->posts = new \Doctrine\Common\Collections\ArrayCollection(); + $this->comments = new \Doctrine\Common\Collections\ArrayCollection(); + $this->meta = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set login + * + * @param string $login + */ + public function setLogin($login) + { + $this->login = $login; + } + + /** + * Get login + * + * @return string + */ + public function getLogin() + { + return $this->login; + } + + /** + * Set password + * + * @param string $password + */ + public function setPassword($password) + { + $this->password = $password; + } + + /** + * Get password + * + * @return string + */ + public function getPassword() + { + return $this->password; + } + + /** + * Set niceName + * + * @param string $niceName + */ + public function setNiceName($niceName) + { + $this->niceName = $niceName; + } + + /** + * Get niceName + * + * @return string + */ + public function getNiceName() + { + return $this->niceName; + } + + /** + * Set email + * + * @param string $email + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * Get email + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Set url + * + * @param string $url + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * Get url + * + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set registeredAt + * + * @param datetime $registeredAt + */ + public function setRegisteredAt($registeredAt) + { + $this->registeredAt = $registeredAt; + } + + /** + * Get registeredAt + * + * @return datetime + */ + public function getRegisteredAt() + { + return $this->registeredAt; + } + + /** + * Set activationKey + * + * @param string $activationKey + */ + public function setActivationKey($activationKey) + { + $this->activationKey = $activationKey; + } + + /** + * Get activationKey + * + * @return string + */ + public function getActivationKey() + { + return $this->activationKey; + } + + /** + * Set status + * + * @param integer $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * Get status + * + * @return integer + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set displayName + * + * @param string $displayName + */ + public function setDisplayName($displayName) + { + $this->displayName = $displayName; + } + + /** + * Add posts + * + * @param PSS\Bundle\BlogBundle\Entity\Post $posts + */ + public function addPost(\PSS\Bundle\BlogBundle\Entity\Post $posts) + { + $this->posts[] = $posts; + } + + /** + * Get posts + * + * @return Doctrine\Common\Collections\Collection + */ + public function getPosts() + { + return $this->posts; + } + + /** + * Add comments + * + * @param PSS\Bundle\BlogBundle\Entity\Comment $comments + */ + public function addComment(\PSS\Bundle\BlogBundle\Entity\Comment $comments) + { + $this->comments[] = $comments; + } + + /** + * Get comments + * + * @return Doctrine\Common\Collections\Collection + */ + public function getComments() + { + return $this->comments; + } + + /** + * Add meta + * + * @param PSS\Bundle\BlogBundle\Entity\UserMeta $meta + */ + public function addUserMeta(\PSS\Bundle\BlogBundle\Entity\UserMeta $meta) + { + $this->meta[] = $meta; + } + + /** + * Get meta + * + * @return Doctrine\Common\Collections\Collection + */ + public function getMeta() + { + return $this->meta; + } +} \ No newline at end of file diff --git a/Entity/UserMeta.php b/Entity/UserMeta.php index 05c56a9..caced9d 100755 --- a/Entity/UserMeta.php +++ b/Entity/UserMeta.php @@ -2,8 +2,22 @@ namespace PSS\Bundle\BlogBundle\Entity; + +// Symfony/Doctrine internal use Doctrine\ORM\Mapping as ORM; + +// Specific + + +// Domain objects + + +// Entities + + + + /** * @ORM\Table(name="wp_usermeta") * @ORM\Entity @@ -40,4 +54,74 @@ class UserMeta * @ORM\Column(name="meta_value", type="text", nullable=true) */ private $value; -} + + /** + * Get id + * + * @return bigint + */ + public function getId() + { + return $this->id; + } + + /** + * Set key + * + * @param string $key + */ + public function setKey($key) + { + $this->key = $key; + } + + /** + * Get key + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Set value + * + * @param text $value + */ + public function setValue($value) + { + $this->value = $value; + } + + /** + * Get value + * + * @return text + */ + public function getValue() + { + return $this->value; + } + + /** + * Set user + * + * @param PSS\Bundle\BlogBundle\Entity\User $user + */ + public function setUser(\PSS\Bundle\BlogBundle\Entity\User $user) + { + $this->user = $user; + } + + /** + * Get user + * + * @return PSS\Bundle\BlogBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } +} \ No newline at end of file diff --git a/Form/CommentForm.php b/Form/CommentForm.php new file mode 100644 index 0000000..21d6999 --- /dev/null +++ b/Form/CommentForm.php @@ -0,0 +1,50 @@ +add('authorName', 'text') + ->add('authorUrl', 'text') + ->add('authorEmail', 'text') + ->add('contentt', 'text') + ->add('post', 'text'); + } + + + public function getDefaultOptions(array $options) + { + return array( + 'data_class'=> self::DATA_CLASS, + 'csrf_field_name' => '_comment_intent' + ); + } + + + public function getName() + { + return 'wordpress_comment_form'; + } +} \ No newline at end of file diff --git a/Manager/AbstractManager.php b/Manager/AbstractManager.php new file mode 100644 index 0000000..158d633 --- /dev/null +++ b/Manager/AbstractManager.php @@ -0,0 +1,93 @@ +dispatcher = $dispatcher; + $this->em = $em; + } + + + public function getRepository($name=null) + { + $entityName = ($name === null)?static::CLASSNAME:$name; + $repository = $this->em->getRepository($entityName); + return $repository; + } + + + + + /** + * Returns a new instance of the Form class + * + * Make sure you adjust the form' __construct($inputArray) + * with the proper index. + * + * e.g. $om->formFactory($injectOne,$injectTwo,$injectThree); + * would return a new SomeRandomFormName instance + * + * Inside the SomeRandomFormName::__construct($inputArray), you + * could get $injectOne value by delcaring $inputArray[0] + * + * @return \Symfony\Component\Form\AbstractType form class instance + */ + public function formFactory() + { + $arguments = func_get_args(); + $formClassname = static::FORM_CLASSNAME; + if(count($arguments) >= 1){ + return new $formClassname($arguments); + } + return new $formClassname(); + } + + + + + /** + * Return a _new Entity_ + */ + public function create() + { + $classname = $this->classname; + return new $classname(); + } + +} \ No newline at end of file diff --git a/Manager/CommentManager.php b/Manager/CommentManager.php new file mode 100644 index 0000000..c6874ec --- /dev/null +++ b/Manager/CommentManager.php @@ -0,0 +1,41 @@ +getDQL()); + } + + + + /** + * Convert Array to ArrayCollection + * + * @param array $array + * @return ArrayCollection + */ + public function toCollection($array) + { + return $this->_toCollection($array); + } + + + + /** + * Convert Array to ArrayCollection + * + * @return ArrayCollection + */ + public function asCollection() + { + return $this->_toCollection($this->qb); + } + + + + /** + * Return the first Entity class + * + * @param QueryBuilder $qb a QueryBuilder instance + * @return Object an Entity object + */ + protected function _fistInCollectionFromQueryBuilder(QueryBuilder $qb) + { + $collection = $this->_collectionFromQueryBuilder($qb); + return $collection->first(); + } + + + + /** + * Convert a result Collection based on QueryBuilder + * + * @param QueryBuilder $qb a QueryBuilder instance + * @return Object an Entity object + */ + protected function _collectionFromQueryBuilder(QueryBuilder $qb) + { + $result = $qb->getQuery()->getResult(); + return $this->_toCollection($result); + } + + + + protected function _toCollection($result) + { + return new \Doctrine\Common\Collections\ArrayCollection($result); + } +} \ No newline at end of file diff --git a/Repository/CommentRepository.php b/Repository/CommentRepository.php new file mode 100644 index 0000000..dda6b30 --- /dev/null +++ b/Repository/CommentRepository.php @@ -0,0 +1,21 @@ +getEntityManager()->createQuery( - 'SELECT p, a FROM PSS\Bundle\BlogBundle\Entity\Post p - INNER JOIN p.author a - WHERE p.type = :type AND p.status = :status - ORDER BY p.publishedAt DESC' - ); + $this->qb = $this->createQueryBuilder("p") + ->select('p,a') + ->innerJoin('p.author', 'a') + ->where('p.type = :type') + ->andWhere('p.status = :status') + ->orderBy('p.publishedAt', 'DESC'); - $query->setParameter('type', Post::TYPE_POST); - $query->setParameter('status', Post::STATUS_PUBLISH); + if (is_numeric($max)) + { + $this->qb->setMaxResults($max); + } - return $query; + $this->qb->setParameter('type', Post::TYPE_POST); + $this->qb->setParameter('status', Post::STATUS_PUBLISH); + + return $this->qb; + } + + /** + * @return Doctrine\ORM\QueryBuilder + */ + public function getPublishedByTerm(Term $term=null) + { + $this->qb = $this->getPublished() + ->innerJoin('p.termRelationships', 'tr') + ->innerJoin('tr.termTaxonomy', 'tt') + ->innerJoin('tt.term','t') + ->andWhere('tt.taxonomy = :taxonomy') + ->andWhere('t.slug = :slug'); + + $this->qb->setParameter('slug', $term->getSlug()); + $this->qb->setParameter('taxonomy', TermTaxonomy::POST_TAG); + + return $this->qb; + } + + /** + * 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() + { + $qb = $this->getPublished(); + $qb->setParameter('type', Post::TYPE_POST); + $qb->setParameter('status', Post::STATUS_PUBLISH); + return $qb->getQuery(); } /** @@ -43,25 +157,10 @@ public function findPublishedPosts($max = 3) */ public function getPublishedPostsByTagQuery($tagSlug) { - $query = $this->getEntityManager()->createQuery( - 'SELECT p, a FROM PSS\Bundle\BlogBundle\Entity\Post p - INNER JOIN p.author a - INNER JOIN p.termRelationships tr - INNER JOIN tr.termTaxonomy tt - INNER JOIN tt.term t - WHERE p.type = :type - AND p.status = :status - AND tt.taxonomy = :taxonomy - AND t.slug = :slug - ORDER BY p.publishedAt DESC' - ); - - $query->setParameter('type', Post::TYPE_POST); - $query->setParameter('status', Post::STATUS_PUBLISH); - $query->setParameter('slug', $tagSlug); - $query->setParameter('taxonomy', TermTaxonomy::POST_TAG); + $this->qb = $this->getPublishedByTerm() + ->setParameter('slug', $tagSlug); - return $query; + return $this->qb->getQuery(); } /** diff --git a/Repository/TermRepository.php b/Repository/TermRepository.php index 0c38156..5ea483d 100755 --- a/Repository/TermRepository.php +++ b/Repository/TermRepository.php @@ -2,10 +2,22 @@ namespace PSS\Bundle\BlogBundle\Repository; +# Symfony/Doctrine internal use Doctrine\ORM\EntityRepository; + + +# Specific + + +# Domain objects + + +# Entities use PSS\Bundle\BlogBundle\Entity\TermTaxonomy; -class TermRepository extends EntityRepository + + +class TermRepository extends AbstractRepository { /** * @return array diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 69696f5..2736268 100755 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -1,6 +1,26 @@ +parameters: + pss.blog.manager.post.class: PSS\Bundle\BlogBundle\Manager\PostManager + pss.blog.manager.comment.class: PSS\Bundle\BlogBundle\Manager\CommentManager + pss.twig.extension.content.class: PSS\Bundle\BlogBundle\Twig\Extension\ContentExtension + services: pss.twig.extension.content: - class: PSS\Bundle\BlogBundle\Twig\Extension\ContentExtension + class: %pss.twig.extension.content.class% public: false tags: - { name: twig.extension } + + pss.blog.manager.entity.abstract: + abstract: true + arguments: + dispatcher: '@event_dispatcher' + em: '@doctrine.orm.entity_manager' + + pss.blog.manager.post: + parent: pss.blog.manager.entity.abstract + class: %pss.blog.manager.post.class% + + + pss.blog.manager.comment: + parent: pss.blog.manager.entity.abstract + class: %pss.blog.manager.comment.class% \ No newline at end of file diff --git a/Resources/doc/recipe-extending-blog-controller.md b/Resources/doc/recipe-extending-blog-controller.md new file mode 100644 index 0000000..e69de29 diff --git a/Resources/doc/recipe-extending-blog.md b/Resources/doc/recipe-extending-blog.md new file mode 100644 index 0000000..8167299 --- /dev/null +++ b/Resources/doc/recipe-extending-blog.md @@ -0,0 +1,7 @@ +HOW TO EXTEND BLOG CONTROLLER TO SUIT WITH SPECIFIC QUERIES + +#TODO: ... to write... + +=Topic: Table of contents + * Introduction + * Adding your own views diff --git a/Resources/views/Blog/postsList.html.twig b/Resources/views/Blog/postsList.html.twig index 3c798d4..7730169 100644 --- a/Resources/views/Blog/postsList.html.twig +++ b/Resources/views/Blog/postsList.html.twig @@ -1,10 +1,10 @@ {% for post in paginator %} -