Stikki Posted July 9, 2015 Share Posted July 9, 2015 Howdy howdy, I was reading stuff about module interfaces init() method and it's declared as required method while being only documentational guidance with in interface. Even all loading methods that i see are checking against existence of this method and executing it only if it's present. So my question: is this actually required method anymore? If not, documentation needs some update. Link to comment Share on other sites More sharing options...
Stikki Posted July 9, 2015 Author Share Posted July 9, 2015 Okey, then again * Optional methods for Module interface * ===================================== * 1. __construct() - called before module config is populated. * 2. init() - called after module config is populated. * 3. ready() - called after init(), after API ready. * Note that ready() applies to 'autoload' modules only. * 4. ___install() - called when module is installed. * 5. ___uninstall() - called when module is uninstalled. While method header says: * While the method is required, if you don't need it, then just leave the implementation blank. Link to comment Share on other sites More sharing options...
Stikki Posted July 9, 2015 Author Share Posted July 9, 2015 And more stuff follows: Is there full documentation what stuff method: getModuleInfo() can return? Documentation says: * 1. Using a static getModuleInfo method: * --------------------------------------- * * public static function getModuleInfo() { * return array( * 'title' => 'Your Module Title', * 'version' => 100, * 'author' => 'Ryan Cramer', * 'summary' => 'Description of what this module does and who made it.', * 'href' => 'http://www.domain.com/info/about/this/module/', * 'singular' => false, * 'autoload' => false, * 'requires' => array('HelloWorld>=1.0.1', 'PHP>=5.4.1', 'ProcessWire>=2.4.1'), * 'installs' => array('Module1', 'Module2', 'Module3'), * ); * } while example in ProcessCommentsManager.module: public static function getModuleInfo() { return array( 'title' => 'Comments', 'summary' => 'Manage comments in your site outside of the page editor.', 'version' => 5, 'author' => 'Ryan Cramer', 'icon' => 'comments', 'requires' => 'FieldtypeComments', 'permission' => 'comments-manager', 'permissions' => array( 'comments-manager' => 'Use the comments manager', ), 'page' => array( 'name' => 'comments', 'parent' => 'setup', 'title' => 'Comments', ), 'nav' => array( array( 'url' => '?go=approved', 'label' => __('Approved', __FILE__), ), array( 'url' => '?go=pending', 'label' => __('Pending', __FILE__), ), array( 'url' => '?go=spam', 'label' => __('Spam', __FILE__), ), array( 'url' => '?go=all', 'label' => __('All', __FILE__), ) ) ); } So are 'page' and 'nav' part of Process Module interface, and if so, where can i read about this? Link to comment Share on other sites More sharing options...
LostKobrakai Posted July 9, 2015 Share Posted July 9, 2015 So are 'page' and 'nav' part of Process Module interface, and if so, where can i read about this? They are and you'll likewise find the documentation in the Process Class: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Process.php 1 Link to comment Share on other sites More sharing options...
Stikki Posted July 9, 2015 Author Share Posted July 9, 2015 They are and you'll likewise find the documentation in the Process Class: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Process.php Thank you again Mr. Kobra Danke Link to comment Share on other sites More sharing options...
Wanze Posted July 9, 2015 Share Posted July 9, 2015 So my question: is this actually required method anymore? If not, documentation needs some update. Technically yes, an interface forces you to implement the public methods in your class. It's like a "contract" that describes the public API of all classes implementing it. However, I just noticed that all the methods in the module interface are commented out. So you're not required to implement the init() method, if you don't need it. Cheers 1 Link to comment Share on other sites More sharing options...
Stikki Posted July 30, 2015 Author Share Posted July 30, 2015 Thanks for the confirmation Wanze, this is exactly what i meant. Cheers also. 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