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


PHP EntityManagerInterface::getBaseFieldDefinitions方法代码示例

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


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

示例1: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $type = $this->entity;
     if ($this->operation == 'add') {
         $form['#title'] = $this->t('Add log type');
         $fields = $this->entityManager->getBaseFieldDefinitions('log');
         // Create a node with a fake bundle using the type's UUID so that we can
         // get the default values for workflow settings.
         // @todo Make it possible to get default values without an entity.
         //   https://www.drupal.org/node/2318187
         $node = $this->entityManager->getStorage('log')->create(array('type' => $type->uuid()));
     } else {
         $form['#title'] = $this->t('Edit %label log type', array('%label' => $type->label()));
         $fields = $this->entityManager->getFieldDefinitions('log', $type->id());
         // Create a node to get the current values for workflow settings fields.
         $node = $this->entityManager->getStorage('log')->create(array('type' => $type->id()));
     }
     $form['name'] = array('#title' => t('Name'), '#type' => 'textfield', '#default_value' => $type->label(), '#description' => t('The human-readable name of this log type. This text will be displayed as part of the list on the <em>Add content</em> page. This name must be unique.'), '#required' => TRUE, '#size' => 30);
     $form['type'] = array('#type' => 'machine_name', '#default_value' => $type->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array('exists' => ['Drupal\\node\\Entity\\LogType', 'load'], 'source' => array('name')), '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %log-add page, in which underscores will be converted into hyphens.', array('%log-add' => t('Add content'))));
     $form['description'] = array('#title' => t('Description'), '#type' => 'textarea', '#default_value' => $type->getDescription(), '#description' => t('This text will be displayed on the <em>Add new content</em> page.'));
     $form['additional_settings'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('node/drupal.content_types')));
     $form['submission'] = array('#type' => 'details', '#title' => t('Submission form settings'), '#group' => 'additional_settings', '#open' => TRUE);
     $form['submission']['preview_mode'] = array('#type' => 'radios', '#title' => t('Preview before submitting'), '#default_value' => $type->getPreviewMode(), '#options' => array(DRUPAL_DISABLED => t('Disabled'), DRUPAL_OPTIONAL => t('Optional'), DRUPAL_REQUIRED => t('Required')));
     $form['submission']['help'] = array('#type' => 'textarea', '#title' => t('Explanation or submission guidelines'), '#default_value' => $type->getHelp(), '#description' => t('This text will be displayed at the top of the page when creating or editing content of this type.'));
     $form['workflow'] = array('#type' => 'details', '#title' => t('Publishing options'), '#group' => 'additional_settings');
     $workflow_options = array('status' => $node->status->value, 'promote' => $node->promote->value, 'sticky' => $node->sticky->value, 'revision' => $type->isNewRevision());
     // Prepare workflow options to be used for 'checkboxes' form element.
     $keys = array_keys(array_filter($workflow_options));
     $workflow_options = array_combine($keys, $keys);
     $form['workflow']['options'] = array('#type' => 'checkboxes', '#title' => t('Default options'), '#default_value' => $workflow_options, '#options' => array('status' => t('Published'), 'promote' => t('Promoted to front page'), 'sticky' => t('Sticky at top of lists'), 'revision' => t('Create new revision')), '#description' => t('Users with the <em>Administer content</em> permission will be able to override these options.'));
     $form['display'] = array('#type' => 'details', '#title' => t('Display settings'), '#group' => 'additional_settings');
     $form['display']['display_submitted'] = array('#type' => 'checkbox', '#title' => t('Display author and date information'), '#default_value' => $type->displaySubmitted(), '#description' => t('Author username and publish date will be displayed.'));
     return $this->protectBundleIdElement($form);
 }
开发者ID:eiriksm,项目名称:log,代码行数:38,代码来源:LogTypeForm.php

示例2: getPotentialFields

 protected function getPotentialFields()
 {
     $field_definitions = $this->entityManager->getBaseFieldDefinitions($this->getEntityType());
     $field_definitions = array_filter($field_definitions, [$this, 'filterFieldTypes']);
     $options = [];
     foreach ($field_definitions as $id => $definition) {
         $options[$id] = SafeMarkup::checkPlain($definition->getLabel());
     }
     return $options;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:10,代码来源:EntityReference.php

示例3: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->config('diff.settings');
     $values = $form_state->getValues();
     $support_ticket_base_fields = $this->entityManager->getBaseFieldDefinitions('support_ticket');
     foreach ($support_ticket_base_fields as $field_key => $field) {
         $config->set('entity.support_ticket' . '.' . $field_key, $values[$field_key]);
         $config->save();
     }
     return parent::submitForm($form, $form_state);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:14,代码来源:SupportTicketEntitySettingsForm.php

示例4: tableFields

  /**
   * {@inheritdoc}
   */
  public function tableFields($bundles) {
    $info = $this->entityManager->getDefinition($this->entityTypeId());
    $definitions = $this->entityManager->getBaseFieldDefinitions($this->entityTypeId());
    $label_key = $info->getKey('label');
    $label_field_label = t('Label');
    if ($label_key && isset($definitions[$label_key])) {
      $label_field_label = $definitions[$label_key]->getLabel();
    }
    $bundle_key = $info->getKey('bundle');
    $bundle_field_label = t('Type');
    if ($bundle_key && isset($definitions[$bundle_key])) {
      $bundle_field_label = $definitions[$bundle_key]->getLabel();
    }

    $fields = [];
    $fields['label'] = [
      'type' => 'label',
      'label' => $label_field_label,
      'weight' => 1,
    ];
    if (count($bundles) > 1) {
      $fields[$bundle_key] = [
        'type' => 'field',
        'label' => $bundle_field_label,
        'weight' => 2,
      ];
    }

    return $fields;
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:33,代码来源:EntityInlineEntityFormHandler.php

示例5: getDefinitionFromEntity

 /**
  * Gets the field definition from a specific entity base field.
  *
  * The method takes the field ID as an argument and returns the field storage
  * definition to be used in getIds() by querying the destination entity base
  * field definition.
  *
  * @param string $key
  *   The field ID key.
  *
  * @return array
  *   An associative array with a structure that contains the field type, keyed
  *   as 'type', together with field storage settings as they are returned by
  *   FieldStorageDefinitionInterface::getSettings().
  *
  * @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()
  */
 protected function getDefinitionFromEntity($key)
 {
     $entity_type_id = static::getEntityTypeId($this->getPluginId());
     /** @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] $definitions */
     $definitions = $this->entityManager->getBaseFieldDefinitions($entity_type_id);
     $field_definition = $definitions[$key];
     return ['type' => $field_definition->getType()] + $field_definition->getSettings();
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:25,代码来源:EntityContentBase.php

示例6: parseEntity

 /**
  * Transforms an entity into an array of strings.
  *
  * Parses an entity's fields and for every field it builds an array of string
  * to be compared. Basically this function transforms an entity into an array
  * of strings.
  *
  * @param ContentEntityInterface $entity
  *   An entity containing fields.
  *
  * @return array
  *   Array of strings resulted by parsing the entity.
  */
 public function parseEntity(ContentEntityInterface $entity)
 {
     $result = array();
     $langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();
     // Load entity of current language, otherwise fields are always compared by
     // their default language.
     if ($entity->hasTranslation($langcode)) {
         $entity = $entity->getTranslation($langcode);
     }
     $entity_type_id = $entity->getEntityTypeId();
     // Load all entity base fields.
     $entity_base_fields = $this->entityManager->getBaseFieldDefinitions($entity_type_id);
     // Loop through entity fields and transform every FieldItemList object
     // into an array of strings according to field type specific settings.
     foreach ($entity as $field_items) {
         $field_type = $field_items->getFieldDefinition()->getType();
         $plugin_config = $this->pluginsConfig->get('field_types.' . $field_type);
         $plugin = NULL;
         if ($plugin_config && $plugin_config['type'] != 'hidden') {
             $plugin = $this->diffBuilderManager->createInstance($plugin_config['type'], $plugin_config['settings']);
         }
         if ($plugin) {
             // Configurable field. It is the responsibility of the class extending
             // this class to hide some configurable fields from comparison. This
             // class compares all configurable fields.
             if (!array_key_exists($field_items->getName(), $entity_base_fields)) {
                 $build = $plugin->build($field_items);
                 if (!empty($build)) {
                     $result[$field_items->getName()] = $build;
                 }
             } else {
                 // Check if this field needs to be compared.
                 $config_key = 'entity.' . $entity_type_id . '.' . $field_items->getName();
                 $enabled = $this->config->get($config_key);
                 if ($enabled) {
                     $build = $plugin->build($field_items);
                     if (!empty($build)) {
                         $result[$field_items->getName()] = $build;
                     }
                 }
             }
         }
     }
     return $result;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:58,代码来源:DiffEntityParser.php

示例7: testUntranslatable

 /**
  * Test that translation destination fails for untranslatable entities.
  *
  * @expectedException \Drupal\migrate\MigrateException
  * @expectedExceptionMessage This entity type does not support translation
  */
 public function testUntranslatable()
 {
     // An entity type without a language.
     $entity_type = $this->prophesize(ContentEntityType::class);
     $entity_type->getKey('langcode')->willReturn('');
     $entity_type->getKey('id')->willReturn('id');
     $this->entityManager->getBaseFieldDefinitions('foo')->willReturn(['id' => BaseFieldDefinitionTest::create('integer')]);
     $this->storage->getEntityType()->willReturn($entity_type->reveal());
     $destination = new EntityTestDestination(['translations' => TRUE], '', [], $this->migration->reveal(), $this->storage->reveal(), [], $this->entityManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal());
     $destination->getIds();
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:17,代码来源:EntityContentBaseTest.php

示例8: cleanIds

 /**
  * Ensures integer entity IDs are valid.
  *
  * The identifier sanitization provided by this method has been introduced
  * as Drupal used to rely on the database to facilitate this, which worked
  * correctly with MySQL but led to errors with other DBMS such as PostgreSQL.
  *
  * @param array $ids
  *   The entity IDs to verify.
  *
  * @return array
  *   The sanitized list of entity IDs.
  */
 protected function cleanIds(array $ids)
 {
     $definitions = $this->entityManager->getBaseFieldDefinitions($this->entityTypeId);
     $id_definition = $definitions[$this->entityType->getKey('id')];
     if ($id_definition->getType() == 'integer') {
         $ids = array_filter($ids, function ($id) {
             return is_numeric($id) && $id == (int) $id;
         });
         $ids = array_map('intval', $ids);
     }
     return $ids;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:25,代码来源:ContentEntityStorageBase.php

示例9: denormalize

 /**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = NULL, array $context = [])
 {
     // Get the entity type ID while letting context override the $class param.
     $entity_type_id = !empty($context['entity_type']) ? $context['entity_type'] : $this->entityManager->getEntityTypeFromClass($class);
     /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type_definition */
     // Get the entity type definition.
     $entity_type_definition = $this->entityManager->getDefinition($entity_type_id, FALSE);
     // Don't try to create an entity without an entity type id.
     if (!$entity_type_definition) {
         throw new UnexpectedValueException(sprintf('The specified entity type "%s" does not exist. A valid etnity type is required for denormalization', $entity_type_id));
     }
     // The bundle property will be required to denormalize a bundleable entity.
     if ($entity_type_definition->hasKey('bundle')) {
         $bundle_key = $entity_type_definition->getKey('bundle');
         // Get the base field definitions for this entity type.
         $base_field_definitions = $this->entityManager->getBaseFieldDefinitions($entity_type_id);
         // Get the ID key from the base field definition for the bundle key or
         // default to 'value'.
         $key_id = isset($base_field_definitions[$bundle_key]) ? $base_field_definitions[$bundle_key]->getFieldStorageDefinition()->getMainPropertyName() : 'value';
         // Normalize the bundle if it is not explicitly set.
         $data[$bundle_key] = isset($data[$bundle_key][0][$key_id]) ? $data[$bundle_key][0][$key_id] : (isset($data[$bundle_key]) ? $data[$bundle_key] : NULL);
         // Get the bundle entity type from the entity type definition.
         $bundle_type_id = $entity_type_definition->getBundleEntityType();
         $bundle_types = $bundle_type_id ? $this->entityManager->getStorage($bundle_type_id)->getQuery()->execute() : [];
         // Make sure a bundle has been provided.
         if (!is_string($data[$bundle_key])) {
             throw new UnexpectedValueException('A string must be provided as a bundle value.');
         }
         // Make sure the submitted bundle is a valid bundle for the entity type.
         if ($bundle_types && !in_array($data[$bundle_key], $bundle_types)) {
             throw new UnexpectedValueException(sprintf('"%s" is not a valid bundle type for denormalization.', $data[$bundle_key]));
         }
     }
     // Create the entity from data.
     $entity = $this->entityManager->getStorage($entity_type_id)->create($data);
     // Pass the names of the fields whose values can be merged.
     // @todo https://www.drupal.org/node/2456257 remove this.
     $entity->_restSubmittedFields = array_keys($data);
     return $entity;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:43,代码来源:EntityNormalizer.php

示例10: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $type = $this->entity;
     if ($this->operation == 'add') {
         $form['#title'] = SafeMarkup::checkPlain($this->t('Add support ticket type'));
         $fields = $this->entityManager->getBaseFieldDefinitions('support_ticket');
         // Create a support ticket with a fake bundle using the type's UUID so that we can
         // get the default values for workflow settings.
         $support_ticket = $this->entityManager->getStorage('support_ticket')->create(array('support_ticket_type' => $type->uuid()));
     } else {
         $form['#title'] = $this->t('Edit %label support ticket type', array('%label' => $type->label()));
         $fields = $this->entityManager->getFieldDefinitions('support_ticket', $type->id());
         // Create a support_ticket to get the current values for workflow settings fields.
         $support_ticket = $this->entityManager->getStorage('support_ticket')->create(array('support_ticket_type' => $type->id()));
     }
     $form['name'] = array('#title' => t('Name'), '#type' => 'textfield', '#default_value' => $type->label(), '#description' => t('The human-readable name of this support ticket type. This text will be displayed as part of the list on the <em>Add support ticket</em> page. This name must be unique.'), '#required' => TRUE, '#size' => 30);
     $form['type'] = array('#type' => 'machine_name', '#default_value' => $type->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => $type->isLocked(), '#machine_name' => array('exists' => ['Drupal\\support_ticket\\Entity\\SupportTicketType', 'load'], 'source' => array('name')), '#description' => t('A unique machine-readable name for this support ticket type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %support-ticket-add page, in which underscores will be converted into hyphens.', array('%support-ticket-add' => t('Add support ticket'))));
     $form['description'] = array('#title' => t('Description'), '#type' => 'textarea', '#default_value' => $type->getDescription(), '#description' => t('Describe this support ticket type. The text will be displayed on the <em>Add support ticket</em> page.'));
     $form['additional_settings'] = array('#type' => 'vertical_tabs', '#attached' => array('library' => array('support_ticket/drupal.support_ticket_types')));
     $form['submission'] = array('#type' => 'details', '#title' => t('Submission form settings'), '#group' => 'additional_settings', '#open' => TRUE);
     $form['submission']['title_label'] = array('#title' => t('Title field label'), '#type' => 'textfield', '#default_value' => $fields['title']->getLabel(), '#required' => TRUE);
     $form['submission']['preview_mode'] = array('#type' => 'radios', '#title' => t('Preview before submitting'), '#default_value' => $type->getPreviewMode(), '#options' => array(DRUPAL_DISABLED => t('Disabled'), DRUPAL_OPTIONAL => t('Optional'), DRUPAL_REQUIRED => t('Required')));
     $form['submission']['help'] = array('#type' => 'textarea', '#title' => t('Explanation or submission guidelines'), '#default_value' => $type->getHelp(), '#description' => t('This text will be displayed at the top of the page when creating or editing support tickets of this type.'));
     $form['workflow'] = array('#type' => 'details', '#title' => t('Publishing options'), '#group' => 'additional_settings');
     $workflow_options = array('status' => $support_ticket->status->value, 'locked' => $support_ticket->locked->value, 'revision' => $type->isNewRevision());
     // Prepare workflow options to be used for 'checkboxes' form element.
     $keys = array_keys(array_filter($workflow_options));
     $workflow_options = array_combine($keys, $keys);
     $form['workflow']['options'] = array('#type' => 'checkboxes', '#title' => t('Default options'), '#default_value' => $workflow_options, '#options' => array('status' => t('Published'), 'locked' => t('Locked'), 'revision' => t('Create new revision')), '#description' => t('Users with the <em>Administer support tickets</em> permission will be able to override these options.'));
     if ($this->moduleHandler->moduleExists('language')) {
         $form['language'] = array('#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings');
         $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('support_ticket', $type->id());
         $form['language']['language_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'support_ticket', 'bundle' => $type->id()), '#default_value' => $language_configuration);
     }
     $form['display'] = array('#type' => 'details', '#title' => t('Display settings'), '#group' => 'additional_settings');
     $form['display']['display_submitted'] = array('#type' => 'checkbox', '#title' => t('Display author and date information'), '#default_value' => $type->displaySubmitted(), '#description' => t('Author username and publish date will be displayed.'));
     return $form;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:42,代码来源:SupportTicketTypeForm.php

示例11: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Only allow content entities and ignore configuration entities.
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         $this->derivatives["entity:{$entity_type_id}"] = ['label' => $this->t('Create a new @entity_type', ['@entity_type' => $entity_type->getLowercaseLabel()]), 'category' => $entity_type->getLabel(), 'entity_type_id' => $entity_type_id, 'context' => [], 'provides' => ['entity' => new ContextDefinition("entity:{$entity_type_id}", $entity_type->getLabel())]] + $base_plugin_definition;
         // Add a required context for the bundle key, and optional contexts for
         // other required base fields. This matches the storage create() behavior,
         // where only the bundle requirement is enforced.
         $bundle_key = $entity_type->getKey('bundle');
         $base_field_definitions = $this->entityManager->getBaseFieldDefinitions($entity_type_id);
         foreach ($base_field_definitions as $field_name => $definition) {
             if ($field_name != $bundle_key && !$definition->isRequired()) {
                 continue;
             }
             $required = $field_name == $bundle_key;
             $multiple = $definition->getCardinality() === 1 ? FALSE : TRUE;
             $this->derivatives["entity:{$entity_type_id}"]['context'][$field_name] = new ContextDefinition($definition->getType(), $definition->getLabel(), $required, $multiple, $definition->getDescription());
         }
     }
     return $this->derivatives;
 }
开发者ID:shahinam,项目名称:drupal8devel,代码行数:27,代码来源:EntityCreateDeriver.php

示例12: getFieldStorageDefinitions

 /**
  * Gets the base field definitions for a content entity type.
  *
  * @return \Drupal\Core\Field\FieldDefinitionInterface[]
  *   The array of base field definitions for the entity type, keyed by field
  *   name.
  */
 public function getFieldStorageDefinitions()
 {
     return $this->entityManager->getBaseFieldDefinitions($this->entityTypeId);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:11,代码来源:ContentEntityDatabaseStorage.php

示例13: getViewsData

 /**
  * {@inheritdoc}
  */
 public function getViewsData()
 {
     $data = [];
     $base_table = $this->entityType->getBaseTable() ?: $this->entityType->id();
     $views_revision_base_table = NULL;
     $revisionable = $this->entityType->isRevisionable();
     $base_field = $this->entityType->getKey('id');
     $revision_table = '';
     if ($revisionable) {
         $revision_table = $this->entityType->getRevisionTable() ?: $this->entityType->id() . '_revision';
     }
     $translatable = $this->entityType->isTranslatable();
     $data_table = '';
     if ($translatable) {
         $data_table = $this->entityType->getDataTable() ?: $this->entityType->id() . '_field_data';
     }
     // Some entity types do not have a revision data table defined, but still
     // have a revision table name set in
     // \Drupal\Core\Entity\Sql\SqlContentEntityStorage::initTableLayout() so we
     // apply the same kind of logic.
     $revision_data_table = '';
     if ($revisionable && $translatable) {
         $revision_data_table = $this->entityType->getRevisionDataTable() ?: $this->entityType->id() . '_field_revision';
     }
     $revision_field = $this->entityType->getKey('revision');
     // Setup base information of the views data.
     $data[$base_table]['table']['group'] = $this->entityType->getLabel();
     $data[$base_table]['table']['provider'] = $this->entityType->getProvider();
     $views_base_table = $base_table;
     if ($data_table) {
         $views_base_table = $data_table;
     }
     $data[$views_base_table]['table']['base'] = ['field' => $base_field, 'title' => $this->entityType->getLabel(), 'cache_contexts' => $this->entityType->getListCacheContexts()];
     $data[$base_table]['table']['entity revision'] = FALSE;
     if ($label_key = $this->entityType->getKey('label')) {
         if ($data_table) {
             $data[$views_base_table]['table']['base']['defaults'] = array('field' => $label_key, 'table' => $data_table);
         } else {
             $data[$views_base_table]['table']['base']['defaults'] = array('field' => $label_key);
         }
     }
     // Entity types must implement a list_builder in order to use Views'
     // entity operations field.
     if ($this->entityType->hasListBuilderClass()) {
         $data[$base_table]['operations'] = array('field' => array('title' => $this->t('Operations links'), 'help' => $this->t('Provides links to perform entity operations.'), 'id' => 'entity_operations'));
     }
     if ($this->entityType->hasViewBuilderClass()) {
         $data[$base_table]['rendered_entity'] = ['field' => ['title' => $this->t('Rendered entity'), 'help' => $this->t('Renders an entity in a view mode.'), 'id' => 'rendered_entity']];
     }
     // Setup relations to the revisions/property data.
     if ($data_table) {
         $data[$base_table]['table']['join'][$data_table] = ['left_field' => $base_field, 'field' => $base_field, 'type' => 'INNER'];
         $data[$data_table]['table']['group'] = $this->entityType->getLabel();
         $data[$data_table]['table']['provider'] = $this->entityType->getProvider();
         $data[$data_table]['table']['entity revision'] = FALSE;
     }
     if ($revision_table) {
         $data[$revision_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]);
         $data[$revision_table]['table']['provider'] = $this->entityType->getProvider();
         $views_revision_base_table = $revision_table;
         if ($revision_data_table) {
             $views_revision_base_table = $revision_data_table;
         }
         $data[$views_revision_base_table]['table']['entity revision'] = TRUE;
         $data[$views_revision_base_table]['table']['base'] = array('field' => $revision_field, 'title' => $this->t('@entity_type revisions', array('@entity_type' => $this->entityType->getLabel())));
         // Join the revision table to the base table.
         $data[$views_revision_base_table]['table']['join'][$views_base_table] = array('left_field' => $revision_field, 'field' => $revision_field, 'type' => 'INNER');
         if ($revision_data_table) {
             $data[$revision_data_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]);
             $data[$revision_data_table]['table']['entity revision'] = TRUE;
             $data[$revision_table]['table']['join'][$revision_data_table] = array('left_field' => $revision_field, 'field' => $revision_field, 'type' => 'INNER');
         }
     }
     $this->addEntityLinks($data[$base_table]);
     // Load all typed data definitions of all fields. This should cover each of
     // the entity base, revision, data tables.
     $field_definitions = $this->entityManager->getBaseFieldDefinitions($this->entityType->id());
     /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
     if ($table_mapping = $this->storage->getTableMapping($field_definitions)) {
         // Fetch all fields that can appear in both the base table and the data
         // table.
         $entity_keys = $this->entityType->getKeys();
         $duplicate_fields = array_intersect_key($entity_keys, array_flip(['id', 'revision', 'bundle']));
         // Iterate over each table we have so far and collect field data for each.
         // Based on whether the field is in the field_definitions provided by the
         // entity manager.
         // @todo We should better just rely on information coming from the entity
         //   storage.
         // @todo https://www.drupal.org/node/2337511
         foreach ($table_mapping->getTableNames() as $table) {
             foreach ($table_mapping->getFieldNames($table) as $field_name) {
                 // To avoid confusing duplication in the user interface, for fields
                 // that are on both base and data tables, only add them on the data
                 // table (same for revision vs. revision data).
                 if ($data_table && ($table === $base_table || $table === $revision_table) && in_array($field_name, $duplicate_fields)) {
                     continue;
                 }
//.........这里部分代码省略.........
开发者ID:eigentor,项目名称:tommiblog,代码行数:101,代码来源:EntityViewsData.php

示例14: getBaseFieldDefinitions

 /**
  * {@inheritdoc}
  */
 public function getBaseFieldDefinitions($entity_type_id)
 {
     return $this->entityManager->getBaseFieldDefinitions($entity_type_id);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:7,代码来源:EntityManagerWrapper.php


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