I really did not know what to call it or to search for an already posted question, so I apologize if this has been noticed here before.
I get some unwanted results with the following code:
$fooManager = $this->getContainer()->get('foo_manager');
$barManager = $this->getContainer()->get('bar_manager');
for (;;) {
while (($foo = $fooManager->findUninitialized()) !== null) {
$bar = $barManager->create();
$bar->setA('...');
$barManager->update($bar);
$foo->setBar($bar);
$fooManager->update($foo);
}
while (($foo = $fooManager->findUnprocessed()) !== null) {
process($foo->getBar()->getB());
}
}
You can see that in the first cycle while, objects $barare created and placed in the database. Another script picks them up and does something with them.
In the second cycle, whileobjects $footry to access their modified "bar" object (note that it is called getB(), we can assume that in another script it is executed separately, it setB()was used to change the state of the object).
, getB(), I, setB() script.
, ( ) , , getB(), , "B", .
, , , , "", $foo->getBar() ( ). , var_dump() , $foo->getBar() , , "bar" .
, - - ( "" script, Doctrine , , ).
, , , . , , Symfony2, "" , ; "", , "", "bar".
, , , $foo->getBar(), . .