Blame view

src/Controller/QrCodesController.php 815 Bytes
5d0d680d   Alexandre   Version: 2.2.0
1
2
3
4
<?php
namespace App\Controller;

use App\Controller\AppController;
8f729bce   Etienne Pallier   QrCode bugfix
5
use \PHPQRCode\QRcode;
5d0d680d   Alexandre   Version: 2.2.0
6
7
8
9

class QrCodesController extends AppController
{
	
f084c88b   Etienne Pallier   Gros bugfix + sim...
10
    // @todo Autoriser "creer" dans isAuthorized de ce controleur, et non pas dans celui de AppController !!!
1f42188e   Alexandre   Version: 2.4.4.4
11
	public function creer($message = null) {
5d0d680d   Alexandre   Version: 2.2.0
12
13
14
		
			$fileName = $this->request->session()->id().'.png';
			$cakephpPath = str_replace('webroot/index.php', '', $_SERVER['SCRIPT_FILENAME']);
aa205f2e   Alexandre   Version: 2.4.2.21
15
			$qrCodePath = $cakephpPath . 'webroot/img/qrcodes/' . $fileName;
5d0d680d   Alexandre   Version: 2.2.0
16
			
5d0d680d   Alexandre   Version: 2.2.0
17
			$this->request->session()->write('filename', $fileName);
d58b8953   Alexandre   Version: 2.4.4.0
18
			$this->request->session()->write('qrCodePath', $qrCodePath);
1f42188e   Alexandre   Version: 2.4.4.4
19
20
			
			if($message == null) {
8f729bce   Etienne Pallier   QrCode bugfix
21
				return QRcode::png($this->request->session()->read('qrUrl'), $qrCodePath);
1f42188e   Alexandre   Version: 2.4.4.4
22
			} else {
8f729bce   Etienne Pallier   QrCode bugfix
23
				return QRcode::png($message, $qrCodePath);
1f42188e   Alexandre   Version: 2.4.4.4
24
25
			}
			
5d0d680d   Alexandre   Version: 2.2.0
26
27
28
	}
	
}