本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::getDiscriminatorColumn方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataInfo::getDiscriminatorColumn方法的具体用法?PHP ClassMetadataInfo::getDiscriminatorColumn怎么用?PHP ClassMetadataInfo::getDiscriminatorColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadataInfo
的用法示例。
在下文中一共展示了ClassMetadataInfo::getDiscriminatorColumn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportClassMetadata
/**
* Converts a single ClassMetadata instance to the exported format
* and returns it
*
* TODO: Should this code be pulled out in to a toArray() method in ClassMetadata
*
* @param ClassMetadataInfo $metadata
* @return mixed $exported
*/
public function exportClassMetadata(ClassMetadataInfo $metadata)
{
$array = array();
if ($metadata->isMappedSuperclass) {
$array['type'] = 'mappedSuperclass';
} else {
$array['type'] = 'entity';
}
$array['table'] = $metadata->primaryTable['name'];
if (isset($metadata->primaryTable['schema'])) {
$array['schema'] = $metadata->primaryTable['schema'];
}
$inheritanceType = $metadata->getInheritanceType();
if ($inheritanceType !== ClassMetadataInfo::INHERITANCE_TYPE_NONE) {
$array['inheritanceType'] = $this->_getInheritanceTypeString($inheritanceType);
}
if ($column = $metadata->getDiscriminatorColumn()) {
$array['discriminatorColumn'] = $column;
}
if ($map = $metadata->discriminatorMap) {
$array['discriminatorMap'] = $map;
}
if ($metadata->changeTrackingPolicy !== ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT) {
$array['changeTrackingPolicy'] = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy);
}
if (isset($metadata->primaryTable['indexes'])) {
$array['indexes'] = $metadata->primaryTable['indexes'];
}
if (isset($metadata->primaryTable['uniqueConstraints'])) {
$array['uniqueConstraints'] = $metadata->primaryTable['uniqueConstraints'];
}
$fieldMappings = $metadata->fieldMappings;
$ids = array();
foreach ($fieldMappings as $name => $fieldMapping) {
if (isset($fieldMapping['length'])) {
$fieldMapping['type'] = $fieldMapping['type'] . '(' . $fieldMapping['length'] . ')';
unset($fieldMapping['length']);
}
$fieldMapping['column'] = $fieldMapping['columnName'];
unset($fieldMapping['columnName'], $fieldMapping['fieldName']);
if ($fieldMapping['column'] == $name) {
unset($fieldMapping['column']);
}
if (isset($fieldMapping['id']) && $fieldMapping['id']) {
$ids[$name] = $fieldMapping;
unset($fieldMappings[$name]);
continue;
}
$fieldMappings[$name] = $fieldMapping;
}
if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) {
$ids[$metadata->getSingleIdentifierFieldName()]['generator']['strategy'] = $this->_getIdGeneratorTypeString($metadata->generatorType);
}
if ($ids) {
$array['fields'] = $ids;
}
if ($fieldMappings) {
if (!isset($array['fields'])) {
$array['fields'] = array();
}
$array['fields'] = array_merge($array['fields'], $fieldMappings);
}
$associations = array();
foreach ($metadata->associationMappings as $name => $associationMapping) {
$associationMappingArray = array('targetEntity' => $associationMapping->targetEntityName, 'cascade' => array('remove' => $associationMapping->isCascadeRemove, 'persist' => $associationMapping->isCascadePersist, 'refresh' => $associationMapping->isCascadeRefresh, 'merge' => $associationMapping->isCascadeMerge, 'detach' => $associationMapping->isCascadeDetach));
if ($associationMapping instanceof OneToOneMapping) {
$joinColumns = $associationMapping->joinColumns;
$newJoinColumns = array();
foreach ($joinColumns as $joinColumn) {
$newJoinColumns[$joinColumn['name']]['referencedColumnName'] = $joinColumn['referencedColumnName'];
}
$oneToOneMappingArray = array('mappedBy' => $associationMapping->mappedByFieldName, 'joinColumns' => $newJoinColumns, 'orphanRemoval' => $associationMapping->orphanRemoval);
$associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray);
$array['oneToOne'][$name] = $associationMappingArray;
} else {
if ($associationMapping instanceof OneToManyMapping) {
$oneToManyMappingArray = array('mappedBy' => $associationMapping->mappedByFieldName, 'orphanRemoval' => $associationMapping->orphanRemoval);
$associationMappingArray = array_merge($associationMappingArray, $oneToManyMappingArray);
$array['oneToMany'][$name] = $associationMappingArray;
} else {
if ($associationMapping instanceof ManyToManyMapping) {
$manyToManyMappingArray = array('mappedBy' => $associationMapping->mappedByFieldName, 'joinTable' => $associationMapping->joinTable);
$associationMappingArray = array_merge($associationMappingArray, $manyToManyMappingArray);
$array['manyToMany'][$name] = $associationMappingArray;
}
}
}
}
return \sfYaml::dump(array($metadata->name => $array), 10);
}