ERP service component¶
To provide a simple interface to the ERP communication, the AbstractErpService
abstract class is defined.
This class is derived from Symfony service classes.
For example the WebConnectorErpService
implements this abstract class for the communication to the Web.Connector.
For every basic request to the ERP one class methods exists (e.g. for price calculation of some products). Currently this includes:
1 2 3 4 |
|
Service method implementation¶
An implementation for the selectCustomer()
method can look like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
First you invoke the message factory to create an instance of the ERP message you want to send.
1 2 3 4 5 6 7 8 9 10 |
|
Then you have to feed the data which was given to the method into the received message object.
1 2 3 4 5 6 7 8 |
|
Next you have to get an instance of the transport service and give the message instance to the sendMessage()
method.
It returns the same instance which you passed as argument, but if is successful, that instance holds the response now.
1 2 3 4 5 6 7 8 9 10 11 |
|
Now you can return the response of the message directly or prepare the response that is defined by this service method.
1 2 |
|
Symfony service configuration¶
If you reimplement the abstract service, you have to register your class as a service:
1 2 3 4 |
|
The service ID has to be silver_erp.facade
. That way this implementation is automatically used when the ERP service is injected as a dependency.
The arguments in the example above are another two services of the ERP bundle.
These are injected as dependency of the example service class.
Since the message inquiry service and the transport service are necessary for all ERP communication,
these two dependencies are the least of all ERP service implementations.
This redefines the default service configuration. Make sure that your configuration has a higher priority than the ERP bundle in your Symfony project setup.