Aah, look at that! A similar response 7 months ago :) On 17 December 2014 at 21:45, Menno Holtkamp <[email protected]> wrote: > > Next to getters and setters, I tend to add 'hassers' on my Entities. For > example: > > class User > { > /** > * @var City > */ > private $city; > > public function hasCity() > { > return $this->city instanceof City; > } > > } > > > works quite well. The whole process of managing the getters, setters, > hassers and other utility functions can be automated using a code generator > which parses your Entity metadata. Then you have your common entity 'User' > extend a generated one, for example 'UserGenerated' and voila. > > Don't believe this is a best practice, but it makes it easier to get new > mappings up and running quickly. Some IDE's also allow you to define your > own code generation templates... > > > Cheers > > On 17 December 2014 at 21:21, Nima Sadjadi <[email protected]> wrote: >> >> Long time ago I wrote this: >> >> > "when I do this: >> $something = $blah->getX(); >> >> $something may have no value, because may be there is not any X >> associated to $blah, I want to checv it with if statement to see if there >> is an entity for $something, update it, if no entity, create it. I tried >> both: >> if ($something === null) { >> and >> if ($something === false) { >> but it goes always to else clause if there is no entity found. I tried >> debug:dump and I get blank entity, this is why it is not null but when I >> want to update it, I get "entity not found" error, what should I check to >> solve this? or what wrong I did? >> I tried it with several other entities, with different associations and >> method names, and there is always such problem. plz help." >> >> Now I am interested to know if noObjectExist validator of >> https://github.com/doctrine/DoctrineModule/blob/master/docs/validator.md >> Would help for my issue? >> Actually my User entity may or ma not have a credit, i want to check if >> it has not, create it, if has it, update it, User is OneToOne with credit >> and when I do find() User a blank credit object proxy is set so that if >> statement I said above does not help. Does this object validator help? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "doctrine-user" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/doctrine-user. >> For more options, visit https://groups.google.com/d/optout. >> >
-- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
