Commit 895cd11b authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Plus de prise en compte d'une route de substitution dans la vue partial/add-button.phtml

parent e8b733e3
Loading
Loading
Loading
Loading
+30 −35
Original line number Diff line number Diff line
@@ -37,24 +37,19 @@ Côté dev, ce module fournit :
Exemple dans un contrôleur :

```php
/**
 * Demande de création d'un jeton d'authentification.
 *
 * NB : à l'issue de la création, l'utilisateur reçoit automatiquement son jeton, cf {@see envoyerToken()}.
 *
 * @return ViewModel|Response
 */
public function ajouterTokenAction()
{
    $utilisateur = $this->getUtilisateurService()->getRequestedUtilisateur($this);
namespace Application\Controller;

    // on délègue au module unicaen/auth-token
    return $this->forward()->dispatch(TokenController::class, [
        'action' => 'creer',
        'user' => $utilisateur->getId(),
    ]);
}
use UnicaenAuthToken\Controller\TokenController;

class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurController implements SearchControllerInterface
{
    // ...
  
    /**
     * Ecoute de l'événement TokenController::EVENT_TOKEN_CREATE_AFTER_SAVE permettant 
     * d'agir après la création du jeton pour par exemple envoyer par mail le jeton à l'utilisateur
     * (cf {@see envoyerToken()}).
     */
    public function listenEventsOf(TokenController $tokenController)
    {
        // écoute pour envoyer automatiquement tout jeton nouvellement créé à l'utlisateur
@@ -75,6 +70,7 @@ public function envoyerToken(EventInterface $event)
            'userToken' => $utilisateurToken->getId(),
        ]);
    }
}
```

Exemple dans une vue :
@@ -87,7 +83,6 @@ Exemple dans une vue :
            <div class="pull-right">
                <br>
                <?php echo $this->partial('unicaen-auth-token/token/partial/add-button', [
                    'route' => 'utilisateur/ajouter-token',
                    'redirect' => $redirect,
                    'user' => $utilisateur->getId(),
                ]) ?>
+1 −2
Original line number Diff line number Diff line
<?php
/**
 * @var string|null $redirect
 * @var string|null $route
 * @var \UnicaenAuth\Entity\Db\UserInterface|int|null $user
 * @var \Application\View\Renderer\PhpRenderer $this
 */
@@ -25,7 +24,7 @@ $creable = $this->isAllowed(new UserToken(), TokenPrivilege::CREER);
        'redirect' => $redirect ?: 'unicaen-auth-token/token',
    ];
    ?>
    <a href="<?php echo $this->url($route ?: 'unicaen-auth-token/token/creer', $options, ['query' => $queryParams]) ?>"
    <a href="<?php echo $this->url('unicaen-auth-token/token/creer', $options, ['query' => $queryParams]) ?>"
       class="btn btn-primary" title="Créer un nouveau jeton utilisateur">Nouveau jeton utilisateur</span></a>
</p>
<?php endif ?>