mirror of
https://github.com/Karaka-Management/oms-Editor.git
synced 2026-01-11 09:08:42 +00:00
autofixes
This commit is contained in:
parent
89053c804c
commit
bf076fa7c2
|
|
@ -18,13 +18,13 @@ use Modules\Admin\Models\NullAccount;
|
|||
use Modules\Editor\Models\EditorDoc;
|
||||
use Modules\Editor\Models\EditorDocMapper;
|
||||
use Modules\Tag\Models\NullTag;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
use phpOMS\Utils\Parser\Markdown\Markdown;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
|
||||
/**
|
||||
* Calendar controller class.
|
||||
|
|
@ -103,9 +103,9 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createDocFromRequest(RequestAbstract $request) : EditorDoc
|
||||
{
|
||||
$doc = new EditorDoc();
|
||||
$doc->title = (string) ($request->getData('title') ?? '');
|
||||
$doc->plaint = (string) ($request->getData('plain') ?? '');
|
||||
$doc = new EditorDoc();
|
||||
$doc->title = (string) ($request->getData('title') ?? '');
|
||||
$doc->plaint = (string) ($request->getData('plain') ?? '');
|
||||
$doc->content = Markdown::parse((string) ($request->getData('plain') ?? ''));
|
||||
$doc->setVirtualPath((string) ($request->getData('virtualpath') ?? '/'));
|
||||
$doc->createdBy = new NullAccount($request->header->account);
|
||||
|
|
@ -163,9 +163,9 @@ final class ApiController extends Controller
|
|||
private function updateEditorFromRequest(RequestAbstract $request) : EditorDoc
|
||||
{
|
||||
/** @var \Modules\Editor\Models\EditorDoc $doc */
|
||||
$doc = EditorDocMapper::get((int) $request->getData('id'));
|
||||
$doc->title = (string) ($request->getData('title') ?? $doc->title);
|
||||
$doc->plaint = (string) ($request->getData('plain') ?? $doc->plain);
|
||||
$doc = EditorDocMapper::get((int) $request->getData('id'));
|
||||
$doc->title = (string) ($request->getData('title') ?? $doc->title);
|
||||
$doc->plaint = (string) ($request->getData('plain') ?? $doc->plain);
|
||||
$doc->content = Markdown::parse((string) ($request->getData('plain') ?? $doc->plain));
|
||||
|
||||
return $doc;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ use phpOMS\Message\Http\RequestStatusCode;
|
|||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Views\View;
|
||||
use Modules\Media\Models\Collection;
|
||||
use Modules\Admin\Models\Account;
|
||||
|
||||
/**
|
||||
* Calendar controller class.
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ final class EditorDocMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
'editor_doc_id' => ['name' => 'editor_doc_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'editor_doc_created_by' => ['name' => 'editor_doc_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'editor_doc_title' => ['name' => 'editor_doc_title', 'type' => 'string', 'internal' => 'title'],
|
||||
'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'],
|
||||
'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'],
|
||||
'editor_doc_id' => ['name' => 'editor_doc_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'editor_doc_created_by' => ['name' => 'editor_doc_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'editor_doc_title' => ['name' => 'editor_doc_title', 'type' => 'string', 'internal' => 'title'],
|
||||
'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'],
|
||||
'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'],
|
||||
'editor_doc_virtual' => ['name' => 'editor_doc_virtual', 'type' => 'string', 'internal' => 'virtualPath'],
|
||||
'editor_doc_created_at' => ['name' => 'editor_doc_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
'editor_doc_created_at' => ['name' => 'editor_doc_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -192,9 +192,9 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testDeleteEditorDoc() : void
|
||||
{
|
||||
$doc = new EditorDoc();
|
||||
$doc->title = 'TestTitle';
|
||||
$doc->content = 'TestContent';
|
||||
$doc = new EditorDoc();
|
||||
$doc->title = 'TestTitle';
|
||||
$doc->content = 'TestContent';
|
||||
$doc->createdBy = new NullAccount(1);
|
||||
|
||||
$docId = EditorDocMapper::create($doc);
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ class EditorDocMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$doc = new EditorDoc();
|
||||
|
||||
$doc->createdBy = new NullAccount(1);
|
||||
$doc->title = 'Title';
|
||||
$doc->content = 'Content';
|
||||
$doc->title = 'Title';
|
||||
$doc->content = 'Content';
|
||||
$doc->setVirtualPath('/some/test/path');
|
||||
|
||||
$id = EditorDocMapper::create($doc);
|
||||
|
|
@ -63,8 +63,8 @@ class EditorDocMapperTest extends \PHPUnit\Framework\TestCase
|
|||
// Test other
|
||||
|
||||
$doc->createdBy = new NullAccount(\mt_rand(1, 1));
|
||||
$doc->title = $text->generateText(\mt_rand(3, 7));
|
||||
$doc->content = $text->generateText(\mt_rand(20, 500));
|
||||
$doc->title = $text->generateText(\mt_rand(3, 7));
|
||||
$doc->content = $text->generateText(\mt_rand(20, 500));
|
||||
$doc->setVirtualPath('/some/test/path');
|
||||
|
||||
$id = EditorDocMapper::create($doc);
|
||||
|
|
|
|||
|
|
@ -115,9 +115,9 @@ class EditorDocTest extends \PHPUnit\Framework\TestCase
|
|||
public function testSerialization() : void
|
||||
{
|
||||
$this->doc->createdBy = new NullAccount(1);
|
||||
$this->doc->title = 'Title';
|
||||
$this->doc->content = 'Content';
|
||||
$this->doc->plaint = 'Plain';
|
||||
$this->doc->title = 'Title';
|
||||
$this->doc->content = 'Content';
|
||||
$this->doc->plaint = 'Plain';
|
||||
$this->doc->setVirtualPath('/some/path');
|
||||
$arr = [
|
||||
'id' => 0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user