PreCreationSubscriber
extends AbstractPrepareSubscriber
in package
AbstractYes
AutoService is a base-class for defining a service (in Civi's service-container).
Child classes are scanned automatically for various annotations and interfaces.
= ANNOTATIONS =
Annotations are used to declare and initialize services:
- Declare a service. This can be done on a
class
or static factory-method. Supported annotations:-
@service NAME
: Set the name of the new service. -
@serviceTags TAG-1,TAG-2
: Declare additional tags for the service. -
@internal
: Generate a hidden/automatic name. Limit discovery of the service.
-
- Initialize the service by calling methods. This works with factory-, constructor-, and setter-methods.
-
@inject SERVICE-1,SERVICE-2
: Call the method automatically. Pass a list of other services as parameters.
-
- Initialize the service by assigning properties. Any property may have these annotations:
-
@inject SERVICE
: Lookup the SERVICE and set the property. If theSERVICE
is blank, then it loads an eponymous service.
-
For examples of using these annotations, consult the tests or the Developer Guide:
Table of Contents
Methods
- getSubscribedEvents() : array<string|int, mixed>
- onApiPrepare() : mixed
- addDefaultCreationValues() : mixed
- Sets default values common to all creation requests
- applies() : bool
- Check if this subscriber should be applied to the request
- modify() : void
- Modify the request
Methods
getSubscribedEvents()
public
static getSubscribedEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>onApiPrepare()
public
onApiPrepare(PrepareEvent $event) : mixed
Parameters
- $event : PrepareEvent
addDefaultCreationValues()
Sets default values common to all creation requests
protected
addDefaultCreationValues(DAOCreateAction $request) : mixed
Parameters
- $request : DAOCreateAction
applies()
Check if this subscriber should be applied to the request
protected
abstract applies(DAOCreateAction $request) : bool
Parameters
- $request : DAOCreateAction
Return values
boolmodify()
Modify the request
protected
abstract modify(DAOCreateAction $request) : void
Parameters
- $request : DAOCreateAction