mirror of
https://github.com/Karaka-Management/oms-Tag.git
synced 2026-02-12 13:18:40 +00:00
rename l11ntag to tagl11n
This commit is contained in:
parent
722892274f
commit
9c86db62fc
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Tag\Controller;
|
||||
|
||||
use Modules\Tag\Models\L11nTag;
|
||||
use Modules\Tag\Models\L11nTagMapper;
|
||||
use Modules\Tag\Models\TagL11n;
|
||||
use Modules\Tag\Models\TagL11nMapper;
|
||||
use Modules\Tag\Models\Tag;
|
||||
use Modules\Tag\Models\TagMapper;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
|
|
@ -135,8 +135,8 @@ final class ApiController extends Controller
|
|||
$l11nRequest->setData('color', $request->getData('color'));
|
||||
$l11nRequest->setData('language', $request->getData('language'));
|
||||
|
||||
$l11nTag = $this->createL11nTagFromRequest($l11nRequest);
|
||||
$this->createModel($request->getHeader()->getAccount(), $l11nTag, L11nTagMapper::class, 'tag_l11n', $request->getOrigin());
|
||||
$l11nTag = $this->createTagL11nFromRequest($l11nRequest);
|
||||
$this->createModel($request->getHeader()->getAccount(), $l11nTag, TagL11nMapper::class, 'tag_l11n', $request->getOrigin());
|
||||
|
||||
$tag->setTitle($l11nTag);
|
||||
|
||||
|
|
@ -186,8 +186,8 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$l11nTag = $this->createL11nTagFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $l11nTag, L11nTagMapper::class, 'tag_l11n', $request->getOrigin());
|
||||
$l11nTag = $this->createTagL11nFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $l11nTag, TagL11nMapper::class, 'tag_l11n', $request->getOrigin());
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Tag localization successfully created', $l11nTag);
|
||||
}
|
||||
|
|
@ -214,13 +214,13 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return L11nTag
|
||||
* @return TagL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createL11nTagFromRequest(RequestAbstract $request) : L11nTag
|
||||
private function createTagL11nFromRequest(RequestAbstract $request) : TagL11n
|
||||
{
|
||||
$l11nTag = new L11nTag();
|
||||
$l11nTag = new TagL11n();
|
||||
$l11nTag->setTag((int) ($request->getData('tag') ?? 0));
|
||||
$l11nTag->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getHeader()->getL11n()->getLanguage()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Tag\Controller;
|
||||
|
||||
use Modules\Tag\Models\L11nTagMapper;
|
||||
use Modules\Tag\Models\TagL11nMapper;
|
||||
use Modules\Tag\Models\TagMapper;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
|
|
@ -113,7 +113,7 @@ final class BackendController extends Controller
|
|||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007501001, $request, $response));
|
||||
$view->addData('tag', $tag);
|
||||
|
||||
$l11n = L11nTagMapper::withConditional('tag', $tag->getId())::getAll();
|
||||
$l11n = TagL11nMapper::withConditional('tag', $tag->getId())::getAll();
|
||||
$view->addData('l11n', $l11n);
|
||||
|
||||
return $view;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ namespace Modules\Tag\Models;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullL11nTag extends Tag
|
||||
final class NullTagL11n extends TagL11n
|
||||
{
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ class Tag implements \JsonSerializable, ArrayableInterface
|
|||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string|L11nTag
|
||||
* @var string|TagL11n
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $title = '';
|
||||
|
|
@ -166,13 +166,13 @@ class Tag implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
public function getTitle() : string
|
||||
{
|
||||
return $this->title instanceof L11nTag ? $this->title->getTitle() : $this->title;
|
||||
return $this->title instanceof TagL11n ? $this->title->getTitle() : $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*
|
||||
* @param string|L11nTag $title Tag article title
|
||||
* @param string|TagL11n $title Tag article title
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -180,12 +180,12 @@ class Tag implements \JsonSerializable, ArrayableInterface
|
|||
*/
|
||||
public function setTitle($title, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($title instanceof L11nTag) {
|
||||
if ($title instanceof TagL11n) {
|
||||
$this->title = $title;
|
||||
} elseif ($this->title instanceof L11nTag && \is_string($title)) {
|
||||
} elseif ($this->title instanceof TagL11n && \is_string($title)) {
|
||||
$this->title->setTitle($title);
|
||||
} elseif (\is_string($title)) {
|
||||
$this->title = new L11nTag();
|
||||
$this->title = new TagL11n();
|
||||
$this->title->setTitle($title);
|
||||
$this->title->setLanguage($lang);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use phpOMS\Localization\ISO639x1Enum;
|
|||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class L11nTag implements \JsonSerializable, ArrayableInterface
|
||||
class TagL11n implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Article ID.
|
||||
|
|
@ -66,9 +66,10 @@ class L11nTag implements \JsonSerializable, ArrayableInterface
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $title = '')
|
||||
public function __construct(string $title = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->title = $title;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -27,7 +27,7 @@ use phpOMS\Localization\Defaults\LanguageMapper;
|
|||
*
|
||||
* @todo Do I really want to create a relation to the language mapper? It's not really needed right?
|
||||
*/
|
||||
final class L11nTagMapper extends DataMapperAbstract
|
||||
final class TagL11nMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
|
|
@ -52,7 +52,7 @@ final class TagMapper extends DataMapperAbstract
|
|||
*/
|
||||
protected static array $hasMany = [
|
||||
'title' => [
|
||||
'mapper' => L11nTagMapper::class,
|
||||
'mapper' => TagL11nMapper::class,
|
||||
'table' => 'tag_l11n',
|
||||
'external' => 'tag_l11n_tag',
|
||||
'column' => 'title',
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Tag\tests\Models;
|
||||
|
||||
use Modules\Tag\Models\L11nTag;
|
||||
use Modules\Tag\Models\L11nTagMapper;
|
||||
use Modules\Tag\Models\TagL11n;
|
||||
use Modules\Tag\Models\TagL11nMapper;
|
||||
use Modules\Tag\Models\Tag;
|
||||
use Modules\Tag\Models\TagMapper;
|
||||
use Modules\Tag\Models\TagType;
|
||||
|
|
@ -24,10 +24,10 @@ use phpOMS\Localization\ISO639x1Enum;
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
class L11nTagMapperTest extends \PHPUnit\Framework\TestCase
|
||||
class TagL11nMapperTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\Tag\Models\L11nTagMapper
|
||||
* @covers Modules\Tag\Models\TagL11nMapper
|
||||
* @group module
|
||||
*/
|
||||
public function testCR() : void
|
||||
|
|
@ -40,16 +40,16 @@ class L11nTagMapperTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertGreaterThan(0, $tag->getId());
|
||||
self::assertEquals($id, $tag->getId());
|
||||
|
||||
$l11n = new L11nTag();
|
||||
$l11n = new TagL11n();
|
||||
$l11n->setTitle('TestTitle');
|
||||
$l11n->setLanguage(ISO639x1Enum::_EN);
|
||||
$l11n->setTag($id);
|
||||
|
||||
$id = L11nTagMapper::create($l11n);
|
||||
$id = TagL11nMapper::create($l11n);
|
||||
self::assertGreaterThan(0, $l11n->getId());
|
||||
self::assertEquals($id, $l11n->getId());
|
||||
|
||||
$l11nR = L11nTagMapper::get($l11n->getId());
|
||||
$l11nR = TagL11nMapper::get($l11n->getId());
|
||||
self::assertEquals($l11n->getTitle(), $l11nR->getTitle());
|
||||
self::assertEquals($l11n->getLanguage(), $l11nR->getLanguage());
|
||||
}
|
||||
|
|
@ -14,23 +14,23 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Tag\tests\Models;
|
||||
|
||||
use Modules\Tag\Models\L11nTag;
|
||||
use Modules\Tag\Models\TagL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class L11nTagTest extends \PHPUnit\Framework\TestCase
|
||||
class TagL11nTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private L11nTag $l11n;
|
||||
private TagL11n $l11n;
|
||||
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->l11n = new L11nTag();
|
||||
$this->l11n = new TagL11n();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Tag\Models\L11nTag
|
||||
* @covers Modules\Tag\Models\TagL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
|
|
@ -42,7 +42,7 @@ class L11nTagTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Tag\Models\L11nTag
|
||||
* @covers Modules\Tag\Models\TagL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testTagInputOutput() : void
|
||||
|
|
@ -52,7 +52,7 @@ class L11nTagTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Tag\Models\L11nTag
|
||||
* @covers Modules\Tag\Models\TagL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testLanguageInputOutput() : void
|
||||
|
|
@ -62,7 +62,7 @@ class L11nTagTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Tag\Models\L11nTag
|
||||
* @covers Modules\Tag\Models\TagL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testTitleInputOutput() : void
|
||||
|
|
@ -72,7 +72,7 @@ class L11nTagTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Tag\Models\L11nTag
|
||||
* @covers Modules\Tag\Models\TagL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Tag\tests\Models;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Tag\Models\L11nTag;
|
||||
use Modules\Tag\Models\TagL11n;
|
||||
use Modules\Tag\Models\Tag;
|
||||
use Modules\Tag\Models\TagType;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class TagTest extends \PHPUnit\Framework\TestCase
|
|||
$this->tag->setTitle('Test');
|
||||
self::assertEquals('Test', $this->tag->getTitle());
|
||||
|
||||
$this->tag->setTitle(new L11nTag('Test2'));
|
||||
$this->tag->setTitle(new TagL11n('Test2'));
|
||||
self::assertEquals('Test2', $this->tag->getTitle());
|
||||
|
||||
$this->tag->setTitle('Test3');
|
||||
|
|
@ -96,7 +96,7 @@ class TagTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->tag->setTitle($t = new L11nTag('Test'));
|
||||
$this->tag->setTitle($t = new TagL11n('Test'));
|
||||
$this->tag->setOwner($a = new NullAccount(2));
|
||||
$this->tag->setColor('ffffffff');
|
||||
$this->tag->setType(TagType::SHARED);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user