Hi there,I've been thinking recently how one module can extend functionality of another.Example:(Let's assume we use DI to get class instances.)Two modules:
identity - manages system userscontact - adds extra functionality to identity moduleIdentity form:usernamepasswordContact form:
first namesurnameemail...1. Contact module needs to add some extra form elements to standard Identity module form. It will do it by adding Contact form as 'contact' subform to identity form.
2. On form submission contact module saves additional data for an identity just created by identity module.Use case 1How can we make sure that when identity form instance is created contact form is always added into it?
Three options (what I could think of):Form triggers "init" eventDI itself triggers "newInstance" eventUsing any other strategy how this could be achieved.... what are they?
Use case 2Contact module subscribes to IdentityService.persist method event and gets $data['identity'] array (returned by $form->getValues() in the controller) and persist them using contact mapper.
What are your thoughts? Could you elaborate on this a bit please?Matus Zeman