fix l11n call

This commit is contained in:
Dennis Eichhorn 2021-06-24 00:07:18 +02:00
parent 9f1e6b5d47
commit fa65e5266c
5 changed files with 12 additions and 20 deletions

View File

@ -309,18 +309,9 @@ final class ApiController extends Controller
} }
$category = $this->createWikiCategoryFromRequest($request); $category = $this->createWikiCategoryFromRequest($request);
$category->setL11n($request->getData('name'), $request->getData('language') ?? $request->getLanguage());
$this->createModel($request->header->account, $category, WikiCategoryMapper::class, 'category', $request->getOrigin()); $this->createModel($request->header->account, $category, WikiCategoryMapper::class, 'category', $request->getOrigin());
$l11nRequest = new HttpRequest($request->uri);
$l11nRequest->setData('category', $category->getId());
$l11nRequest->setData('name', $request->getData('name'));
$l11nRequest->setData('language', $request->getData('language'));
$l11nWikiCategory = $this->createWikiCategoryL11nFromRequest($l11nRequest);
$this->createModel($request->header->account, $l11nWikiCategory, WikiCategoryL11nMapper::class, 'tag_l11n', $request->getOrigin());
$category->setName($l11nWikiCategory);
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Category', 'Category successfully created.', $category); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Category', 'Category successfully created.', $category);
} }

View File

@ -98,9 +98,9 @@ class WikiCategory implements \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function getName() : string public function getL11n() : string
{ {
return $this->name instanceof WikiCategoryL11n ? $this->name->getName() : $this->name; return $this->name instanceof WikiCategoryL11n ? $this->name->name : $this->name;
} }
/** /**
@ -112,7 +112,7 @@ class WikiCategory implements \JsonSerializable
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public function setName($name, string $lang = ISO639x1Enum::_EN) : void public function setL11n($name, string $lang = ISO639x1Enum::_EN) : void
{ {
if ($name instanceof WikiCategoryL11n) { if ($name instanceof WikiCategoryL11n) {
$this->name = $name; $this->name = $name;

View File

@ -14,7 +14,8 @@ declare(strict_types=1);
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
$categories = $this->getData('categories'); /** @var \Modules\Knowledgebase\Models\WikiCategory[] $categories */
$categories = $this->getData('categories') ?? [];
/** @var \phpOMS\Views\View $this */ /** @var \phpOMS\Views\View $this */
echo $this->getData('nav')->render(); echo $this->getData('nav')->render();
@ -35,8 +36,8 @@ echo $this->getData('nav')->render();
$url = UriFactory::build('{/prefix}admin/account/settings?{?}&id=' . $value->getId()); ?> $url = UriFactory::build('{/prefix}admin/account/settings?{?}&id=' . $value->getId()); ?>
<tr tabindex="0" data-href="<?= $url; ?>"> <tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->getId(); ?></a> <td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a> <td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getL11n()); ?></a>
<td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->parent !== null ? $value->parent->getName() : ''); ?></a> <td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->parent !== null ? $value->parent->getL11n() : ''); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
<?php if (empty($categories)) : ?> <?php if (empty($categories)) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?> <tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>

View File

@ -41,7 +41,7 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-foot"> <div class="portlet-foot">
<div class="overflowfix"> <div class="overflowfix">
<?php $tags = $doc->getTags(); foreach ($tags as $tag) : ?> <?php $tags = $doc->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->getTitle()); ?></span> <span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?> <?php endforeach; ?>
<a href="<?= $url; ?>" class="button floatRight"><?= $this->getHtml('More', '0', '0'); ?></a> <a href="<?= $url; ?>" class="button floatRight"><?= $this->getHtml('More', '0', '0'); ?></a>
</div> </div>
@ -71,7 +71,7 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-body"> <div class="portlet-body">
<ul> <ul>
<?php foreach ($categories as $category) : ?> <?php foreach ($categories as $category) : ?>
<li><a href="<?= UriFactory::build('{/prefix}wiki/doc/list?{?}&id=' . $category->getId()); ?>"><?= $this->printHtml($category->getName()); ?></a> <li><a href="<?= UriFactory::build('{/prefix}wiki/doc/list?{?}&id=' . $category->getId()); ?>"><?= $this->printHtml($category->getL11n()); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
</div> </div>

View File

@ -46,7 +46,7 @@ echo $this->getData('nav')->render();
<div class="row"> <div class="row">
<div class="col-xs-6 overflowfix"> <div class="col-xs-6 overflowfix">
<?php foreach ($tags as $tag) : ?> <?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->getTitle()); ?></span> <span class="tag" style="background: <?= $this->printHtml($tag->color); ?>"><?= $tag->icon !== null ? '<i class="' . $this->printHtml($tag->icon ?? '') . '"></i>' : ''; ?><?= $this->printHtml($tag->getL11n()); ?></span>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<?php if ($editable) : ?> <?php if ($editable) : ?>
@ -66,7 +66,7 @@ echo $this->getData('nav')->render();
<div class="portlet-body"> <div class="portlet-body">
<ul> <ul>
<?php foreach ($categories as $category) : ?> <?php foreach ($categories as $category) : ?>
<li><a href="<?= UriFactory::build('{/prefix}wiki/doc/list?{?}&id=' . $category->getId()); ?>"><?= $this->printHtml($category->getName()); ?></a> <li><a href="<?= UriFactory::build('{/prefix}wiki/doc/list?{?}&id=' . $category->getId()); ?>"><?= $this->printHtml($category->getL11n()); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
</div> </div>