mirror of
https://github.com/Karaka-Management/oms-News.git
synced 2026-01-11 16:18:41 +00:00
fix phpstan lvl 9 bugs
This commit is contained in:
parent
93ee535659
commit
98fb4bcc48
|
|
@ -95,7 +95,9 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiNewsUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
$old = clone NewsArticleMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
/** @var \Modules\News\Models\NewsArticle $old */
|
||||
$old = NewsArticleMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$old = clone $old;
|
||||
$new = $this->updateNewsFromRequest($request);
|
||||
$this->updateModel($request->header->account, $old, $new, NewsArticleMapper::class, 'news', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'News', 'News successfully updated', $new);
|
||||
|
|
@ -112,11 +114,11 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function updateNewsFromRequest(RequestAbstract $request) : NewsArticle
|
||||
{
|
||||
/** @var NewsArticle $newsArticle */
|
||||
/** @var \Modules\News\Models\NewsArticle $newsArticle */
|
||||
$newsArticle = NewsArticleMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$newsArticle->publish = new \DateTime((string) ($request->getData('publish') ?? $newsArticle->publish->format('Y-m-d H:i:s')));
|
||||
$newsArticle->title = (string) ($request->getData('title') ?? $newsArticle->title);
|
||||
$newsArticle->plain = $request->getData('plain') ?? $newsArticle->plain;
|
||||
$newsArticle->plain = (string) ($request->getData('plain') ?? $newsArticle->plain);
|
||||
$newsArticle->content = Markdown::parse((string) ($request->getData('plain') ?? $newsArticle->plain));
|
||||
$newsArticle->setLanguage(\strtolower((string) ($request->getData('lang') ?? $newsArticle->getLanguage())));
|
||||
$newsArticle->setType((int) ($request->getData('type') ?? $newsArticle->getType()));
|
||||
|
|
@ -172,7 +174,9 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createNewsMedia(NewsArticle $news, RequestAbstract $request) : void
|
||||
{
|
||||
$path = $this->createNewsDir($news);
|
||||
$path = $this->createNewsDir($news);
|
||||
|
||||
/** @var \Modules\Admin\Models\Account $account */
|
||||
$account = AccountMapper::get()->where('id', $request->header->account)->execute();
|
||||
|
||||
if (!empty($uploadedFiles = $request->getFiles())) {
|
||||
|
|
@ -280,7 +284,7 @@ final class ApiController extends Controller
|
|||
$newsArticle->createdBy = new NullAccount($request->header->account);
|
||||
$newsArticle->publish = new \DateTime((string) ($request->getData('publish') ?? 'now'));
|
||||
$newsArticle->title = (string) ($request->getData('title') ?? '');
|
||||
$newsArticle->plain = $request->getData('plain') ?? '';
|
||||
$newsArticle->plain = (string) ($request->getData('plain') ?? '');
|
||||
$newsArticle->content = Markdown::parse((string) ($request->getData('plain') ?? ''));
|
||||
$newsArticle->setLanguage(\strtolower((string) ($request->getData('lang') ?? $request->getLanguage())));
|
||||
$newsArticle->setType((int) ($request->getData('type') ?? NewsType::ARTICLE));
|
||||
|
|
@ -306,7 +310,12 @@ final class ApiController extends Controller
|
|||
|
||||
$internalResponse = new HttpResponse();
|
||||
$this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null);
|
||||
$newsArticle->addTag($internalResponse->get($request->uri->__toString())['response']);
|
||||
|
||||
if (!\is_array($data = $internalResponse->get($request->uri->__toString()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$newsArticle->addTag($data['response']);
|
||||
} else {
|
||||
$newsArticle->addTag(new NullTag((int) $tag['id']));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,25 +67,30 @@ final class BackendController extends Controller implements DashboardElementInte
|
|||
->where('language', $response->getLanguage())
|
||||
->where('tags/title/language', $response->getLanguage());
|
||||
|
||||
/** @var \Modules\News\Models\NewsArticle[] $objs */
|
||||
$objs = [];
|
||||
if ($request->getData('ptype') === 'p') {
|
||||
$view->setData('news',
|
||||
$data = $mapperQuery->where('id', (int) ($request->getData('id') ?? 0), '<')
|
||||
->limit(25)->execute()
|
||||
);
|
||||
/** @var \Modules\News\Models\NewsArticle[] $objs */
|
||||
$objs = $mapperQuery->where('id', (int) ($request->getData('id') ?? 0), '<')
|
||||
->limit(25)->execute();
|
||||
|
||||
$view->setData('news', $objs);
|
||||
} elseif ($request->getData('ptype') === 'n') {
|
||||
$view->setData('news',
|
||||
$data = $mapperQuery->where('id', (int) ($request->getData('id') ?? 0), '>')
|
||||
->limit(25)->execute()
|
||||
);
|
||||
/** @var \Modules\News\Models\NewsArticle[] $objs */
|
||||
$objs = $mapperQuery->where('id', (int) ($request->getData('id') ?? 0), '>')
|
||||
->limit(25)->execute();
|
||||
|
||||
$view->setData('news', $objs);
|
||||
} else {
|
||||
$view->setData('news',
|
||||
$data = $mapperQuery->where('id', 0, '>')
|
||||
->limit(25)->execute()
|
||||
);
|
||||
/** @var \Modules\News\Models\NewsArticle[] $objs */
|
||||
$objs = $mapperQuery->where('id', 0, '>')
|
||||
->limit(25)->execute();
|
||||
|
||||
$view->setData('news', $objs);
|
||||
}
|
||||
|
||||
$ids = [];
|
||||
foreach ($data as $news) {
|
||||
foreach ($objs as $news) {
|
||||
$ids[] = $news->getId();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="portlet-foot">
|
||||
<div class="overflowfix">
|
||||
<?php $tags = $news->getTags(); foreach ($tags as $tag) : ?>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= !empty($tag->icon) ? '<i class="' . $this->printHtml($tag->icon) . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
|
||||
<?php endforeach; ?>
|
||||
<a tabindex="0" href="<?= $url; ?>" class="button floatRight"><?= $this->getHtml('More', '0', '0'); ?></a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="row">
|
||||
<div class="col-xs-6 overflowfix">
|
||||
<?php foreach ($tags as $tag) : ?>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= !empty($tag->icon) ? '<i class="' . $this->printHtml($tag->icon) . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php $files = $news->getMedia(); foreach ($files as $file) : ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user