adrianmak Posted January 24, 2016 Share Posted January 24, 2016 I'm really new on pw's module development. And I'm working on a process module. I read a few of other core or 3rd party Process module, I found that there are some kind of similarity in method naming convention Like, public function executeXXXX () { // code } Take the ProcessField.module of pw core process module as an example public function ___executeChangeType() public function ___executeSaveChangeType() public function ___executeImport() public function ___executeExport() However , I search thru the method name executeChangeType, executeSaveChangeType, executeImport executeExport They are never been called in other function within the module Link to comment Share on other sites More sharing options...
GuruMeditation Posted January 24, 2016 Share Posted January 24, 2016 (edited) I'm probably wrong with this as I usually am but aren't methods with 3 underscores hookable methods? Edit, yeah it appears they are, I just looked up the docs: https://processwire.com/api/hooks/ Edited January 24, 2016 by GuruMeditation Link to comment Share on other sites More sharing options...
BitPoet Posted January 24, 2016 Share Posted January 24, 2016 These are automagically called by ProcessController when an URL segment is appended to the path of an admin page. If an admin page url is http://server/processwire/adminpage/ and that page is called, the execute method is called. But if you open, for example, http://server/processwire/adminpage/edit, the first letter of the URL segement (edit) is uppercased and it is appended to the process method, resulting in executeEdit. Process methods with multiple uppercase letters (camel case) are called by passing URL segments with hyphens. The hyphens are stripped, but each letter after a hyphen is uppercased, so http://server/processwire/adminpage/point-me-to-crocodiles will look for a method executePointMeToCrocodiles in adminpage's process module. This way, one doesn't have to set up another process module for a subtasks and create a page for it or parse even more form values in execute. For a new subtask XXX, it's sufficient to add links/form targets with an URL segment of xxx and define a matching executeXxx method. A perfect starting point to learn more about creating process modules is the source code of Ryan's ProcessHello module, which can be found at github and in the module repository. 9 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now