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


PHP EntityTypeInterface::getBundleLabel方法代码示例

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


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

示例1: bundleLabel

 /**
  * Returns the bundle label for the entity being processed.
  *
  * @return string
  *   The bundle label.
  */
 protected function bundleLabel()
 {
     if ($label = $this->entityType->getBundleLabel()) {
         return $label;
     }
     return $this->t('Bundle');
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:13,代码来源:EntityProcessorBase.php

示例2: summary

 /**
  * {@inheritdoc}
  */
 public function summary()
 {
     if (count($this->configuration['bundles']) > 1) {
         $bundles = $this->configuration['bundles'];
         $last = array_pop($bundles);
         $bundles = implode(', ', $bundles);
         return $this->t('@bundle_type is @bundles or @last', array('@bundle_type' => $this->bundleOf->getBundleLabel(), '@bundles' => $bundles, '@last' => $last));
     }
     $bundle = reset($this->configuration['bundles']);
     return $this->t('@bundle_type is @bundle', array('@bundle_type' => $this->bundleOf->getBundleLabel(), '@bundle' => $bundle));
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:14,代码来源:EntityBundle.php

示例3: getEntityBundleLabel

 /**
  * Provides the bundle label with a fallback when not defined.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type we are looking the bundle label for.
  *
  * @return \Drupal\Core\StringTranslation\TranslatableMarkup
  *   The entity bundle label or a fallback label.
  */
 protected function getEntityBundleLabel($entity_type)
 {
     if ($label = $entity_type->getBundleLabel()) {
         return $this->t('@label', ['@label' => $label]);
     }
     $fallback = $entity_type->getLabel();
     if ($bundle_entity_type = $entity_type->getBundleEntityType()) {
         // This is a better fallback.
         $fallback = $this->entityManager->getDefinition($bundle_entity_type)->getLabel();
     }
     return $this->t('@label bundle', ['@label' => $fallback]);
 }
开发者ID:Wylbur,项目名称:gj,代码行数:21,代码来源:EntityBundle.php

示例4: getBundleLabel

 /**
  * Returns the bundle label for a given entity type.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return string
  *   The bundle label.
  */
 protected function getBundleLabel(EntityTypeInterface $entity_type)
 {
     if ($entity_type->getBundleLabel()) {
         return $entity_type->getBundleLabel();
     }
     if ($entity_type->getBundleEntityType()) {
         return \Drupal::entityTypeManager()->getDefinition($entity_type->getBundleEntityType())->getLabel();
     }
     return $this->t('@label type', ['@label' => $entity_type->getLabel()]);
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:19,代码来源:ContentEntitySource.php

示例5: baseFieldDefinitions

 /**
  * {@inheritdoc}
  */
 public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
 {
     $fields = [];
     if ($entity_type->hasKey('id')) {
         $fields[$entity_type->getKey('id')] = BaseFieldDefinition::create('integer')->setLabel(new TranslatableMarkup('ID'))->setReadOnly(TRUE)->setSetting('unsigned', TRUE);
     }
     if ($entity_type->hasKey('uuid')) {
         $fields[$entity_type->getKey('uuid')] = BaseFieldDefinition::create('uuid')->setLabel(new TranslatableMarkup('UUID'))->setReadOnly(TRUE);
     }
     if ($entity_type->hasKey('revision')) {
         $fields[$entity_type->getKey('revision')] = BaseFieldDefinition::create('integer')->setLabel(new TranslatableMarkup('Revision ID'))->setReadOnly(TRUE)->setSetting('unsigned', TRUE);
     }
     if ($entity_type->hasKey('langcode')) {
         $fields[$entity_type->getKey('langcode')] = BaseFieldDefinition::create('language')->setLabel(new TranslatableMarkup('Language'))->setDisplayOptions('view', ['type' => 'hidden'])->setDisplayOptions('form', ['type' => 'language_select', 'weight' => 2]);
         if ($entity_type->isRevisionable()) {
             $fields[$entity_type->getKey('langcode')]->setRevisionable(TRUE);
         }
         if ($entity_type->isTranslatable()) {
             $fields[$entity_type->getKey('langcode')]->setTranslatable(TRUE);
         }
     }
     if ($entity_type->hasKey('bundle')) {
         if ($bundle_entity_type_id = $entity_type->getBundleEntityType()) {
             $fields[$entity_type->getKey('bundle')] = BaseFieldDefinition::create('entity_reference')->setLabel($entity_type->getBundleLabel())->setSetting('target_type', $bundle_entity_type_id)->setRequired(TRUE)->setReadOnly(TRUE);
         } else {
             $fields[$entity_type->getKey('bundle')] = BaseFieldDefinition::create('string')->setLabel($entity_type->getBundleLabel())->setRequired(TRUE)->setReadOnly(TRUE);
         }
     }
     return $fields;
 }
开发者ID:318io,项目名称:318-io,代码行数:33,代码来源:ContentEntityBase.php


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