public function save() { $membershipId = $this->getValue('membershipId'); if (!empty($membershipId)) { $membership = $this->getMembershipService()->getMembershipById($membershipId); } else { $membership = new Membership(); } $membership->setName($this->getValue('name')); $membership->save(); }