Browse Source

update shared memory pool api

PHP-GTK3
yggverse 4 months ago
parent
commit
74ac29f217
  1. 53
      src/Abstract/Model/Connection.php

53
src/Abstract/Model/Connection.php

@ -18,49 +18,43 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
// Set defaults // Set defaults
$this->_pool->set( $this->_pool->set(
'completed', 'completed'
false
); );
$this->_pool->set( $this->_pool->set(
'title', 'title'
null
); );
$this->_pool->set( $this->_pool->set(
'subtitle', 'subtitle'
null
); );
$this->_pool->set( $this->_pool->set(
'tooltip', 'tooltip'
null
); );
$this->_pool->set( $this->_pool->set(
'mime', 'mime'
null
); );
$this->_pool->set( $this->_pool->set(
'data', 'data'
null
); );
$this->_pool->set( $this->_pool->set(
'redirect', 'redirect'
null
); );
$this->_pool->set( $this->_pool->set(
'request', 'request'
null
); );
} }
public function isCompleted(): bool public function isCompleted(): bool
{ {
return $this->_pool->get( return boolval(
$this->_pool->get(
'completed' 'completed'
)
); );
} }
@ -70,7 +64,9 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
{ {
$this->_pool->set( $this->_pool->set(
'completed', 'completed',
strval(
$completed $completed
)
); );
} }
@ -178,11 +174,16 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
public function getRequest(): ?array public function getRequest(): ?array
{ {
return $this->_pool->get( if ($request = $this->_pool->get('request'))
'request' {
return unserialize(
$request
); );
} }
return null;
}
public function setRequest( public function setRequest(
?string $placeholder, ?string $placeholder,
bool $visible = true bool $visible = true
@ -190,27 +191,31 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
{ {
$this->_pool->set( $this->_pool->set(
'request', 'request',
serialize(
[ [
'placeholder' => $placeholder, 'placeholder' => $placeholder,
'visible' => $visible 'visible' => $visible
] ]
)
); );
} }
public function unsetRequest(): void public function unsetRequest(): void
{ {
$this->_pool->set( $this->_pool->set(
'request', 'request'
null
); );
} }
public function getLength(): ?int public function getLength(): ?int
{
if ($data = $this->_pool->get('data'))
{ {
return mb_strlen( return mb_strlen(
$this->_pool->get( $data
'data'
)
); );
} }
return null;
}
} }
Loading…
Cancel
Save