/** * testGetModules * * @since 2.4.0 */ public function testGetModules() { /* setup */ Hook::init($this->_registry); /* actual */ $actual = Hook::getModules(); /* compare */ $this->assertArrayHasKey('Test', $actual); }
/** * parse the module tag * * @since 2.2.0 * * @param string $input content be parsed * * @return string */ protected function _parseModule($input = null) { $namespace = 'Redaxscript\\Modules\\'; $output = str_replace($this->_tags['module']['search'], $this->_delimiter, $input); $parts = array_filter(explode($this->_delimiter, $output)); /* parse needed parts */ foreach ($parts as $key => $value) { $object = $namespace . $value . '\\' . $value; if ($key % 2) { /* decode to array */ $json = json_decode($value, true); ob_start(); /* multiple calls with parameter */ if (is_array($json)) { foreach ($json as $module => $parameter) { $object = $namespace . $module . '\\' . $module; if (in_array($module, Hook::getModules()) && method_exists($object, 'render')) { echo call_user_func_array(array($object, 'render'), $parameter); } } } else { if (in_array($value, Hook::getModules()) && method_exists($object, 'render')) { echo call_user_func(array($object, 'render')); } } $parts[$key] = ob_get_clean(); } } $output = implode($parts); return $output; }