Commit bea28e6d authored by Indra Raja's avatar Indra Raja

Merge branch 'v1.3' into 'Volume1.1'

V1.4

See merge request !11
parents 1b1e00d1 4bee9a03
This diff is collapsed.
......@@ -166,6 +166,7 @@ return [
Controller\UmumController::class => Factory\UmumControllerFactory::class,
// Master\GlobalActionController::class => Factory\GlobalActionControllerFactory::class,
Controller\ApiController::class => Factory\ApiControllerFactory::class,
// Controller\ApiController::class => InvokableFactory::class,
],
],
......
......@@ -11,8 +11,12 @@ use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Khansia\Generic\Result;
class AdminController extends \Application\Master\GlobalActionController
{
public function __construct($headScript)
{
$this->headScript = $headScript;
......@@ -31,6 +35,8 @@ class AdminController extends \Application\Master\GlobalActionController
$uri = $this->getRequest()->getUri();
$baseurl = sprintf('//%s', $uri->getHost());
$this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');
$this->headScript->appendFile('/action-js/antrian-js/action-dasboaard.js');
......@@ -43,7 +49,9 @@ class AdminController extends \Application\Master\GlobalActionController
}
public function antrianadminAction()
{
$this->isLoggedIn();
$this->isLoggedIn();
$view = new ViewModel();
$result = new Result();
......@@ -52,36 +60,9 @@ class AdminController extends \Application\Master\GlobalActionController
$baseurl = sprintf('//%s', $uri->getHost());
$getpath = explode("/",$uri->getPath());
// echo "<pre>";
$id = $getpath[3];
// $curl = curl_init();
// curl_setopt_array($curl, array(
// CURLOPT_URL => "http://queue.indra/api/nextantrian",
// CURLOPT_RETURNTRANSFER => true,
// CURLOPT_ENCODING => "",
// CURLOPT_MAXREDIRS => 10,
// CURLOPT_TIMEOUT => 0,
// CURLOPT_FOLLOWLOCATION => true,
// CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
// CURLOPT_CUSTOMREQUEST => "POST",
// CURLOPT_POSTFIELDS => array('inoantrian' => '7','idok' => '74','istatus' => '40'),
// ));
// $response = curl_exec($curl);
// curl_close($curl);
// echo $response;
// $data = json_decode(file_get_contents('php://input'),true);
// echo $data;
// print_r($data);
$this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');
$this->headScript->appendScript(' var id = "' . $id . '"');
$this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');
$this->headScript->appendFile('/action-js/antrian-js/action-admin.js');
$this->layout("layout/layoutAdmin");
......
......@@ -5,11 +5,16 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;
use Application\Master;
use Zend\View\Model\ViewModel;
use Khansia\Generic\Result;
use ZfrPusher\Client\Credentials;
use ZfrPusher\Client\PusherClient;
use ZfrPusher\Service\PusherService;
use ZfrPusher\Exception\ExceptionInterface as PusherExceptionInterface;
class ApiController extends \Application\Master\GlobalActionController {
......@@ -252,7 +257,7 @@ class ApiController extends \Application\Master\GlobalActionController {
return $this->getOutput($result->toJson());
}
public function saveregisterAction(){
$result = new Result();
$request = $this->getRequest();
......@@ -265,6 +270,9 @@ class ApiController extends \Application\Master\GlobalActionController {
$tb_antrian ='antrian';
$tb_antrian_pasien ='antrian_pasien';
if ($request->isPost()) {
......@@ -344,10 +352,32 @@ class ApiController extends \Application\Master\GlobalActionController {
$result->info = $result::INFO_SUCCESS;
$result->data = $ruang;
}
$dataArrayRegisterDokter= array (
'create_date' => gmdate("Y-m-d H:i:s", time()+60*60*7),
'id_ruang' => $ruang,
'id_poli' => $poli,
'id_dokter' => $dokter,
'antrian_all' => $antrian_all,
'waktu_antrian' => $waktu_antrian,
'id_condition' =>1,
'jam_mulai' => $jam_mulai,
);
$dataArrayRegisterAntrian= array (
'create_date' => gmdate("Y-m-d H:i:s", time()+60*60*7),
'antrian_all' => $antrian_all,
'waktu_antrian' => $waktu_antrian,
'jam_mulai' => $jam_mulai,
);
$param->saveGlobal($dataArrayRegisterDokter, $tb_register_dokter);
$param->saveGlobal($dataArrayRegisterAntrian, $tb_register_antrian);
$seqAfter1 = $param->getLastSeqPostgree($tb_register_dokter, 'id_register');
......@@ -418,19 +448,6 @@ class ApiController extends \Application\Master\GlobalActionController {
$result->code = 1;
$result->info = 'gagal total';
}
// echo '<pre>';
//print_r($result->data['id_re']['ui']['k'] );die;
// if($seqAfter1->data['total'] > $seqBefore1->data['total']){
// $result->code = $result::CODE_SUCCESS; // code 0
// $result->info = $result::INFO_SUCCESS;
// $result->data = $seqAfter1->data['total'];
// }else{
// $result->code = 1;
// $result->info = 'Gagal insert';
// }
}catch (\Exception $exc) {
$result = new Result(0,1,$exc->getMessage() .'-'.$exc->getTraceAsString());
......@@ -1249,6 +1266,8 @@ class ApiController extends \Application\Master\GlobalActionController {
$storage = \Application\Model\Param\Storage::factory($this->getDb(), $this->getConfig());
$test = new \Application\Model\Param($storage);
$load = $test->loadantrianmiss($post->id);
// print_r($load);die;
......@@ -1862,20 +1881,21 @@ class ApiController extends \Application\Master\GlobalActionController {
public function nextantrianAction(){
$result = new Result();
$request = $this->getRequest();
$post = $request->getPost();
$post = $request->getPost();
// First, run 'composer require pusher/pusher-php-server'
if ($request->isPost()) {
$storage = \Application\Model\Param\Storage::factory($this->getDb(), $this->getConfig());
$test = new \Application\Model\Param($storage);
require 'C:/laragon/www/queue/load.php';
try{
$noantrian = $post->inoantrian;
$iddok = $post->idok;
$status = $post->istatus;
$dataarray = array(
'status_code' => $status,
......
......@@ -10,6 +10,10 @@ namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Khansia\Generic\Result;
use ZfrPusher\Client\Credentials;
use ZfrPusher\Client\PusherClient;
use ZfrPusher\Service\PusherService;
class UmumController extends \Application\Master\GlobalActionController
{
......@@ -41,6 +45,8 @@ class UmumController extends \Application\Master\GlobalActionController
{
$view = new ViewModel();
$result = new Result();
$today = gmdate("d M Y ", time()+60*60*7);
......@@ -53,7 +59,13 @@ class UmumController extends \Application\Master\GlobalActionController
// echo "<pre>";
$decodeid = base64_decode($getpath[3]);
// $data = $this->getRequest()->getRawBody();
// print_r($data);
$this->headScript->appendScript(' var baseURL = "' . $baseurl . '"');
......
......@@ -135,6 +135,12 @@ class Param extends Mapper {
$data = $this->_storage->loadantrianmiss($id);
return $data;
}
public function loadantrianregister($id = null){
$data = $this->_storage->loadantrianregister($id);
return $data;
}
public function loadPoli($id_poli = null){
$data = $this->_storage->loadPoli($id_poli);
return $data;
......
......@@ -1287,7 +1287,60 @@ class Mysql extends \Khansia\Db\Storage implements Skeleton {
$result->info = 'ERROR : ' . $ex->getMessage();
}
return $result;
}
}
public function loadantrianregister($id = null){
$result = new Result();
try {
$sql = " SELECT register_dokter.id_register, dokter_to_poli.nama_dokter, poli.nama_poli, ruang.nama_ruang,register_dokter.antrian_all,register_dokter.waktu_antrian, register_dokter.jam_mulai, register_dokter.create_date
FROM register_dokter
INNER JOIN poli
ON register_dokter.id_poli = poli.id_poli
INNER JOIN dokter_to_poli
ON register_dokter.id_dokter = dokter_to_poli.id_dokter
INNER JOIN ruang
ON register_dokter.id_ruang = ruang.id_ruang
Where register_dokter.create_date = CURRENT_DATE
";
if($id){
$sql .= " AND register_dokter.id_register= $id AND register_dokter.id_register IS NOT NULL" ;
}
$sql .= " ORDER BY poli.nama_poli asc , register_dokter.create_date";
// print_r($sql);die;
$stmt = $this->_db->query($sql);
$resdata = $stmt->execute();
$listdata = array();
foreach($resdata as $val){
// print_r($val);die;
array_push($listdata, $val);
}
if ($listdata) {
$result->code = 0;
$result->info = 'OK';
$result->data = $listdata;
}else{
$result->code = 1;
$result->info = 'nok';
}
}catch (\Zend\Db\Adapter\Exception\RuntimeException $ex) {
$result->code = 3;
$result->info = 'ERROR : ' . $ex->getMessage();
}catch (\Exception $ex) {
$result->code = 4;
$result->info = 'ERROR : ' . $ex->getMessage();
}
return $result;
}
public function loadantrianmiss($id){
$result = new Result();
try {
......
<!-- Page header -->
<div class="row">
<div class="page-header" style="border-bottom: 0px solid #ddd0;">
......@@ -20,18 +21,24 @@
</div>
</div>
<div class="justify-content-center">
<div class="col-sm-200" >
<audio id="MyAudioElement" autoplay>
<source src="a1.mp3" type="audio/ogg">
<source src="a1.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<div class="card mb-3 alert alert-info alert-styled-left alert-arrow-left alert-component col-sm-100" style="border-color: #e94c72;background: #faebd73b;width: 1300px;margin-left: 100px;">
<div class="text-center content-group">
<div><input type="hidden" value="nomer antrian" id="text-to-speech" placeholder="Enter text to speak..."/></div>
<p class="error-title" style=" font-weight: ;font-size:50px;font-family: Times New Roman, Times, serif;color: #fff"><span > Nomer</span></p>
<h1 class="error-title" style=" font-weight: bold;font-size:100px;font-family: Times New Roman, Times, serif;color: #fff"><span id="no_antrian"></span></h1>
<h1 class="error-title" style=" font-weight: bold;font-size:100px;font-family: Times New Roman, Times, serif;color: #fff"><span id="no_antrian_panggil"></span></h1>
<p class="error-title" style=" font-weight: ;font-size:50px;font-family: Times New Roman, Times, serif;color: #fff"><span > Please Proceed To</span></p>
<p class="error-title" style=" font-weight: ;font-size:50px;font-family: Times New Roman, Times, serif;color: #fff"><span id="ruang"></span></p>
<p class="error-title" style=" font-weight: ;font-size:50px;font-family: Times New Roman, Times, serif;color: #fff"><span > Silahkan Menuju Ke</span></p>
<p class="error-title" style=" font-weight: ;font-size:50px;font-family: Times New Roman, Times, serif;color: #fff"><span id="ruang_panggil"></span></p>
<!-- <div><input type="hidden" value="no_antrian" id="no_antrian" /></div>
<div><input type="hidden" value="nama_ruang" id="nama_ruang" /><span style="visibility:hidden" id="nama_ruang"></span></div> -->
......@@ -43,7 +50,6 @@
</div>
</div>
<!--
......
<div class="container"></div>
<form class="form-inline">
<div class="form-group form-control-lg ">
......@@ -25,7 +26,7 @@
</div>
<div class="text-center content-group">
<div><input type="hidden" value="nomer antrian" id="text-to-speech" placeholder="Enter text to speak..."/></div>
<h1 class="error-title" style="padding-top: 48px; padding-bottom:47px; font-weight: bold;font-size:170px;font-family: Times New Roman, Times, serif;color: #808080"><span id="no_antrian"></span></h1>
<h1 class="error-title" style=" font-weight: bold;font-size:243px;font-family: Times New Roman, Times, serif;color: #808080"><span id="no_antrian"></span></h1>
</div>
<div><input type="hidden" value="no_antrian" id="no_antrian" /></div>
......
......@@ -208,6 +208,7 @@
<?= $this->headScript()?>
<script src="<?php $this->basePath();?>/tamplateadmin/js/sb-admin-2.min.js"></script>
<script src="<?php $this->basePath();?>/js/jquery-clock-timepicker.min.js"></script>
<script src="<?php $this->basePath();?>/tamplateadmin/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="<?php $this->basePath();?>/tamplateadmin/vendor/datatables/dataTables.bootstrap4.min.js"></script>
......
......@@ -87,7 +87,11 @@
<?= $this->headScript()
->prependFile($this->basePath('js/bootstrap.min.js'))
->prependFile($this->basePath('js/jquery-3.1.0.min.js'))
->prependFile($this->basePath('js/jquery-3.1.0.min.js'))
->prependFile(('https://js.pusher.com/7.0/pusher.min.js'))
?>
......
......@@ -2,23 +2,24 @@
/* JS comes here */
/* JS comes here */
function textToAudio() {
// let msg1 = "nomor antrian";
let no_antrian = document.getElementById("no_antrian").innerHTML;
let voice = "nomor antrian " + no_antrian;
console.log(voice)
let speech = new SpeechSynthesisUtterance();
speech.lang = "id";
speech.text = voice;
speech.volume = 1;
speech.rate = 0.70;
speech.rate = 0.70;
speech.pitch = 1;
window.speechSynthesis.speak(speech);
}
window.speechSynthesis.speak(speech);
}
function textToAudioRuang() {
// let msg1 = "nomor antrian";
......@@ -31,12 +32,12 @@ function textToAudioRuang() {
console.log(voice)
let speech = new SpeechSynthesisUtterance();
speech.lang = "id";
speech.text = voice;
speech.volume = 1;
speech.rate = 0.70;
speech.rate = 0.70;
speech.pitch = 1;
window.speechSynthesis.speak(speech);
}
......@@ -70,18 +71,7 @@ $('#poli').on('change', function () {
});
});
$('#dokter').on("change", function () {
$id_dokter = $('#dokter').val();
window.location.href = ("/admin/antrianadmin/" + $id_dokter);
});
if (window.location.pathname == "/admin/antrianadmin/" + id) {
$(window).on("load", function () {
tampilangka(id)
loadantrian(id)
});
}
function loadpoli() {
$.ajax({
type: 'POST',
......@@ -107,15 +97,14 @@ function loadpoli() {
});
}
function loadantrian(id) {
$iddok = $('#dokter').val();
function loadantrian() {
var iddokter = $('#dokter').val();
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/loadAntrianAdmin',
data: {
iid: id,
id: iddokter
},
......@@ -128,7 +117,7 @@ function loadantrian(id) {
if (result.code == 0) {
let data = result.data;
// console.log(data);
console.log(data);
let counter = 1;
for (x in data) {
......@@ -163,17 +152,23 @@ function loadantrian(id) {
}
$('#dokter').on('change', function () {
loadantrian();
tampilangka();
});
$('#no_antrian').html('-');
function tampilangka(id) {
$('#no_antrian').html('-');
function tampilangka() {
var iddokter = $('#dokter').val();
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/loadNoAntrian',
data: {
id_dokter: id,
id_dokter: iddokter,
},
async: false,
......@@ -245,41 +240,40 @@ function tampilangka(id) {
$('#btnNext').on('click', function () {
actionqueue(noantrian + 1, 20, id);
loadantrian(id)
actionqueue(noantrian + 1, 20);
loadantrian()
});
$('#btnCall').on('click', function () {
actionqueue(noantrian, 30, id);
actionqueue(noantrian, 30);
});
$('#btnDone').on('click', function () {
actionqueue(noantrian, 50, id);
actionqueue(noantrian, 50);
});
$('#btnMissed').on('click', function () {
actionqueue(noantrian, 60, id);
actionqueue(noantrian, 60);
});
$('#btnServed').on('click', function () {
actionqueue(noantrian, 40, id);
actionqueue(noantrian, 40);
});
function actionqueue(antrianno, status, iddok) {
function actionqueue(antrianno, status) {
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/nextantrian',
data: {
inoantrian: antrianno,
istatus: status,
idok: iddok,
istatus: status
},
success: function (result) {
......@@ -292,9 +286,9 @@ function actionqueue(antrianno, status, iddok) {
html: true,
type: "warning"
});
$('#no_antrian').html('-');
return false;
}
if (status == 20) {
......@@ -317,23 +311,9 @@ function actionqueue(antrianno, status, iddok) {
} else if (status == 30) {
// SOound call
var flush = new Audio('../../data/tone/a1.mp3');
setTimeout(function () {
flush.play();
})
flush.onended = function () {
textToAudio()
setTimeout(function () {
textToAudioRuang()
}, 3000)
};
swal({
swal({
title: "Call!",
text: "Sedang Melakukan Panggilan",
type: "success",
......@@ -341,6 +321,21 @@ function actionqueue(antrianno, status, iddok) {
timer: 14000
});
var flush = new Audio('../../data/tone/a1.mp3');
flush.muted = true;
setTimeout(function() {
flush.muted = false;
flush.play() }, )
flush.onended = function() {
textToAudio()
setTimeout(function() {
textToAudioRuang() }, 3000)
};
$('#btnNext').prop('disabled', true);
......@@ -377,4 +372,4 @@ function actionqueue(antrianno, status, iddok) {
}
});
}
\ No newline at end of file
}
......@@ -253,16 +253,14 @@ $('#pilihno').on('click', function () {
});
function pilihAntrian() {
var $dokter = $('#dokter option:selected').attr("value");
var dokter = $('#dokter option:selected').attr("value");
$.ajax({
type: 'POST',
dataType: 'json',
url: baseURL + '/api/loadPilihAntrian',
data: {
iddok: $dokter,
iddok: dokter,
},
success: function (response) {
......
......@@ -20,7 +20,7 @@ $(document).ready(function () {
durationNegative: true
});
});
//
$(document).ready(function () {
$("#waktu_antrian").clockTimePicker({
required: true,
......@@ -153,6 +153,9 @@ function reset() {
}
LoadDadta();
function LoadDadta() {
......@@ -232,7 +235,12 @@ function LoadDadta() {
$('#tambahmodal').on('click', function () {
$('#addData').modal('hide');
})
......@@ -243,6 +251,7 @@ $('#tambah').on('click', function () {
})
function SaveDataRegister(param) {
let ruang = $("#ruang option:selected").attr("value");
......@@ -331,6 +340,7 @@ function SaveDataRegister(param) {
ipoli: poli,
idokter: dokter,
ijam_mulai: jam_mulai,
itanggal_buka : tanggal_buka,
},
......@@ -606,4 +616,4 @@ function Delete(param) {
}
});
}
}
\ No newline at end of file
......@@ -2,9 +2,13 @@
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../zendframework/zend-servicemanager/bin" && pwd)
if [ -d /proc/cygdrive ] && [[ $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
# We are in Cgywin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
;;
esac
fi
"${dir}/generate-deps-for-config-factory" "$@"
......@@ -2,9 +2,13 @@
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../zendframework/zend-servicemanager/bin" && pwd)
if [ -d /proc/cygdrive ] && [[ $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
# We are in Cgywin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
;;
esac
fi
"${dir}/generate-factory-for-class" "$@"
......@@ -2,9 +2,13 @@
dir=$(cd "${0%[/\\]*}" > /dev/null; cd "../zendframework/zend-view/bin" && pwd)
if [ -d /proc/cygdrive ] && [[ $(which php) == $(readlink -n /proc/cygdrive)/* ]]; then
# We are in Cgywin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
if [ -d /proc/cygdrive ]; then
case $(which php) in
$(readlink -n /proc/cygdrive)/*)
# We are in Cygwin using Windows php, so the path must be translated
dir=$(cygpath -m "$dir");
;;
esac
fi
"${dir}/templatemap_generator.php" "$@"
......@@ -60,7 +60,7 @@ class ClassLoader
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
......@@ -279,7 +279,7 @@ class ClassLoader
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
......@@ -377,11 +377,11 @@ class ClassLoader
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
$length = $this->prefixLengthsPsr4[$first][$search];
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
......
......@@ -6,4 +6,19 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ZfrPusherTest\\Client\\Listener\\SignatureListenerTest' => $vendorDir . '/zfr/zfr-pusher/tests/ZfrPusherTest/Client/Listener/SignatureListenerTest.php',
'ZfrPusherTest\\Client\\PusherClientTest' => $vendorDir . '/zfr/zfr-pusher/tests/ZfrPusherTest/Client/PusherClientTest.php',
'ZfrPusherTest\\Client\\PusherSignatureTest' => $vendorDir . '/zfr/zfr-pusher/tests/ZfrPusherTest/Client/PusherSignatureTest.php',
'ZfrPusherTest\\Service\\PusherServiceTest' => $vendorDir . '/zfr/zfr-pusher/tests/ZfrPusherTest/Service/PusherServiceTest.php',
'ZfrPusher\\Client\\Credentials' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Client/Credentials.php',
'ZfrPusher\\Client\\Listener\\SignatureListener' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Client/Listener/SignatureListener.php',
'ZfrPusher\\Client\\PusherClient' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Client/PusherClient.php',
'ZfrPusher\\Client\\PusherSignature' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Client/PusherSignature.php',
'ZfrPusher\\Exception\\ExceptionInterface' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Exception/ExceptionInterface.php',
'ZfrPusher\\Service\\Exception\\ForbiddenException' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/ForbiddenException.php',
'ZfrPusher\\Service\\Exception\\RuntimeException' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/RuntimeException.php',
'ZfrPusher\\Service\\Exception\\UnauthorizedException' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/UnauthorizedException.php',
'ZfrPusher\\Service\\Exception\\UnknownResourceException' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/UnknownResourceException.php',
'ZfrPusher\\Service\\PusherService' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Service/PusherService.php',
'ZfrPusher\\Version' => $vendorDir . '/zfr/zfr-pusher/src/ZfrPusher/Version.php',
);
......@@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir);
return array(
'10a6847eba8a430a134fad89f4a30a26' => $vendorDir . '/zendframework/zend-cache/autoload/patternPluginManagerPolyfill.php',
'3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php',
);
......@@ -6,4 +6,8 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'ZfrPusher\\' => array($vendorDir . '/zfr/zfr-pusher/src'),
'ZfrPusherTest\\' => array($vendorDir . '/zfr/zfr-pusher/tests'),
'Guzzle\\Tests' => array($vendorDir . '/guzzle/guzzle/tests'),
'Guzzle' => array($vendorDir . '/guzzle/guzzle/src'),
);
......@@ -27,8 +27,11 @@ return array(
'Zend\\ComponentInstaller\\' => array($vendorDir . '/zendframework/zend-component-installer/src'),
'Zend\\Cache\\' => array($vendorDir . '/zendframework/zend-cache/src'),
'ZF\\DevelopmentMode\\' => array($vendorDir . '/zfcampus/zf-development-mode/src'),
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'RestApi\\' => array($vendorDir . '/multidots/zf3-rest-api/src'),
'Pusher\\' => array($vendorDir . '/pusher/pusher-php-server/src'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
'Khansia\\' => array($vendorDir . '/Khansia'),
......
......@@ -13,6 +13,9 @@ class ComposerAutoloaderInitfe7d3cb9e3e556360705ee29bb11bde9
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
......
......@@ -8,6 +8,7 @@ class ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9
{
public static $files = array (
'10a6847eba8a430a134fad89f4a30a26' => __DIR__ . '/..' . '/zendframework/zend-cache/autoload/patternPluginManagerPolyfill.php',
'3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php',
);
public static $prefixLengthsPsr4 = array (
......@@ -35,13 +36,19 @@ class ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9
'Zend\\Cache\\' => 11,
'ZF\\DevelopmentMode\\' => 19,
),
'S' =>
array (
'Symfony\\Component\\EventDispatcher\\' => 34,
),
'R' =>
array (
'RestApi\\' => 8,
),
'P' =>
array (
'Pusher\\' => 7,
'Psr\\SimpleCache\\' => 16,
'Psr\\Log\\' => 8,
'Psr\\Container\\' => 14,
'Psr\\Cache\\' => 10,
),
......@@ -149,14 +156,26 @@ class ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9
array (
0 => __DIR__ . '/..' . '/zfcampus/zf-development-mode/src',
),
'Symfony\\Component\\EventDispatcher\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/event-dispatcher',
),
'RestApi\\' =>
array (
0 => __DIR__ . '/..' . '/multidots/zf3-rest-api/src',
),
'Pusher\\' =>
array (
0 => __DIR__ . '/..' . '/pusher/pusher-php-server/src',
),
'Psr\\SimpleCache\\' =>
array (
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
),
'Psr\\Log\\' =>
array (
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
),
'Psr\\Container\\' =>
array (
0 => __DIR__ . '/..' . '/psr/container/src',
......@@ -187,11 +206,56 @@ class ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9
),
);
public static $prefixesPsr0 = array (
'Z' =>
array (
'ZfrPusher\\' =>
array (
0 => __DIR__ . '/..' . '/zfr/zfr-pusher/src',
),
'ZfrPusherTest\\' =>
array (
0 => __DIR__ . '/..' . '/zfr/zfr-pusher/tests',
),
),
'G' =>
array (
'Guzzle\\Tests' =>
array (
0 => __DIR__ . '/..' . '/guzzle/guzzle/tests',
),
'Guzzle' =>
array (
0 => __DIR__ . '/..' . '/guzzle/guzzle/src',
),
),
);
public static $classMap = array (
'ZfrPusherTest\\Client\\Listener\\SignatureListenerTest' => __DIR__ . '/..' . '/zfr/zfr-pusher/tests/ZfrPusherTest/Client/Listener/SignatureListenerTest.php',
'ZfrPusherTest\\Client\\PusherClientTest' => __DIR__ . '/..' . '/zfr/zfr-pusher/tests/ZfrPusherTest/Client/PusherClientTest.php',
'ZfrPusherTest\\Client\\PusherSignatureTest' => __DIR__ . '/..' . '/zfr/zfr-pusher/tests/ZfrPusherTest/Client/PusherSignatureTest.php',
'ZfrPusherTest\\Service\\PusherServiceTest' => __DIR__ . '/..' . '/zfr/zfr-pusher/tests/ZfrPusherTest/Service/PusherServiceTest.php',
'ZfrPusher\\Client\\Credentials' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Client/Credentials.php',
'ZfrPusher\\Client\\Listener\\SignatureListener' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Client/Listener/SignatureListener.php',
'ZfrPusher\\Client\\PusherClient' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Client/PusherClient.php',
'ZfrPusher\\Client\\PusherSignature' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Client/PusherSignature.php',
'ZfrPusher\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Exception/ExceptionInterface.php',
'ZfrPusher\\Service\\Exception\\ForbiddenException' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/ForbiddenException.php',
'ZfrPusher\\Service\\Exception\\RuntimeException' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/RuntimeException.php',
'ZfrPusher\\Service\\Exception\\UnauthorizedException' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/UnauthorizedException.php',
'ZfrPusher\\Service\\Exception\\UnknownResourceException' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Service/Exception/UnknownResourceException.php',
'ZfrPusher\\Service\\PusherService' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Service/PusherService.php',
'ZfrPusher\\Version' => __DIR__ . '/..' . '/zfr/zfr-pusher/src/ZfrPusher/Version.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9::$prefixesPsr0;
$loader->classMap = ComposerStaticInitfe7d3cb9e3e556360705ee29bb11bde9::$classMap;
}, null, ClassLoader::class);
}
......
This diff is collapsed.
......@@ -2,6 +2,60 @@
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 2.9.0 - 2019-08-29
### Added
- [#178](https://github.com/zendframework/zend-cache/pull/178) adds support for PHP 7.3.
### Changed
- [#186](https://github.com/zendframework/zend-cache/pull/186) replaces
deprecated `delete()` calls with `del()` in Redis adapter. `delete()`
function is deprecated since version 5.0.0 and `del()` is available
since version 2.1.0.
### Deprecated
- Nothing.
### Removed
- [#178](https://github.com/zendframework/zend-cache/pull/178) removes support for zend-stdlib v2 releases.
### Fixed
- Nothing.
## 2.8.3 - 2019-08-28
### Added
- Nothing.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#184](https://github.com/zendframework/zend-cache/pull/184) fixes
an issue with SimpleCacheDecorator where elements were deleted
after creation. Wrong TTL was set instead of using default value
from options.
- [#182](https://github.com/zendframework/zend-cache/pull/182) fixes
a typo in variable name within the `ExtMongoDbResourceManager::getResource`
method which prevented using custom db name when using that adapter.
## 2.8.2 - 2018-05-01
### Added
......
......@@ -23,7 +23,7 @@
"psr/simple-cache": "^1.0",
"zendframework/zend-eventmanager": "^2.6.3 || ^3.2",
"zendframework/zend-servicemanager": "^2.7.8 || ^3.3",
"zendframework/zend-stdlib": "^2.7.7 || ^3.1"
"zendframework/zend-stdlib": "^3.2.1"
},
"require-dev": {
"cache/integration-tests": "^0.16",
......@@ -76,8 +76,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.8.x-dev",
"dev-develop": "2.9.x-dev"
"dev-master": "2.9.x-dev",
"dev-develop": "2.10.x-dev"
},
"zf": {
"component": "Zend\\Cache",
......
......@@ -297,7 +297,7 @@ class CaptureCache extends AbstractPattern
ErrorHandler::start();
if ($perm === false) {
// build-in mkdir function is enough
// built-in mkdir function is enough
$umask = ($umask !== false) ? umask($umask) : false;
$res = mkdir($pathname, ($perm !== false) ? $perm : 0775, true);
......@@ -318,7 +318,7 @@ class CaptureCache extends AbstractPattern
throw new Exception\RuntimeException("chmod('{$pathname}', 0{$oct}) failed", 0, $err);
}
} else {
// build-in mkdir function sets permission together with current umask
// built-in mkdir function sets permission together with current umask
// which doesn't work well on multo threaded webservers
// -> create directories one by one and set permissions
......
......@@ -152,7 +152,7 @@ class PatternOptions extends AbstractOptions
public function __construct($options = null)
{
// disable file/directory permissions by default on windows systems
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
if (stripos(PHP_OS, 'WIN') === 0) {
$this->filePermission = false;
$this->dirPermission = false;
}
......@@ -446,7 +446,7 @@ class PatternOptions extends AbstractOptions
);
} elseif ($filePermission & 0111) {
throw new Exception\InvalidArgumentException(
"Invalid file permission: Files shoudn't be executable"
"Invalid file permission: Files shouldn't be executable"
);
}
}
......
......@@ -104,7 +104,7 @@ class CacheItemPoolDecorator implements CacheItemPoolInterface
$keys = array_diff($keys, array_keys($items));
if (count($keys)) {
if ($keys) {
try {
$cacheItems = $this->storage->getItems($keys);
} catch (Exception\InvalidArgumentException $e) {
......
<?php
/**
* @see https://github.com/zendframework/zend-cache for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2018-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License
*/
......@@ -113,7 +113,10 @@ class SimpleCacheDecorator implements SimpleCacheInterface
$options = $this->storage->getOptions();
$previousTtl = $options->getTtl();
$options->setTtl($ttl);
if ($ttl !== null) {
$options->setTtl($ttl);
}
try {
$result = $this->storage->setItem($key, $value);
......@@ -213,7 +216,10 @@ class SimpleCacheDecorator implements SimpleCacheInterface
$options = $this->storage->getOptions();
$previousTtl = $options->getTtl();
$options->setTtl($ttl);
if ($ttl !== null) {
$options->setTtl($ttl);
}
try {
$result = $this->storage->setItems($values);
......
......@@ -220,7 +220,6 @@ class Dba extends AbstractAdapter implements
}
$prefix = $namespace . $this->getOptions()->getNamespaceSeparator();
$prefixl = strlen($prefix);
$result = true;
$this->_open();
......@@ -230,7 +229,7 @@ class Dba extends AbstractAdapter implements
$recheck = false;
$internalKey = dba_firstkey($this->handle);
while ($internalKey !== false && $internalKey !== null) {
if (substr($internalKey, 0, $prefixl) === $prefix) {
if (strpos($internalKey, $prefix) === 0) {
$result = dba_delete($internalKey, $this->handle) && $result;
}
......@@ -259,7 +258,6 @@ class Dba extends AbstractAdapter implements
$options = $this->getOptions();
$namespace = $options->getNamespace();
$prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator() . $prefix;
$prefixL = strlen($prefix);
$result = true;
$this->_open();
......@@ -269,7 +267,7 @@ class Dba extends AbstractAdapter implements
$recheck = false;
$internalKey = dba_firstkey($this->handle);
while ($internalKey !== false && $internalKey !== null) {
if (substr($internalKey, 0, $prefixL) === $prefix) {
if (strpos($internalKey, $prefix) === 0) {
$result = dba_delete($internalKey, $this->handle) && $result;
$recheck = true;
}
......
<?php
/**
* @see https://github.com/zendframework/zend-cache for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @copyright Copyright (c) 2018-2019 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-cache/blob/master/LICENSE.md New BSD License
*/
......@@ -98,7 +98,7 @@ class ExtMongoDbResourceManager
}
$collection = $resource['client_instance']->selectCollection(
isset($resouce['db']) ? $resource['db'] : 'zend',
isset($resource['db']) ? $resource['db'] : 'zend',
isset($resource['collection']) ? $resource['collection'] : 'cache'
);
$collection->createIndex(['key' => 1]);
......
......@@ -1451,7 +1451,7 @@ class Filesystem extends AbstractAdapter implements
ErrorHandler::start();
if ($perm === false || $level == 1) {
// build-in mkdir function is enough
// built-in mkdir function is enough
$umask = ($umask !== false) ? umask($umask) : false;
$res = mkdir($pathname, ($perm !== false) ? $perm : 0775, true);
......@@ -1480,7 +1480,7 @@ class Filesystem extends AbstractAdapter implements
throw new Exception\RuntimeException("chmod('{$pathname}', 0{$oct}) failed", 0, $err);
}
} else {
// build-in mkdir function sets permission together with current umask
// built-in mkdir function sets permission together with current umask
// which doesn't work well on multo threaded webservers
// -> create directories one by one and set permissions
......
......@@ -119,7 +119,7 @@ class FilesystemOptions extends AdapterOptions
public function __construct($options = null)
{
// disable file/directory permissions by default on windows systems
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
if (stripos(PHP_OS, 'WIN') === 0) {
$this->filePermission = false;
$this->dirPermission = false;
}
......@@ -322,7 +322,7 @@ class FilesystemOptions extends AdapterOptions
);
} elseif ($filePermission & 0111) {
throw new Exception\InvalidArgumentException(
"Invalid file permission: Cache files shoudn't be executable"
"Invalid file permission: Cache files shouldn't be executable"
);
}
}
......
......@@ -332,7 +332,7 @@ class MemcachedResourceManager
$reflection = new ReflectionClass('Memcached');
$constants = $reflection->getConstants();
foreach ($constants as $constName => $constValue) {
if (substr($constName, 0, 4) == 'OPT_') {
if (strpos($constName, 'OPT_') === 0) {
$libOptions[$constValue] = $resource->getOption($constValue);
}
}
......
......@@ -203,10 +203,9 @@ class Memory extends AbstractAdapter implements
return true;
}
$prefixL = strlen($prefix);
$data = & $this->data[$ns];
foreach ($data as $key => & $item) {
if (substr($key, 0, $prefixL) === $prefix) {
if (strpos($key, $prefix) === 0) {
unset($data[$key]);
}
}
......
......@@ -356,7 +356,7 @@ class Redis extends AbstractAdapter implements
{
$redis = $this->getRedisResource();
try {
return (bool) $redis->delete($this->namespacePrefix . $normalizedKey);
return (bool) $redis->del($this->namespacePrefix . $normalizedKey);
} catch (RedisResourceException $e) {
throw new Exception\RuntimeException($redis->getLastError(), $e->getCode(), $e);
}
......@@ -434,7 +434,7 @@ class Redis extends AbstractAdapter implements
$options = $this->getOptions();
$prefix = $namespace . $options->getNamespaceSeparator();
$redis->delete($redis->keys($prefix . '*'));
$redis->del($redis->keys($prefix . '*'));
return true;
}
......@@ -460,7 +460,7 @@ class Redis extends AbstractAdapter implements
$namespace = $options->getNamespace();
$prefix = ($namespace === '') ? '' : $namespace . $options->getNamespaceSeparator() . $prefix;
$redis->delete($redis->keys($prefix.'*'));
$redis->del($redis->keys($prefix.'*'));
return true;
}
......
......@@ -299,7 +299,7 @@ class RedisResourceManager
}
if (! $success) {
throw new Exception\RuntimeException('Could not estabilish connection with Redis instance');
throw new Exception\RuntimeException('Could not establish connection with Redis instance');
}
$resource['initialized'] = true;
......@@ -492,7 +492,7 @@ class RedisResourceManager
$reflection = new ReflectionClass('Redis');
$constants = $reflection->getConstants();
foreach ($constants as $constName => $constValue) {
if (substr($constName, 0, 4) == 'OPT_') {
if (strpos($constName, 'OPT_') === 0) {
$libOptions[$constValue] = $resource['resource']->getOption($constValue);
}
}
......
......@@ -123,9 +123,8 @@ class Session extends AbstractAdapter implements
}
$data = $cntr->offsetGet($ns);
$prefixL = strlen($prefix);
foreach ($data as $key => & $item) {
if (substr($key, 0, $prefixL) === $prefix) {
if (strpos($key, $prefix) === 0) {
unset($data[$key]);
}
}
......
......@@ -122,7 +122,7 @@ class Capabilities
protected $supportedDatatypes;
/**
* Supported metdata
* Supported metadata
*
* If it's NULL the capability isn't set and the getter
* returns the base capability or the default value.
......
......@@ -2,6 +2,33 @@
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 3.3.0 - 2019-06-08
### Added
- [#54](https://github.com/zendframework/zend-config/pull/54) adds support for PHP 7.3.
- [#58](https://github.com/zendframework/zend-config/pull/58) adds
`$processSections` to INI reader, allowing control over whether sections
should be parsed or not
- [#63](https://github.com/zendframework/zend-config/pull/63) adds .yml to
Zend\Config\Factory as an alternative extension for yaml
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- Nothing.
## 3.2.0 - 2018-04-24
### Added
......
......@@ -52,8 +52,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.2.x-dev",
"dev-develop": "3.3.x-dev"
"dev-master": "3.3.x-dev",
"dev-develop": "3.4.x-dev"
}
},
"scripts": {
......
......@@ -192,6 +192,6 @@ class AbstractConfigFactory implements AbstractFactoryInterface
return $matches[1];
}
}
return;
return null;
}
}
......@@ -37,6 +37,7 @@ class Factory
'json' => 'json',
'xml' => 'xml',
'yaml' => 'yaml',
'yml' => 'yaml',
'properties' => 'javaproperties',
];
......@@ -52,6 +53,7 @@ class Factory
'json' => 'json',
'xml' => 'xml',
'yaml' => 'yaml',
'yml' => 'yaml',
];
/**
......
......@@ -116,7 +116,7 @@ class Constant extends Token implements ProcessorInterface
return parent::doProcess($value, $replacements);
}
$class = substr($value, 0, strlen($value) - 7);
$class = substr($value, 0, -7);
if (class_exists($class)) {
return $class;
}
......
<?php
/**
* @see https://github.com/zendframework/zend-config for the canonical source repository
* @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-config/blob/master/LICENSE.md New BSD License
*/
......@@ -28,6 +28,14 @@ class Ini implements ReaderInterface
*/
protected $directory;
/**
* Flag which determines whether sections are processed or not.
*
* @see https://www.php.net/parse_ini_file
* @var bool
*/
protected $processSections = true;
/**
* Set nest separator.
*
......@@ -50,6 +58,34 @@ class Ini implements ReaderInterface
return $this->nestSeparator;
}
/**
* Marks whether sections should be processed.
* When sections are not processed,section names are stripped and section
* values are merged
*
* @see https://www.php.net/parse_ini_file
* @param bool $processSections
* @return $this
*/
public function setProcessSections($processSections)
{
$this->processSections = (bool) $processSections;
return $this;
}
/**
* Get if sections should be processed
* When sections are not processed,section names are stripped and section
* values are merged
*
* @see https://www.php.net/parse_ini_file
* @return bool
*/
public function getProcessSections()
{
return $this->processSections;
}
/**
* fromFile(): defined by Reader interface.
*
......@@ -78,7 +114,7 @@ class Ini implements ReaderInterface
},
E_WARNING
);
$ini = parse_ini_file($filename, true);
$ini = parse_ini_file($filename, $this->getProcessSections());
restore_error_handler();
return $this->process($ini);
......@@ -107,7 +143,7 @@ class Ini implements ReaderInterface
},
E_WARNING
);
$ini = parse_ini_string($string, true);
$ini = parse_ini_string($string, $this->getProcessSections());
restore_error_handler();
return $this->process($ini);
......@@ -148,7 +184,7 @@ class Ini implements ReaderInterface
*/
private function buildNestedSection($sections, $value)
{
if (count($sections) == 0) {
if (! $sections) {
return $this->processSection($value);
}
......@@ -191,9 +227,11 @@ class Ini implements ReaderInterface
if (strpos($key, $this->nestSeparator) !== false) {
$pieces = explode($this->nestSeparator, $key, 2);
if (! strlen($pieces[0]) || ! strlen($pieces[1])) {
if ($pieces[0] === '' || $pieces[1] === '') {
throw new Exception\RuntimeException(sprintf('Invalid key "%s"', $key));
} elseif (! isset($config[$pieces[0]])) {
}
if (! isset($config[$pieces[0]])) {
if ($pieces[0] === '0' && ! empty($config)) {
$config = [$pieces[0] => $config];
} else {
......
......@@ -138,7 +138,7 @@ class JavaProperties implements ReaderInterface
$delimLength = strlen($delimiter);
$result = [];
$lines = explode("\n", $string);
$key = "";
$key = '';
$isWaitingOtherLine = false;
foreach ($lines as $i => $line) {
// Ignore empty lines and commented lines
......@@ -159,7 +159,7 @@ class JavaProperties implements ReaderInterface
// Check if ends with single '\' (indicating another line is expected)
if (strrpos($value, "\\") === strlen($value) - strlen("\\")) {
$value = substr($value, 0, strlen($value) - 1);
$value = substr($value, 0, -1);
$isWaitingOtherLine = true;
} else {
$isWaitingOtherLine = false;
......
......@@ -143,13 +143,17 @@ class Ini extends AbstractWriter
{
if (is_int($value) || is_float($value)) {
return $value;
} elseif (is_bool($value)) {
}
if (is_bool($value)) {
return ($value ? 'true' : 'false');
} elseif (false === strpos($value, '"')) {
}
if (false === strpos($value, '"')) {
return '"' . $value . '"';
} else {
throw new Exception\RuntimeException('Value can not contain double quotes');
}
throw new Exception\RuntimeException('Value can not contain double quotes');
}
/**
......
......@@ -2,7 +2,107 @@
All notable changes to this project will be documented in this file, in reverse chronological order by release.
## 2.9.3 - TBD
## 2.11.0 - 2019-12-31
### Added
- [#336](https://github.com/zendframework/zend-db/pull/336) adds `InsertIgnore` class for "INSERT IGNORE" usage (usable in `MySQL` platform).
- [#356](https://github.com/zendframework/zend-db/pull/356) adds support for `IN (NULL)` for empty value-set.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#146](https://github.com/zendframework/zend-db/pull/146) fixes setting correct value for `lastInsertValue` pre-insert in `SequenceFeature`.
## 2.10.1 - 2019-12-31
- Nothing.
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#382](https://github.com/zendframework/zend-db/pull/382) fixes `Zend\Db\Sql\Expression` to allow `0` value for parameter.
- [#395](https://github.com/zendframework/zend-db/pull/395) fixes PHP 7.4 compatibility.
- [#392](https://github.com/zendframework/zend-db/pull/392) fixes `MetadataFeature` to work with `TableIdentifier`.
- [#399](https://github.com/zendframework/zend-db/pull/399) fixes accessing constraint metadata within the Oracle adapter.
- [#375](https://github.com/zendframework/zend-db/pull/375) fixes detecting number of replacements in `Zend\Db\Sql\Expression`.
- [#377](https://github.com/zendframework/zend-db/pull/377) allows any `AdapterInterface` instance in `RowGateway`.
- [#342](https://github.com/zendframework/zend-db/pull/342) fixes deleting from aliased tables.
- [#386](https://github.com/zendframework/zend-db/pull/386) fixes too strongly casting integer parameters in PDO adapter.
## 2.10.0 - 2019-02-25
### Added
- [#157](https://github.com/zendframework/zend-db/pull/157) added support of
`Zend\Db\Sql\TableIdentifier` in DDL
- [#345](https://github.com/zendframework/zend-db/pull/345) allow usage with
zend-hydrator v3
- [#346](https://github.com/zendframework/zend-db/pull/346) adds support for PHP
7.3
### Changed
- Nothing.
### Deprecated
- Nothing.
### Removed
- Nothing.
### Fixed
- [#303](https://github.com/zendframework/zend-db/pull/303) fixes #295 issue:
handle empty array as datasource at `AbstractResultSet::initialize()` at PHP
7.2
- [#313](https://github.com/zendframework/zend-db/pull/313) test
`AbstractResultSet::current()` to return null on empty array
- [#329](https://github.com/zendframework/zend-db/pull/329) fixes Exception
thrown when calling `prepareStatementForSqlObject` on a Select with a
sub-Select that has limit and/or offset set
- [#337](https://github.com/zendframework/zend-db/pull/337) fixes #330 current
NULL for mysqli
- [#338](https://github.com/zendframework/zend-db/pull/338) restore missing use
`ResultSet` in `AbstractTableGateway`
- [#341](https://github.com/zendframework/zend-db/pull/341) fixes undefined
variable bug in MetadataFeature
- [#357](https://github.com/zendframework/zend-db/pull/357) fixes named params
in subquery - limit and offset (issue #355)
## 2.9.3 - 2018-04-09
### Added
......@@ -22,7 +122,19 @@ All notable changes to this project will be documented in this file, in reverse
### Fixed
- [#295](https://github.com/zendframework/zend-db/pull/295) fix error when datasource passed to `AbstractResultSet::initialize()` is empty array at php 7.2 environment.
- [#295](https://github.com/zendframework/zend-db/pull/295) fix error when
datasource passed to `AbstractResultSet::initialize()` is empty array at
php 7.2 environment
- [#300](https://github.com/zendframework/zend-db/pull/300) Fix error for nested
queries inside field parameters
- [#301](https://github.com/zendframework/zend-db/pull/301) fix for issue with
set fields that exists in different tables in one query
- [#304](https://github.com/zendframework/zend-db/pull/304) fix PDO bind
parameter name to use field name with extended charset (PDO only supports
alphanumeric and underscore for placeholder/parameter names).
## 2.9.2 - 2017-12-11
......
Copyright (c) 2005-2017, Zend Technologies USA, Inc.
Copyright (c) 2005-2019, Zend Technologies USA, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
......
......@@ -12,7 +12,7 @@
"issues": "https://github.com/zendframework/zend-db/issues",
"source": "https://github.com/zendframework/zend-db",
"rss": "https://github.com/zendframework/zend-db/releases.atom",
"slack": "https://zendframework-slack.herokuapp.com",
"chat": "https://zendframework-slack.herokuapp.com",
"forum": "https://discourse.zendframework.com/c/questions/components"
},
"require": {
......@@ -20,10 +20,10 @@
"zendframework/zend-stdlib": "^2.7 || ^3.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.25 || ^6.4.4",
"phpunit/phpunit": "^5.7.27 || ^6.5.14",
"zendframework/zend-coding-standard": "~1.0.0",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
"zendframework/zend-hydrator": "^1.1 || ^2.1",
"zendframework/zend-hydrator": "^1.1 || ^2.1 || ^3.0",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3"
},
"suggest": {
......@@ -50,8 +50,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.9-dev",
"dev-develop": "2.10-dev"
"dev-master": "2.11.x-dev",
"dev-develop": "2.12.x-dev"
},
"zf": {
"component": "Zend\\Db",
......@@ -67,7 +67,7 @@
"cs-fix": "phpcbf",
"test": "phpunit --colors=always --testsuite \"unit test\"",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"test-integration" : "phpunit --colors=always --testsuite \"integration test\"",
"test-integration": "phpunit --colors=always --testsuite \"integration test\"",
"upload-coverage": "coveralls -v"
}
}
<?xml version="1.0"?>
<ruleset name="Zend Framework coding standard">
<rule ref="./vendor/zendframework/zend-coding-standard/ruleset.xml" />
<rule ref="PSR1.Files.SideEffects">
<exclude-pattern>*/test/unit/Adapter/Driver/IbmDb2/StatementTest.php</exclude-pattern>
</rule>
<!-- Paths to check -->
<file>src</file>
<file>test</file>
</ruleset>
......@@ -51,9 +51,9 @@ class Result implements
protected $nextComplete = false;
/**
* @var bool
* @var mixed
*/
protected $currentData = false;
protected $currentData = null;
/**
*
......
......@@ -171,7 +171,6 @@ class Connection extends AbstractConnection
if (strpos($value, 'pdo') === 0) {
$pdoDriver = str_replace(['-', '_', ' '], '', $value);
$pdoDriver = substr($pdoDriver, 3) ?: '';
$pdoDriver = strtolower($pdoDriver);
}
break;
case 'pdodriver':
......
......@@ -136,7 +136,7 @@ class Result implements Iterator, ResultInterface
/**
* Get the data
* @return array
* @return mixed
*/
public function current()
{
......
......@@ -269,8 +269,6 @@ class Statement implements StatementInterface, Profiler\ProfilerAwareInterface
foreach ($parameters as $name => &$value) {
if (is_bool($value)) {
$type = \PDO::PARAM_BOOL;
} elseif (is_int($value)) {
$type = \PDO::PARAM_INT;
} else {
$type = \PDO::PARAM_STR;
}
......
......@@ -172,6 +172,8 @@ class OracleMetadata extends AbstractSource
}
}
$this->data['constraints'][$schema][$table] = $constraints;
return $this;
}
......
......@@ -11,6 +11,7 @@ namespace Zend\Db\ResultSet;
use ArrayObject;
use Zend\Hydrator\ArraySerializable;
use Zend\Hydrator\ArraySerializableHydrator;
use Zend\Hydrator\HydratorInterface;
class HydratingResultSet extends AbstractResultSet
......@@ -33,7 +34,10 @@ class HydratingResultSet extends AbstractResultSet
*/
public function __construct(HydratorInterface $hydrator = null, $objectPrototype = null)
{
$this->setHydrator(($hydrator) ?: new ArraySerializable);
$defaultHydratorClass = class_exists(ArraySerializableHydrator::class)
? ArraySerializableHydrator::class
: ArraySerializable::class;
$this->setHydrator($hydrator ?: new $defaultHydratorClass());
$this->setObjectPrototype(($objectPrototype) ?: new ArrayObject);
}
......
......@@ -46,7 +46,7 @@ class ResultSet extends AbstractResultSet
*/
public function __construct($returnType = self::TYPE_ARRAYOBJECT, $arrayObjectPrototype = null)
{
if (in_array($returnType, [self::TYPE_ARRAY, self::TYPE_ARRAYOBJECT])) {
if (in_array($returnType, $this->allowedReturnTypes, true)) {
$this->returnType = $returnType;
} else {
$this->returnType = self::TYPE_ARRAYOBJECT;
......
......@@ -204,7 +204,9 @@ abstract class AbstractRowGateway implements ArrayAccess, Countable, RowGatewayI
$where = [];
// primary key is always an array even if its a single column
foreach ($this->primaryKeyColumn as $pkColumn) {
$where[$pkColumn] = $this->primaryKeyData[$pkColumn];
$where[$pkColumn] = isset($this->primaryKeyData[$pkColumn])
? $this->primaryKeyData[$pkColumn]
: null;
}
// @todo determine if we need to do a select to ensure 1 row will be affected
......
......@@ -9,7 +9,7 @@
namespace Zend\Db\RowGateway;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Adapter\AdapterInterface;
use Zend\Db\Sql\Sql;
class RowGateway extends AbstractRowGateway
......@@ -19,7 +19,7 @@ class RowGateway extends AbstractRowGateway
*
* @param string $primaryKeyColumn
* @param string|\Zend\Db\Sql\TableIdentifier $table
* @param Adapter|Sql $adapterOrSql
* @param AdapterInterface|Sql $adapterOrSql
* @throws Exception\InvalidArgumentException
*/
public function __construct($primaryKeyColumn, $table, $adapterOrSql = null)
......@@ -33,7 +33,7 @@ class RowGateway extends AbstractRowGateway
// set Sql object
if ($adapterOrSql instanceof Sql) {
$this->sql = $adapterOrSql;
} elseif ($adapterOrSql instanceof Adapter) {
} elseif ($adapterOrSql instanceof AdapterInterface) {
$this->sql = new Sql($adapterOrSql, $this->table);
} else {
throw new Exception\InvalidArgumentException('A valid Sql object was not provided.');
......
......@@ -11,6 +11,7 @@ namespace Zend\Db\Sql\Ddl;
use Zend\Db\Adapter\Platform\PlatformInterface;
use Zend\Db\Sql\AbstractSql;
use Zend\Db\Sql\TableIdentifier;
class AlterTable extends AbstractSql implements SqlInterface
{
......@@ -85,7 +86,7 @@ class AlterTable extends AbstractSql implements SqlInterface
protected $table = '';
/**
* @param string $table
* @param string|TableIdentifier $table
*/
public function __construct($table = '')
{
......@@ -179,7 +180,7 @@ class AlterTable extends AbstractSql implements SqlInterface
protected function processTable(PlatformInterface $adapterPlatform = null)
{
return [$adapterPlatform->quoteIdentifier($this->table)];
return [$this->resolveTable($this->table, $adapterPlatform)];
}
protected function processAddColumns(PlatformInterface $adapterPlatform = null)
......
......@@ -11,6 +11,7 @@ namespace Zend\Db\Sql\Ddl;
use Zend\Db\Adapter\Platform\PlatformInterface;
use Zend\Db\Sql\AbstractSql;
use Zend\Db\Sql\TableIdentifier;
class CreateTable extends AbstractSql implements SqlInterface
{
......@@ -58,7 +59,7 @@ class CreateTable extends AbstractSql implements SqlInterface
protected $table = '';
/**
* @param string $table
* @param string|TableIdentifier $table
* @param bool $isTemporary
*/
public function __construct($table = '', $isTemporary = false)
......@@ -139,7 +140,7 @@ class CreateTable extends AbstractSql implements SqlInterface
{
return [
$this->isTemporary ? 'TEMPORARY ' : '',
$adapterPlatform->quoteIdentifier($this->table),
$this->resolveTable($this->table, $adapterPlatform),
];
}
......
......@@ -11,6 +11,7 @@ namespace Zend\Db\Sql\Ddl;
use Zend\Db\Adapter\Platform\PlatformInterface;
use Zend\Db\Sql\AbstractSql;
use Zend\Db\Sql\TableIdentifier;
class DropTable extends AbstractSql implements SqlInterface
{
......@@ -29,7 +30,7 @@ class DropTable extends AbstractSql implements SqlInterface
protected $table = '';
/**
* @param string $table
* @param string|TableIdentifier $table
*/
public function __construct($table = '')
{
......@@ -38,6 +39,6 @@ class DropTable extends AbstractSql implements SqlInterface
protected function processTable(PlatformInterface $adapterPlatform = null)
{
return [$adapterPlatform->quoteIdentifier($this->table)];
return [$this->resolveTable($this->table, $adapterPlatform)];
}
}
......@@ -56,7 +56,7 @@ class Expression extends AbstractExpression
}
}
if ($parameters) {
if ($parameters !== null) {
$this->setParameters($parameters);
}
}
......@@ -135,7 +135,7 @@ class Expression extends AbstractExpression
$parametersCount = count($parameters);
$expression = str_replace('%', '%%', $this->expression);
if ($parametersCount == 0) {
if ($parametersCount === 0) {
return [
str_ireplace(self::PLACEHOLDER, '', $expression)
];
......@@ -146,10 +146,13 @@ class Expression extends AbstractExpression
// test number of replacements without considering same variable begin used many times first, which is
// faster, if the test fails then resort to regex which are slow and used rarely
if ($count !== $parametersCount && $parametersCount === preg_match_all('/\:[a-zA-Z0-9_]*/', $expression)) {
throw new Exception\RuntimeException(
'The number of replacements in the expression does not match the number of parameters'
);
if ($count !== $parametersCount) {
preg_match_all('/\:\w*/', $expression, $matches);
if ($parametersCount !== count(array_unique($matches[0]))) {
throw new Exception\RuntimeException(
'The number of replacements in the expression does not match the number of parameters'
);
}
}
foreach ($parameters as $parameter) {
......
......@@ -52,7 +52,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface
if ($parameterContainer) {
$paramPrefix = $this->processInfo['paramPrefix'];
$parameterContainer->offsetSet($paramPrefix . 'limit', $this->limit, ParameterContainer::TYPE_INTEGER);
return [$driver->formatParameterName('limit')];
return [$driver->formatParameterName($paramPrefix . 'limit')];
}
return [$this->limit];
......@@ -69,7 +69,7 @@ class SelectDecorator extends Select implements PlatformDecoratorInterface
if ($parameterContainer) {
$paramPrefix = $this->processInfo['paramPrefix'];
$parameterContainer->offsetSet($paramPrefix . 'offset', $this->offset, ParameterContainer::TYPE_INTEGER);
return [$driver->formatParameterName('offset')];
return [$driver->formatParameterName($paramPrefix . 'offset')];
}
return [$this->offset];
......
......@@ -102,8 +102,9 @@ class In extends AbstractExpression implements PredicateInterface
$replacements = [];
if (is_array($identifier)) {
$identifierSpecFragment = '(' . implode(', ', array_fill(0, count($identifier), '%s')) . ')';
$types = array_fill(0, count($identifier), self::TYPE_IDENTIFIER);
$countIdentifier = count($identifier);
$identifierSpecFragment = '(' . implode(', ', array_fill(0, $countIdentifier, '%s')) . ')';
$types = array_fill(0, $countIdentifier, self::TYPE_IDENTIFIER);
$replacements = $identifier;
} else {
$identifierSpecFragment = '%s';
......@@ -122,10 +123,15 @@ class In extends AbstractExpression implements PredicateInterface
foreach ($values as $argument) {
list($replacements[], $types[]) = $this->normalizeArgument($argument, self::TYPE_VALUE);
}
$valuePlaceholders = count($values) > 0 ? array_fill(0, count($values), '%s') : [];
$countValues = count($values);
$valuePlaceholders = $countValues > 0 ? array_fill(0, $countValues, '%s') : [];
$inValueList = implode(', ', $valuePlaceholders);
if ('' === $inValueList) {
$inValueList = 'NULL';
}
$specification = vsprintf(
$this->specification,
[$identifierSpecFragment, '(' . implode(', ', $valuePlaceholders) . ')']
[$identifierSpecFragment, '(' . $inValueList . ')']
);
}
......
......@@ -84,9 +84,9 @@ class PredicateSet implements PredicateInterface, Countable
}
if (is_string($predicates)) {
// String $predicate should be passed as an expression
$predicates = (strpos($predicates, Expression::PLACEHOLDER) !== false)
$predicate = (strpos($predicates, Expression::PLACEHOLDER) !== false)
? new Expression($predicates) : new Literal($predicates);
$this->addPredicate($predicates, $combination);
$this->addPredicate($predicate, $combination);
return $this;
}
if (is_array($predicates)) {
......@@ -96,31 +96,31 @@ class PredicateSet implements PredicateInterface, Countable
if (strpos($pkey, '?') !== false) {
// First, process strings that the abstraction replacement character ?
// as an Expression predicate
$predicates = new Expression($pkey, $pvalue);
$predicate = new Expression($pkey, $pvalue);
} elseif ($pvalue === null) {
// Otherwise, if still a string, do something intelligent with the PHP type provided
// map PHP null to SQL IS NULL expression
$predicates = new IsNull($pkey);
$predicate = new IsNull($pkey);
} elseif (is_array($pvalue)) {
// if the value is an array, assume IN() is desired
$predicates = new In($pkey, $pvalue);
$predicate = new In($pkey, $pvalue);
} elseif ($pvalue instanceof PredicateInterface) {
throw new Exception\InvalidArgumentException(
'Using Predicate must not use string keys'
);
} else {
// otherwise assume that array('foo' => 'bar') means "foo" = 'bar'
$predicates = new Operator($pkey, Operator::OP_EQ, $pvalue);
$predicate = new Operator($pkey, Operator::OP_EQ, $pvalue);
}
} elseif ($pvalue instanceof PredicateInterface) {
// Predicate type is ok
$predicates = $pvalue;
$predicate = $pvalue;
} else {
// must be an array of expressions (with int-indexed array)
$predicates = (strpos($pvalue, Expression::PLACEHOLDER) !== false)
$predicate = (strpos($pvalue, Expression::PLACEHOLDER) !== false)
? new Expression($pvalue) : new Literal($pvalue);
}
$this->addPredicate($predicates, $combination);
$this->addPredicate($predicate, $combination);
}
}
return $this;
......
......@@ -17,6 +17,7 @@ use Zend\Db\Adapter\Platform\PlatformInterface;
*
* @property Where $where
* @property Having $having
* @property Join $joins
*/
class Select extends AbstractPreparableSql
{
......@@ -328,7 +329,7 @@ class Select extends AbstractPreparableSql
}
/**
* @param string|array $order
* @param string|array|Expression $order
* @return self Provides a fluent interface
*/
public function order($order)
......@@ -716,7 +717,7 @@ class Select extends AbstractPreparableSql
if ($parameterContainer) {
$paramPrefix = $this->processInfo['paramPrefix'];
$parameterContainer->offsetSet($paramPrefix . 'limit', $this->limit, ParameterContainer::TYPE_INTEGER);
return [$driver->formatParameterName('limit')];
return [$driver->formatParameterName($paramPrefix . 'limit')];
}
return [$platform->quoteValue($this->limit)];
}
......@@ -732,7 +733,7 @@ class Select extends AbstractPreparableSql
if ($parameterContainer) {
$paramPrefix = $this->processInfo['paramPrefix'];
$parameterContainer->offsetSet($paramPrefix . 'offset', $this->offset, ParameterContainer::TYPE_INTEGER);
return [$driver->formatParameterName('offset')];
return [$driver->formatParameterName($paramPrefix . 'offset')];
}
return [$platform->quoteValue($this->offset)];
......
......@@ -158,7 +158,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface
/**
* Get select result prototype
*
* @return ResultSet
* @return ResultSetInterface
*/
public function getResultSetPrototype()
{
......@@ -177,7 +177,7 @@ abstract class AbstractTableGateway implements TableGatewayInterface
* Select
*
* @param Where|\Closure|string|array $where
* @return ResultSet
* @return ResultSetInterface
*/
public function select($where = null)
{
......@@ -199,7 +199,6 @@ abstract class AbstractTableGateway implements TableGatewayInterface
/**
* @param Select $select
* @return ResultSetInterface
* @throws \RuntimeException
*/
public function selectWith(Select $select)
{
......@@ -211,13 +210,14 @@ abstract class AbstractTableGateway implements TableGatewayInterface
/**
* @param Select $select
* @return ResultSet
* @return ResultSetInterface
* @throws Exception\RuntimeException
*/
protected function executeSelect(Select $select)
{
$selectState = $select->getRawState();
if ($selectState['table'] != $this->table
if (isset($selectState['table'])
&& $selectState['table'] != $this->table
&& (is_array($selectState['table'])
&& end($selectState['table']) != $this->table)
) {
......@@ -226,7 +226,8 @@ abstract class AbstractTableGateway implements TableGatewayInterface
);
}
if ($selectState['columns'] == [Select::SQL_STAR]
if (isset($selectState['columns'])
&& $selectState['columns'] == [Select::SQL_STAR]
&& $this->columns !== []) {
$select->columns($this->columns);
}
......@@ -450,12 +451,24 @@ abstract class AbstractTableGateway implements TableGatewayInterface
// pre delete update
$this->featureSet->apply(EventFeatureEventsInterface::EVENT_PRE_DELETE, [$delete]);
$unaliasedTable = false;
if (is_array($deleteState['table'])) {
$tableData = array_values($deleteState['table']);
$unaliasedTable = array_shift($tableData);
$delete->from($unaliasedTable);
}
$statement = $this->sql->prepareStatementForSqlObject($delete);
$result = $statement->execute();
// apply postDelete features
$this->featureSet->apply(EventFeatureEventsInterface::EVENT_POST_DELETE, [$statement, $result]);
// Reset original table information in Delete instance, if necessary
if ($unaliasedTable) {
$delete->from($deleteState['table']);
}
return $result->getAffectedRows();
}
......
......@@ -13,6 +13,7 @@ use Zend\Db\Metadata\MetadataInterface;
use Zend\Db\TableGateway\Exception;
use Zend\Db\Metadata\Object\TableObject;
use Zend\Db\Metadata\Source\Factory as SourceFactory;
use Zend\Db\Sql\TableIdentifier;
class MetadataFeature extends AbstractFeature
{
......@@ -47,21 +48,31 @@ class MetadataFeature extends AbstractFeature
$t = $this->tableGateway;
$m = $this->metadata;
$tableGatewayTable = is_array($t->table) ? current($t->table) : $t->table;
if ($tableGatewayTable instanceof TableIdentifier) {
$table = $tableGatewayTable->getTable();
$schema = $tableGatewayTable->getSchema();
} else {
$table = $tableGatewayTable;
$schema = null;
}
// get column named
$columns = $m->getColumnNames($t->table);
$columns = $m->getColumnNames($table, $schema);
$t->columns = $columns;
// set locally
$this->sharedData['metadata']['columns'] = $columns;
// process primary key only if table is a table; there are no PK constraints on views
if (! ($m->getTable($t->table) instanceof TableObject)) {
if (! ($m->getTable($table, $schema) instanceof TableObject)) {
return;
}
$pkc = null;
foreach ($m->getConstraints($t->table) as $constraint) {
foreach ($m->getConstraints($table, $schema) as $constraint) {
/** @var $constraint \Zend\Db\Metadata\Object\ConstraintObject */
if ($constraint->getType() == 'PRIMARY KEY') {
$pkc = $constraint;
......@@ -73,11 +84,11 @@ class MetadataFeature extends AbstractFeature
throw new Exception\RuntimeException('A primary key for this column could not be found in the metadata.');
}
if (count($pkc->getColumns()) == 1) {
$pkck = $pkc->getColumns();
$primaryKey = $pkck[0];
$pkcColumns = $pkc->getColumns();
if (count($pkcColumns) === 1) {
$primaryKey = $pkcColumns[0];
} else {
$primaryKey = $pkc->getColumns();
$primaryKey = $pkcColumns;
}
$this->sharedData['metadata']['primaryKey'] = $primaryKey;
......
......@@ -47,6 +47,8 @@ class SequenceFeature extends AbstractFeature
*/
public function preInsert(Insert $insert)
{
$this->tableGateway->lastInsertValue = $this->lastSequenceId();
$columns = $insert->getRawState('columns');
$values = $insert->getRawState('values');
$key = array_search($this->primaryKeyField, $columns);
......@@ -70,9 +72,7 @@ class SequenceFeature extends AbstractFeature
*/
public function postInsert(StatementInterface $statement, ResultInterface $result)
{
if ($this->sequenceValue !== null) {
$this->tableGateway->lastInsertValue = $this->sequenceValue;
}
$this->tableGateway->lastInsertValue = $this->sequenceValue;
}
/**
......
Copyright (c) 2005-2018, Zend Technologies USA, Inc.
Copyright (c) 2005-2019, Zend Technologies USA, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
......
This diff is collapsed.
Copyright (c) 2005-2018, Zend Technologies USA, Inc.
Copyright (c) 2005-2019, Zend Technologies USA, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment