本文整理汇总了PHP中Doctrine\ODM\MongoDB\Mapping\ClassMetadata::getSingleAssociationJoinColumnName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getSingleAssociationJoinColumnName方法的具体用法?PHP ClassMetadata::getSingleAssociationJoinColumnName怎么用?PHP ClassMetadata::getSingleAssociationJoinColumnName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\MongoDB\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::getSingleAssociationJoinColumnName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mapTranslation
/**
* Add mapping data to a translation entity.
*
* @param ClassMetadata $metadata
*/
private function mapTranslation(ClassMetadata $metadata)
{
// In the case A -> B -> TranslationInterface, B might not have mapping defined as it
// is probably defined in A, so in that case, we just return.
if (!isset($this->configs[$metadata->name])) {
return;
}
$metadata->mapManyToOne(array('fieldName' => 'translatable', 'targetEntity' => $this->configs[$metadata->name]['model'], 'inversedBy' => 'translations', 'joinColumns' => array(array('name' => 'translatable_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE', 'nullable' => false))));
if (!$metadata->hasField('locale')) {
$metadata->mapField(array('fieldName' => 'locale', 'type' => 'string', 'nullable' => false));
}
// Map unique index.
$columns = array($metadata->getSingleAssociationJoinColumnName('translatable'), 'locale');
if (!$this->hasUniqueConstraint($metadata, $columns)) {
$constraints = isset($metadata->table['uniqueConstraints']) ? $metadata->table['uniqueConstraints'] : array();
$constraints[$metadata->getTableName() . '_uniq_trans'] = array('columns' => $columns);
$metadata->setPrimaryTable(array('uniqueConstraints' => $constraints));
}
}