public static function instance($itemid, $componentname, $areaname, $engine = false) {

        if ($engine === false) {
            $search = \core_search\manager::instance();
            $engine = $search->get_engine();
        }

        $pluginname = $engine->get_plugin_name();

        if (!empty(self::$docclassnames[$pluginname])) {
            return new self::$docclassnames[$pluginname]($itemid, $componentname, $areaname);
        }

        self::$docclassnames[$pluginname] = $engine->get_document_classname();

        return new self::$docclassnames[$pluginname]($itemid, $componentname, $areaname);
    }
public static function instance($itemid, $componentname, $areaname, $engine = false) {

        if ($engine === false) {
            $search = \core_search\manager::instance();
            $engine = $search->get_engine();
        }

        $pluginname = $engine->get_plugin_name();

        if (!empty(self::$docclassnames[$pluginname])) {
            return new self::$docclassnames[$pluginname]($itemid, $componentname, $areaname);
        }

        self::$docclassnames[$pluginname] = $engine->get_document_classname();

        return new self::$docclassnames[$pluginname]($itemid, $componentname, $areaname);
    }
public static function instance ( $ itemid , $ componentname , $ areaname , $ engine = false ) { if ( $ engine === false ) { $ search = \ core_search \ manager :: instance ( ) ; $ engine = $ search -> get_engine ( ) ; } $ pluginname = $ engine -> get_plugin_name ( ) ; if ( ! empty ( self :: $ docclassnames [ $ pluginname ] ) ) { return new self :: $ docclassnames [ $ pluginname ] ( $ itemid , $ componentname , $ areaname ) ; } self :: $ docclassnames [ $ pluginname ] = $ engine -> get_document_classname ( ) ; return new self :: $ docclassnames [ $ pluginname ] ( $ itemid , $ componentname , $ areaname ) ; }
Returns the appropiate document object as it depends on the engine.

@param int $itemid Document itemid
@param string $componentname Document component name
@param string $areaname Document area name
@param \core_search\engine $engine Falls back to the search engine in use.
@return \core_search\document Base document or the engine implementation.
Returns the appropiate document object as it depends on the engine .