We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17959 ☆ A M B ☆
    • 57 Posts
    Magnatron [Maarten Wolzak] Reply #1, 14 years, 11 months ago
    Hi all,

    Is it possible to extend an extended core class and have it auto load using the extension_packages system setting?

    I have an extended modUser called 'extUser'.
    Now I want to extend modUser again, including the stuff from 'extUser'.
    I've tried to do so by extending the extUser into a extBusinessUser but when a user logs in with that class_key I get the PHP error:

    Class 'extUser' not found in /.../extbusinessuser.class.php on line 1

    (Which reads:
    class extBusinessUser extends extUser {
        function __construct(xPDO & $xpdo) {
            parent :: __construct($xpdo);
            $this->set('class_key','extBusinessUser');
        }
    }
    

    )

    Is it possible in the current Revolution?

    Thanks,
    Maarten
      • 22303 MODX Staff
      • 10,725 Posts
      I assume these extended user classes are in a custom package, which you have added to extension_packages with an appropriate base path location? If so, the derivative (extBusinessUser) just needs a require_once() for the extUser which it extends, e.g. if in the same directory as extUser...

      <?php
      require_once(dirname(__FILE__) . '/extuser.class.php');
      class extBusinessUser extends extUser {
          function __construct(xPDO & $xpdo) {
              parent :: __construct($xpdo);
              $this->set('class_key','extBusinessUser');
          }
      }
      
        • 17959 ☆ A M B ☆
        • 57 Posts
        Magnatron [Maarten Wolzak] Reply #3, 14 years, 11 months ago
        Thanks.
        I tried that but the included extUser is not an extended modUser when require(d)_once.

        Am I making a mistake by directly including the extUser and extBusinessUser in the extension_packages? Should it be included through a intermediate package class? (e.g.: the SampleClass in the "extending modUSer" tut)
          • 17959 ☆ A M B ☆
          • 57 Posts
          Magnatron [Maarten Wolzak] Reply #4, 14 years, 11 months ago
          Anybody?

          As a workaround I included all the extUser extensions in the extBusinessUser scheme but that is, of course, far from ideal.

          Hope to hear about a better solution.

          Thanks
            • 22303 MODX Staff
            • 10,725 Posts
            I think you're going to have to better describe the issue. How is extUser not extending modUser? I'm not following what the actual problem is here...
              • 17959 ☆ A M B ☆
              • 57 Posts
              Magnatron [Maarten Wolzak] Reply #6, 14 years, 11 months ago
              I'm sorry about the poor description, hope the following is better;

              I have the extBusinesUser in the extension_packages settings.
              I have the extUser included (through require_once) in the extBusinessUser class file as you propose.

              The extBusinessUser class does extend the extUser class and has it's properties but has none of the modUser properties or methods available. So extUser does not seem to extend modUser.

              Hope you can help.

              Thanks