本文整理汇总了PHP中Drupal\Core\Field\FieldDefinitionInterface::getBundle方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldDefinitionInterface::getBundle方法的具体用法?PHP FieldDefinitionInterface::getBundle怎么用?PHP FieldDefinitionInterface::getBundle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Field\FieldDefinitionInterface
的用法示例。
在下文中一共展示了FieldDefinitionInterface::getBundle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readFieldItemsToPurge
/**
* {@inheritdoc}
*/
protected function readFieldItemsToPurge(FieldDefinitionInterface $field_definition, $batch_size)
{
// Check whether the whole field storage definition is gone, or just some
// bundle fields.
$storage_definition = $field_definition->getFieldStorageDefinition();
$is_deleted = $this->storageDefinitionIsDeleted($storage_definition);
$table_name = static::_fieldTableName($storage_definition, $is_deleted);
// Get the entities which we want to purge first.
$entity_query = $this->database->select($table_name, 't', array('fetch' => \PDO::FETCH_ASSOC));
$or = $entity_query->orConditionGroup();
foreach ($storage_definition->getColumns() as $column_name => $data) {
$or->isNotNull(static::_fieldColumnName($storage_definition, $column_name));
}
$entity_query->distinct(TRUE)->fields('t', array('entity_id'))->condition('bundle', $field_definition->getBundle())->range(0, $batch_size);
// Create a map of field data table column names to field column names.
$column_map = array();
foreach ($storage_definition->getColumns() as $column_name => $data) {
$column_map[static::_fieldColumnName($storage_definition, $column_name)] = $column_name;
}
$entities = array();
$items_by_entity = array();
foreach ($entity_query->execute() as $row) {
$item_query = $this->database->select($table_name, 't', array('fetch' => \PDO::FETCH_ASSOC))->fields('t')->condition('entity_id', $row['entity_id'])->orderBy('delta');
foreach ($item_query->execute() as $item_row) {
if (!isset($entities[$item_row['revision_id']])) {
// Create entity with the right revision id and entity id combination.
$item_row['entity_type'] = $this->entityTypeId;
// @todo: Replace this by an entity object created via an entity
// factory, see https://drupal.org/node/1867228.
$entities[$item_row['revision_id']] = _field_create_entity_from_ids((object) $item_row);
}
$item = array();
foreach ($column_map as $db_column => $field_column) {
$item[$field_column] = $item_row[$db_column];
}
$items_by_entity[$item_row['revision_id']][] = $item;
}
}
// Create field item objects and return.
foreach ($items_by_entity as $revision_id => $values) {
$items_by_entity[$revision_id] = \Drupal::typedDataManager()->create($field_definition, $values, $field_definition->getName(), $entities[$revision_id]);
}
return $items_by_entity;
}