public function addResolverType(string $type, string $path, string $extension = "", SubResolver $instance = null)
    {
        // Check argument validity
        if (isset($this->resolvers[$type]))
            throw new \LogicException("Duplicate resolver type: " . $type);

        if ($instance !== null && $extension !== "")
            throw new \LogicException("Cannot set a file extension for a provided instance");

        // Instantiate a new resolver when none has been passed
        if ($instance === null)
            $instance = new SubResolver($type, $extension);

        $this->resolvers[$type] = [
            'path' => $path,
            'resolver' => $instance
        ];

        if ($this->cache)
            $this->resolvers[$type]['resolver']->setCache($this->cache);

        // Register found modules with the new resolver
        foreach ($this->modules as $name => $module_path)
            if (is_dir($module_path . DIRECTORY_SEPARATOR . $path))
                $instance->addToSearchPath($name, $path);

        return $this;
    }
public function addResolverType(string $type, string $path, string $extension = "", SubResolver $instance = null)
    {
        // Check argument validity
        if (isset($this->resolvers[$type]))
            throw new \LogicException("Duplicate resolver type: " . $type);

        if ($instance !== null && $extension !== "")
            throw new \LogicException("Cannot set a file extension for a provided instance");

        // Instantiate a new resolver when none has been passed
        if ($instance === null)
            $instance = new SubResolver($type, $extension);

        $this->resolvers[$type] = [
            'path' => $path,
            'resolver' => $instance
        ];

        if ($this->cache)
            $this->resolvers[$type]['resolver']->setCache($this->cache);

        // Register found modules with the new resolver
        foreach ($this->modules as $name => $module_path)
            if (is_dir($module_path . DIRECTORY_SEPARATOR . $path))
                $instance->addToSearchPath($name, $path);

        return $this;
    }
public function addResolverType ( string $ type , string $ path , string $ extension = "" , SubResolver $ instance = null ) { // Check argument validity if ( isset ( $ this -> resolvers [ $ type ] ) ) throw new \ LogicException ( "Duplicate resolver type: " . $ type ) ; if ( $ instance !== null && $ extension !== "" ) throw new \ LogicException ( "Cannot set a file extension for a provided instance" ) ; // Instantiate a new resolver when none has been passed if ( $ instance === null ) $ instance = new SubResolver ( $ type , $ extension ) ; $ this -> resolvers [ $ type ] = [ 'path' => $ path , 'resolver' => $ instance ] ; if ( $ this -> cache ) $ this -> resolvers [ $ type ] [ 'resolver' ] -> setCache ( $ this -> cache ) ; // Register found modules with the new resolver foreach ( $ this -> modules as $ name => $ module_path ) if ( is_dir ( $ module_path . DIRECTORY_SEPARATOR . $ path ) ) $ instance -> addToSearchPath ( $ name , $ path ) ; return $ this ; }
Add a resolver type
@param string $type The resolver type to add
@param string $path The sub-path this resolver looks in in each module
@param string $extension The required extension on resolved elements. If absent from a reference,
it will be appended
@param SubResolver $instance A way to pass in a SubResolver instance. When null, a new one will be
instantiated. Cannot be used in combination with $extension
@return Resolver Provides fluent interface
Add a resolver type