|
|
@ -4,107 +4,183 @@ declare(strict_types=1); |
|
|
|
|
|
|
|
|
|
|
|
namespace Yggverse\Yoda\Abstract\Model; |
|
|
|
namespace Yggverse\Yoda\Abstract\Model; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use \Yggverse\Yoda\Model\Buffer; |
|
|
|
|
|
|
|
|
|
|
|
abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection |
|
|
|
abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Status |
|
|
|
private Buffer $_buffer; |
|
|
|
private bool $_completed = false; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct( |
|
|
|
// Response |
|
|
|
Buffer $buffer |
|
|
|
private ?string $_title = null; |
|
|
|
) { |
|
|
|
private ?string $_subtitle = null; |
|
|
|
// Use shared memory for async operations |
|
|
|
private ?string $_tooltip = null; |
|
|
|
$this->_buffer = $buffer; |
|
|
|
private ?string $_mime = null; |
|
|
|
|
|
|
|
private ?string $_data = null; |
|
|
|
// Set defaults |
|
|
|
private ?string $_redirect = null; |
|
|
|
$this->_buffer->set( |
|
|
|
private ?array $_request = null; |
|
|
|
'completed', |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'title', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'subtitle', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'tooltip', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'mime', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'data', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'redirect', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'request', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function isCompleted(): bool |
|
|
|
public function isCompleted(): bool |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_completed; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'completed' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setCompleted( |
|
|
|
public function setCompleted( |
|
|
|
bool $completed |
|
|
|
bool $completed |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_completed = $completed; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'completed', |
|
|
|
|
|
|
|
$completed |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTitle(): ?string |
|
|
|
public function getTitle(): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_title; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'title' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setTitle( |
|
|
|
public function setTitle( |
|
|
|
?string $title = null |
|
|
|
?string $title = null |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_title = $title; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'title', |
|
|
|
|
|
|
|
$title |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getSubtitle(): ?string |
|
|
|
public function getSubtitle(): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_subtitle; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'subtitle' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setSubtitle( |
|
|
|
public function setSubtitle( |
|
|
|
?string $subtitle = null |
|
|
|
?string $subtitle = null |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_subtitle = $subtitle; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'subtitle', |
|
|
|
|
|
|
|
$subtitle |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTooltip(): ?string |
|
|
|
public function getTooltip(): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_tooltip; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'tooltip' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setTooltip( |
|
|
|
public function setTooltip( |
|
|
|
?string $tooltip = null |
|
|
|
?string $tooltip = null |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_tooltip = $tooltip; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'tooltip', |
|
|
|
|
|
|
|
$tooltip |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getMime(): ?string |
|
|
|
public function getMime(): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_mime; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'mime' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setMime( |
|
|
|
public function setMime( |
|
|
|
?string $mime = null |
|
|
|
?string $mime = null |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_mime = $mime; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'mime', |
|
|
|
|
|
|
|
$mime |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getData(): ?string |
|
|
|
public function getData(): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_data; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'data' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setData( |
|
|
|
public function setData( |
|
|
|
?string $data = null |
|
|
|
?string $data = null |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_data = $data; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'data', |
|
|
|
|
|
|
|
$data |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getRedirect(): ?string |
|
|
|
public function getRedirect(): ?string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_redirect; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'redirect' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setRedirect( |
|
|
|
public function setRedirect( |
|
|
|
?string $redirect = null |
|
|
|
?string $redirect = null |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_redirect = $redirect; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'redirect', |
|
|
|
|
|
|
|
$redirect |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getRequest(): ?array |
|
|
|
public function getRequest(): ?array |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_request; |
|
|
|
return $this->_buffer->get( |
|
|
|
|
|
|
|
'request' |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setRequest( |
|
|
|
public function setRequest( |
|
|
@ -112,21 +188,29 @@ abstract class Connection implements \Yggverse\Yoda\Interface\Model\Connection |
|
|
|
bool $visible = true |
|
|
|
bool $visible = true |
|
|
|
): void |
|
|
|
): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_request = [ |
|
|
|
$this->_buffer->set( |
|
|
|
'placeholder' => $placeholder, |
|
|
|
'request', |
|
|
|
'visible' => $visible |
|
|
|
[ |
|
|
|
]; |
|
|
|
'placeholder' => $placeholder, |
|
|
|
|
|
|
|
'visible' => $visible |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function unsetRequest(): void |
|
|
|
public function unsetRequest(): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->_request = null; |
|
|
|
$this->_buffer->set( |
|
|
|
|
|
|
|
'request', |
|
|
|
|
|
|
|
null |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getLength(): ?int |
|
|
|
public function getLength(): ?int |
|
|
|
{ |
|
|
|
{ |
|
|
|
return mb_strlen( |
|
|
|
return mb_strlen( |
|
|
|
$this->_data |
|
|
|
$this->_buffer->get( |
|
|
|
|
|
|
|
'data' |
|
|
|
|
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |