AutoService
in package
implements
AutoServiceInterface
uses
AutoServiceTrait
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:
Tags
Table of Contents
Interfaces
- AutoServiceInterface
- The CiviCRM container will automatically load classes that implement AutoServiceInterface.