TYPO3中获取不受支持或不存在的属性名称异常

时间:2018-07-23 10:35:14

标签: typo3 typoscript typo3-7.6.x typo3-8.x typo3-extensions

我正在尝试通过在sys_category中使用此代码在自己的自定义模式中添加setup.txt

config.tx_extbase {
    objects {
        TYPO3\CMS\Extbase\Domain\Model\Category {
            className = ABC\MyExt\Domain\Model\Category
        }
    TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository {
        className = ABC\MyExt\Domain\Repository\CategoryRepository
        }
    }
}

plugin.tx_myext {
    persistence {
        classes {
            ABC\MyExt\Domain\Model\Category {
                mapping {
                    tableName = sys_category
                }
            }
        }
    }
}

但是我遇到了这个异常Unsupported or non-existing property name \"categories\" used in relation matching

在我的模型中,我正在使用

/**
 * categories
 *
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\ABC\MyExt\Domain\Model\Category>
 */
protected $categories = null;

建立关系时我做错了什么?

我的TCA我正在ext_tables.php

中使用它
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable(
            'myext',
            'tx_myext_domain_model_tablename,
            // Do not use the default field name ("categories") for pages, tt_content, sys_file_metadata, which is already used
            'categories',
            array(
                // Set a custom label
                'label'              => 'LLL:EXT:myext/Resources/Private/Language/locallang.xlf:additional_categories',
                // This field should not be an exclude-field
                'exclude'            => false,
                // Override generic configuration, e.g. sort by title rather than by sorting
                'fieldConfiguration' => array(
                    'foreign_table_where' => ' AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC',
                ),
                // string (keyword), see TCA reference for details
                'l10n_mode'          => 'exclude',
                // list of keywords, see TCA reference for details
                'l10n_display'       => 'hideDiff',
            )
        );

在表中我有这个categories int(11) DEFAULT '0' NOT NULL,

1 个答案:

答案 0 :(得分:0)

从TYPO3 8.5(TYPO3 CMS Core ChangeLog)开始,前端请求不再在请求中加载ext_tables.php

makeCategorizable()的呼叫必须移至Configuration/TCA/Overrides/<table>.php