Overriding Functions and Controller Files in Mercury
In the same way that you have the ability to create custom display files you can override functions. Most of this time you won't do this, the core functionality will be enough. And when it's not enough a lot of the time you can achieve what you're after by making hooks (more on that to come). Sometimes, however, you just might have to build a custom function.
File Locations
Going back to our login example, a controller file might call a function like:
m("users", "validateLogin", $m);
Most of the time this is going to call a function in the core Mercury system, running the file mercury/users/functions/validateLogin.php.
Imagine a scenario where instead of validating against a database you have to initialize a web service and validate against your parent company's authentication server. In other words the way that you're validating is completely different. You can create your own function at html/mercury/users/functions/validateLogin.php and write whatever logic you need to make it work.
You will receive the same third parameter, in this case the $m array, and you can process it however you need to. Take care to return the same type of result if you are using the rest of the Mercury code, it will be expecting a certain type of answer from your function.
Note
So far, about five months into the Mercury process, in the sites we have worked on there are very, very few functional overrides. You are at least twenty times more likely to customize a display file than a function. This isn't to say that you won't make your own functions in custom modules, just that with the MVC system you're not going to need to update very many functions that already exist.
Controller Files
You can override controller files in exactly the same way that you override display and function files. A URL like /users/login-action will typically find the controller file in mercury/users/login-action.php. If you want to modify the behavior or the controller file you can put your own version in html/mercury/users/login-action.php and your file will be used instead.
