getNew(X) or new X()

Game development with Board Game Arena Studio
Post Reply
User avatar
Ilmion
Posts: 30
Joined: 28 March 2020, 03:26

getNew(X) or new X()

Post 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
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: getNew(X) or new X()

Post 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.
User avatar
Ilmion
Posts: 30
Joined: 28 March 2020, 03:26

Re: getNew(X) or new X()

Post by Ilmion »

I know I can, I am just curious and want to know the utility of getNew()
Post Reply

Return to “Developers”