本文整理汇总了PHP中Drupal\Core\Session\AccountInterface::getDisplayName方法的典型用法代码示例。如果您正苦于以下问题:PHP AccountInterface::getDisplayName方法的具体用法?PHP AccountInterface::getDisplayName怎么用?PHP AccountInterface::getDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Session\AccountInterface
的用法示例。
在下文中一共展示了AccountInterface::getDisplayName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = NULL)
{
$this->data['name'] = $this->currentUser->getDisplayName();
$this->data['authenticated'] = $this->currentUser->isAuthenticated();
$this->data['roles'] = [];
$storage = $this->entityManager->getStorage('user_role');
foreach ($this->currentUser->getRoles() as $role) {
$entity = $storage->load($role);
$this->data['roles'][] = $entity->label();
}
foreach ($this->providerCollector->getSortedProviders() as $provider_id => $provider) {
if ($provider->applies($request)) {
$this->data['provider'] = $provider_id;
}
}
$this->data['anonymous'] = $this->configFactory->get('user.settings')->get('anonymous');
}
示例2: display
/**
* Display a given user's identity.
*
* @param \Drupal\Core\Session\AccountInterface|NULL $user
* The user to retrieve data on behalf of.
*
* @return array
* Render array with all the results.
*/
public function display(AccountInterface $user = NULL)
{
// Build the output (as a render array).
$output = ['#cache' => ['max-age' => 0]];
if ($user) {
$output['name'] = ['#markup' => $this->t('Name: %name', ['%name' => $user->getDisplayName()])];
$output['mail'] = ['#markup' => $this->t('Mail: %mail', ['%mail' => $user->getEmail()])];
}
return $output;
}