當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FieldDefinitionInterface::getBundle方法代碼示例

本文整理匯總了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;
 }
開發者ID:alnutile,項目名稱:drunatra,代碼行數:47,代碼來源:ContentEntityDatabaseStorage.php


注:本文中的Drupal\Core\Field\FieldDefinitionInterface::getBundle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。