name = $name; $this->title = $title; $this->variables = $variables; if(is_string($content)) { $this->content = $content; } } public function getCallback(string $name) : mixed { if(!isset($this->callbacks[$name])) { return null; } return $this->callbacks[$name]; } public function onSave(mixed $method) : Modal { $this->callbacks['save'] = $method; return $this; } public function getName() : ?string { return $this->name; } public function getTitle() : ?string { return $this->title; } public function isShowing() : bool { return $this->show; } public function addButton(array $button) : Modal { $this->buttons[] = $button; return $this; } public function getButtons() : array { return $this->buttons; } public function getContent(Template $template) : mixed { foreach($this->variables AS $name => $value) { ${$name} = $value; } // @ToDo check if is template file if(!empty($this->content)) { $template->display($this->content, $this->variables, true, false); return null; } return $this->content; } public function show($variables = []) { $this->variables = array_merge($this->variables, $variables); $this->show = true; } } ?>