src/View/View.php
public function set($template, $data = [], $sort = 0, $type = "file")
    {
        if (empty($template)) {
            $type = "empty";
        } elseif (is_array($template)) {
            if (isset($template["callback"])) {
                $type = "callback";
                $this->template = $template["callback"];
            } else {
                $this->template = $template["template"];
            }

            $this->sortOrder = $template["sort"] ?? $sort;
            $this->type = $template["type"] ?? $type;

            // Merge data array
            $data1 = $template["data"] ?? [];
            if (empty($data)) {
                $this->templateData = $data1;
            } else if (empty($data1)) {
                $this->templateData = $data;
            } else {
                foreach ($data as $key => $val) {
                    if (is_array($val)) {
                        if (!array_key_exists($key, $data1)) {
                            $data1[$key] = [];
                        }
                        $data1[$key] = array_merge($data1[$key], $val);
                    } else {
                        $data1[$key] = $val;
                    }
                    $this->templateData = $data1;
                }
            }

            return;
        }

        $this->template     = $template;
        $this->templateData = $data;
        $this->sortOrder    = $sort;
        $this->type         = $type;

        return $this;
    }
public function set($template, $data = [], $sort = 0, $type = "file")
    {
        if (empty($template)) {
            $type = "empty";
        } elseif (is_array($template)) {
            if (isset($template["callback"])) {
                $type = "callback";
                $this->template = $template["callback"];
            } else {
                $this->template = $template["template"];
            }

            $this->sortOrder = $template["sort"] ?? $sort;
            $this->type = $template["type"] ?? $type;

            // Merge data array
            $data1 = $template["data"] ?? [];
            if (empty($data)) {
                $this->templateData = $data1;
            } else if (empty($data1)) {
                $this->templateData = $data;
            } else {
                foreach ($data as $key => $val) {
                    if (is_array($val)) {
                        if (!array_key_exists($key, $data1)) {
                            $data1[$key] = [];
                        }
                        $data1[$key] = array_merge($data1[$key], $val);
                    } else {
                        $data1[$key] = $val;
                    }
                    $this->templateData = $data1;
                }
            }

            return;
        }

        $this->template     = $template;
        $this->templateData = $data;
        $this->sortOrder    = $sort;
        $this->type         = $type;

        return $this;
    }
Set values for the view.

@param array|string|callable $template the template file, array
or callable
@param array        $data     variables to make available to the
view, default is empty
@param integer      $sort     which order to display the views,
if suitable
@param string       $type     which type of view

@return self