Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
App Modules extends of Global Modules
  • We can extend an "application modules" of a "global modules"? And use the methods of the "global modules"?

    In the following situation:

    (Default) Payments Module - vs - (Custom) Payments Module

    Simulating the (Default) Payments Module added 10% discount on final value.

    Now the (Custom) Module Payments must add 20% discount on final value.


    image
  • HarroHarro
    Accepted Answer
    Not this way.

    Every module must have it's own namespace, and the namespace must be unique. If not the autoloader doesn't know what to load. If your module names are unique, you can extend like any other class, providing the module that has the calss to be extended is loaded first.
  • Thank you.

    The namespace unique
    was the perfect solution.



    Example code used:



    MODULE USERS_CUSTOM

    <?php
    namespace Users_Custom;

    class Controller_Users extends \Users\Controller
    ?>


    EXTENDS

    MODULE USERS
    <?php
    namespace Users;

    class Controller_Users extends \Controller
    ?>


    --------------------------
    but it was necessary loading the module users

    CONFIG.PHP

    'modules'  => array('users'),



  • Yes, as I said you need to load the module before you can access it. If you don't, the autoloader doesn't know the namespace, and doesn't know where to load the class from.
  • My big problem!

    So far everything has been wonderful, but I would like to access the extended module using the same URL and not put _custom.

    www.site.com/user/ -> YES
    www.site.com/user_custom/
    -> NOT :(

    but it is not loaded in the routes.php custom module.


    Is this possible?

    Or my idea of ​​modules customized per client is a madness?

  • That indeed doesn't work. The route should work, providing it's defined in the app and not in the module. Routes defined in modules are only used when something in the module is loaded via the URL.

    I can't judge wether or not your design is ok, it depends on your requirements, and what you want to achieve.

Howdy, Stranger!

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

In this Discussion