Witam wszystkich serdecznie, właśnie zaczynam przygodę z ZF2 i natrafiłem na problem. Staram się zastosować wzorzec DAO w mojej testowej aplikacji ale niestety wyskakuje mi

Fatal error: Call to a member function get() on a non-object in C:\xampp\htdocs\test\module\Lists\src\Lists\Dao\FactoryEntityManager.php on line 38

Mój kontroler:
  1. namespace Lists\Controller;
  2.  
  3. use Lists\Dao\UserDaoImpl;
  4.  
  5. use Zend\Mvc\Controller\AbstractActionController;
  6. use Zend\View\Model\ViewModel;
  7.  
  8. class ListsController extends AbstractActionController
  9. {
  10. public function indexAction()
  11. {
  12. $queryTest = new UserDaoImpl();
  13. $query = $queryTest->getUserList();
  14. return array(
  15. 'profiles' => $query
  16. );
  17. }
  18. }


DAO:
  1. namespace Lists\Dao;
  2.  
  3. use Zend\Mvc\Controller\AbstractActionController;
  4.  
  5. class UserDaoImpl extends FactoryEntityManager implements UserDao {
  6.  
  7. public function getUserList() {
  8. $sql = $this->getEntityManager()->createQuery('SELECT u FROM Lists\Entity\User u');
  9. $query = $sql->getResult();
  10. return $query;
  11. }
  12. }


Klasa EntityManager
  1. namespace Lists\Dao;
  2. use Doctrine\ORM\EntityManager;
  3. use Zend\Mvc\Controller\AbstractActionController;
  4.  
  5. class FactoryEntityManager extends AbstractActionController {
  6. /**
  7. * @var EntityManager
  8. */
  9. protected $entityManager;
  10.  
  11. /**
  12. * Sets the EntityManager
  13. *
  14. * @param EntityManager $em
  15. * @access protected
  16. * @return PostController
  17. */
  18. protected function setEntityManager(EntityManager $em)
  19. {
  20. $this->entityManager = $em;
  21. return $this;
  22. }
  23.  
  24. /**
  25. * Returns the EntityManager
  26. *
  27. * Fetches the EntityManager from ServiceLocator if it has not been initiated
  28. * and then returns it
  29. *
  30. * @access protected
  31. * @return EntityManager
  32. */
  33. protected function getEntityManager()
  34. {
  35. if (null === $this->entityManager) {
  36. $this->setEntityManager($this->getServiceLocator()->get('Doctrine\ORM\EntityManager'));
  37. }
  38. return $this->entityManager;
  39. }
  40. }


W sytuacji kiedy metody EntityManager implementuje bezpośrednio w kontrolerze wszystko działa poprawnie. Ale w powyższym przykładzie dosteję błąd:

Fatal error: Call to a member function get() on a non-object in C:\xampp\htdocs\test\module\Lists\src\Lists\Dao\FactoryEntityManager.php on line 38

Jakieś pomysły?