function file_field_find_file_reference_column
Same name in other branches
- 9 core/modules/file/file.field.inc \file_field_find_file_reference_column()
- 10 core/modules/file/file.module \file_field_find_file_reference_column()
- 11.x core/modules/file/file.module \file_field_find_file_reference_column()
Determine whether a field references files stored in {file_managed}.
Parameters
\Drupal\Core\Field\FieldDefinitionInterface $field: A field definition.
Return value
bool The field column if the field references {file_managed}.fid, typically fid, FALSE if it does not.
1 call to file_field_find_file_reference_column()
- file_get_file_references in core/
modules/ file/ file.module - Retrieves a list of references to a file.
File
-
core/
modules/ file/ file.field.inc, line 197
Code
function file_field_find_file_reference_column(FieldDefinitionInterface $field) {
$schema = $field->getFieldStorageDefinition()
->getSchema();
foreach ($schema['foreign keys'] as $data) {
if ($data['table'] == 'file_managed') {
foreach ($data['columns'] as $field_column => $column) {
if ($column == 'fid') {
return $field_column;
}
}
}
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.