Feature #28868

Default Doctrine Annotation for single object relation should be derived automatically

Added by Christian Müller about 10 years ago. Updated about 10 years ago.

Status:
Resolved
Priority:
Should have
Category:
Persistence
Start date:
2011-08-09
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

/** * @var \Me\MyPackage\Domain\Model\DepartmentPerson
*/
protected $departmentPerson = NULL;

Will result in strange errors that are not really helpful. Should by default create OneToOne or ManyToOne (maybe better) Relation (tbd) or at least give some warning on compile?

#1

Updated by Sascha Egerer about 10 years ago

I got the same case wich throws a "Object of class XXX\XXX\Domain\Model\ClassName could not be converted to string" exception.

But I think it's a better idea to throw an exception in this case, wich explains that there is something missing for the relation.

#2

Updated by Karsten Dambekalns about 10 years ago

  • Category set to Persistence
  • Status changed from New to Needs Feedback
  • Assignee set to Karsten Dambekalns

Since there cannot be a reasonable default (OneToOne vs @ManyToOne) this will not be changed. Also, you *could* actually want to store "objects as strings" using @__toString(), so an exception during compile is not an option either.

Any better ideas?

#3

Updated by Robert Lemke about 10 years ago

  • Target version changed from 1.0 beta 1 to 1.0 beta 2
#4

Updated by Karsten Dambekalns about 10 years ago

  • Tracker changed from Bug to Feature
#5

Updated by Mr. Hudson about 10 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 2 of change I0252e4ea07854908d5a04c3d083e560174f9ca77 has been pushed to the review server.
It is available at http://review.typo3.org/4549

#6

Updated by Karsten Dambekalns about 10 years ago

The exception idea is fine, if someone really wants to store objects as string using __toString() a simple type attribute to @Column is possible.

#7

Updated by Karsten Dambekalns about 10 years ago

  • Target version changed from 1.0 beta 2 to 1.0 beta 1

Fine for beta 1 IMHO.

#8

Updated by Sascha Egerer about 10 years ago

Karsten Dambekalns wrote:

The exception idea is fine, if someone really wants to store objects as string using __toString() a simple type attribute to @Column is possible.

Ok that's true! Thx for your fast review!

#9

Updated by Sascha Egerer about 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF