[symfony 3.4.2] Erreur paramètres regex route
bonjour,
Je developpe en Symfony 3.4.2 un petit projet.
fichier routing.yml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
factvente_add:
path: /factventeadd
defaults: { _controller: ZGZagabaBundle:Main:factventeAdd }
factvente_del:
path: /factventedel/{id}
defaults: { _controller: ZGZagabaBundle:Main:factventeDel }
requirements:
id:'(\d{4}/[AZ]{2}/\d{1,6})'
factvente_list:
path: /factventelist
defaults: { _controller: ZGZagabaBundle:Main:factventeList }
factvente_find:
path: /
defaults: { _controller: ZGZagabaBundle:Main:factventeFind }
factvente_up:
path: /factventeup/{id}
defaults: { _controller: ZGZagabaBundle:Main:factventeUp }
requirements:
id:'(\d{4}/[AZ]{2}/\d{1,6})' |
fichier dans le contrôleur affichant la liste des factures
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public function factventeListAction()
{
$em = $this->getDoctrine()->getManager();
$listFacturevente = $em->getRepository('ZGZagabaBundle:Facture_vente')->findBy(
array(), // Pas de critère
array('id' => 'desc')
);
return $this->render('ZGZagabaBundle:Template:factventeList.html.twig', array(
'listFacturevente' => $listFacturevente
));
} |
Template d'affichage liste facture factventeList.html.twig
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| {% block body %}
<div class="animated fadeIn">
<div class="row">
<div class="col-md-12">
<p>
<a href="{{ path('factvente_add') }}" class="btn btn-primary btn-sm">
{#<i class="glyphicon glyphicon-chevron-left"></i> fa fa-table #}
<i class="fa fa-chevron-left"></i>
Nouveau Produit
</a>
</p>
</div>
<div class="col-md-12">
<div class="card">
<div class="card-header">
<strong class="card-title">Liste des Factures d'achat</strong>
</div>
<div class="card-body">
<table id="bootstrap-data-table-export" class="table table-striped table-bordered">
<thead>
<tr>
<th>Exercice</th>
<th>N° Vente</th>
<th>N° Facture</th>
<th>Mnt Facture</th>
<th>Mnt Payé</th>
<th>Mnt Restant</th>
{# <th>Date paie</th> #}
<th width="5%">Modif</th>
<th width="5%">Supp</th>
</tr>
</thead>
<tbody>
{% for factvente in listFacturevente %}
<tr>
<td> {{ factvente.exeId.getId() }} </td>
<td> {{ factvente.venId.getId() }} </td>
<td> {{ factvente.id }} </td>
<td> {{ factvente.mntTotal }} </td>
<td> {{ factvente.mntPaye }} </td>
<td> {{ factvente.mntRest }} </td>
{# <td> {{ factvente.datePaie }} </td> #}
<td align="center" > <a href="{{ path('factvente_up', {'id': factvente.id}) }}"> <img src="{{ asset('images/edit.png') }}" alt="Logo"> </a> </td>
<td align="center"> <a href="{{ path('factvente_del', {'id': factvente.id}) }}"> <img src="{{ asset('images/del.png') }}" alt="Logo"> </a> </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- .animated -->
{% endblock %} |
Quand j'essaie d'afficher la liste des factures dans la vue, j'ai une erreur concernant le format de mes routes factvente_up et factvente_del. Le paramètre sur l'ID des routes est un regex qui me permet d'imposer un format de l'id de facture sous le format 2019/ZG/12 (année sur 4 chiffres, bar , deux caractères, bar, un nombre qui peut être sur 6 chiffres)
Citation:
Exception thrown when handling an exception (Symfony\Component\Config\Exception\FileLoaderLoadException:
Catchable Fatal Error: Argument 3 passed to Symfony\Component\Routing\Route::__construct() must be of the type array, string given,
called in C:\wamp64\www\zagaba\vendor\symfony\symfony\src\Symfony\Component\Routing\Loader\YamlFileLoader.php on line 130
and defined in C:\wamp64\www\zagaba\src\ZG\ZagabaBundle/Resources/config/routing.yml (which is being imported from "C:\wamp64\www\zagaba/app/config\routing.yml").)