当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldDefinitionInterface::getTargetBundle方法代码示例

本文整理汇总了PHP中Drupal\Core\Field\FieldDefinitionInterface::getTargetBundle方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldDefinitionInterface::getTargetBundle方法的具体用法?PHP FieldDefinitionInterface::getTargetBundle怎么用?PHP FieldDefinitionInterface::getTargetBundle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Field\FieldDefinitionInterface的用法示例。


在下文中一共展示了FieldDefinitionInterface::getTargetBundle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isApplicable

 /**
  * {@inheritdoc}
  */
 public static function isApplicable(FieldDefinitionInterface $field_definition)
 {
     if (empty($field_definition->getTargetBundle()) && $field_definition->isList()) {
         return TRUE;
     } else {
         $entity_form_display = entity_get_form_display($field_definition->getTargetEntityTypeId(), $field_definition->getTargetBundle(), 'default');
         $widget = $entity_form_display->getRenderer($field_definition->getName());
         $widget_id = $widget->getBaseId();
         if ($field_definition->isList() && $widget_id == 'video_upload') {
             return TRUE;
         }
     }
     return FALSE;
 }
开发者ID:badelas,项目名称:afroweb,代码行数:17,代码来源:VideoPlayerListFormatter.php

示例2: createPayment

 /**
  * {@inheritdoc}
  */
 public function createPayment(FieldDefinitionInterface $field_definition)
 {
     /** @var \Drupal\payment\Entity\PaymentInterface $payment */
     $payment = $this->entityManager->getStorage('payment')->create(['bundle' => 'payment_reference']);
     /** @var \Drupal\payment_reference\Plugin\Payment\Type\PaymentReference $payment_type */
     $payment_type = $payment->getPaymentType();
     $payment_type->setEntityTypeId($field_definition->getFieldStorageDefinition()->getTargetEntityTypeId());
     $payment_type->setBundle($field_definition->getTargetBundle());
     $payment_type->setFieldName($field_definition->getName());
     $payment->setCurrencyCode($field_definition->getSetting('currency_code'));
     foreach ($field_definition->getSetting('line_items_data') as $line_item_data) {
         $line_item = $this->paymentLineItemManager->createInstance($line_item_data['plugin_id'], $line_item_data['plugin_configuration']);
         $payment->setLineItem($line_item);
     }
     return $payment;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:19,代码来源:PaymentFactory.php

示例3: 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_mapping = $this->getTableMapping();
     $table_name = $table_mapping->getDedicatedDataTableName($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($table_mapping->getFieldColumnName($storage_definition, $column_name));
     }
     $entity_query->distinct(TRUE)->fields('t', array('entity_id'))->condition('bundle', $field_definition->getTargetBundle())->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[$table_mapping->getFieldColumnName($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://www.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) {
         $entity_adapter = $entities[$revision_id]->getTypedData();
         $items_by_entity[$revision_id] = \Drupal::typedDataManager()->create($field_definition, $values, $field_definition->getName(), $entity_adapter);
     }
     return $items_by_entity;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:49,代码来源:SqlContentEntityStorage.php

示例4: onFieldDefinitionDelete

 /**
  * {@inheritdoc}
  */
 public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition)
 {
     $entity_type_id = $field_definition->getTargetEntityTypeId();
     $bundle = $field_definition->getTargetBundle();
     $field_name = $field_definition->getName();
     // Notify the storage about the field deletion.
     $this->getStorage($entity_type_id)->onFieldDefinitionDelete($field_definition);
     // Unset the bundle from the bundle field map key value collection.
     $bundle_field_map = $this->keyValueFactory->get('entity.definitions.bundle_field_map')->get($entity_type_id);
     unset($bundle_field_map[$field_name]['bundles'][$bundle]);
     if (empty($bundle_field_map[$field_name]['bundles'])) {
         // If there are no bundles left, remove the field from the map.
         unset($bundle_field_map[$field_name]);
     }
     $this->keyValueFactory->get('entity.definitions.bundle_field_map')->set($entity_type_id, $bundle_field_map);
     // Delete the cache entry.
     $this->cacheBackend->delete('entity_field_map');
     // If the field map is initialized, update it as well, so that calls to it
     // do not have to rebuild it again.
     if ($this->fieldMap) {
         unset($this->fieldMap[$entity_type_id][$field_name]['bundles'][$bundle]);
         if (empty($this->fieldMap[$entity_type_id][$field_name]['bundles'])) {
             unset($this->fieldMap[$entity_type_id][$field_name]);
         }
     }
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:29,代码来源:EntityManager.php


注:本文中的Drupal\Core\Field\FieldDefinitionInterface::getTargetBundle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。