Show class name of security token in WDT

This commit is contained in:
Lee McDermott 2012-12-20 06:23:44 +00:00
parent 8df9b7a2de
commit 15c52f507e
2 changed files with 27 additions and 0 deletions

View File

@ -39,6 +39,7 @@ class SecurityDataCollector extends DataCollector
$this->data = array(
'enabled' => false,
'authenticated' => false,
'token_class' => null,
'user' => '',
'roles' => array(),
);
@ -46,13 +47,17 @@ class SecurityDataCollector extends DataCollector
$this->data = array(
'enabled' => true,
'authenticated' => false,
'token_class' => null,
'user' => '',
'roles' => array(),
);
} else {
$class = explode('\\', get_class($token));
$this->data = array(
'enabled' => true,
'authenticated' => $token->isAuthenticated(),
'token_class' => end($class),
'user' => $token->getUsername(),
'roles' => array_map(function ($role){ return $role->getRole();}, $token->getRoles()),
);
@ -99,6 +104,16 @@ class SecurityDataCollector extends DataCollector
return $this->data['authenticated'];
}
/**
* Get the class name of the security token (without namespace).
*
* @return String The token
*/
public function getTokenClass()
{
return $this->data['token_class'];
}
/**
* {@inheritdoc}
*/

View File

@ -18,6 +18,12 @@
<b>Authenticated</b>
<span class="sf-toolbar-status sf-toolbar-status-{{ authentication_color_code }}">{{ authentication_color_text }}</span>
</div>
{% if collector.tokenClass != null %}
<div class="sf-toolbar-info-piece">
<b>Token class</b>
{{ collector.tokenClass }}
</div>
{% endif %}
{% elseif collector.enabled %}
You are not authenticated.
{% else %}
@ -61,6 +67,12 @@
<th>Roles</th>
<td>{{ collector.roles|yaml_encode }}</td>
</tr>
{% if collector.tokenClass != null %}
<tr>
<th>Token class</th>
<td>{{ collector.tokenClass }}</td>
</tr>
{% endif %}
</table>
{% elseif collector.enabled %}
<p>