From dea2c11f72d96485aad8bcbd610a50a2d37dd442 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 02:37:06 +0200 Subject: [PATCH 1/4] remove getId() --- Models/SurveyTemplateElementL11n.php | 12 ------------ Models/SurveyTemplateL11n.php | 12 ------------ Models/SurveyTemplateLabelL11n.php | 12 ------------ 3 files changed, 36 deletions(-) diff --git a/Models/SurveyTemplateElementL11n.php b/Models/SurveyTemplateElementL11n.php index ceea284..df1de7d 100755 --- a/Models/SurveyTemplateElementL11n.php +++ b/Models/SurveyTemplateElementL11n.php @@ -92,18 +92,6 @@ class SurveyTemplateElementL11n implements \JsonSerializable $this->language = $language; } - /** - * Get id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * Get language * diff --git a/Models/SurveyTemplateL11n.php b/Models/SurveyTemplateL11n.php index 665dff9..f946540 100755 --- a/Models/SurveyTemplateL11n.php +++ b/Models/SurveyTemplateL11n.php @@ -108,18 +108,6 @@ class SurveyTemplateL11n implements \JsonSerializable $this->language = $language; } - /** - * Get id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * Get language * diff --git a/Models/SurveyTemplateLabelL11n.php b/Models/SurveyTemplateLabelL11n.php index e9001a5..047095b 100755 --- a/Models/SurveyTemplateLabelL11n.php +++ b/Models/SurveyTemplateLabelL11n.php @@ -80,18 +80,6 @@ class SurveyTemplateLabelL11n implements \JsonSerializable $this->language = $language; } - /** - * Get id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * Get language * From 884d6289cf8b117df274f07527a9ca2b735e6708 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 03:42:51 +0200 Subject: [PATCH 2/4] use direct data access for response data --- Controller/ApiController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 584881e..fd52ca0 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -82,7 +82,7 @@ final class ApiController extends Controller public function apiSurveyTemplateCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateSurveyTemplateCreate($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -141,7 +141,7 @@ final class ApiController extends Controller } } - if (!empty($uploadedFiles = $request->getFiles())) { + if (!empty($uploadedFiles = $request->files)) { $uploaded = $this->app->moduleManager->get('Media')->uploadFiles( [], [], @@ -205,7 +205,7 @@ final class ApiController extends Controller public function apiSurveyTemplateElementCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateSurveyTemplateElementCreate($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -293,7 +293,7 @@ final class ApiController extends Controller public function apiSurveyAnswerCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateSurveyAnswerCreate($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; From 3ea02ac4ef34c0e7f058f4bf7260f0cc50964b7f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 04:15:41 +0200 Subject: [PATCH 3/4] continue with getter/setter removal --- Controller/BackendController.php | 12 ++++++------ tests/Models/SurveyTemplateElementL11nTest.php | 4 ++-- tests/Models/SurveyTemplateL11nTest.php | 4 ++-- tests/Models/SurveyTemplateLabelL11nTest.php | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Controller/BackendController.php b/Controller/BackendController.php index c8eb24e..d007fd2 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -71,8 +71,8 @@ final class BackendController extends Controller $path = \str_replace('+', ' ', (string) ($request->getData('path') ?? '/')); $surveys = SurveyTemplateMapper::getByVirtualPath($path) - ->where('tags/title/language', $response->getLanguage()) - ->where('l11n/language', $response->getLanguage()) + ->where('tags/title/language', $response->header->l11n->language) + ->where('l11n/language', $response->header->l11n->language) ->execute(); list($collection, $parent) = CollectionMapper::getCollectionsByPath($path); @@ -136,10 +136,10 @@ final class BackendController extends Controller ->with('tags') ->with('tags/title') ->where('id', $request->getData('id')) - ->where('tags/title/language', $response->getLanguage()) - ->where('l11n/language', $response->getLanguage()) - ->where('elements/l11n/language', $response->getLanguage()) - ->where('elements/labels/language', $response->getLanguage()) + ->where('tags/title/language', $response->header->l11n->language) + ->where('l11n/language', $response->header->l11n->language) + ->where('elements/l11n/language', $response->header->l11n->language) + ->where('elements/labels/language', $response->header->l11n->language) ->execute(); $view->addData('survey', $survey); diff --git a/tests/Models/SurveyTemplateElementL11nTest.php b/tests/Models/SurveyTemplateElementL11nTest.php index 67f0538..30fb6af 100755 --- a/tests/Models/SurveyTemplateElementL11nTest.php +++ b/tests/Models/SurveyTemplateElementL11nTest.php @@ -42,7 +42,7 @@ final class SurveyTemplateElementL11nTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $this->l11n->text); self::assertEquals('', $this->l11n->description); self::assertEquals('', $this->l11n->descriptionPlain); - self::assertEquals(ISO639x1Enum::_EN, $this->l11n->getLanguage()); + self::assertEquals(ISO639x1Enum::_EN, $this->l11n->language); } /** @@ -72,7 +72,7 @@ final class SurveyTemplateElementL11nTest extends \PHPUnit\Framework\TestCase public function testLanguageInputOutput() : void { $this->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->l11n->getLanguage()); + self::assertEquals(ISO639x1Enum::_DE, $this->l11n->language); } /** diff --git a/tests/Models/SurveyTemplateL11nTest.php b/tests/Models/SurveyTemplateL11nTest.php index 76796b4..9a499ed 100755 --- a/tests/Models/SurveyTemplateL11nTest.php +++ b/tests/Models/SurveyTemplateL11nTest.php @@ -42,7 +42,7 @@ final class SurveyTemplateL11nTest extends \PHPUnit\Framework\TestCase self::assertEquals('', $this->l11n->title); self::assertEquals('', $this->l11n->description); self::assertEquals('', $this->l11n->descriptionPlain); - self::assertEquals(ISO639x1Enum::_EN, $this->l11n->getLanguage()); + self::assertEquals(ISO639x1Enum::_EN, $this->l11n->language); } /** @@ -72,7 +72,7 @@ final class SurveyTemplateL11nTest extends \PHPUnit\Framework\TestCase public function testLanguageInputOutput() : void { $this->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->l11n->getLanguage()); + self::assertEquals(ISO639x1Enum::_DE, $this->l11n->language); } /** diff --git a/tests/Models/SurveyTemplateLabelL11nTest.php b/tests/Models/SurveyTemplateLabelL11nTest.php index 5b1ae84..0ecaefb 100755 --- a/tests/Models/SurveyTemplateLabelL11nTest.php +++ b/tests/Models/SurveyTemplateLabelL11nTest.php @@ -40,7 +40,7 @@ final class SurveyTemplateLabelL11nTest extends \PHPUnit\Framework\TestCase { self::assertEquals(0, $this->l11n->id); self::assertEquals('', $this->l11n->title); - self::assertEquals(ISO639x1Enum::_EN, $this->l11n->getLanguage()); + self::assertEquals(ISO639x1Enum::_EN, $this->l11n->language); } /** @@ -60,7 +60,7 @@ final class SurveyTemplateLabelL11nTest extends \PHPUnit\Framework\TestCase public function testLanguageInputOutput() : void { $this->l11n->setLanguage(ISO639x1Enum::_DE); - self::assertEquals(ISO639x1Enum::_DE, $this->l11n->getLanguage()); + self::assertEquals(ISO639x1Enum::_DE, $this->l11n->language); } /** From 7ebb810e3b894b16905abae4cb911353d80494d5 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 15:44:25 +0200 Subject: [PATCH 4/4] Continue with getter/setter cleanup --- Controller/BackendController.php | 22 +++++++++++----------- Theme/Backend/surveys-create.tpl.php | 4 ++-- Theme/Backend/surveys-list.tpl.php | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Controller/BackendController.php b/Controller/BackendController.php index d007fd2..2abc766 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -47,7 +47,7 @@ final class BackendController extends Controller */ public function setUpBackend(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { - $head = $response->get('Content')->getData('head'); + $head = $response->get('Content')->head; $head->addAsset(AssetType::CSS, '/Modules/Surveys/Theme/Backend/styles.css?v=1.0.0'); } @@ -67,7 +67,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-list'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response); $path = \str_replace('+', ' ', (string) ($request->getData('path') ?? '/')); $surveys = SurveyTemplateMapper::getByVirtualPath($path) @@ -77,11 +77,11 @@ final class BackendController extends Controller list($collection, $parent) = CollectionMapper::getCollectionsByPath($path); - $view->addData('parent', $parent); - $view->addData('collections', $collection); - $view->addData('path', $path); - $view->addData('surveys', $surveys); - $view->addData('account', $this->app->accountManager->get($request->header->account)); + $view->data['parent'] = $parent; + $view->data['collections'] = $collection; + $view->data['path'] = $path; + $view->data['surveys'] = $surveys; + $view->data['account'] = $this->app->accountManager->get($request->header->account); return $view; } @@ -102,7 +102,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-create'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response); return $view; } @@ -123,7 +123,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-create'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response); /** @var \Modules\Surveys\Models\SurveyTemplate $survey */ $survey = SurveyTemplateMapper::get() @@ -142,7 +142,7 @@ final class BackendController extends Controller ->where('elements/labels/language', $response->header->l11n->language) ->execute(); - $view->addData('survey', $survey); + $view->data['survey'] = $survey; return $view; } @@ -163,7 +163,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-survey'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response); return $view; } diff --git a/Theme/Backend/surveys-create.tpl.php b/Theme/Backend/surveys-create.tpl.php index b857278..89380f2 100755 --- a/Theme/Backend/surveys-create.tpl.php +++ b/Theme/Backend/surveys-create.tpl.php @@ -15,9 +15,9 @@ declare(strict_types=1); use Modules\Surveys\Models\SurveyElementType; /** @var null|Modules\Surveys\Models\SurveyTemplate $survey */ -$survey = $this->getData('survey'); +$survey = $this->data['survey']; -echo $this->getData('nav')->render(); ?> +echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/surveys-list.tpl.php b/Theme/Backend/surveys-list.tpl.php index d17098c..c3b6ab2 100755 --- a/Theme/Backend/surveys-list.tpl.php +++ b/Theme/Backend/surveys-list.tpl.php @@ -18,21 +18,21 @@ use phpOMS\Uri\UriFactory; * @var \phpOMS\Views\View $this * @var \Modules\Surveys\Models\Survey[] $surveys */ -$surveys = $this->getData('surveys') ?? []; +$surveys = $this->data['surveys'] ?? []; /** @var \Modules\Admin\Models\Account $account */ -$account = $this->getData('account'); +$account = $this->data['account']; $accountDir = $account->id . ' ' . $account->login; /** @var \Modules\Media\Models\Collection[] */ -$collections = $this->getData('collections'); +$collections = $this->data['collections']; $mediaPath = \urldecode($this->getData('path') ?? '/'); $previous = empty($surveys) ? '{/base}/survey/list' : '{/base}/survey/list?{?}&id=' . \reset($surveys)->id . '&ptype=p'; $next = empty($surveys) ? '{/base}/survey/list' : '{/base}/survey/list?{?}&id=' . \end($surveys)->id . '&ptype=n'; -echo $this->getData('nav')->render(); ?> +echo $this->data['nav']->render(); ?>