Bonjour
je souhaite créer un service et utiliser doctrine dans ce service
j'ai mis dans mon fichier services.yml ceci:
NetBeans me signal une erreur du type:parameters: dsi_main.log.class: DSI\MainBundle\Service\GestionLog services: dsi_main.log: class: %dsi_main.log.class% arguments: [@doctrine]
donc sûrement lié à l'@ de doctrine...ScannerException while scanning for the next token we had this found character @(64) that cannot start any token
voici ma class service:
quand je lance mon test voici ce que j’obtiens:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php //=================================================================// //== DSI-MainBundle - Système de Gestion DSI Université Stendhal ==// //== Viduc 2012 - viduc@sugarbox.fr ==// //== Pôle Développement - tristan.fleury@u-grenoble3.fr ==// //=================================================================// // Cette class est un service. Il permet d'accéder à la gestion des logs depuis n'importe quelle class // Utilise un objet entity Log namespace DSI\MainBundle\Service; use DSI\MainBundle\Entity\Log; use Doctrine\Bundle\DoctrineBundle\Registry; class GestionLog { /** * @var Symfony\Bundle\DoctrineBundle\Registry */ protected $doctrine; protected $em; // EntityManager protected $log; // class Entity Log.php /** * Constructeur de la class */ public function __construct(Registry $doctrine) { $this->doctrine = $doctrine; // Récupération de l'EntityManager $this->em = $this->doctrine->getEntityManager(); // Génération de l'objet ENtity Log $this->log = new Log(); } /** * Fonction d'enregistrement des logs * @param $user le login de l'utilisateur qui fait l'action * @param $objet l'objet sur lequel porte l'action * @param $desclog la description de l'action */ public function saveLog($user,$objet,$desclog) { $this->log->setUser($user); $this->log->setObjet($objet); $this->log->setLog($desclog); $this->em->persist($log); $this->em->flush(); } } ?>
j'ai déjà eu ce pb avec l'@ mais je ne sais pas si l'erreur vient de la ou pas...Catchable Fatal Error: Argument 1 passed to DSI\MainBundle\Service\GestionLog::__construct() must be an instance of Doctrine\Bundle\DoctrineBundle\Registry, instance of Symfony\Bundle\DoctrineBundle\Registry given, called in /Synfony-Cache/dsiweb/cache/dev/appDevDebugProjectContainer.php on line 327 and defined in /MOUNT/STOCKAGE/WORKPLACE/Dsi-Symfony/src/DSI/MainBundle/Service/GestionLog.php line 28
Partager