/** * testGetModuleArray * * @since 2.4.0 */ public function testGetModuleArray() { /* setup */ Hook::construct($this->_registry); Hook::init(); /* actual */ $actualArray = Hook::getModuleArray(); /* compare */ $this->assertArrayHasKey('TestDummy', $actualArray); }
/** * parse the module tag * * @since 3.0.0 * * @param string $content 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; }