Service Class
All services should extends this base service class. Located in the namespace Canteen\Services.
Constructor
Item Index
Methods
Methods
bindObject
-
data
-
dataClass
-
[prepends=null]
-
[useFirstRow=true]
Bind an associate array to a data object
Parameters:
-
data
ArrayThe data to bind
-
dataClass
StringThe name of the data class (string to bind)
-
[prepends=null]
Array optionalThe array of maps to prepend to the variables used for prepending a path or directory to a file/path/url
-
[useFirstRow=true]
Boolean optionalIf to just return the row in a return, only getting one item from a mysql array call
Returns:
The typed data object
bindObjects
-
data
-
dataClass
-
[prepends=null]
Same as bindObject but done on a whole collection
Parameters:
Returns:
The data object
dataMap
-
results
-
[key='id']
Turn a collection of objects into a dictionary by a property name.
Parameters:
Returns:
The objects mapped by property
gateway
-
uri
-
method
-
[privilege=Privilege::ANONYMOUS]
Add for use on the Gateway, these methods can be
called from javascript. For an example see the
TimeService
class.
Parameters:
Returns:
Return the instance of this for chaining
get
-
alias
Get a particular service by alias
Parameters:
-
alias
StringThe _registered alias or class name
Returns:
The instance of the service
getCaller
-
[ignore=1]
Get the method/function name of the caller function
Parameters:
-
[ignore=1]
Int optionalThe depth of the call, default is the immediate function before this one is called
getStack
-
[limit=0]
-
[ignore=1]
Get the method/function name of the caller function
Parameters:
-
[limit=0]
Int optionalThe number of stack items to return, default is all
-
[ignore=1]
Int optionalThe number of stack levesl to ignore, default is the immediate function before this one is called.
parse
-
content
-
substitutions
Convenience method for parsing content
Parameters:
-
content
StringThe string to parse
-
substitutions
DictionaryThe dictionary of tags to replace
Returns:
The parsed string
privilege
-
[required=Privilege::GUEST]
You can run to make sure a process requires a particular privilege
Parameters:
-
[required=Privilege::GUEST]
Int optionalThe privilege level required, default is anonymous
register
-
alias
-
service
Add a single service alias
service
-
alias
Get a service by alias
Parameters:
-
alias
StringThe alias
Returns:
The service matching the alias
template
-
name
-
[substitutions=[]
Convenience method for parsing content
Parameters:
-
name
StringThe name of the template to parse
-
[substitutions=[]
Dictionary optionalThe dictionary of tags to replace
Returns:
The parsed string
valueSet
-
A
-
[validationType=null]
Get a set of ids
Parameters:
Returns:
The MySQL formatted set of IDs
verify
-
data
-
[type=null]
-
[suppressErrors=false]
Sanitize input data using the validation types above
Parameters:
Returns:
If we don't verify and suppress errors, returns false, else returns the data
Properties
db
Database
Convenience getter for the database connection
parser
Parser
The parser is responsible for rendering templates
profiler
Profiler
The instance of the profiler for debugging performance
registerd
Dictionary
private
static
The registered list of services by alias