-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for array of objects as reference #141
base: 1.5.x
Are you sure you want to change the base?
Conversation
PhpStorm shows an error. I think it's because ObjectManager was already imported.
Updated incorrect PhpDoc
addReference() actually throws exception
…et managed my UnitOfWork.
Add explicit visibility for function load
Syntax highlighting on README.md
Add explicit visibility following PSR-2
Add explicit visibility for method getOrder
Add support for 2.5 embeddables
@@ -98,7 +98,7 @@ protected function getIdentifier($reference, $uow) | |||
* @param string $name | |||
* @param object $reference | |||
*/ | |||
public function setReference($name, $reference) | |||
public function setReference($name, object $reference) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
object
is not a valid typehint in PHP
@stof please motivate your answer, i shall edit the first post to motivate my PR |
return $this->_loadReference($name, $references); | ||
} | ||
|
||
$return = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid PHP 5.3 code
@flip111 the goal of the ReferenceRepository is to keep a reference to a managed entity to share it between fixtures ("managed" being the reason why we need some logic for it). Having 2 different meaning for the reference seems weird to me. Thus, even the naming is confusing: setting a reference to an arrya is done with |
@stof i agree with what you are saying. However i was too afraid to adjust more code then i already have and come up with new names for "reference". Anyway if you or anyone else agrees that the use case is there and validates a change then we can discuss a possible solution to this problem. Right now it's up to the programmer to remember if a single reference is a reference to an object or an array of objects. But actually i think the By the way, didn't know this lib had to be compatible with php 5.3 |
Could not start test from working test code, see #142
Why is this useful? Consider model relations:
A OneToMany B OneToMany C
(a tree)When creating the entities for
B
, it's easy to grab that oneA
. However when creating fixtures forC
there are now multipleB
's, they clearly belong together (are part of the same A), but they can't be grouped. The only alternative is to doaddReference('B1', $Bs[0]); addReference('B2', $Bs[1]);
etc