本文整理汇总了PHP中ColumnMap::setTypeOfRelation方法的典型用法代码示例。如果您正苦于以下问题:PHP ColumnMap::setTypeOfRelation方法的具体用法?PHP ColumnMap::setTypeOfRelation怎么用?PHP ColumnMap::setTypeOfRelation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColumnMap
的用法示例。
在下文中一共展示了ColumnMap::setTypeOfRelation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setManyToManyRelation
/**
* This method sets the configuration for a m:n relation based on
* the $TCA column configuration
*
* @param string|ColumnMap $columnMap The column map
* @param string $columnConfiguration The column configuration from $TCA
* @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedRelationException
* @return ColumnMap
*/
protected function setManyToManyRelation(ColumnMap $columnMap, $columnConfiguration)
{
if (isset($columnConfiguration['MM'])) {
$columnMap->setTypeOfRelation(ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY);
$columnMap->setChildTableName($columnConfiguration['foreign_table']);
$columnMap->setChildTableWhereStatement($columnConfiguration['foreign_table_where']);
$columnMap->setRelationTableName($columnConfiguration['MM']);
if (is_array($columnConfiguration['MM_match_fields'])) {
$columnMap->setRelationTableMatchFields($columnConfiguration['MM_match_fields']);
}
if (is_array($columnConfiguration['MM_insert_fields'])) {
$columnMap->setRelationTableInsertFields($columnConfiguration['MM_insert_fields']);
}
$columnMap->setRelationTableWhereStatement($columnConfiguration['MM_table_where']);
if (!empty($columnConfiguration['MM_opposite_field'])) {
$columnMap->setParentKeyFieldName('uid_foreign');
$columnMap->setChildKeyFieldName('uid_local');
$columnMap->setChildSortByFieldName('sorting_foreign');
} else {
$columnMap->setParentKeyFieldName('uid_local');
$columnMap->setChildKeyFieldName('uid_foreign');
$columnMap->setChildSortByFieldName('sorting');
}
} else {
throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedRelationException('The given information to build a many-to-many-relation was not sufficient. Check your TCA definitions. mm-relations with IRRE must have at least a defined "MM" or "foreign_selector".', 1268817963);
}
if ($this->getControlSection($columnMap->getRelationTableName()) !== null) {
$columnMap->setRelationTablePageIdColumnName('pid');
}
return $columnMap;
}