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


PHP EntityTypeInterface::isSubclassOf方法代码示例

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


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

 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $tokens = ['@entity' => Unicode::strtolower($this->entityTypeLabel()), '@entities' => Unicode::strtolower($this->entityTypeLabelPlural())];
     $form['update_existing'] = ['#type' => 'radios', '#title' => $this->t('Update existing @entities', $tokens), '#description' => $this->t('Existing @entities will be determined using mappings that are <strong>unique</strong>.', $tokens), '#options' => [static::SKIP_EXISTING => $this->t('Do not update existing @entities', $tokens), static::REPLACE_EXISTING => $this->t('Replace existing @entities', $tokens), static::UPDATE_EXISTING => $this->t('Update existing @entities', $tokens)], '#default_value' => $this->configuration['update_existing']];
     $times = [static::EXPIRE_NEVER, 3600, 10800, 21600, 43200, 86400, 259200, 604800, 2592000, 2592000 * 3, 2592000 * 6, 31536000];
     $period = array_map([$this, 'formatExpire'], array_combine($times, $times));
     $form['expire'] = ['#type' => 'select', '#title' => $this->t('Expire @entities', $tokens), '#options' => $period, '#description' => $this->t('Select after how much time @entities should be deleted.', $tokens), '#default_value' => $this->configuration['expire']];
     if ($this->entityType->isSubclassOf('Drupal\\user\\EntityOwnerInterface')) {
         $form['owner_id'] = ['#type' => 'entity_autocomplete', '#title' => $this->t('Owner'), '#description' => $this->t('Select the owner of the entities to be created. Leave blank for %anonymous.', ['%anonymous' => \Drupal::config('user.settings')->get('anonymous')]), '#target_type' => 'user', '#default_value' => User::load($this->configuration['owner_id'])];
     }
     $form['advanced'] = ['#title' => $this->t('Advanced settings'), '#type' => 'details', '#collapsed' => TRUE, '#collapsible' => TRUE, '#weight' => 10];
     if ($this->entityType->isSubclassOf('Drupal\\user\\EntityOwnerInterface')) {
         $form['advanced']['authorize'] = ['#type' => 'checkbox', '#title' => $this->t('Authorize'), '#description' => $this->t('Check that the author has permission to create the @entity.', $tokens), '#default_value' => $this->configuration['authorize'], '#parents' => ['processor_configuration', 'authorize']];
     }
     $form['advanced']['skip_hash_check'] = ['#type' => 'checkbox', '#title' => $this->t('Force update'), '#description' => $this->t('Forces the update of items even if the feed did not change.'), '#default_value' => $this->configuration['skip_hash_check'], '#parents' => ['processor_configuration', 'skip_hash_check'], '#states' => ['visible' => ['input[name="processor_configuration[update_existing]"]' => ['value' => static::UPDATE_EXISTING]]]];
     return $form;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:20,代码来源:EntityProcessorBase.php

示例3: getEntityTypeIdKeyType

 /**
  * Gets the type of the ID key for a given entity type.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   An entity type.
  *
  * @return string|null
  *   The type of the ID key for a given entity type, or NULL if the entity
  *   type does not support fields.
  */
 protected function getEntityTypeIdKeyType(EntityTypeInterface $entity_type)
 {
     if (!$entity_type->isSubclassOf(FieldableEntityInterface::class)) {
         return NULL;
     }
     $field_storage_definitions = $this->entityFieldManager->getFieldStorageDefinitions($entity_type->id());
     return $field_storage_definitions[$entity_type->getKey('id')]->getType();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:EntityModerationRouteProvider.php

示例4: hasChangedTime

 /**
  * Checks whether the entity type supports modification time natively.
  *
  * @return bool
  *   TRUE if metadata is natively supported, FALSE otherwise.
  */
 protected function hasChangedTime()
 {
     return $this->entityType->isSubclassOf('Drupal\\Core\\Entity\\EntityChangedInterface') && $this->checkFieldStorageDefinitionTranslatability('changed');
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:10,代码来源:ContentTranslationHandler.php

示例5: loadBundleDescriptions

 /**
  * Expands the bundle information with descriptions, if known.
  *
  * @param array $bundles
  *   An array of bundle information.
  * @param \Drupal\Core\Entity\EntityTypeInterface $bundle_entity_type
  *   The ID of the bundle entity type.
  *
  * @return array
  *   The expanded array of bundle information.
  */
 protected function loadBundleDescriptions(array $bundles, EntityTypeInterface $bundle_entity_type)
 {
     if (!$bundle_entity_type->isSubclassOf('\\Drupal\\Core\\Entity\\EntityDescriptionInterface')) {
         return $bundles;
     }
     $bundle_names = array_keys($bundles);
     $storage = $this->entityTypeManager->getStorage($bundle_entity_type->id());
     /** @var \Drupal\Core\Entity\EntityDescriptionInterface[] $bundle_entities */
     $bundle_entities = $storage->loadMultiple($bundle_names);
     foreach ($bundles as $bundle_name => &$bundle_info) {
         if (isset($bundle_entities[$bundle_name])) {
             $bundle_info['description'] = $bundle_entities[$bundle_name]->getDescription();
         }
     }
     return $bundles;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:27,代码来源:EntityController.php

示例6: isApplicable

 /**
  * {@inheritdoc}
  */
 public function isApplicable(EntityTypeInterface $entity_type)
 {
     return $entity_type->isSubclassOf(FileInterface::class);
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:7,代码来源:ImageThumbnail.php


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