From 23307c61161bea4a8f64559f727a9a329c342381 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 28 Aug 2023 22:06:34 +0000 Subject: [PATCH] update --- Controller/ApiController.php | 12 ++++++------ Controller/BackendController.php | 2 +- tests/Autoloader.php | 4 +--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 7d3287b..047d412 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -255,7 +255,7 @@ final class ApiController extends Controller $doc->isVersioned = $request->getDataBool('versioned') ?? false; $doc->createdBy = new NullAccount($request->header->account); $doc->version = $request->getDataString('version') ?? ''; - $doc->setVirtualPath((string) ($request->getData('virtualpath') ?? '/')); + $doc->setVirtualPath($request->getDataString('virtualpath') ?? '/'); if (!empty($tags = $request->getDataJson('tags'))) { foreach ($tags as $tag) { @@ -344,11 +344,11 @@ final class ApiController extends Controller { /** @var \Modules\Editor\Models\EditorDoc $doc */ $doc = EditorDocMapper::get()->where('id', (int) $request->getData('id'))->execute(); - $doc->isVersioned = (bool) ($request->getData('versioned') ?? $doc->isVersioned); - $doc->title = (string) ($request->getData('title') ?? $doc->title); - $doc->plain = (string) ($request->getData('plain') ?? $doc->plain); - $doc->content = Markdown::parse((string) ($request->getData('plain') ?? $doc->plain)); - $doc->version = (string) ($request->getData('version') ?? $doc->version); + $doc->isVersioned = $request->getDataBool('versioned') ?? $doc->isVersioned; + $doc->title = $request->getDataString('title') ?? $doc->title; + $doc->plain = $request->getDataString('plain') ?? $doc->plain; + $doc->content = Markdown::parse($request->getDataString('plain') ?? $doc->plain); + $doc->version = $request->getDataString('version') ?? $doc->version; return $doc; } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 44fb3a6..51cd427 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -101,7 +101,7 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Editor/Theme/Backend/editor-list'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005301001, $request, $response); - $path = \str_replace('+', ' ', (string) ($request->getData('path') ?? '/')); + $path = \strtr($request->getDataString('path') ?? '/', '+', ' '); $docs = EditorDocMapper::getByVirtualPath($path, $request->header->account)->where('tags/title/language', $response->header->l11n->language)->execute(); list($collection, $parent) = CollectionMapper::getCollectionsByPath($path); diff --git a/tests/Autoloader.php b/tests/Autoloader.php index 80a0a1e..d2d0080 100755 --- a/tests/Autoloader.php +++ b/tests/Autoloader.php @@ -71,14 +71,12 @@ final class Autoloader * * @return void * - * @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation. - * * @since 1.0.0 */ public static function defaultAutoloader(string $class) : void { $class = \ltrim($class, '\\'); - $class = \str_replace(['_', '\\'], '/', $class); + $class = \strtr($class, '_\\', '//'); foreach (self::$paths as $path) { $file = $path . $class . '.php';