[TYPO3-mvc] Question regarding usage of Tx_Extbase_Domain_Model_FrontendUser

Joerg Schoppet joerg at schoppet.de
Tue Aug 4 22:30:31 CEST 2009


Hi,

before I'll a bug-report I want to ask if I made something wrong ;-)

I have a category-table with a fe_user field. In the TCA of the category-table I defined fe_user the following way:
                 'fe_user' => array(
                         'exclude' => 1,
                         'label' => 'LLL:EXT:lang/locallang_general.php:LGL.name',
                         'config' => array(
                                 'type' => 'select',
                                 'items' => array(
                                         array('', 0),
                                 ),
                                 'foreign_class' => 'Tx_Extbase_Domain_Model_FrontendUser',
                                 'foreign_table' => 'fe_users',
                                 'foreign_table_where' => 'ORDER BY fe_users.name',
                                 'size' => 1,
                                 'minitems' => 1,
                                 'maxitems' => 1,

                         ),
                 ),

In the category-model I have for the fe_user field:
         /**
          * The fe_user of the backup_user
          *
         * @var Tx_Extbase_Domain_Model_FrontendUser
          */
         protected $feUser = 0;
         /**
          * Sets the fe_user value
          *
          * @param Tx_Extbase_Domain_Model_FrontendUser $feUser
          * @return void
          */
         public function setFeUser(Tx_Extbase_Domain_Model_FrontendUser $feUser) {
                 $this->feUser = $feUser;
         }
         /**
          * Gets the fe_user value
          *
          * @return Tx_Extbase_Domain_Model_FrontendUser
          */
         public function getFeUser() {
                 return $this->feUser;
         }

In the category-repository I have a method defined to get all categories by fe-user:
         public function getByFeUser(Tx_Extbase_Domain_Model_FrontendUser $feUser) {
                 $query = $this->createQuery();
                 $query->getQuerySettings()->setRespectStoragePageState(FALSE);
                 return $query->matching($query->equals('fe_user', $feUser->getUid()))
                         ->setOrderings(array('name' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING))
                         ->execute();
         }

And in the category-controller the index-action looks as follow:
         public function indexAction() {
                 $this->feUserRepository = t3lib_div::makeInstance('Tx_Extbase_Domain_Repository_FrontendUserRepository');
                 $this->categoryRepository = t3lib_div::makeInstance('Tx_DistributedBackup_Domain_Repository_CategoryRepository');
                 $feUser = $this->feUserRepository->findByUid((int)$GLOBALS['TSFE']->fe_user->user['uid']);
                 $users = $this->categoryRepository->getByFeUser($feUser);
                 $this->view->assign(
                         'users',
                         $this->categoryRepository->getByFeUser(
                                 $this->feUserRepository->findByUid((int)$GLOBALS['TSFE']->fe_user->user['uid'])
                         )
                 );
         }

As soon as I try to access this plugin in the frontend I get the following errors:
	Warning: class_parents() [function.class-parents]: object or string expected in /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php on line 317
	Warning: Invalid argument supplied for foreach() in /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php on line 317
	Warning: class_implements() [function.class-implements]: object or string expected in /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php on line 146
	Warning: in_array() [function.in-array]: Wrong datatype for second argument in /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php on line 146
	Fatal error: Uncaught exception 'Tx_Extbase_Object_Exception_CannotReconstituteObject' with message 'Cannot create empty instance of the class "" because it does not implement the Tx_Extbase_DomainObject_DomainObjectInterface.' in /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php:146 Stack trace: #0 /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php(128): Tx_Extbase_Persistence_Mapper_DataMapper->createEmptyObject(NULL) #1 /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php(113): Tx_Extbase_Persistence_Mapper_DataMapper->mapSingleRow(NULL, Object(Tx_Extbase_Persistence_Row)) #2 /path/to/extbase/Classes/Persistence/Query.php(214): Tx_Extbase_Persistence_Mapper_DataMapper->map(NULL, Object(Tx_Extbase_Persistence_RowIterator)) #3 /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php(260): Tx_Extbase_Persistence_Query->execute() #4 /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php on line 146


I tracked it down, that the columnMap of "usergroup" in "fe_users" has not "childClassName" set. As soon as I put:
	$GLOBALS['TCA']['fe_users']['columns']['usergroup']['config']['foreign_class'] = 'Tx_Extbase_Domain_Model_FrontendUserGroup';

in "typo3conf/extTables.php" it is working!!


Have I made something wrong?


Joerg


More information about the TYPO3-project-typo3v4mvc mailing list