Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Events in modules
  • I put Event::trigger('toolbar_add_menu') into my toolbar module so any other modules can add their own menus to the toolbar. The trigger runs after all the Event::registers. All my modules have a toolbar_menu method which returns an array of menu title, links etc., and also an Event::register('toolbar_add_menu', 'Mymodulename::toolbar_menu'). But this way it isnt works, becouse the module Event::register methods only run if the first URI segment matches with the module name. How can I implement thet each module's menu load into the toolbar without loading all the modules? Thank you!
  • You can't. There is no mechanism that magically scans your modules and calls 'something'. You will have to do the calling yourself.
  • This isn't ideal because modules should be self-contained... but you could put all of your event::register()'s in your app/bootstrap.php
  • In FuelPHP 2.0 modules and packages will be merged into one, and will have their own bootstrap.
    It will still mean you will have to load all of them, otherwise the bootstrap will not be loaded. In the meantime, I suggest you add a specific class to your modules, loop through all your modules, and use is_callable to check if your special class exists, and if it does, call it.
  • Harro Verton wrote on Tuesday 29th of November 2011:
    In FuelPHP 2.0 modules and packages will be merged into one, and will have their own bootstrap.

    Can't wait for this! :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion