Instead of calling a single tone (Router :: getRequest ()) in the afterSave () method and entering the tight connection suggested by Matthew, why can't you pass in any parameter you need along with the data of the record you are trying save?
Then it will be present in $ this-> data in afterSave (). Plus, this method is easy to verify. Enjoy testing Router :: getRequest () in this method.
If you need the whole request, you can add the Model :: $ request property in the AppModel and the setRequest () method, as well as in your beforeFilter () controllers you can do $ this → {$ this-> modelClass} → SetRequest ($ this- > request);
burzum
source share