0

I've tried to get a list with all Frontend Usergroups

I've tried this:

    /**
 * Protected Variable FrontendUserGroupRepository wird mit NULL initialisiert.
 *
 * @var \ReRe\Rere\Domain\Repository\FrontendUserGroupRepository
 * @inject
 */
protected $FrontendUserGroupRepository = NULL;

and then this

 $feUserGroups = $this->frontendUserGroupRepository->findAll();

But the list is always empty, even if there are 2 usergroups in the database.

Update ... i tried this as repository

class FrontendUserGroupRepository extends \Typo3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository {

     // Example for repository wide settings
    public function initializeObject() {
        /** @var $defaultQuerySettings Tx_Extbase_Persistence_Typo3QuerySettings */
        $defaultQuerySettings = $this->objectManager->get('Tx_Extbase_Persistence_Typo3QuerySettings');
        // go for $defaultQuerySettings = $this->createQuery()->getQuerySettings(); if you want to make use of the TS persistence.storagePid with defaultQuerySettings(), see #51529 for details

        // don't add the pid constraint
        $defaultQuerySettings->setRespectStoragePage(FALSE);
        // don't add fields from enablecolumns constraint
        $defaultQuerySettings->setRespectEnableFields(FALSE);
        // don't add sys_language_uid constraint
        $defaultQuerySettings->setRespectSysLanguage(FALSE);
        $this->setDefaultQuerySettings($defaultQuerySettings);
    }

}

but I got this error:

Could not analyse class:Typo3\CMS\Extbase\Domain\Repository\FEUserGroupsRepositry maybe not loaded or no autoloader

I've added the a new dependecy injection and reinstalled the module ...

Felix
  • 5,452
  • 12
  • 68
  • 163

1 Answers1

4

By default each Extbase repository has flag respectStoragePage set to true, that means that user groups need to be placed at the page which is configured as Default storage PID in your exts constants, anyway as I saw you probably don't include it at all.

In such case you need to create own repository extending FrontendUserGroupRepository and then initialize it without respecting the storage.

It's described in official docs.

Edit: if you extending some model/repo in your extension Builder automatically limits your repo to objects of your type only, i.e. by adding in TS mapping:

 recordType = Tx_Rere_FrontendUserGroup

So if you want to get access to all records of extended model, just remove the recordType from ext_typoscript_setup.txt completely (don't forget to clear system cache).

biesior
  • 55,576
  • 10
  • 125
  • 182
  • @biesior: You might add an information about ```module.tx_myext``` being used for Backend modules. – lorenz Jan 06 '15 at 20:02
  • I've added my new repository code with exception above .. whats going wrong? – Felix Jan 06 '15 at 22:07
  • thanks besior very stupid copy paste mistake ... really stupid ... to much time in my cellar office – Felix Jan 07 '15 at 12:46
  • corrected the code above .. but the problem extists as well. – Felix Jan 07 '15 at 13:02
  • okay solved some problems ... but now I got this error: `Could not find class definition for name "ReRe\Rere\Domain\Model\FrontendUserGroup". This could be caused by a mis-spelling of the class name in the class definition. ` It's clear why I got this but how can I resolve it? – Felix Jan 07 '15 at 13:34
  • Create this model extending with `\TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup` – biesior Jan 07 '15 at 13:47
  • I've created the Model `ReRe\Rere\Domain\Model\FrontendUserGroup`and extended the original FrontendUsrGroup Modul ... and now it says no Table in database `#1247602160: Table 'typo3.tx_rere_domain_model_frontendusergroup' doesn't exist (More information)` Do I have to edit the TypoScript also?? – Felix Jan 07 '15 at 22:20
  • @Felix some time ago I described you a difference between extending model in Builder and making the relation. Check this clue for solution, curently I'm AFK – biesior Jan 07 '15 at 22:37
  • thats right. sorry forgotten it. I've done lit like figure 3 http://stackoverflow.com/questions/27601254/foreign-key-to-typo3-frontend-user ... but the return value is NULL ... but there are 2 entries in database :( – Felix Jan 07 '15 at 23:24
  • I asked if have you got your code in some git repo, sorry ;) – biesior Jan 08 '15 at 12:02