jcb-compiler/src/94f4939f-82cc-4196-802b-1346ce5c7f99/code.power
2023-10-10 11:39:16 +02:00

60 lines
1.2 KiB
Plaintext

/**
* Constructor.
*
* @since 3.2.0
*/
public function __construct()
{
$this->setSeparator('|');
}
/**
* Get the build component content
*
* @return string
* @since 3.2.0
*/
public function build(): string
{
if ($this->isActive())
{
$bucket = ['<section name="component">'];
// get the header
if ($this->exists('->HEAD<-'))
{
$headers = $this->get('->HEAD<-');
// remove from active values
$this->remove('->HEAD<-');
foreach ($headers as $action)
{
$bucket[] = Indent::_(2) . '<action name="'
. $action['name'] . '" title="'
. $action['title'] . '" description="'
. $action['description'] . '" />';
}
}
if ($this->isActive())
{
ksort($this->active, SORT_STRING);
foreach ($this->active as $active)
{
$bucket[] = Indent::_(2) . '<action name="'
. $active['name'] . '" title="'
. $active['title'] . '" description="'
. $active['description'] . '" />';
}
}
// reset memory
$this->active = [];
return implode(PHP_EOL, $bucket) . PHP_EOL . Indent::_(1) . "</section>";
}
return '';
}