1

I try to instantiate the core repository for frontend user groups of TYPO3 in the following way:

    $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
    $feGroupRepo = $objectManager->create('\\TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserGroupRepository');
    var_dump($feGroupRepo->findAll()->toArray());

As result I get the sql error:

#1247602160: Table 'tablename.tx_extbase_domain_model_frontendusergroup' doesn't exist

Why does this repo use the wrong table? And how can I configure it in the correct way to use the system table 'fe_groups'?

Rick
  • 11
  • 1

3 Answers3

1

What TYPO3 version are you using? Normaly there should be typoscript included by extbase that tells itself to not look in the table that matches the namespace and classname but fe_groups. It should be something like this:

config.tx_extbase {
    persistence{
        classes {
            TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup {
                mapping {
                    tableName = fe_groups
                    columns {
                        lockToDomain.mapOnProperty = lockToDomain
                    }
                }
            }
        }
    }
}

If this is not present for some reason, include it yourself in your TypoScript.

And please dont use the dprecated method $objectManager->create() but always $objectManager->get().

Daniel
  • 6,916
  • 2
  • 36
  • 47
0

Try to do what Daniel says:

  • Replace ->create( with ->get(
  • Check your the TypoScript Object Browser Setup section for config.tx_extbase.persistence.classes.TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup.mapping.tableName, should be equal to fe_groups. It should be pressent, else add it - but it should be there!

As a little extra, remove the double backslash in front of TYPO3 like. That may be the reason why TYPO3 can not detect the correct TypoScript path:

$feGroupRepo = $objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserGroupRepository');

After that, clear the entire cache (Eventually delete all files from typo3temp folder, sometimes its needed).

Lasse
  • 575
  • 3
  • 14
0

Instead of $objectManager->create('etcetera'), try $objectManager->get('etcetera'). If you want a longer discussion and more ideas, look at the accepted answer here.

Community
  • 1
  • 1
Andrew
  • 585
  • 4
  • 17