encapsulate memory container

This commit is contained in:
yggverse 2024-04-09 16:56:25 +03:00
parent 6c1213e180
commit e518b0a898
2 changed files with 8 additions and 6 deletions

View file

@ -13,9 +13,15 @@ class Main
public \Yggverse\Yoda\Label\Content $content; public \Yggverse\Yoda\Label\Content $content;
public \Yggverse\Yoda\Label\Tray $tray; public \Yggverse\Yoda\Label\Tray $tray;
public \Yggverse\Yoda\Model\Memory $memory;
public function __construct( public function __construct(
string $name = 'boxMain' string $name = 'boxMain'
) { ) {
// Init memory
$this->memory = new \Yggverse\Yoda\Model\Memory();
// Init container
$this->box = new \GtkBox( $this->box = new \GtkBox(
\GtkOrientation::VERTICAL \GtkOrientation::VERTICAL
); );
@ -72,7 +78,6 @@ class Main
function ($entry) function ($entry)
{ {
global $config; global $config;
global $memory;
$this->tray->label->set_text( $this->tray->label->set_text(
sprintf( sprintf(
@ -93,7 +98,7 @@ class Main
$name = $address->getHost(); $name = $address->getHost();
if (!$host = $memory->get($name)) if (!$host = $this->memory->get($name))
{ {
$resolve = new \Yggverse\Net\Resolve( $resolve = new \Yggverse\Net\Resolve(
$config->resolver->request->record, $config->resolver->request->record,
@ -110,7 +115,7 @@ class Main
{ {
$host = $resolved->getHost(); $host = $resolved->getHost();
$memory->set( $this->memory->set(
$name, $name,
$host $host
); );

View file

@ -9,9 +9,6 @@ require_once __DIR__ .
// Init config // Init config
$config = \Yggverse\Yoda\Model\File::getConfig(); $config = \Yggverse\Yoda\Model\File::getConfig();
// Init memory
$memory = new \Yggverse\Yoda\Model\Memory();
// Init GTK // Init GTK
\Gtk::init(); \Gtk::init();