本文整理匯總了PHP中Doctrine\ORM\Mapping\ClassMetadataInfo::isIdentifierNatural方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMetadataInfo::isIdentifierNatural方法的具體用法?PHP ClassMetadataInfo::isIdentifierNatural怎麽用?PHP ClassMetadataInfo::isIdentifierNatural使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\Mapping\ClassMetadataInfo
的用法示例。
在下文中一共展示了ClassMetadataInfo::isIdentifierNatural方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getFieldsFromMetadata
/**
* Returns an array of fields. Fields can be both column fields and
* association fields.
*
* @param ClassMetadataInfo $metadata
* @return array $fields
*/
private function getFieldsFromMetadata(ClassMetadataInfo $metadata)
{
$fields = (array) $metadata->fieldMappings;
// Remove the primary key field if it's not managed manually
if (!$metadata->isIdentifierNatural()) {
foreach ($metadata->identifier as $id) {
if (array_key_exists($id, $fields)) {
unset($fields[$id]);
}
}
}
return $fields;
}
示例2: getFieldsFromMetadata
/**
* Returns an array of fields. Fields can be both column fields and
* association fields.
*
* @param ClassMetadataInfo $metadata
* @return array $fields
*/
private function getFieldsFromMetadata(ClassMetadataInfo $metadata)
{
$fields = (array) $metadata->fieldNames;
// Remove the primary key field if it's not managed manually
if (!$metadata->isIdentifierNatural()) {
$fields = array_diff($fields, $metadata->identifier);
}
foreach ($metadata->associationMappings as $fieldName => $relation) {
if ($relation['type'] !== ClassMetadataInfo::ONE_TO_MANY) {
$fields[] = $fieldName;
}
}
return $fields;
}
示例3: getFieldsFromMetadata
/**
* Returns an array of fields. Fields can be both column fields and
* association fields.
*
* @param ClassMetadataInfo $metadata
*
* @return array $fields
*/
private function getFieldsFromMetadata(ClassMetadataInfo $metadata)
{
$fields = (array) $metadata->fieldNames;
if (!$metadata->isIdentifierNatural()) {
$fields = array_diff($fields, $metadata->identifier);
}
$fieldsMapping = array();
foreach ($fields as $field) {
$fieldsMapping[$field] = $metadata->getTypeOfField($field);
}
foreach ($metadata->associationMappings as $fieldName => $relation) {
if ($relation['type'] !== ClassMetadataInfo::ONE_TO_MANY) {
$fieldsMapping[$fieldName] = 'relation';
}
}
return $fieldsMapping;
}
示例4: getFieldsFromMetadata
/**
* Returns an array of fields. Fields can be both column fields and
* association fields.
*
* @param ClassMetadataInfo $metadata
*
* @return array $fields
*/
private function getFieldsFromMetadata(ClassMetadataInfo $metadata)
{
$fields = $this->tplOptions['fields'];
foreach ($fields as $field => $null) {
if (in_array($field, $this->ignoreFeilds)) {
unset($fields[$field]);
}
}
foreach ($fields as &$field) {
if (in_array($field['type'], ['date', 'datetime', 'dateinterval', 'string_array', 'integer_array'])) {
$field['formType'] = $field['type'];
}
}
if (!$metadata->isIdentifierNatural()) {
foreach ($metadata->identifier as $id) {
unset($fields[$id]);
}
}
foreach ($metadata->associationMappings as $fieldName => $relation) {
if ($relation['type'] !== ClassMetadataInfo::ONE_TO_MANY) {
$label = preg_replace('/([A-Z])/', ' \\1', $fieldName);
$label = trim($label);
$label = strtolower($label);
$label = ucfirst($label);
$fields[$fieldName] = ['fieldName' => $fieldName, 'type' => $relation['targetEntity'], 'columnName' => $fieldName, 'length' => null, 'nullable' => '', 'label' => $label, 'columnNameSize' => strlen($fieldName), 'formType' => 'objectChoice'];
}
}
foreach ($fields as &$field) {
$entityBundle = '\\' . $this->tplOptions['entity_bundle_ns'];
$type = $field['type'];
if (strpos($type, 'Entity', 0)) {
$type = '\\' . $type;
}
if (strpos($type, $entityBundle, 0) === 0) {
$type = str_replace($entityBundle . '\\', '', $type);
$type = '@var ' . $type;
}
$field['formTypeHint'] = "/* {$type} */";
}
return $fields;
}
示例5: getFieldsFromMetadata
/**
* Returns an array of fields. Fields can be both column fields and
* association fields.
*
* @param ClassMetadataInfo $metadata
* @return array $fields
*/
protected function getFieldsFromMetadata(ClassMetadataInfo $metadata)
{
$fields = array_merge($metadata->fieldMappings, $metadata->associationMappings);
// Remove the primary key field if it's not managed manually
if (!$metadata->isIdentifierNatural()) {
foreach ($metadata->identifier as $identifier) {
unset($fields[$identifier]);
}
}
foreach ($metadata->associationMappings as $fieldName => $relation) {
$multiTypes = array(ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY);
if (in_array($relation['type'], $multiTypes)) {
$fields[$fieldName]['relatedType'] = 'many';
} else {
$fields[$fieldName]['relatedType'] = 'single';
}
$fields[$fieldName]['relatedEntityShortcut'] = $this->getEntityBundleShortcut($fields[$fieldName]['targetEntity']);
}
return $fields;
}