RepoResourceResolver
in package
Returns repository resource object having a given id.
Automatically configures the repository connection (REST or direct database access) based on the provided configutation.
Tags
Table of Contents
Properties
- $config : Config|null
- $log : AbstractLogger|null
- $repo : RepoInterface|null
Methods
- __construct() : mixed
- Sets up the resolver.
- handleException() : void
- resolve() : RepoResourceInterface
- Resolves a given resource URI according to the resolver settings.
- resolveUrl() : RepoResourceInterface
- Resolves a given URL in a zero-configuration mode.
Properties
$config
private
Config|null
$config
$log
private
AbstractLogger|null
$log
$repo
private
RepoInterface|null
$repo
Methods
__construct()
Sets up the resolver.
public
__construct(object|null $config[, AbstractLogger|null $log = null ]) : mixed
May work in three modes:
- zero-config mode (when
$config
is null). In this mode resolution is done by just trying to resolve the URL. It's the slowest mode but requires no configutation at all. This mode is always available as a fallback resolution method for the resolve() method and explicitely as the resolveUrl() method. - REST API mode (when
$config
is provided and misses$config->dbConnStr
) This mode is faster but works only against a single repository. - direct database access mode (when
$config
is provided and contains$config->dbConnStr
). This is definitely the fastest mode but works only against a single repository and requires direct database access.
If modes other than zero-config one are used, the $config
parameter has to
contain a minimum repository description including $config->rest->urlBase
,
$config->rest->pathBase
, $config->rest->headers
, $config->schema->id
,
$config->schema->parent
, $config->schema->label
and $config->schema->searchMatch
.
In case of REST API mode credentials can be provided with
$config->auth->httpBasic->user
and $config->auth->httpBasic->password
.
Parameters
- $config : object|null
- $log : AbstractLogger|null = null
handleException()
public
handleException(Throwable $e, AbstractLogger|null $log) : void
Parameters
- $e : Throwable
- $log : AbstractLogger|null
resolve()
Resolves a given resource URI according to the resolver settings.
public
resolve(string $resId[, bool $fallback = true ]) : RepoResourceInterface
Parameters
- $resId : string
- $fallback : bool = true
-
Should fallback zero-config mode be used when a resource is not found? (valid only for non-zero-config modes - see the constructor descrription)
Tags
Return values
RepoResourceInterfaceresolveUrl()
Resolves a given URL in a zero-configuration mode.
public
resolveUrl(string $url) : RepoResourceInterface
Parameters
- $url : string