Redaxscript\Parser::_parseModule PHP Method

_parseModule() protected method

parse the module tag
Since: 3.0.0
protected _parseModule ( string $content = null ) : string
$content string content to be parsed
return string
    protected function _parseModule($content = null)
    {
        $output = str_replace($this->_tagArray['module']['search'], $this->_optionArray['delimiter'], $content);
        $partArray = array_filter(explode($this->_optionArray['delimiter'], $output));
        $modulesLoaded = Hook::getModuleArray();
        /* parse as needed */
        foreach ($partArray as $key => $value) {
            $object = $this->_tagArray['module']['namespace'] . '\\' . $value . '\\' . $value;
            if ($key % 2) {
                $partArray[$key] = null;
                $json = json_decode($value, true);
                /* call with parameter */
                if (is_array($json)) {
                    foreach ($json as $module => $parameterArray) {
                        $object = $this->_tagArray['module']['namespace'] . '\\' . $module . '\\' . $module;
                        /* method exists */
                        if (in_array($module, $modulesLoaded) && method_exists($object, 'render')) {
                            $partArray[$key] = call_user_func_array([$object, 'render'], $parameterArray);
                        }
                    }
                } else {
                    if (in_array($value, $modulesLoaded) && method_exists($object, 'render')) {
                        $partArray[$key] = call_user_func([$object, 'render']);
                    }
                }
            }
        }
        $output = implode($partArray);
        return $output;
    }