[TYPO3-dev] Repository class not injected correctly

Dirk Ho dirk_studivz at web.de
Sat Aug 2 21:41:26 CEST 2014


Hi Ivano,

thanks. That solved my problem (even if there's not button "Clear PHP op 
code"). But now I probably found another one: The relation between the 
ForumModel and CategoryModel.

One Category can have many Forums. In my ForumModel, there's one 
attribute $category

     /**
      * category
      *
      * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<>
      * @cascade remove
      */
     protected $category = NULL;

and in my forum table, there's also a column category.

After cleaning the cache the page does not load, because I get the 
exception "Could not determine the child object type.". Only if I 
comment the above relation, it works. In my Forum dummy entry in the DB, 
I have a relation set and the Category with this id is also available in 
the database.

Should my 1:N relation not be created in the ForumModel with the attribute

     /**
      * category
      *
      * @var \DH\Forum\Domain\Model\Category
      * @cascade remove
      */
     protected $category = NULL;

and in the CategoryModel as

     /**
      * forums
      *
      * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<>
      */
     protected $forums= NULL;

? Or do the categories know nothing about their related forums?

Thanks and best wishes,

Dirk

Am 02.08.2014 10:28, schrieb Ivano Luberti:
> Could it be that you declared wrongly $forumRepository then corrected it
> and TYPO3 is no recognizing the changes?
>
> Have you tried cleaning the cache? You should go to the Install Tool and
> select Important Actions (up left).
> Scrollling donw you should see buttons "Clear all Cache" and  "Clear PHP
> op code cache"
>
> Use both and reload the page.
>
>
>
>
> Il 01/08/2014 23:36, Dirk Ho ha scritto:
>> 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
>> _______________________________________________
>> TYPO3-dev mailing list
>> TYPO3-dev at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
>>
>




More information about the TYPO3-dev mailing list