Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-67

EmbeddedDocument - no LifecycleCallbacks

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Persister
    • Labels:
      None

      Description

      LifecycleCallbacks in EmbeddedDocument are not called

      /**
       * @EmbeddedDocument
       * @HasLifecycleCallbacks
       */
      class SocialNetworkUser {
      
      	/**
      	 * @Int(name="id")
      	 * @var int
      	 */
      	protected $id;
      	/**
      	 * @String(name="fN")
      	 * @var string
      	 */
      	protected $firstName;
      	/**
      	 * @String(name="lN")
      	 * @var string
      	 */
      	protected $lastName;
      	/**
      	 * @NotSaved
      	 * @var string
      	 */
      	protected $name;
      
              // ....
      
      	/**
      	 * @PostLoad
      	 */
              public function postLoad() {
      		$this->name = $this->firstName . ' ' . $this->lastName;
      	}
      }
      
      /**
       * @Document(collection="users")
       */
      class User {
      	/**
      	 * @Id
      	 */
      	protected $id;
      	/**
      	 * @EmbedOne(
      	 * 	discriminatorField="php",
      	 * 	discriminatorMap={
      	 * 		"fbu"="Documents\SocialNetworkUser "
      	 * 	},
      	 * 	name="snu",
      	 * 	cascade={"persist", "remove"}
      	 * )
      	 */
      	protected $socialNetworkUser;
      }
      
      $_user = $this->dm->findOne('Documents\User', array('snu.id' => $uid));
      print_r($_user->getSocialNetworkUser()->getName())
      

      $name is empty.
      postLoad is never called after load

        Activity

        Hide
        Thomas Adam added a comment -

        Sorry, my mistake.
        I have forgotten "callbacks" in cascade attribute .

        Show
        Thomas Adam added a comment - Sorry, my mistake. I have forgotten "callbacks" in cascade attribute .

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Thomas Adam
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: