[TYPO3-dev] Repository class not injected correctly

Dirk Ho dirk_studivz at web.de
Fri Aug 1 23:36:46 CEST 2014


Hi all,

I'm still coding a test project (a forum) and in this project, I get an 
error that I do not understand.

When I use my list and add method for categories, everything works fine, 
but when I try to select a forum in my forumController with the 
forumRepository, I get an exception, that the method findAll does not exist.

Here's the source code that I checked several times against my (working) 
CategoryController and cannot find any difference (except the names of 
the Controller / Repository):

/**
  * ForumController
  */
class ForumController extends 
\TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

     /**
      * forumRepository
      *
      * @var \DH\Forum\Domain\Repository\ForumRepository
      * @inject
      */
     protected $forumRepository = NULL;

     /**
      * persistenceManager
      *
      * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
      * @inject
      */
     protected $persistenceManager;

     /**
      * action list
      *
      * @return void
      */
     public function listAction() {
         $logger = 
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);

         $logger->info('Forum List START');

        if (!($this->forumRepository instanceof ForumRepository)) {
             $logger->info('No valid forumRepositoryObj' .
             get_class($this->forumRepository));
         }

         $forums = $this->forumRepository->findAll();

         $this->view->assign('forums', $forums);

         $logger->info('Forum List END');
     }
}

In my case, the logger logs, that $this->forumRepository is 
"\DH\Forum\Controller\ForumController"???

May you please help me what I do wrong injecting the ForumRepository?

My ForumRepository class looks like

/**
  * The repository for Forums
  */
class ForumRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
      // Nothing in here
}

I don't know what I may try. I also created a dummy entry in db to 
ensure the error does not occure because on non-existing datasets in the db.

Thanks and best wishes,

Dirk



More information about the TYPO3-dev mailing list