[TYPO3-mvc] Re: Create predefined fe_groups when activating extension
NGUYEN Duc Quan
quan at apart.lu
Thu Dec 3 11:54:47 CET 2015
Hi again,
I tried to add the following code to my ext_localconf.php file:
// Create default frontend group
// create new objectManager to instantiate FrontendUserGroupRepository and FrontendUserGroup
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
// reference to FrontendUserGroupRepository to handle frontend user groups
$userGroupRepository = $objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserGroupRepository');
// create new frontend user group
$newFeGroup = $objectManager->create('\\TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUserGroup');
$newFeGroup->setTitle('myNewGroup');
$userGroupRepository->frontendUserGroupRepository->add($newFeGroup);
try {
$objectManager->objectManager
->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')
->persistAll();
} catch (Exception $e) {
echo 'Caught exception while adding group: ', $e->getMessage(), "\n";
}
which leads to a fatal error:
( ! ) Fatal error: Call to a member function exec_SELECTgetSingleRow() on null in /home/vagrant/Projects/typo3_src-7.6.0/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php on line 174
Maybe this is the wrong approach to dynamically create a group when activating the plugin?
More information about the TYPO3-project-typo3v4mvc
mailing list