/** * @return array */ public function serialize() { $data = ['auth_data' => $this->authData, 'value' => $this->value]; if ($this->promotion === null) { throw new NotEnoughDataException('promotion is null'); } if ($this->promotion->getId() !== null) { $data['promotion_id'] = $this->promotion->getId(); } elseif ($this->promotion->getAlias() !== null) { $data['promotion_alias'] = $this->promotion->getAlias(); } else { throw new NotEnoughDataException('promotion->id is null and promotion->alias is null'); } return $data; }
/** * @return array */ public function serialize() { $parentData = parent::serialize(); if ($this->promotion === null) { throw new NotEnoughDataException('promotion is null'); } if ($this->promotion->getAlias() === null) { throw new NotEnoughDataException('promotion->alias is null'); } if ($this->user === null) { throw new NotEnoughDataException('user is null'); } if ($this->user->getId() === null) { throw new NotEnoughDataException('user->id is null'); } $parentData['promotion_alias'] = $this->promotion->getAlias(); $parentData['user_id'] = $this->user->getId(); return $parentData; }