首页 文章

TYPO3如何重新声明FrontendUser类

提问于
浏览
1

我有TYPO3 7.6.18 . 我需要重新声明TYPO3 \ CMS \ Extbase \ Domain \ Model \ FrontendUser类并使用我的新类Fhk \ Feusersplus \ Domain \ Model \ FrontendUser扩展它 . 我需要TYPO3使用我的FrontEnd类 . (我需要添加新的上传字段)

我试过了:

ext_typoscript_setup.txt:

config.tx_extbase{
    persistence{
        classes{
            In2code\Femanager\Domain\Model\User {
                subclasses {
                    0 = Fhk\Feusersplus\Domain\Model\User
                }
            }
            TYPO3\CMS\Extbase\Domain\Model\FrontendUser{
                subclasses {
                    0 = Fhk\Feusersplus\Domain\Model\FrontendUser
                }
            }
            Fhk\Feusersplus\Domain\Model\User {
                mapping {
                    tableName = fe_users
                    recordType = 0
                }
            }
        }
    }
    objects {
        In2code\Femanager\Controller\NewController.className  = Fhk\Feusersplus\Controller\NewController
        In2code\Femanager\Controller\EditController.className = Fhk\Feusersplus\Controller\EditController
        In2code\Femanager\Controller\UserController.className = Fhk\Feusersplus\Controller\UserController
        #Kennziffer\KeQuestionnaire\Domain\Repository\ResultRepository.className = Fhk\Feusersplus\Domain\Repository\ResultRepository
    }
}

ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Extbase\Domain\Model\FrontendUser'] = array(
    'className' => 'Fhk\Feusersplus\Domain\Model\FrontendUser'
);

但我有错误:

Exception while property mapping at property path "": Property "backgroundimage" was not found in target object of type "Fhk\Feusersplus\Domain\Model\User".

我的文件分机:Configuration / TCA / Overrides / fe_users.php

$tmp_feusersplus_columns = array(
    'backgroundimage' => [
        'exclude' => 1,
        'label' => 'Background image',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'image', [
            'appearance' => [
                'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
            ],
            'maxitems' => 1,
            // custom configuration for displaying fields in the overlay/reference table
            // to use the imageoverlayPalette instead of the basicoverlayPalette
            'foreign_match_fields' => [
                'fieldname' => 'backgroundimage',
                'tablenames' => 'fe_users',
                'table_local' => 'sys_file',
            ],
            'foreign_types' => [
                '0' => [
                    'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                            --palette--;;filePalette'
                ],
                \TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
                    'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                            --palette--;;filePalette'
                ],
                \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
                    'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                            --palette--;;filePalette'
                ],
                \TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
                    'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                            --palette--;;filePalette'
                ],
                \TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
                    'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                            --palette--;;filePalette'
                ],
                \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
                    'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                            --palette--;;filePalette'
                ]
            ]
        ], $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])
    ],

);

是的,我使用backgroundimage字段扩展ext_tables

似乎TYPO3没有使用我的新FrontendUser类 . 请帮助我任何人!

1 回答

  • 1

    我不认为DB或TCA存在问题,很可能在您的模型中缺少该属性 Property "backgroundimage" was not found

    protected $backgroundimage = null;
    
        public function getBackgroundimage()
        {
            return $this->backgroundimage;
        }
    

相关问题