]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Entity/Dance.php
Use getObject event args member function instead of deprecated getEntity
[airbundle] / Entity / Dance.php
index dccee339801f6dd00cec7c9a4bfc032bc4a212d5..0b132c8418cd76f59846514ffb62784aaa222743 100644 (file)
@@ -209,6 +209,9 @@ class Dance {
         * @return Dance
         */
        public function addUser(User $user): Dance {
+               //Add from owning side
+               $user->addDance($this);
+
                $this->users[] = $user;
 
                return $this;
@@ -222,6 +225,13 @@ class Dance {
         * @return bool
         */
        public function removeUser(User $user): bool {
+               if (!$this->dances->contains($user)) {
+                       return true;
+               }
+
+               //Remove from owning side
+               $user->removeDance($this);
+
                return $this->users->removeElement($user);
        }
 
@@ -239,7 +249,7 @@ class Dance {
         */
        public function preUpdate(PreUpdateEventArgs $eventArgs) {
                //Check that we have a dance instance
-               if (($dance = $eventArgs->getEntity()) instanceof Dance) {
+               if (($dance = $eventArgs->getObject()) instanceof Dance) {
                        //Set updated value
                        $dance->setUpdated(new \DateTime('now'));
                }