Created
May 21, 2014 13:59
-
-
Save gquemener/5c87598b956e0d0b4330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @ORM/Entity | |
*/ | |
class Product | |
{ | |
/** | |
* @OneToMany(targetEntity="Price", mappedBy="product", cascade={"refresh"}) | |
*/ | |
public $prices; | |
/** | |
* @OneToMany(targetEntity="Color", mappedBy="product", cascade={"refresh"}, fetch="EAGER") | |
*/ | |
public $colors; | |
} | |
$product = //fetch a product from db through doctrine and hydrate it | |
$em->refresh($product); // $product->prices is empty | |
// because the BasicEmptyPersister unwrap the PersistentCollection (thus not initialize it) | |
// and refresh each elements (which it doesn't have, because it was not initialized) | |
// $product->colors is correctly refreshed and contains same colors than in DB | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment