本文整理汇总了PHP中Drupal\field\Entity\FieldStorageConfig::getReservedColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldStorageConfig::getReservedColumns方法的具体用法?PHP FieldStorageConfig::getReservedColumns怎么用?PHP FieldStorageConfig::getReservedColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\field\Entity\FieldStorageConfig
的用法示例。
在下文中一共展示了FieldStorageConfig::getReservedColumns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _fieldColumnName
/**
* Generates a column name for a field data table.
*
* @private Calling this function circumvents the entity system and is
* strongly discouraged. This function is not considered part of the public
* API and modules relying on it might break even in minor releases. Only
* call this function to write a query that \Drupal::entityQuery() does not
* support. Always call entity_load() before using the data found in the
* table.
*
* @param \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition
* The field storage definition.
* @param string $column
* The name of the column.
*
* @return string
* A string containing a generated column name for a field data table that is
* unique among all other fields.
*/
public static function _fieldColumnName(FieldStorageDefinitionInterface $storage_definition, $column)
{
return in_array($column, FieldStorageConfig::getReservedColumns()) ? $column : $storage_definition->getName() . '_' . $column;
}
示例2: addField
/**
* {@inheritdoc}
*/
public function addField($field, $type, $langcode)
{
$entity_type_id = $this->sqlQuery->getMetaData('entity_type');
$age = $this->sqlQuery->getMetaData('age');
// This variable ensures grouping works correctly. For example:
// ->condition('tags', 2, '>')
// ->condition('tags', 20, '<')
// ->condition('node_reference.nid.entity.tags', 2)
// The first two should use the same table but the last one needs to be a
// new table. So for the first two, the table array index will be 'tags'
// while the third will be 'node_reference.nid.tags'.
$index_prefix = '';
$specifiers = explode('.', $field);
$base_table = 'base_table';
$count = count($specifiers) - 1;
// This will contain the definitions of the last specifier seen by the
// system.
$propertyDefinitions = array();
$entity_type = $this->entityManager->getDefinition($entity_type_id);
$field_storage_definitions = array();
// @todo Needed for menu links, make this implementation content entity
// specific after https://drupal.org/node/2256521.
if ($entity_type instanceof ContentEntityTypeInterface) {
$field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id);
}
for ($key = 0; $key <= $count; $key++) {
// If there is revision support and only the current revision is being
// queried then use the revision id. Otherwise, the entity id will do.
if (($revision_key = $entity_type->getKey('revision')) && $age == EntityStorageInterface::FIELD_LOAD_CURRENT) {
// This contains the relevant SQL field to be used when joining entity
// tables.
$entity_id_field = $revision_key;
// This contains the relevant SQL field to be used when joining field
// tables.
$field_id_field = 'revision_id';
} else {
$entity_id_field = $entity_type->getKey('id');
$field_id_field = 'entity_id';
}
// This can either be the name of an entity base field or a configurable
// field.
$specifier = $specifiers[$key];
if (isset($field_storage_definitions[$specifier])) {
$field_storage = $field_storage_definitions[$specifier];
} else {
$field_storage = FALSE;
}
// If we managed to retrieve a configurable field, process it.
if ($field_storage instanceof FieldStorageConfigInterface) {
// Find the field column.
$column = $field_storage->getMainPropertyName();
if ($key < $count) {
$next = $specifiers[$key + 1];
// Is this a field column?
$columns = $field_storage->getColumns();
if (isset($columns[$next]) || in_array($next, FieldStorageConfig::getReservedColumns())) {
// Use it.
$column = $next;
// Do not process it again.
$key++;
}
// If there are more specifiers, the next one must be a
// relationship. Either the field name followed by a relationship
// specifier, for example $node->field_image->entity. Or a field
// column followed by a relationship specifier, for example
// $node->field_image->fid->entity. In both cases, prepare the
// property definitions for the relationship. In the first case,
// also use the property definitions for column.
if ($key < $count) {
$relationship_specifier = $specifiers[$key + 1];
$propertyDefinitions = $field_storage->getPropertyDefinitions();
// Prepare the next index prefix.
$next_index_prefix = "{$relationship_specifier}.{$column}";
}
}
$table = $this->ensureFieldTable($index_prefix, $field_storage, $type, $langcode, $base_table, $entity_id_field, $field_id_field);
$sql_column = ContentEntityDatabaseStorage::_fieldColumnName($field_storage, $column);
} else {
// ensureEntityTable() decides whether an entity property will be
// queried from the data table or the base table based on where it
// finds the property first. The data table is preferred, which is why
// it gets added before the base table.
$entity_tables = array();
if ($data_table = $entity_type->getDataTable()) {
$this->sqlQuery->addMetaData('simple_query', FALSE);
$entity_tables[$data_table] = $this->getTableMapping($data_table, $entity_type_id);
}
$entity_base_table = $entity_type->getBaseTable();
$entity_tables[$entity_base_table] = $this->getTableMapping($entity_base_table, $entity_type_id);
$sql_column = $specifier;
$table = $this->ensureEntityTable($index_prefix, $specifier, $type, $langcode, $base_table, $entity_id_field, $entity_tables);
}
// If there are more specifiers to come, it's a relationship.
if ($field_storage && $key < $count) {
// Computed fields have prepared their property definition already, do
// it for properties as well.
if (!$propertyDefinitions) {
//.........这里部分代码省略.........