本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityBase::label方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityBase::label方法的具体用法?PHP ContentEntityBase::label怎么用?PHP ContentEntityBase::label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityBase
的用法示例。
在下文中一共展示了ContentEntityBase::label方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: label
/**
* Overrides \Drupal\Core\Entity\label().
*/
public function label()
{
$field_label = $this->getHost()->getFieldDefinition($this->bundle())->label();
if (empty($field_label)) {
return parent::label();
} else {
return t('@label @delta of @host', array('@label' => $field_label, '@delta' => $this->getDelta(), '@host' => $this->getHost()->label()));
}
}
示例2: testLabel
/**
* @covers ::label
*/
public function testLabel()
{
// Make a mock with one method that we use as the entity's label callback.
// We check that it is called, and that the entity's label is the callback's
// return value.
$callback_label = $this->randomMachineName();
$callback_container = $this->getMock(get_class());
$callback_container->expects($this->once())->method(__FUNCTION__)->will($this->returnValue($callback_label));
$this->entityType->expects($this->once())->method('getLabelCallback')->will($this->returnValue(array($callback_container, __FUNCTION__)));
$this->assertSame($callback_label, $this->entity->label());
}
示例3: label
/**
* {@inheritdoc}
*/
public function label()
{
$label = parent::label();
if (empty($label)) {
$label = t('Nameless #@id', ['@id' => $this->id()]);
}
return $label;
}