QrCodesController.php
896 Bytes
<?php
namespace App\Controller;
use App\Controller\AppController;
use \PHPQRCode\QRcode;
class QrCodesController extends AppController
{
// @todo Autoriser "creer" dans isAuthorized de ce controleur, et non pas dans celui de AppController !!!
public function creer($message = null)
{
$fileName = $this->request->getSession()->id() . '.png';
$cakephpPath = str_replace('webroot/index.php', '', $_SERVER['SCRIPT_FILENAME']);
$qrCodePath = $cakephpPath . 'webroot/img/qrcodes/' . $fileName;
$this->request->getSession()->write('filename', $fileName);
$this->request->getSession()->write('qrCodePath', $qrCodePath);
if ($message == null) {
return QRcode::png($this->request->getSession()->read('qrUrl'), $qrCodePath);
} else {
return QRcode::png($message, $qrCodePath);
}
}
}