Customer Save Manager
The customer save manager is responsible for all actions/hooks which are executed when a customer object is saved. It consists of several parts:
Customer Save Handlers
Customer save handlers special PHP classes that are executed when a customer gets saved and can be used to normalize, validate, optimize or modify customers on save.
Customer save handlers need to be registered as symfony services with the tag "cmf.customer_save_handler"
.
So it is possible to add multiple customer save handlers to one project. Take a look at the
CustomerSaveHandlerInterface
for how to implement them. The interface consists of methods for each Pimcore object event (preAdd
,
postAdd
, preUpdate
etc.).
Additionally it is possible to get the original customer object from the database. This is handy to compare if some fields got changed.
Example service definition
services:
appbundle.cmf.customer_save_handler.normalize_zip:
class: CustomerManagementFrameworkBundle\CustomerSaveHandler\NormalizeZip
tags: [cmf.customer_save_handler]
Built in customer save handlers
The CMF offers the following customer save handlers out of the box. They are all located in the namespace
CustomerManagementFrameworkBundle\CustomerSaveHandler
and need to be enabled as services by adding
a corresponding service with the tag cmf.customer_save_handler
to the container. Also have a look at their constructors
to see possible configuration options.
Cleanup\Email
Removes invalid characters from an email field.
NormalizeZip
Tries to normalize zip numbers. For example A-1010 would become 1010. It offers zip correction regexes for several countries. It would be possible to extend the logic for other countries.