Continue with getter/setter cleanup

This commit is contained in:
Dennis Eichhorn 2023-05-30 15:44:16 +02:00
parent 9fcee2e25a
commit 1f0e082b70
3 changed files with 15 additions and 21 deletions

View File

@ -52,24 +52,18 @@ final class BackendController extends Controller
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-list'); $view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response)); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response);
$mapper = ContractMapper::getAll() $mapper = ContractMapper::getAll()
->with('account') ->with('account')
->limit(25); ->limit(25);
if ($request->getData('ptype') === 'p') { if ($request->getData('ptype') === 'p') {
$view->setData('contracts', $view->data['contracts'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '<')->execute();
$mapper->where('id', $request->getDataInt('id') ?? 0, '<')->execute()
);
} elseif ($request->getData('ptype') === 'n') { } elseif ($request->getData('ptype') === 'n') {
$view->setData('contracts', $view->data['contracts'] = $mapper->where('id', $request->getDataInt('id') ?? 0, '>')->execute();
$mapper->where('id', $request->getDataInt('id') ?? 0, '>')->execute()
);
} else { } else {
$view->setData('contracts', $view->data['contracts'] = $mapper->where('id', 0, '>')->execute();
$mapper->where('id', 0, '>')->execute()
);
} }
return $view; return $view;
@ -92,7 +86,7 @@ final class BackendController extends Controller
$view = new View($this->app->l11nManager, $request, $response); $view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-single'); $view->setTemplate('/Modules/ContractManagement/Theme/Backend/contract-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response)); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1007901001, $request, $response);
$contract = ContractMapper::get() $contract = ContractMapper::get()
->with('account') ->with('account')
@ -100,20 +94,20 @@ final class BackendController extends Controller
->where('id', (int) $request->getData('id')) ->where('id', (int) $request->getData('id'))
->sort('files/id', 'DESC') ->sort('files/id', 'DESC')
->execute(); ->execute();
$view->addData('contract', $contract); $view->data['contract'] = $contract;
$contractTypes = ContractTypeMapper::getAll() $contractTypes = ContractTypeMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $response->header->l11n->language) ->where('l11n/language', $response->header->l11n->language)
->execute(); ->execute();
$view->setData('contractTypes', $contractTypes); $view->data['contractTypes'] = $contractTypes;
$units = UnitMapper::getAll() $units = UnitMapper::getAll()
->execute(); ->execute();
$view->setData('units', $units); $view->data['units'] = $units;
$editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response); $editor = new \Modules\Editor\Theme\Backend\Components\Editor\BaseView($this->app->l11nManager, $request, $response);
$view->addData('editor', $editor); $view->data['editor'] = $editor;
return $view; return $view;
} }

View File

@ -18,14 +18,14 @@ use phpOMS\Uri\UriFactory;
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
* @var \Modules\ContractManagement\Models\Contract[] $contracts * @var \Modules\ContractManagement\Models\Contract[] $contracts
*/ */
$contracts = $this->getData('contracts') ?? []; $contracts = $this->data['contracts'] ?? [];
$previous = empty($contracts) ? '{/base}/contract/list' : '{/base}/contract/list?{?}&id=' . \reset($contracts)->id . '&ptype=p'; $previous = empty($contracts) ? '{/base}/contract/list' : '{/base}/contract/list?{?}&id=' . \reset($contracts)->id . '&ptype=p';
$next = empty($contracts) ? '{/base}/contract/list' : '{/base}/contract/list?{?}&id=' . \end($contracts)->id . '&ptype=n'; $next = empty($contracts) ? '{/base}/contract/list' : '{/base}/contract/list?{?}&id=' . \end($contracts)->id . '&ptype=n';
$now = new \DateTime('now'); $now = new \DateTime('now');
echo $this->getData('nav')->render(); ?> echo $this->data['nav']->render(); ?>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">

View File

@ -18,10 +18,10 @@ use phpOMS\Uri\UriFactory;
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
* @var \Modules\ContractManagement\Models\Contract $contract * @var \Modules\ContractManagement\Models\Contract $contract
*/ */
$contract = $this->getData('contract'); $contract = $this->data['contract'];
$contractFile = $contract->files; $contractFile = $contract->files;
echo $this->getData('nav')->render(); ?> echo $this->data['nav']->render(); ?>
<div class="tabview tab-2 col-simple"> <div class="tabview tab-2 col-simple">
<div class="box"> <div class="box">
@ -52,7 +52,7 @@ echo $this->getData('nav')->render(); ?>
<label for="iType"><?= $this->getHtml('Type'); ?></label> <label for="iType"><?= $this->getHtml('Type'); ?></label>
<select id="iType" name="type" data-tpl-text="/type" data-tpl-value="/type"> <select id="iType" name="type" data-tpl-text="/type" data-tpl-value="/type">
<?php <?php
$types = $this->getData('contractTypes') ?? []; $types = $this->data['contractTypes'] ?? [];
foreach ($types as $type) : ?> foreach ($types as $type) : ?>
<option value="<?= $type->id; ?>" <?= $type->id === $contract->type->id ? ' selected' : ''; ?>><?= $this->printHtml($type->getL11n()); ?> <option value="<?= $type->id; ?>" <?= $type->id === $contract->type->id ? ' selected' : ''; ?>><?= $this->printHtml($type->getL11n()); ?>
<?php endforeach; ?> <?php endforeach; ?>
@ -95,7 +95,7 @@ echo $this->getData('nav')->render(); ?>
<select id="iUnit" name="unit"> <select id="iUnit" name="unit">
<option value=""> <option value="">
<?php <?php
$units = $this->getData('units') ?? []; $units = $this->data['units'] ?? [];
foreach ($units as $unit) : ?> foreach ($units as $unit) : ?>
<option value="<?= $unit->id; ?>"<?= $contract->unit->id === $unit->id ? ' selected' : ''; ?>><?= $this->printHtml($unit->name); ?> <option value="<?= $unit->id; ?>"<?= $contract->unit->id === $unit->id ? ' selected' : ''; ?>><?= $this->printHtml($unit->name); ?>
<?php endforeach; ?> <?php endforeach; ?>