We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Agreed on the simple and powerful --> that’s exactly where we are heading ;-)

    I’m not sure I understand what you mean by the difference between loadExtension and getExtension, all I was suggesting is we write ContentManager.class.php and reference that as ContentManagerClass in config.inc.php. Then in index.php we dynamically load the class from the config. This would allow someone to copy the class and reimplement it, extend it to add additional methods, or just about anything they wanted, without ever overwriting their core file. But I do see how loadExtension is a private method and shold not be exposed as an API method, but rather can be used by ContentManager extension class writers to include additional extensions in their implementation/extension of the ContentManager.

    Also, the methods should be part of the class being loaded as an extension. That way I can say $user= &$cms->user and then go around doing user->getUserName() or user->save() or user->get(’userdefined-attribute-name’). Or just $cms->user->save().
      • 32963
      • 1,732 Posts
      Hi,

      I don’t think I like the idea of having users create a class file to extend the core. This in itself could pose a problem for users if in the future we decided to add a method that their customized class is using:

      example:

      1) User A extends ContentManager to add a getFuctionA()
      2) We then later and a getFunctionA() to the ContentManager class.
      3) User B ships a Widget that relies on getFunctionA from ContentManager
      4) User A downloads and installs the widget but it fails to work due to the fact that they have over ContentManager getFunctionA

      IMO I think the idea of extending the core using $cms->extension is much better and allows the user to load multiple extensions and any given time.

      The getExtension() function is used to return a reference to the object:

      $e = $cms->getExtension('Event'); // get reference
      $e->invoke('OnCustomEvent');
      // this is the same as the above
      $cms->event->invoke('OnCustomEvent');


        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 22303 MODX Staff
        • 10,725 Posts
        Cool, I understand what you mean now and agree, though I was referring to custom implementations of the class by overriding the behavior of existing methods.
          • 32963
          • 1,732 Posts
          I would like to also propose that we make it a rule when writing extensions all class names must end with the _EXT characters

          example:

          // Event Extension Class
          class Event_EXT {
             // code here
          }
          
          // Manager Extension Class
          class Manager_EXT {
             // code here
          }
          
          // Parser Extension Class
          class Parser_EXT {
             // code here
          }


          This way (I think) our class names will be more unique and will be less likely to clash with other application class.
            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
            • 25663 MODX Staff
            • 12,272 Posts
            Out of curiosity, why all caps?
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 22303 MODX Staff
              • 10,725 Posts
              Yeah, I personally would like to see just the word Extension on the end. Its more intuitive and more descriptive than the cryptic ’_EXT’.
                • 32963
                • 1,732 Posts
                Quote from: OpenGeek at Nov 27, 2005, 01:28 PM

                Yeah, I personally would like to see just the word Extension on the end.  Its more intuitive and more descriptive than the cryptic ’_EXT’.

                Cool! Will do
                  xWisdom
                  www.xwisdomhtml.com
                  The fear of the Lord is the beginning of wisdom:
                  MODx Co-Founder - Create and do more with less.