Closed taufik-nurrohman closed 3 years ago
Helper function should be attached to the function call scope to be used easily by third-party extensions:
namespace _\lot\x\panel\h;
function field(array $value, $key) {
$out = /* … */;
return new \HTML($out);
}
namespace _\lot\x\panel\type\field;
function text(array $value, $key) {
$out = $this->field($value, $key);
$out['content'][0] = 'input';
$out['content'][1] = false;
return $out;
}
// …
$v = "\\_\\lot\\x\\panel\\type";
$type = $value['type'] ?? "";
return \fire($v . ($type ? "\\" . $type : ""), [$value, $key], (object) [
'description' => "\\_\\lot\\x\\panel\\h\\description",
'field' => "\\_\\lot\\x\\panel\\h\\field",
'title' => "\\_\\lot\\x\\panel\\h\\title"
]);
Developer should construct the GUI function as
_\lot\x\panel\type\button(array $in, $key)
instead of_\lot\x\panel\button(array $in, $key)
to be used in the GUI data like so:Most of function names that bound to the
_\lot\x\panel
namespace are added to be used by thetype
property such asbutton
,link
, andtext
. But some categories are no longer suitable to be declared under this namespace because they cannot be used as a validtype
data. One example is theroute
category. Every functions under_\lot\x\panel\route
namespace are intended to be used as custom routes.My categorization plan for the future is like this:
_\lot\x\panel\*
→ Generic function for thepanel
extension._\lot\x\panel\form\error\*
→ Form data validator._\lot\x\panel\form\info\*
→ Form data filter and sanitizer._\lot\x\panel\route\*
→ Custom panel routes._\lot\x\panel\task\{f,g,l,s}\*
→ Hook function to be used in the form action._\lot\x\panel\type\*
→ Custom panel GUI that returns HTML markup.