public static function getById($nid) { $news = new NewsModel(); $nextNews = Yii::$app->businesslayer->news->getById($nid); $news->setAttributes(['newsId' => $nextNews['ID'], 'newsDate' => $nextNews['NewsDate'], 'newsFormatId' => $nextNews['NewsFormatID'], 'textPreview' => $nextNews['TextPreview'], 'bannerPicture' => $nextNews['BannerPicture'], 'hyperLinkTypeId' => $nextNews['HyperLinkTypeID'], 'hyperLinkUrl' => $nextNews['HyperLinkUrl'], 'textFull' => $nextNews['TextFull'], 'pictureTop' => $nextNews['PictureTopInFull'], 'pictureBottom' => $nextNews['PictureBottomInFull'], 'author' => $nextNews['NewsAuthorID']]); if (!$news->hyperLinkUrl) { $news->hyperLinkUrl = ""; } return $news; }
/** * @inheritdoc */ protected function prepareModels() { $models = []; $pagination = $this->getPagination(); if ($pagination === false) { foreach (Yii::$app->businesslayer->schools->getNews($this->sid) as $nextNews) { $nextModel = new NewsModel(); $nextModel->setAttributes(['newsId' => $nextNews['ID'], 'newsDate' => $nextNews['NewsDate'], 'newsFormatId' => $nextNews['NewsFormatID'], 'textPreview' => $nextNews['TextPreview'], 'bannerPicture' => $nextNews['BannerPicture'], 'hyperLinkTypeId' => $nextNews['HyperLinkTypeID'], 'hyperLinkUrl' => $nextNews['HyperLinkUrl']]); $models[] = $nextModel; } } else { // $pagination->totalCount = $this->getTotalCount(); // $this->fileObject->seek($pagination->getOffset()); // $limit = $pagination->getLimit(); // for ($count = 0; $count < $limit; ++$count) { // $models[] = $this->fileObject->fgetcsv(); // $this->fileObject->next(); // } } return $models; }