本文整理匯總了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;
}