1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

`XenForo_Model::create("{$class}")` and `new {$class}`

Discussion in 'XenForo Development Discussions' started by vbresults, Oct 19, 2011.

  1. vbresults

    vbresults Well-Known Member

    What are the full benefits and drawbacks of each one? I know that XenForo_Model::create allows classes to be extended using the XFCP system, and I know that `new {$class}` is less code. I also know that the first choice allows me to immediately call non-static methods while the second option does not. Can someone add to this list of pros/cons so I can better know when to use one and not the other?
     
  2. James

    James Well-Known Member

    You should always use XenForo_Model::create('Class') instead of new class.
     
  3. SheepCow

    SheepCow Well-Known Member

    Indeed. You should never use "new Model", the reasons are the ones you've just pointed, basically it means it can't be extended by add-ons.
     

Share This Page