TYPO3 / How to make repository from existing table fe_users?

前端 未结 2 1459
醉话见心
醉话见心 2020-12-18 06:51

I am creating a special BE module with Extbase and Fluid and I need a domain object which would be representing standard FE user. When I create new domain object called e.g.

相关标签:
2条回答
  • 2020-12-18 07:00

    For Extbase 6.X

    You need to give class like \TYPO3\CMS\Extbase\Domain\Model\FrontendUser instead of Tx_Extbase_Domain_Repository_FrontendUserRepository in Extend existing model class field inside extension builder

    After that you can have control of fe_users inside your model....

    Also add file ext_typoscript_setup.txt in root of your extension(added automatically if generated via extension_builder)

    config.tx_extbase{
        persistence{
            classes{
    
                TYPO3\CMS\Extbase\Domain\Model\FrontendUser {
                    subclasses {
                        Tx_Extendfeuser_Extended = Model_class_with_namespace
                        
                    }
                }
                Vendor\EXt\Domain\Model\Extended {
                    mapping {
                        tableName = fe_users
                        recordType = Tx_Extendfeuser_Extended
                    }
                }
                
            }
        }
    }
    

    Thanks!!!

    Works with TYPO3 7.6.X as well

    0 讨论(0)
  • 2020-12-18 07:07

    ExtBase already comes with a domain model for the existing table fe_user. This domain model is:

    Tx_Extbase_Domain_Model_FrontendUser
    

    It contains all default fe_users fields that come with TYPO3.

    If you have extended fe_users with your own fields, you also have to extend the Tx_Extbase_Domain_Model_FrontendUser domain model and the associated repository so it knows the new fields you have added to fe_users.

    The associated repository is:

    Tx_Extbase_Domain_Repository_FrontendUserRepository
    

    You have to set the storage PID(s) for the repository, so it can find your fe_users.

    For controller actions used in frontend plugins use:

    plugin.your_plugin {
        persistence {
            storagePid = somePid, anotherPid
        }
    }
    

    If controller actions used in backend modules use:

    module.your_module {
        persistence {
            storagePid = somePid, anotherPid
        }
    }
    

    As far as I know it is not possible to use the same dialogs which come with TYPO3 for your own extension, so you have to create your own actions (new/edit/show) and forms in your backend module.

    [Edit]

    By default, ExtBase assumes, that all fe_users have assigned a record type. When you open one of your frontend users, you will see the tab "extended" contains a dropdown field, which is labeled "record type". If this field is not set, ExtBase will not be able to find the fe_user by using one of the find-methods from the repository.

    You should set the record type for all fe_users (recommended way) or you can disable the mapping to the field by using the following TS in your setup

    config.tx_extbase.persistence.classes {
        Tx_Extbase_Domain_Model_FrontendUser {
            mapping.recordType >
        }
    }
    

    For newly created fe_users or fe_groups, you can set the default value for the field "record type" by adding the following TS to your root pageTS

    TCAdefaults.fe_users.tx_extbase_type = Tx_Extbase_Domain_Model_FrontendUser
    TCAdefaults.fe_groups.tx_extbase_type = Tx_Extbase_Domain_Model_FrontendUserGroup
    
    0 讨论(0)
提交回复
热议问题