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


PHP EntityTypeInterface::getProvider方法代码示例

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


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

示例1: setUpEntityWithFieldDefinition

 /**
  * Prepares an entity that defines a field definition.
  *
  * @param bool $custom_invoke_all
  *   (optional) Whether the test will set up its own
  *   ModuleHandlerInterface::invokeAll() implementation. Defaults to FALSE.
  * @param string $field_definition_id
  *   (optional) The ID to use for the field definition. Defaults to 'id'.
  * @param array $entity_keys
  *   (optional) An array of entity keys for the mocked entity type. Defaults
  *   to an empty array.
  *
  * @return \Drupal\Core\Field\BaseFieldDefinition|\Prophecy\Prophecy\ProphecyInterface
  *   A field definition object.
  */
 protected function setUpEntityWithFieldDefinition($custom_invoke_all = FALSE, $field_definition_id = 'id', $entity_keys = array())
 {
     $field_type_manager = $this->prophesize(FieldTypePluginManagerInterface::class);
     $field_type_manager->getDefaultStorageSettings('boolean')->willReturn([]);
     $field_type_manager->getDefaultFieldSettings('boolean')->willReturn([]);
     $this->container->get('plugin.manager.field.field_type')->willReturn($field_type_manager->reveal());
     $string_translation = $this->prophesize(TranslationInterface::class);
     $this->container->get('string_translation')->willReturn($string_translation->reveal());
     $entity_class = EntityManagerTestEntity::class;
     $field_definition = $this->prophesize()->willImplement(FieldDefinitionInterface::class)->willImplement(FieldStorageDefinitionInterface::class);
     $entity_class::$baseFieldDefinitions = array($field_definition_id => $field_definition->reveal());
     $entity_class::$bundleFieldDefinitions = array();
     if (!$custom_invoke_all) {
         $this->moduleHandler->getImplementations(Argument::cetera())->willReturn([]);
     }
     // Mock the base field definition override.
     $override_entity_type = $this->prophesize(EntityTypeInterface::class);
     $this->entityType = $this->prophesize(EntityTypeInterface::class);
     $this->setUpEntityManager(array('test_entity_type' => $this->entityType, 'base_field_override' => $override_entity_type));
     $override_entity_type->getClass()->willReturn($entity_class);
     $override_entity_type->getHandlerClass('storage')->willReturn(TestConfigEntityStorage::class);
     $this->entityType->getClass()->willReturn($entity_class);
     $this->entityType->getKeys()->willReturn($entity_keys + ['default_langcode' => 'default_langcode']);
     $this->entityType->isSubclassOf(FieldableEntityInterface::class)->willReturn(TRUE);
     $this->entityType->isTranslatable()->willReturn(FALSE);
     $this->entityType->getProvider()->willReturn('the_provider');
     $this->entityType->id()->willReturn('the_entity_id');
     return $field_definition->reveal();
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:44,代码来源:EntityManagerTest.php

示例2: calculateDependencies

 /**
  * {@inheritdoc}
  */
 public function calculateDependencies()
 {
     if (isset($this->entityType)) {
         return ['module' => [$this->entityType->getProvider()]];
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:9,代码来源:EntityResource.php

示例3: getViewsData

 /**
  * {@inheritdoc}
  */
 public function getViewsData()
 {
     $data = [];
     $base_table = $this->entityType->getBaseTable();
     $base_field = $this->entityType->getKey('id');
     $data_table = $this->entityType->getDataTable();
     $revision_table = $this->entityType->getRevisionTable();
     $revision_data_table = $this->entityType->getRevisionDataTable();
     $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);
         }
     }
     $data[$base_table]['operations'] = array('field' => array('title' => $this->t('Operations links'), 'help' => $this->t('Provides links to perform entity operations.'), 'id' => 'entity_operations'));
     // 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_data_table]['table']['join'][$revision_table] = array('left_field' => $revision_field, 'field' => $revision_field, 'type' => 'INNER');
         }
     }
     // 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());
     if ($table_mapping = $this->storage->getTableMapping()) {
         // 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://drupal.org/node/2337511
         foreach ($table_mapping->getTableNames() as $table) {
             foreach ($table_mapping->getFieldNames($table) as $field_name) {
                 $this->mapFieldDefinition($table, $field_name, $field_definitions[$field_name], $table_mapping, $data[$table]);
             }
         }
     }
     // Add the entity type key to each table generated.
     $entity_type_id = $this->entityType->id();
     array_walk($data, function (&$table_data) use($entity_type_id) {
         $table_data['table']['entity type'] = $entity_type_id;
     });
     return $data;
 }
开发者ID:brstde,项目名称:gap1,代码行数:76,代码来源:EntityViewsData.php

示例4: 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


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