Page 1 of 1

getNew(X) or new X()

Posted: 25 March 2021, 21:35
by Ilmion
I want to make a class in my modules extending APP_DbObject and I'm wondering what is the accepted method to create a new instance of it.

For the deck class, the tutorial show this :
$this->mydeck = self::getNew( "module.common.deck" );

And I'm wondering what getNew() does this does not do :
$this->mydeck = new Deck();

Thank you

Re: getNew(X) or new X()

Posted: 25 March 2021, 21:38
by Tisaac
Ilmion wrote: 25 March 2021, 21:35 I want to make a class in my modules extending APP_DbObject and I'm wondering what is the accepted method to create a new instance of it.

For the deck class, the tutorial show this :
$this->mydeck = self::getNew( "module.common.deck" );

And I'm wondering what getNew() does this does not do :
$this->mydeck = new Deck();

Thank you
Just create an instance as in any php script with the new operator.

Re: getNew(X) or new X()

Posted: 25 March 2021, 21:47
by Ilmion
I know I can, I am just curious and want to know the utility of getNew()