Reputation:
first to say I'm really new to both Symfony and Doctrine and am trying really hard to learn it. I found this tutorial http://tutorial.symblog.co.uk/ which guides you through making your own blog in it. The problem is, it was designed for Symfony 2.0 and I'm using 2.1.5. So along the way I had to fix quite a few issues that occured due to changes introduced in both Symfony and Doctrine.
However, this problem is the one I just can't seem to solve the right way. Its really short chapter, 10-15 lines of code total:
http://tutorial.symblog.co.uk/docs/customising-the-view-more-with-twig.html#recent-comments
Its actually only 1 line of code that bugs me! I have a PageController with an action function inside it:
public function sidebarAction()
{
$em = $this->getDoctrine()->getEntityManager;
$blogRep = $em->getRepository('BloggerBlogBundle:Blog');
//........ stuff here
$em->getRepository('BloggerBlogBundle:Comment') <--------------- THIS
}
The damn thing just doesn't seem to work! I get the error:
Fatal error: Class 'Blogger\BlogBundle\Entity\CommentRepository' not found in /home/igor/Documents/www/igor/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php on line 689
Key thing! : Class 'Blogger....**Entity**
It searches in Entity !
My Repositories are stored in Blogger\BlogBundle\Repository namespace! And the weirdest thing is, it finds 'BloggerBlogBundle:Blog' repository without problems, but doesn't find Comment!
Both reside in same folder (Bundles\Blogger\BlogBundle\Repository) and both are declared exactly the same way:
CommentRepository:
namespace Blogger\BlogBundle\Repository;
class CommentRepository extends EntityRepository
BlogRepository:
namespace Blogger\BlogBundle\Repository;
class BlogRepository extends EntityRepository
I moved CommentRepository file to "Entity" directory and changed it's namespace to Blogger\BlogBundle\Entity. It works perfectly then. No problems at all. But that way I'm stuck with repositories scattered through dirs and namespaces......
Why does Doctrine find Blog repo and not Comment repo in Blogger\BlogBundle\Repository ?
Upvotes: 0
Views: 1765
Reputation: 45721
Does your Blog-entity have an @ORM/Repository-annotation while your Comment-entity does not?
Upvotes: 1