Adding plugins to our component
In the previous sections, we covered how to call Joomla! plugins from our component. We also created our own content plugin that looks at our component and displays it where needed using just a shortcode. If we put these two things together, we can deduce another benefit of using plugins in our projects: the ability to extend our features without changing our code.
In our Simple Project Manager component, we can add as many plugin events as we need for this. For instance, we could add an event that is called before a new customer is added to our system. In this event, we could fix the casing of our customer email before saving it into the database.
The first thing we have to do is create the trigger for our event. This step will be exactly as we saw in the previous Calling Joomla! plugins from our component section.
So, to proceed, we edit the, /src/component/admin/src/Model/CustomerModel.php
file, adding the save()
method to include our plugin...