public function toJson() { if (!empty($this->raw)) { return $this->raw; } $ret = array(); if ($this->type == self::TYPE_NOTIFICATION) { $ret['title'] = $this->title; $ret['content'] = $this->content; $ret['accept_time'] = $this->acceptTimeToJson(); $ret['builder_id'] = $this->style->getBuilderId(); $ret['ring'] = $this->style->getRing(); $ret['vibrate'] = $this->style->getVibrate(); $ret['clearable'] = $this->style->getClearable(); $ret['n_id'] = $this->style->getNId(); if (!is_null($this->style->getRingRaw())) { $ret['ring_raw'] = $this->style->getRingRaw(); } $ret['lights'] = $this->style->getLights(); $ret['icon_type'] = $this->style->getIconType(); if (!is_null($this->style->getIconRes())) { $ret['icon_res'] = $this->style->getIconRes(); } $ret['style_id'] = $this->style->getStyleId(); if (!is_null($this->style->getSmallIcon())) { $ret['small_icon'] = $this->style->getSmallIcon(); } $ret['action'] = $this->action->toJson(); } else { if ($this->type == self::TYPE_MESSAGE) { $ret['title'] = $this->title; $ret['content'] = $this->content; $ret['accept_time'] = $this->acceptTimeToJson(); } } $ret['custom_content'] = $this->custom; return json_encode($ret); }
/** * * @param Style $style */ public function setStyle(Style $style) { $this->setStyleID($style->getStyleId()); }