Commit 1b25075a authored by David Surville's avatar David Surville
Browse files

Bug sur la récupération du role dans l'aide de vue

parent a81033a2
<?php <?php
namespace UnicaenAuth\View\Helper; namespace UnicaenAuth\View\Helper;
use Application\Acl\Role; use Zend\Permissions\Acl\Role\RoleInterface;
use Zend\Form\Element\Radio; use Zend\Form\Element\Radio;
/** /**
...@@ -14,7 +14,7 @@ use Zend\Form\Element\Radio; ...@@ -14,7 +14,7 @@ use Zend\Form\Element\Radio;
class UserProfileSelectRadioItem extends UserAbstract class UserProfileSelectRadioItem extends UserAbstract
{ {
/** /**
* @var Role * @var RoleInterface
*/ */
protected $role; protected $role;
...@@ -30,11 +30,11 @@ class UserProfileSelectRadioItem extends UserAbstract ...@@ -30,11 +30,11 @@ class UserProfileSelectRadioItem extends UserAbstract
/** /**
* *
* @param Role $role * @param RoleInterface $role
* @param bool $selected * @param bool $selected
* @return self * @return self
*/ */
public function __invoke(Role $role, $selected = false) public function __invoke(RoleInterface $role, $selected = false)
{ {
$this->role = $role; $this->role = $role;
$this->selected = $selected; $this->selected = $selected;
...@@ -74,10 +74,12 @@ class UserProfileSelectRadioItem extends UserAbstract ...@@ -74,10 +74,12 @@ class UserProfileSelectRadioItem extends UserAbstract
$id = $this->role->getRoleId(); $id = $this->role->getRoleId();
$inputClass = 'user-profile-select-input'; $inputClass = 'user-profile-select-input';
$roleToString = method_exists($this->role, '__toString') ? (string) $this->role : $this->role->getRoleId();
// rendu sous forme de radio // rendu sous forme de radio
$radio = new Radio('role'); $radio = new Radio('role');
$radio $radio
->setValueOptions(array($id => (string) $this->role)) ->setValueOptions(array($id => $roleToString))
->setAttribute('class', $inputClass) ->setAttribute('class', $inputClass)
->setAttribute('title', "Cliquez pour changer de profil courant") ->setAttribute('title', "Cliquez pour changer de profil courant")
->setValue($this->selected ? $id : null); ->setValue($this->selected ? $id : null);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment