The services.json specifies services which are available to the controller and global data for those services.
Each service declaration consists of at least three infos.
"< servicename >": {
"type": "service",
"< source >",
}
RequestHandler
.Router
to use."class": "< classname >"
This way the constructor of a class will be used.
"static": "< full path of method >"`:
This way a static method will be used.
"factory": "< factoryname >",
"method": "< methodname >",
["args": ...]
This way the method of a factory-class will be called.
Given these three infos, the service is then available through $this->get('< servicename >') inside a [Controller](graphit/giwt/Controller.md)
.
Additionally to the three mandatory infos one can specify:
Arguments for the method can be specified in tree different ways:
"type": "service", "name": "< value name >"
: The value of the argument, the method with be called with, can be found under here given 'value'-value."type": "value", "value": "< value name >"
: the value given to the argument is the value given inside the configuration under < value name >."value": < value >
: the value given to the argument is the given value."config": [
{ "method": "< methodname >",
"args": [
{ "type": "service", "name": "< value name >" },
{ "type": "value", "value": "< value name >" },
{ "value": < value > },
]
}
]
Each method that should be called needs to be specified by the name of the method to call (< methodname >) and potentially an array of arguments.
Same as above.
Aside from the services there are also a few already used parameters that can be set through the services.json.
"requestHandler": ...
: Sets the service which should be used as RequestHandler
. If not set, Graphit\Core\DefaultRequestHandler
will be used. (see: DefaultRequestHandler)"router": ...
: Sets the service which should be used as Router
. Needs to be set."defaultLocale": "< iso31661a2 country code >"
: Sets the default locale."possibleLocales": [< iso31661a2 country codes separated by comma >]
: Sets the possible locales.Any additional parameters that are used in the source code should be set accordingly inside the services.json.