From 44abf6044de179c786765ddff100325c4bdfb3be Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 01:41:22 +0200 Subject: [PATCH 1/6] Implement Inspections and BaseStringL11nType --- Admin/Install/db.json | 88 +++++++++++++ Controller/ApiController.php | 30 ++--- Models/FuelType.php | 121 ------------------ Models/FuelTypeMapper.php | 5 +- Models/Inspection.php | 54 ++++++++ Models/InspectionMapper.php | 84 ++++++++++++ Models/InspectionMapper_.php | 0 ...{NullFuelType.php => InspectionStatus.php} | 30 ++--- Models/InspectionTypeL11nMapper.php | 69 ++++++++++ Models/InspectionTypeMapper.php | 83 ++++++++++++ Models/NullVehicleType.php | 46 ------- Models/Vehicle.php | 8 +- Models/VehicleType.php | 121 ------------------ Models/VehicleTypeL11nMapper.php | 1 - Models/VehicleTypeMapper.php | 8 +- 15 files changed, 415 insertions(+), 333 deletions(-) delete mode 100644 Models/FuelType.php create mode 100644 Models/InspectionMapper.php delete mode 100644 Models/InspectionMapper_.php rename Models/{NullFuelType.php => InspectionStatus.php} (52%) create mode 100644 Models/InspectionTypeL11nMapper.php create mode 100644 Models/InspectionTypeMapper.php delete mode 100644 Models/NullVehicleType.php delete mode 100644 Models/VehicleType.php diff --git a/Admin/Install/db.json b/Admin/Install/db.json index ddda20c..f790e47 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -95,6 +95,54 @@ } } }, + "fleetmgmt_inspection_type": { + "name": "fleetmgmt_inspection_type", + "fields": { + "fleetmgmt_inspection_type_id": { + "name": "fleetmgmt_inspection_type_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "fleetmgmt_inspection_type_name": { + "name": "fleetmgmt_inspection_type_name", + "type": "VARCHAR(255)", + "null": false + } + } + }, + "fleetmgmt_inspection_type_l11n": { + "name": "fleetmgmt_inspection_type_l11n", + "fields": { + "fleetmgmt_inspection_type_l11n_id": { + "name": "fleetmgmt_inspection_type_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "fleetmgmt_inspection_type_l11n_title": { + "name": "fleetmgmt_inspection_type_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "fleetmgmt_inspection_type_l11n_type": { + "name": "fleetmgmt_inspection_type_l11n_type", + "type": "INT(11)", + "null": false, + "foreignTable": "fleetmgmt_inspection_type", + "foreignKey": "fleetmgmt_inspection_type_id" + }, + "fleetmgmt_inspection_type_l11n_lang": { + "name": "fleetmgmt_inspection_type_l11n_lang", + "type": "VARCHAR(2)", + "null": false, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, "fleetmgmt_vehicle": { "name": "fleetmgmt_vehicle", "fields": { @@ -155,6 +203,46 @@ } } }, + "fleetmgmt_vehicle_inspection": { + "name": "fleetmgmt_vehicle_inspection", + "fields": { + "fleetmgmt_vehicle_inspection_id": { + "name": "fleetmgmt_vehicle_inspection_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "fleetmgmt_vehicle_inspection_description": { + "name": "fleetmgmt_vehicle_inspection_description", + "type": "TEXT", + "null": false + }, + "fleetmgmt_vehicle_inspection_status": { + "name": "fleetmgmt_vehicle_inspection_status", + "type": "TINYINT(1)", + "null": false + }, + "fleetmgmt_vehicle_inspection_interval": { + "name": "fleetmgmt_vehicle_inspection_interval", + "type": "TINYINT(3)", + "null": false + }, + "fleetmgmt_vehicle_inspection_next": { + "name": "fleetmgmt_vehicle_inspection_next", + "type": "DATETIME", + "null": true, + "default": null + }, + "fleetmgmt_vehicle_inspection_type": { + "name": "fleetmgmt_vehicle_inspection_type", + "type": "INT", + "null": false, + "foreignTable": "fleetmgmt_inspection_type", + "foreignKey": "fleetmgmt_inspection_type_id" + } + } + }, "fleetmgmt_vehicle_usage": { "name": "fleetmgmt_vehicle_usage", "fields": { diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 01553ae..5c2a874 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -20,11 +20,8 @@ use Modules\Attribute\Models\AttributeType; use Modules\Attribute\Models\AttributeValue; use Modules\Attribute\Models\NullAttributeType; use Modules\Attribute\Models\NullAttributeValue; -use Modules\FleetManagement\Models\FuelType; use Modules\FleetManagement\Models\FuelTypeL11nMapper; use Modules\FleetManagement\Models\FuelTypeMapper; -use Modules\FleetManagement\Models\NullFuelType; -use Modules\FleetManagement\Models\NullVehicleType; use Modules\FleetManagement\Models\Vehicle; use Modules\FleetManagement\Models\VehicleAttributeMapper; use Modules\FleetManagement\Models\VehicleAttributeTypeL11nMapper; @@ -33,7 +30,8 @@ use Modules\FleetManagement\Models\VehicleAttributeValueL11nMapper; use Modules\FleetManagement\Models\VehicleAttributeValueMapper; use Modules\FleetManagement\Models\VehicleMapper; use Modules\FleetManagement\Models\VehicleStatus; -use Modules\FleetManagement\Models\VehicleType; +use phpOMS\Localization\NullBaseStringL11nType; +use phpOMS\Localization\BaseStringL11nType; use Modules\FleetManagement\Models\VehicleTypeL11nMapper; use Modules\FleetManagement\Models\VehicleTypeMapper; use Modules\Media\Models\CollectionMapper; @@ -81,7 +79,7 @@ final class ApiController extends Controller return; } - /** @var VehicleType $vehicle */ + /** @var BaseStringL11nType $vehicle */ $vehicle = $this->createVehicleTypeFromRequest($request); $this->createModel($request->header->account, $vehicle, VehicleTypeMapper::class, 'vehicle_type', $request->getOrigin()); @@ -100,14 +98,14 @@ final class ApiController extends Controller * * @param RequestAbstract $request Request * - * @return VehicleType Returns the created vehicle from the request + * @return BaseStringL11nType Returns the created vehicle from the request * * @since 1.0.0 */ - public function createVehicleTypeFromRequest(RequestAbstract $request) : VehicleType + public function createVehicleTypeFromRequest(RequestAbstract $request) : BaseStringL11nType { - $type = new VehicleType(); - $type->name = $request->getDataString('name') ?? ''; + $type = new BaseStringL11nType(); + $type->title = $request->getDataString('name') ?? ''; $type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); return $type; @@ -225,7 +223,7 @@ final class ApiController extends Controller return; } - /** @var FuelType $vehicle */ + /** @var BaseStringL11nType $vehicle */ $vehicle = $this->createFuelTypeFromRequest($request); $this->createModel($request->header->account, $vehicle, FuelTypeMapper::class, 'fuel_type', $request->getOrigin()); @@ -244,14 +242,14 @@ final class ApiController extends Controller * * @param RequestAbstract $request Request * - * @return FuelType Returns the created vehicle from the request + * @return BaseStringL11nType Returns the created vehicle from the request * * @since 1.0.0 */ - public function createFuelTypeFromRequest(RequestAbstract $request) : FuelType + public function createFuelTypeFromRequest(RequestAbstract $request) : BaseStringL11nType { - $type = new FuelType(); - $type->name = $request->getDataString('name') ?? ''; + $type = new BaseStringL11nType(); + $type->title = $request->getDataString('name') ?? ''; $type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); return $type; @@ -403,8 +401,8 @@ final class ApiController extends Controller $vehicle = new Vehicle(); $vehicle->name = $request->getDataString('name') ?? ''; $vehicle->info = $request->getDataString('info') ?? ''; - $vehicle->type = new NullVehicleType((int) ($request->getDataInt('type') ?? 0)); - $vehicle->fuelType = new NullFuelType((int) ($request->getDataInt('fuel') ?? 0)); + $vehicle->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0)); + $vehicle->fuelType = new NullBaseStringL11nType((int) ($request->getDataInt('fuel') ?? 0)); $vehicle->status = (int) ($request->getDataInt('status') ?? VehicleStatus::INACTIVE); $vehicle->unit = $request->getDataInt('unit') ?? $this->app->unitId; diff --git a/Models/FuelType.php b/Models/FuelType.php deleted file mode 100644 index 2c7c5e2..0000000 --- a/Models/FuelType.php +++ /dev/null @@ -1,121 +0,0 @@ -name = $name; - } - - /** - * Set l11n - * - * @param string|BaseStringL11n $l11n Tag article l11n - * @param string $lang Language - * - * @return void - * - * @since 1.0.0 - */ - public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void - { - if ($l11n instanceof BaseStringL11n) { - $this->l11n = $l11n; - } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); - } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); - } - } - - /** - * @return string - * - * @since 1.0.0 - */ - public function getL11n() : string - { - if (!isset($this->l11n)) { - return ''; - } - - return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; - } - - /** - * {@inheritdoc} - */ - public function toArray() : array - { - return [ - 'id' => $this->id, - 'name' => $this->name, - ]; - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return $this->toArray(); - } -} diff --git a/Models/FuelTypeMapper.php b/Models/FuelTypeMapper.php index 10c16f0..0059b21 100644 --- a/Models/FuelTypeMapper.php +++ b/Models/FuelTypeMapper.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\FleetManagement\Models; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; +use phpOMS\Localization\BaseStringL11nType; /** * Item mapper class. @@ -37,7 +38,7 @@ final class FuelTypeMapper extends DataMapperFactory */ public const COLUMNS = [ 'fleetmgmt_fuel_type_id' => ['name' => 'fleetmgmt_fuel_type_id', 'type' => 'int', 'internal' => 'id'], - 'fleetmgmt_fuel_type_name' => ['name' => 'fleetmgmt_fuel_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'fleetmgmt_fuel_type_name' => ['name' => 'fleetmgmt_fuel_type_name', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], ]; /** @@ -62,7 +63,7 @@ final class FuelTypeMapper extends DataMapperFactory * @var class-string * @since 1.0.0 */ - public const MODEL = FuelType::class; + public const MODEL = BaseStringL11nType::class; /** * Primary table. diff --git a/Models/Inspection.php b/Models/Inspection.php index e69de29..3d90bb2 100644 --- a/Models/Inspection.php +++ b/Models/Inspection.php @@ -0,0 +1,54 @@ +type = new BaseStringL11nType(); + } + + use \Modules\Media\Models\MediaListTrait; +} diff --git a/Models/InspectionMapper.php b/Models/InspectionMapper.php new file mode 100644 index 0000000..66a798b --- /dev/null +++ b/Models/InspectionMapper.php @@ -0,0 +1,84 @@ + + */ +final class InspectionMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_vehicle_inspection_id' => ['name' => 'fleetmgmt_vehicle_inspection_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_vehicle_inspection_description' => ['name' => 'fleetmgmt_vehicle_inspection_description', 'type' => 'string', 'internal' => 'description'], + 'fleetmgmt_vehicle_inspection_status' => ['name' => 'fleetmgmt_vehicle_inspection_status', 'type' => 'int', 'internal' => 'status'], + 'fleetmgmt_vehicle_inspection_interval' => ['name' => 'fleetmgmt_vehicle_inspection_interval', 'type' => 'int', 'internal' => 'interval'], + 'fleetmgmt_vehicle_inspection_next' => ['name' => 'fleetmgmt_vehicle_inspection_next', 'type' => 'DateTime', 'internal' => 'next'], + 'fleetmgmt_vehicle_inspection_type' => ['name' => 'fleetmgmt_vehicle_inspection_type', 'type' => 'int', 'internal' => 'type'], + ]; + + /** + * Has one relation. + * + * @var array + * @since 1.0.0 + */ + public const OWNS_ONE = [ + 'type' => [ + 'mapper' => InspectionTypeMapper::class, + 'external' => 'fleetmgmt_vehicle_inspection_type', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_vehicle_inspection'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_vehicle_inspection_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = Inspection::class; +} diff --git a/Models/InspectionMapper_.php b/Models/InspectionMapper_.php deleted file mode 100644 index e69de29..0000000 diff --git a/Models/NullFuelType.php b/Models/InspectionStatus.php similarity index 52% rename from Models/NullFuelType.php rename to Models/InspectionStatus.php index 9502384..c4a8921 100644 --- a/Models/NullFuelType.php +++ b/Models/InspectionStatus.php @@ -14,33 +14,23 @@ declare(strict_types=1); namespace Modules\FleetManagement\Models; +use phpOMS\Stdlib\Base\Enum; + /** - * Null model + * Inspection status enum. * * @package Modules\FleetManagement\Models * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 */ -final class NullFuelType extends FuelType +abstract class InspectionStatus extends Enum { - /** - * Constructor - * - * @param int $id Model id - * - * @since 1.0.0 - */ - public function __construct(int $id = 0) - { - $this->id = $id; - } + public const DONE = 1; - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return ['id' => $this->id]; - } + public const PASSED = 2; + + public const ONGOING = 4; + + public const TODO = 5; } diff --git a/Models/InspectionTypeL11nMapper.php b/Models/InspectionTypeL11nMapper.php new file mode 100644 index 0000000..f5485ff --- /dev/null +++ b/Models/InspectionTypeL11nMapper.php @@ -0,0 +1,69 @@ + + */ +final class InspectionTypeL11nMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_inspection_type_l11n_id' => ['name' => 'fleetmgmt_inspection_type_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_inspection_type_l11n_title' => ['name' => 'fleetmgmt_inspection_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'fleetmgmt_inspection_type_l11n_type' => ['name' => 'fleetmgmt_inspection_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], + 'fleetmgmt_inspection_type_l11n_lang' => ['name' => 'fleetmgmt_inspection_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_inspection_type_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_inspection_type_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; +} diff --git a/Models/InspectionTypeMapper.php b/Models/InspectionTypeMapper.php new file mode 100644 index 0000000..01ddbe5 --- /dev/null +++ b/Models/InspectionTypeMapper.php @@ -0,0 +1,83 @@ + + */ +final class InspectionTypeMapper extends DataMapperFactory +{ + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + public const COLUMNS = [ + 'fleetmgmt_inspection_type_id' => ['name' => 'fleetmgmt_inspection_type_id', 'type' => 'int', 'internal' => 'id'], + 'fleetmgmt_inspection_type_name' => ['name' => 'fleetmgmt_inspection_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'l11n' => [ + 'mapper' => FuelTypeL11nMapper::class, + 'table' => 'fleetmgmt_inspection_type_l11n', + 'self' => 'fleetmgmt_inspection_type_l11n_type', + 'column' => 'content', + 'external' => null, + ], + ]; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11nType::class; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + public const TABLE = 'fleetmgmt_inspection_type'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + public const PRIMARYFIELD = 'fleetmgmt_inspection_type_id'; +} diff --git a/Models/NullVehicleType.php b/Models/NullVehicleType.php deleted file mode 100644 index cee550b..0000000 --- a/Models/NullVehicleType.php +++ /dev/null @@ -1,46 +0,0 @@ -id = $id; - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return ['id' => $this->id]; - } -} diff --git a/Models/Vehicle.php b/Models/Vehicle.php index eb010e7..d16c316 100644 --- a/Models/Vehicle.php +++ b/Models/Vehicle.php @@ -14,8 +14,10 @@ declare(strict_types=1); namespace Modules\FleetManagement\Models; +use phpOMS\Localization\BaseStringL11n; + /** - * class. + * Vehicle class. * * @package Modules\Attribute\Models * @license OMS License 2.0 @@ -30,7 +32,7 @@ class Vehicle implements \JsonSerializable public int $status = VehicleStatus::ACTIVE; - public VehicleType $type; + public BaseStringL11n $type; public FuelType $fuelType; @@ -53,7 +55,7 @@ class Vehicle implements \JsonSerializable public function __construct() { $this->createdAt = new \DateTimeImmutable('now'); - $this->type = new VehicleType(); + $this->type = new BaseStringL11n(); $this->fuelType = new FuelType(); } diff --git a/Models/VehicleType.php b/Models/VehicleType.php deleted file mode 100644 index c3c2bf9..0000000 --- a/Models/VehicleType.php +++ /dev/null @@ -1,121 +0,0 @@ -name = $name; - } - - /** - * Set l11n - * - * @param string|BaseStringL11n $l11n Tag article l11n - * @param string $lang Language - * - * @return void - * - * @since 1.0.0 - */ - public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void - { - if ($l11n instanceof BaseStringL11n) { - $this->l11n = $l11n; - } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); - } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); - } - } - - /** - * @return string - * - * @since 1.0.0 - */ - public function getL11n() : string - { - if (!isset($this->l11n)) { - return ''; - } - - return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n; - } - - /** - * {@inheritdoc} - */ - public function toArray() : array - { - return [ - 'id' => $this->id, - 'name' => $this->name, - ]; - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return $this->toArray(); - } -} diff --git a/Models/VehicleTypeL11nMapper.php b/Models/VehicleTypeL11nMapper.php index 87ef2c8..48a6eb2 100644 --- a/Models/VehicleTypeL11nMapper.php +++ b/Models/VehicleTypeL11nMapper.php @@ -40,7 +40,6 @@ final class VehicleTypeL11nMapper extends DataMapperFactory 'fleetmgmt_vehicle_type_l11n_id' => ['name' => 'fleetmgmt_vehicle_type_l11n_id', 'type' => 'int', 'internal' => 'id'], 'fleetmgmt_vehicle_type_l11n_title' => ['name' => 'fleetmgmt_vehicle_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], 'fleetmgmt_vehicle_type_l11n_type' => ['name' => 'fleetmgmt_vehicle_type_l11n_type', 'type' => 'int', 'internal' => 'ref'], - 'fleetmgmt_vehicle_type_l11n_lang' => ['name' => 'fleetmgmt_vehicle_type_l11n_lang', 'type' => 'string', 'internal' => 'language'], ]; /** diff --git a/Models/VehicleTypeMapper.php b/Models/VehicleTypeMapper.php index b188470..f222719 100644 --- a/Models/VehicleTypeMapper.php +++ b/Models/VehicleTypeMapper.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\FleetManagement\Models; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; +use phpOMS\Localization\BaseStringL11nType; /** * Item mapper class. @@ -24,7 +25,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @link https://jingga.app * @since 1.0.0 * - * @template T of VehicleType + * @template T of BaseStringL11nType * @extends DataMapperFactory */ final class VehicleTypeMapper extends DataMapperFactory @@ -37,7 +38,8 @@ final class VehicleTypeMapper extends DataMapperFactory */ public const COLUMNS = [ 'fleetmgmt_vehicle_type_id' => ['name' => 'fleetmgmt_vehicle_type_id', 'type' => 'int', 'internal' => 'id'], - 'fleetmgmt_vehicle_type_name' => ['name' => 'fleetmgmt_vehicle_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true], + 'fleetmgmt_vehicle_type_name' => ['name' => 'fleetmgmt_vehicle_type_name', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], + ]; /** @@ -62,7 +64,7 @@ final class VehicleTypeMapper extends DataMapperFactory * @var class-string * @since 1.0.0 */ - public const MODEL = VehicleType::class; + public const MODEL = BaseStringL11nType::class; /** * Primary table. From 28f9162c10bd04792e3485323fc2bb58825890f2 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 02:05:40 +0200 Subject: [PATCH 2/6] Switch to BaseStringL11nType --- Controller/ApiController.php | 146 ++++++++++++++++++++++++++++++++ Models/FuelTypeMapper.php | 2 +- Models/InspectionTypeMapper.php | 4 +- Models/PermissionCategory.php | 10 +++ 4 files changed, 159 insertions(+), 3 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 5c2a874..a83a70e 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -22,6 +22,8 @@ use Modules\Attribute\Models\NullAttributeType; use Modules\Attribute\Models\NullAttributeValue; use Modules\FleetManagement\Models\FuelTypeL11nMapper; use Modules\FleetManagement\Models\FuelTypeMapper; +use Modules\FleetManagement\Models\InspectionTypeL11nMapper; +use Modules\FleetManagement\Models\InspectionTypeMapper; use Modules\FleetManagement\Models\Vehicle; use Modules\FleetManagement\Models\VehicleAttributeMapper; use Modules\FleetManagement\Models\VehicleAttributeTypeL11nMapper; @@ -1177,4 +1179,148 @@ final class ApiController extends Controller return []; } + + /** + * Api method to create a vehicle + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiInspectionTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateInspectionTypeCreate($request))) { + $response->set($request->uri->__toString(), new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + /** @var BaseStringL11nType $vehicle */ + $vehicle = $this->createInspectionTypeFromRequest($request); + $this->createModel($request->header->account, $vehicle, InspectionTypeMapper::class, 'inspection_type', $request->getOrigin()); + + $this->fillJsonResponse( + $request, + $response, + NotificationLevel::OK, + '', + $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $vehicle + ); + } + + /** + * Method to create vehicle from request. + * + * @param RequestAbstract $request Request + * + * @return BaseStringL11nType Returns the created vehicle from the request + * + * @since 1.0.0 + */ + public function createInspectionTypeFromRequest(RequestAbstract $request) : BaseStringL11nType + { + $type = new BaseStringL11nType(); + $type->title = $request->getDataString('name') ?? ''; + $type->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + + return $type; + } + + /** + * Validate vehicle create request + * + * @param RequestAbstract $request Request + * + * @return array Returns the validation array of the request + * + * @since 1.0.0 + */ + private function validateInspectionTypeCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['name'] = !$request->hasData('name')) + || ($val['title'] = !$request->hasData('title')) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create vehicle attribute l11n + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiInspectionTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void + { + if (!empty($val = $this->validateInspectionTypeL11nCreate($request))) { + $response->set('inspection_type_l11n_create', new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $typeL11n = $this->createInspectionTypeL11nFromRequest($request); + $this->createModel($request->header->account, $typeL11n, InspectionTypeL11nMapper::class, 'inspection_type_l11n', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $typeL11n); + } + + /** + * Method to create vehicle attribute l11n from request. + * + * @param RequestAbstract $request Request + * + * @return BaseStringL11n + * + * @since 1.0.0 + */ + private function createInspectionTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n + { + $typeL11n = new BaseStringL11n(); + $typeL11n->ref = $request->getDataInt('type') ?? 0; + $typeL11n->setLanguage( + $request->getDataString('language') ?? $request->getLanguage() + ); + $typeL11n->content = $request->getDataString('title') ?? ''; + + return $typeL11n; + } + + /** + * Validate vehicle attribute l11n create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateInspectionTypeL11nCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = !$request->hasData('title')) + || ($val['type'] = !$request->hasData('type')) + ) { + return $val; + } + + return []; + } } diff --git a/Models/FuelTypeMapper.php b/Models/FuelTypeMapper.php index 0059b21..d1c5eec 100644 --- a/Models/FuelTypeMapper.php +++ b/Models/FuelTypeMapper.php @@ -25,7 +25,7 @@ use phpOMS\Localization\BaseStringL11nType; * @link https://jingga.app * @since 1.0.0 * - * @template T of FuelType + * @template T of BaseStringL11nType * @extends DataMapperFactory */ final class FuelTypeMapper extends DataMapperFactory diff --git a/Models/InspectionTypeMapper.php b/Models/InspectionTypeMapper.php index 01ddbe5..f7df79f 100644 --- a/Models/InspectionTypeMapper.php +++ b/Models/InspectionTypeMapper.php @@ -25,7 +25,7 @@ use phpOMS\Localization\BaseStringL11nType; * @link https://jingga.app * @since 1.0.0 * - * @template T of FuelType + * @template T of BaseStringL11nType * @extends DataMapperFactory */ final class InspectionTypeMapper extends DataMapperFactory @@ -49,7 +49,7 @@ final class InspectionTypeMapper extends DataMapperFactory */ public const HAS_MANY = [ 'l11n' => [ - 'mapper' => FuelTypeL11nMapper::class, + 'mapper' => InspectionTypeL11nMapper::class, 'table' => 'fleetmgmt_inspection_type_l11n', 'self' => 'fleetmgmt_inspection_type_l11n_type', 'column' => 'content', diff --git a/Models/PermissionCategory.php b/Models/PermissionCategory.php index 0dd83ba..f13ab8f 100755 --- a/Models/PermissionCategory.php +++ b/Models/PermissionCategory.php @@ -27,4 +27,14 @@ use phpOMS\Stdlib\Base\Enum; abstract class PermissionCategory extends Enum { public const VEHICLE = 1; + + public const FUEL_TYPE = 2; + + public const VEHICLE_TYPE = 3; + + public const INSPECTION_TYPE = 4; + + public const INSPECTION = 5; + + public const ATTRIBUTE_TYPE = 6; } From 2951f6d2758cac558bcb4c0bb0cd0c81d1b4ac10 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 02:37:01 +0200 Subject: [PATCH 3/6] remove getId() --- Models/Vehicle.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Models/Vehicle.php b/Models/Vehicle.php index d16c316..fb1b779 100644 --- a/Models/Vehicle.php +++ b/Models/Vehicle.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Modules\FleetManagement\Models; -use phpOMS\Localization\BaseStringL11n; +use phpOMS\Localization\BaseStringL11nType; /** * Vehicle class. @@ -32,9 +32,9 @@ class Vehicle implements \JsonSerializable public int $status = VehicleStatus::ACTIVE; - public BaseStringL11n $type; + public BaseStringL11nType $type; - public FuelType $fuelType; + public BaseStringL11nType $fuelType; public string $info = ''; @@ -55,8 +55,8 @@ class Vehicle implements \JsonSerializable public function __construct() { $this->createdAt = new \DateTimeImmutable('now'); - $this->type = new BaseStringL11n(); - $this->fuelType = new FuelType(); + $this->type = new BaseStringL11nType(); + $this->fuelType = new BaseStringL11nType(); } /** From 2ea7a004d6ace73d49292e5460970ad0675f8abc Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 03:42:46 +0200 Subject: [PATCH 4/6] use direct data access for response data --- Controller/ApiController.php | 38 +++++++++++++-------------- Theme/Backend/vehicle-profile.tpl.php | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index a83a70e..478dbdb 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -75,7 +75,7 @@ final class ApiController extends Controller public function apiVehicleTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleTypeCreate($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -150,7 +150,7 @@ final class ApiController extends Controller public function apiVehicleTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleTypeL11nCreate($request))) { - $response->set('vehicle_type_l11n_create', new FormValidation($val)); + $response->data['vehicle_type_l11n_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -219,7 +219,7 @@ final class ApiController extends Controller public function apiFuelTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateFuelTypeCreate($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -294,7 +294,7 @@ final class ApiController extends Controller public function apiFuelTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateFuelTypeL11nCreate($request))) { - $response->set('fuel_type_l11n_create', new FormValidation($val)); + $response->data['fuel_type_l11n_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -363,7 +363,7 @@ final class ApiController extends Controller public function apiVehicleCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleCreate($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -373,7 +373,7 @@ final class ApiController extends Controller $vehicle = $this->createVehicleFromRequest($request); $this->createModel($request->header->account, $vehicle, VehicleMapper::class, 'vehicle', $request->getOrigin()); - if (!empty($request->getFiles()) + if (!empty($request->files) || !empty($request->getDataJson('media')) ) { $this->createVehicleMedia($vehicle, $request); @@ -425,7 +425,7 @@ final class ApiController extends Controller { $path = $this->createVehicleDir($vehicle); - if (!empty($uploadedFiles = $request->getFiles())) { + if (!empty($uploadedFiles = $request->files)) { $uploaded = $this->app->moduleManager->get('Media')->uploadFiles( names: [], fileNames: [], @@ -561,7 +561,7 @@ final class ApiController extends Controller public function apiVehicleAttributeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleAttributeCreate($request))) { - $response->set('attribute_create', new FormValidation($val)); + $response->data['attribute_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -640,7 +640,7 @@ final class ApiController extends Controller public function apiVehicleAttributeUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleAttributeUpdate($request))) { - $response->set('attribute_update', new FormValidation($val)); + $response->data['attribute_update'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -730,7 +730,7 @@ final class ApiController extends Controller public function apiVehicleAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleAttributeTypeL11nCreate($request))) { - $response->set('attr_type_l11n_create', new FormValidation($val)); + $response->data['attr_type_l11n_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -799,7 +799,7 @@ final class ApiController extends Controller public function apiVehicleAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleAttributeTypeCreate($request))) { - $response->set('attr_type_create', new FormValidation($val)); + $response->data['attr_type_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -870,7 +870,7 @@ final class ApiController extends Controller public function apiVehicleAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleAttributeValueCreate($request))) { - $response->set('attr_value_create', new FormValidation($val)); + $response->data['attr_value_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -955,7 +955,7 @@ final class ApiController extends Controller public function apiVehicleAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleAttributeValueL11nCreate($request))) { - $response->set('attr_value_l11n_create', new FormValidation($val)); + $response->data['attr_value_l11n_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -1024,7 +1024,7 @@ final class ApiController extends Controller public function apiVehicleAttribute(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateVehicleAttributeValueL11nCreate($request))) { - $response->set('attr_value_l11n_create', new FormValidation($val)); + $response->data['attr_value_l11n_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -1051,7 +1051,7 @@ final class ApiController extends Controller public function apiMediaAddToVehicle(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateMediaAddToVehicle($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -1062,7 +1062,7 @@ final class ApiController extends Controller $path = $this->createVehicleDir($vehicle); $uploaded = []; - if (!empty($uploadedFiles = $request->getFiles())) { + if (!empty($uploadedFiles = $request->files)) { $uploaded = $this->app->moduleManager->get('Media')->uploadFiles( names: [], fileNames: [], @@ -1171,7 +1171,7 @@ final class ApiController extends Controller private function validateMediaAddToVehicle(RequestAbstract $request) : array { $val = []; - if (($val['media'] = (!$request->hasData('media') && empty($request->getFiles()))) + if (($val['media'] = (!$request->hasData('media') && empty($request->files))) || ($val['vehicle'] = !$request->hasData('vehicle')) ) { return $val; @@ -1196,7 +1196,7 @@ final class ApiController extends Controller public function apiInspectionTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateInspectionTypeCreate($request))) { - $response->set($request->uri->__toString(), new FormValidation($val)); + $response->data[$request->uri->__toString()] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; @@ -1271,7 +1271,7 @@ final class ApiController extends Controller public function apiInspectionTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void { if (!empty($val = $this->validateInspectionTypeL11nCreate($request))) { - $response->set('inspection_type_l11n_create', new FormValidation($val)); + $response->data['inspection_type_l11n_create'] = new FormValidation($val); $response->header->status = RequestStatusCode::R_400; return; diff --git a/Theme/Backend/vehicle-profile.tpl.php b/Theme/Backend/vehicle-profile.tpl.php index 1f2e22f..f22b656 100755 --- a/Theme/Backend/vehicle-profile.tpl.php +++ b/Theme/Backend/vehicle-profile.tpl.php @@ -25,7 +25,7 @@ $vehicleStatus = VehicleStatus::getConstants(); * @var \Modules\FleetManagement\Models\Vehicle $vehicle */ $vehicle = $this->getData('vehicle') ?? new NullVehicle(); -$files = $vehicle->getFiles(); +$files = $vehicle->files; $vehicleImage = $this->getData('vehicleImage') ?? new NullMedia(); $vehicleTypes = $this->getData('types') ?? []; From fe4ad79ba2d2b48865d38418c924b7237c27dd5f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 04:15:36 +0200 Subject: [PATCH 5/6] continue with getter/setter removal --- Controller/ApiController.php | 18 +++++++++--------- Controller/BackendController.php | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 478dbdb..206393e 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -90,7 +90,7 @@ final class ApiController extends Controller $response, NotificationLevel::OK, '', - $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'), $vehicle ); } @@ -175,7 +175,7 @@ final class ApiController extends Controller $typeL11n = new BaseStringL11n(); $typeL11n->ref = $request->getDataInt('type') ?? 0; $typeL11n->setLanguage( - $request->getDataString('language') ?? $request->getLanguage() + $request->getDataString('language') ?? $request->header->l11n->language ); $typeL11n->content = $request->getDataString('title') ?? ''; @@ -234,7 +234,7 @@ final class ApiController extends Controller $response, NotificationLevel::OK, '', - $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'), $vehicle ); } @@ -319,7 +319,7 @@ final class ApiController extends Controller $typeL11n = new BaseStringL11n(); $typeL11n->ref = $request->getDataInt('type') ?? 0; $typeL11n->setLanguage( - $request->getDataString('language') ?? $request->getLanguage() + $request->getDataString('language') ?? $request->header->l11n->language ); $typeL11n->content = $request->getDataString('title') ?? ''; @@ -384,7 +384,7 @@ final class ApiController extends Controller $response, NotificationLevel::OK, '', - $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'), $vehicle ); } @@ -755,7 +755,7 @@ final class ApiController extends Controller $attrL11n = new BaseStringL11n(); $attrL11n->ref = $request->getDataInt('type') ?? 0; $attrL11n->setLanguage( - $request->getDataString('language') ?? $request->getLanguage() + $request->getDataString('language') ?? $request->header->l11n->language ); $attrL11n->content = $request->getDataString('title') ?? ''; @@ -980,7 +980,7 @@ final class ApiController extends Controller $attrL11n = new BaseStringL11n(); $attrL11n->ref = $request->getDataInt('value') ?? 0; $attrL11n->setLanguage( - $request->getDataString('language') ?? $request->getLanguage() + $request->getDataString('language') ?? $request->header->l11n->language ); $attrL11n->content = $request->getDataString('title') ?? ''; @@ -1211,7 +1211,7 @@ final class ApiController extends Controller $response, NotificationLevel::OK, '', - $this->app->l11nManager->getText($response->getLanguage(), '0', '0', 'SucessfulCreate'), + $this->app->l11nManager->getText($response->header->l11n->language, '0', '0', 'SucessfulCreate'), $vehicle ); } @@ -1296,7 +1296,7 @@ final class ApiController extends Controller $typeL11n = new BaseStringL11n(); $typeL11n->ref = $request->getDataInt('type') ?? 0; $typeL11n->setLanguage( - $request->getDataString('language') ?? $request->getLanguage() + $request->getDataString('language') ?? $request->header->l11n->language ); $typeL11n->content = $request->getDataString('title') ?? ''; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 33b2c0e..6ca2c85 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -58,7 +58,7 @@ final class BackendController extends Controller /** @var \Modules\Attribute\Models\AttributeType[] $attributes */ $attributes = VehicleAttributeTypeMapper::getAll() ->with('l11n') - ->where('l11n/language', $response->getLanguage()) + ->where('l11n/language', $response->header->l11n->language) ->execute(); $view->addData('attributes', $attributes); @@ -88,7 +88,7 @@ final class BackendController extends Controller $list = VehicleMapper::getAll() ->with('type') ->with('type/l11n') - ->where('type/l11n/language', $response->getLanguage()) + ->where('type/l11n/language', $response->header->l11n->language) ->sort('id', 'DESC') ->execute(); @@ -119,7 +119,7 @@ final class BackendController extends Controller $attribute = VehicleAttributeTypeMapper::get() ->with('l11n') ->where('id', (int) $request->getData('id')) - ->where('l11n/language', $response->getLanguage()) + ->where('l11n/language', $response->header->l11n->language) ->execute(); $l11ns = VehicleAttributeTypeL11nMapper::getAll() @@ -161,9 +161,9 @@ final class BackendController extends Controller ->with('fuelType') ->with('fuelType/l11n') ->where('id', (int) $request->getData('id')) - ->where('type/l11n/language', $response->getLanguage()) - ->where('fuelType/l11n/language', $response->getLanguage()) - ->where('attributes/type/l11n/language', $response->getLanguage()) + ->where('type/l11n/language', $response->header->l11n->language) + ->where('fuelType/l11n/language', $response->header->l11n->language) + ->where('attributes/type/l11n/language', $response->header->l11n->language) ->execute(); $view->setData('vehicle', $vehicle); @@ -192,7 +192,7 @@ final class BackendController extends Controller $vehicleTypes = VehicleTypeMapper::getAll() ->with('l11n') - ->where('l11n/language', $response->getLanguage()) + ->where('l11n/language', $response->header->l11n->language) ->execute(); $view->addData('types', $vehicleTypes); From cb44e3ac3aa443f3c7548a4ec2a8ee35acf4b70c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 30 May 2023 15:44:18 +0200 Subject: [PATCH 6/6] Continue with getter/setter cleanup --- Controller/BackendController.php | 22 +++++++++++----------- Theme/Backend/attribute-type-list.tpl.php | 4 ++-- Theme/Backend/attribute-type.tpl.php | 6 +++--- Theme/Backend/vehicle-create.tpl.php | 2 +- Theme/Backend/vehicle-list.tpl.php | 4 ++-- Theme/Backend/vehicle-profile.tpl.php | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 6ca2c85..f7d468d 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -53,7 +53,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/FleetManagement/Theme/Backend/attribute-type-list'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003503001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003503001, $request, $response); /** @var \Modules\Attribute\Models\AttributeType[] $attributes */ $attributes = VehicleAttributeTypeMapper::getAll() @@ -61,7 +61,7 @@ final class BackendController extends Controller ->where('l11n/language', $response->header->l11n->language) ->execute(); - $view->addData('attributes', $attributes); + $view->data['attributes'] = $attributes; return $view; } @@ -83,7 +83,7 @@ final class BackendController extends Controller $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/FleetManagement/Theme/Backend/vehicle-list'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response); $list = VehicleMapper::getAll() ->with('type') @@ -92,7 +92,7 @@ final class BackendController extends Controller ->sort('id', 'DESC') ->execute(); - $view->setData('vehicles', $list); + $view->data['vehicles'] = $list; return $view; } @@ -113,7 +113,7 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/FleetManagement/Theme/Backend/attribute-type'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response); /** @var \Modules\Attribute\Models\AttributeType $attribute */ $attribute = VehicleAttributeTypeMapper::get() @@ -126,8 +126,8 @@ final class BackendController extends Controller ->where('ref', $attribute->id) ->execute(); - $view->addData('attribute', $attribute); - $view->addData('l11ns', $l11ns); + $view->data['attribute'] = $attribute; + $view->data['l11ns'] = $l11ns; return $view; } @@ -149,7 +149,7 @@ final class BackendController extends Controller $view = new View($this->app->l11nManager, $request, $response); $view->setTemplate('/Modules/FleetManagement/Theme/Backend/vehicle-profile'); - $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response)); + $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1003502001, $request, $response); $vehicle = VehicleMapper::get() ->with('attributes') @@ -166,7 +166,7 @@ final class BackendController extends Controller ->where('attributes/type/l11n/language', $response->header->l11n->language) ->execute(); - $view->setData('vehicle', $vehicle); + $view->data['vehicle'] = $vehicle; $query = new Builder($this->app->dbPool->get()); $results = $query->selectAs(VehicleMapper::HAS_MANY['files']['external'], 'file') @@ -188,14 +188,14 @@ final class BackendController extends Controller ->limit(1) ->execute(); - $view->addData('vehicleImage', $vehicleImage); + $view->data['vehicleImage'] = $vehicleImage; $vehicleTypes = VehicleTypeMapper::getAll() ->with('l11n') ->where('l11n/language', $response->header->l11n->language) ->execute(); - $view->addData('types', $vehicleTypes); + $view->data['types'] = $vehicleTypes; return $view; } diff --git a/Theme/Backend/attribute-type-list.tpl.php b/Theme/Backend/attribute-type-list.tpl.php index 09bdaee..edcbe2d 100755 --- a/Theme/Backend/attribute-type-list.tpl.php +++ b/Theme/Backend/attribute-type-list.tpl.php @@ -15,9 +15,9 @@ declare(strict_types=1); use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ -$attributes = $this->getData('attributes'); +$attributes = $this->data['attributes']; -echo $this->getData('nav')->render(); ?> +echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/attribute-type.tpl.php b/Theme/Backend/attribute-type.tpl.php index bed6997..ab560c4 100755 --- a/Theme/Backend/attribute-type.tpl.php +++ b/Theme/Backend/attribute-type.tpl.php @@ -17,10 +17,10 @@ use phpOMS\Localization\ISO639Enum; $types = AttributeValueType::getConstants(); -$attribute = $this->getData('attribute'); -$l11ns = $this->getData('l11ns'); +$attribute = $this->data['attribute']; +$l11ns = $this->data['l11ns']; -echo $this->getData('nav')->render(); ?> +echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/vehicle-create.tpl.php b/Theme/Backend/vehicle-create.tpl.php index 62d4c00..868169a 100755 --- a/Theme/Backend/vehicle-create.tpl.php +++ b/Theme/Backend/vehicle-create.tpl.php @@ -15,7 +15,7 @@ declare(strict_types=1); /** * @var \phpOMS\Views\View $this */ -echo $this->getData('nav')->render(); ?> +echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/vehicle-list.tpl.php b/Theme/Backend/vehicle-list.tpl.php index 0eafa88..c8ad41e 100755 --- a/Theme/Backend/vehicle-list.tpl.php +++ b/Theme/Backend/vehicle-list.tpl.php @@ -16,9 +16,9 @@ declare(strict_types=1); use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ -$vehicles = $this->getData('vehicles') ?? []; +$vehicles = $this->data['vehicles'] ?? []; -echo $this->getData('nav')->render(); ?> +echo $this->data['nav']->render(); ?>
diff --git a/Theme/Backend/vehicle-profile.tpl.php b/Theme/Backend/vehicle-profile.tpl.php index f22b656..af594f9 100755 --- a/Theme/Backend/vehicle-profile.tpl.php +++ b/Theme/Backend/vehicle-profile.tpl.php @@ -27,12 +27,12 @@ $vehicleStatus = VehicleStatus::getConstants(); $vehicle = $this->getData('vehicle') ?? new NullVehicle(); $files = $vehicle->files; $vehicleImage = $this->getData('vehicleImage') ?? new NullMedia(); -$vehicleTypes = $this->getData('types') ?? []; +$vehicleTypes = $this->data['types'] ?? []; /** * @var \phpOMS\Views\View $this */ -echo $this->getData('nav')->render(); +echo $this->data['nav']->render(); ?>