Browse Source

update shared memory pool api

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

71
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(
'completed' $this->_pool->get(
'completed'
)
); );
} }
@ -70,7 +64,9 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
{ {
$this->_pool->set( $this->_pool->set(
'completed', 'completed',
$completed strval(
$completed
)
); );
} }
@ -178,9 +174,14 @@ 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(
@ -190,27 +191,31 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection
{ {
$this->_pool->set( $this->_pool->set(
'request', 'request',
[ serialize(
'placeholder' => $placeholder, [
'visible' => $visible 'placeholder' => $placeholder,
] '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
{ {
return mb_strlen( if ($data = $this->_pool->get('data'))
$this->_pool->get( {
'data' return mb_strlen(
) $data
); );
}
return null;
} }
} }
Loading…
Cancel
Save