| @@ 161-182 (lines=22) @@ | ||
| 158 | * |
|
| 159 | * @return array |
|
| 160 | */ |
|
| 161 | public function transformNews($news) |
|
| 162 | { |
|
| 163 | $articles = []; |
|
| 164 | ||
| 165 | if (!is_array($news)) { |
|
| 166 | $news = [$news]; |
|
| 167 | } |
|
| 168 | ||
| 169 | foreach ($news as $item) { |
|
| 170 | $articles[] = [ |
|
| 171 | 'Title' => $item->get('title'), |
|
| 172 | 'Description' => $item->get('description'), |
|
| 173 | 'Url' => $item->get('url'), |
|
| 174 | 'PicUrl' => $item->get('pic_url'), |
|
| 175 | ]; |
|
| 176 | } |
|
| 177 | ||
| 178 | return [ |
|
| 179 | 'ArticleCount' => count($articles), |
|
| 180 | 'Articles' => $articles, |
|
| 181 | ]; |
|
| 182 | } |
|
| 183 | ||
| 184 | public function transformDeviceText(AbstractMessage $message) |
|
| 185 | { |
|
| @@ 144-162 (lines=19) @@ | ||
| 141 | * |
|
| 142 | * @return array |
|
| 143 | */ |
|
| 144 | public function transformNews($news) |
|
| 145 | { |
|
| 146 | $articles = []; |
|
| 147 | ||
| 148 | if (!is_array($news)) { |
|
| 149 | $news = [$news]; |
|
| 150 | } |
|
| 151 | ||
| 152 | foreach ($news as $item) { |
|
| 153 | $articles[] = [ |
|
| 154 | 'title' => $item->get('title'), |
|
| 155 | 'description' => $item->get('description'), |
|
| 156 | 'url' => $item->get('url'), |
|
| 157 | 'picurl' => $item->get('pic_url'), |
|
| 158 | ]; |
|
| 159 | } |
|
| 160 | ||
| 161 | return ['msgtype' => 'news', 'news' => ['articles' => $articles]]; |
|
| 162 | } |
|
| 163 | ||
| 164 | /** |
|
| 165 | * Transform material message. |
|