Bonjour,
Dans mon controller, je cherche à appeler une fonction d'un autre controller (parfois d'un module différent). J'ai entendu parlé des _forward, _redirect ... mais ceux ci arrêtent l'exécusion du code actuel. Je procède actuellement avec des curl mais cela est très très long ...
Actuellement j'ai ça :
Dans mon premier controller :
Je ne sais pas si j'ai été très clair.
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 public function get($id) { $data = array(); // du code ... return new JsonModel($data); } // Dans mon second controller : public function get($id) { $config = $this->getServiceLocator()->get('Config'); $data = array(); $dataU =curl_init($config['url'] .'/url1/url2/'. $id); $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_TIMEOUT => 0, ); curl_setopt_array($dataU, $options); $table=json_decode(curl_exec($dataU)); $data = get_object_vars($table); // du code ... return new JsonModel($data); }
Merci d'avance
Partager