mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
call callbacks after running the stream operation
This commit is contained in:
parent
22966cdade
commit
acb8b69108
1 changed files with 7 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ namespace Icewind\Streams;
|
||||||
* ]
|
* ]
|
||||||
* ]
|
* ]
|
||||||
*
|
*
|
||||||
* All callbacks are called before the operation is executed on the source stream
|
* All callbacks are called after the operation is executed on the source stream
|
||||||
*/
|
*/
|
||||||
class CallBackWrapper extends Wrapper {
|
class CallBackWrapper extends Wrapper {
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,23 +54,26 @@ class CallBackWrapper extends Wrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_read($count) {
|
public function stream_read($count) {
|
||||||
|
$result = parent::stream_read($count);
|
||||||
if ($this->readCallback) {
|
if ($this->readCallback) {
|
||||||
call_user_func($this->readCallback, $count);
|
call_user_func($this->readCallback, $count);
|
||||||
}
|
}
|
||||||
return parent::stream_read($count);
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_write($data) {
|
public function stream_write($data) {
|
||||||
|
$result = parent::stream_write($data);
|
||||||
if ($this->writeCallback) {
|
if ($this->writeCallback) {
|
||||||
call_user_func($this->writeCallback, $data);
|
call_user_func($this->writeCallback, $data);
|
||||||
}
|
}
|
||||||
return parent::stream_write($data);
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_close() {
|
public function stream_close() {
|
||||||
|
$result = parent::stream_close();
|
||||||
if ($this->closeCallback) {
|
if ($this->closeCallback) {
|
||||||
call_user_func($this->closeCallback);
|
call_user_func($this->closeCallback);
|
||||||
}
|
}
|
||||||
return parent::stream_close();
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue