You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then I would love it if my generated Product.php then contains a constructor function which requires the $name property. Like this:
// src/AppBundle/Entity/Product.phpclassProduct
{
// ...publicfunction__construct(string$name)
{
$this->setName($name);
// using the setter that already exists// so we can utilize any validation that that method might have
}
// ...
}
That way you can guarantee when I or another developer wants to initialize a new Product, that it will be a valid entity right after initialization.
The text was updated successfully, but these errors were encountered:
I'm looking into a way to implement this with a PR.
I actually have 2 questions:
-should i think about a global setting (all classes will be generated with constructor), a local one(only the ones with a specific parameter set), or both?
-id generation: possibly different policies will be involved : sometimes the id will be auto-generated (in this case, is there a reason about "isNullable" for an auto-generated id is true?), sometimes we want to initialize a Uuid inside the constructor (but not pass it inside the parameters), sometimes we want to pass the Uuid in the parameters, etc...so i'm not sure which policy to implement...ideas? Maybe an additional "constructorParameter" configuration inside the ID configuration...
If my
schema.yml
says this:Then I would love it if my generated
Product.php
then contains a constructor function which requires the$name
property. Like this:That way you can guarantee when I or another developer wants to initialize a new
Product
, that it will be a valid entity right after initialization.The text was updated successfully, but these errors were encountered: