55 lines
1.2 KiB
Plaintext
55 lines
1.2 KiB
Plaintext
|
/**
|
||
|
* Compiler Joomla Module Data Class
|
||
|
*
|
||
|
* @var Module
|
||
|
* @since 3.2.0
|
||
|
*/
|
||
|
protected Module $module;
|
||
|
|
||
|
/**
|
||
|
* Constructor
|
||
|
*
|
||
|
* @param Module|null $module The compiler Joomla module data object.
|
||
|
*
|
||
|
* @since 3.2.0
|
||
|
*/
|
||
|
public function __construct(?Module $module = null)
|
||
|
{
|
||
|
$this->module = $module ?: Compiler::_('Joomlamodule.Data');
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Set Joomla Module
|
||
|
*
|
||
|
* @param object $item The item data
|
||
|
*
|
||
|
* @return void
|
||
|
* @since 3.2.0
|
||
|
*/
|
||
|
public function set(object &$item)
|
||
|
{
|
||
|
// get all modules
|
||
|
$item->addjoomla_modules = (isset($item->addjoomla_modules)
|
||
|
&& JsonHelper::check($item->addjoomla_modules))
|
||
|
? json_decode((string) $item->addjoomla_modules, true) : null;
|
||
|
|
||
|
if (ArrayHelper::check($item->addjoomla_modules))
|
||
|
{
|
||
|
$joomla_modules = array_map(
|
||
|
function ($array) use (&$item) {
|
||
|
// only load the modules whose target association calls for it
|
||
|
if (!isset($array['target']) || $array['target'] != 2)
|
||
|
{
|
||
|
return $this->module->set(
|
||
|
$array['module'], $item
|
||
|
);
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}, array_values($item->addjoomla_modules)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
unset($item->addjoomla_modules);
|
||
|
}
|