RepoTrait
A common (mostly boiler plate) code for classes implementing the RepoInterface.
Tags
Table of Contents
Properties
- $headers : object
- An object providing mappings of repository REST API parameters to HTTP headers used by a given repository instance.
- $queryLog : AbstractLogger|null
- $schema : Schema
- An object providing mappings of repository concepts to RDF properties used to denote them by a given repository instance.
Methods
- getHeaderName() : string
- Returns an HTTP header name to be used to pass a given information in the repository request.
- getResourceById() : RepoResourceInterface
- Tries to find a repository resource with a given id.
- getSchema() : Schema
- Returns the `Schema` object defining repository entities to RDF property mappings.
- setQueryLog() : void
- Sets a search queries logger
- extractResourcesFromGraph() : Generator<string|int, RepoResourceInterface>
- Extracts collection of RepoResource objects from the EasyRdf graph being parsed from a search response.
- sortMatchingResources() : void
Properties
$headers
An object providing mappings of repository REST API parameters to HTTP headers used by a given repository instance.
private
object
$headers
$queryLog
private
AbstractLogger|null
$queryLog
$schema
An object providing mappings of repository concepts to RDF properties used to denote them by a given repository instance.
private
Schema
$schema
Methods
getHeaderName()
Returns an HTTP header name to be used to pass a given information in the repository request.
public
getHeaderName(string $purpose) : string
Parameters
- $purpose : string
Return values
stringgetResourceById()
Tries to find a repository resource with a given id.
public
getResourceById(string $id[, SearchConfig|null $config = null ]) : RepoResourceInterface
Throws an error on failure.
Parameters
- $id : string
- $config : SearchConfig|null = null
Return values
RepoResourceInterfacegetSchema()
Returns the `Schema` object defining repository entities to RDF property mappings.
public
getSchema() : Schema
Return values
SchemasetQueryLog()
Sets a search queries logger
public
setQueryLog(AbstractLogger $log) : void
Parameters
- $log : AbstractLogger
extractResourcesFromGraph()
Extracts collection of RepoResource objects from the EasyRdf graph being parsed from a search response.
private
extractResourcesFromGraph(Dataset $graph, SearchConfig $config) : Generator<string|int, RepoResourceInterface>
Parameters
- $graph : Dataset
-
graph returned by the parseSearchResponse() method
- $config : SearchConfig
-
search configuration object
Return values
Generator<string|int, RepoResourceInterface>sortMatchingResources()
private
sortMatchingResources(array<string|int, DatasetNodeInterface> &$resources, NamedNode $searchOrderProp) : void
Parameters
- $resources : array<string|int, DatasetNodeInterface>
- $searchOrderProp : NamedNode