From 58682a7fb4f342b3cf5a606419b418deaf09302c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 17 Feb 2018 18:31:04 +0100 Subject: [PATCH] docblocks+api functions --- Admin/Install/Navigation.php | 4 +- Admin/Installer.php | 13 ++- Admin/Status.php | 4 +- Admin/Uninstaller.php | 4 +- Admin/Updater.php | 4 +- Controller.php | 23 +++-- Models/Department.php | 178 +++++++++++++++++++++++++++++++++-- Models/DepartmentMapper.php | 29 ++++-- Models/NullDepartment.php | 10 +- Models/NullPosition.php | 10 +- Models/NullUnit.php | 10 +- Models/PermissionState.php | 4 +- Models/Position.php | 176 ++++++++++++++++++++++++++++++++-- Models/PositionMapper.php | 29 ++++-- Models/Status.php | 4 +- Models/Unit.php | 162 +++++++++++++++++++++++++++++-- Models/UnitMapper.php | 27 ++++-- 17 files changed, 620 insertions(+), 71 deletions(-) diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index 19ab45d..8d07304 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization\Admin\Install * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -19,7 +19,7 @@ use phpOMS\DataStorage\Database\DatabasePool; /** * Navigation class. * - * @package Modules + * @package Modules\Organization\Admin\Install * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 diff --git a/Admin/Installer.php b/Admin/Installer.php index 92be453..54df87d 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization\Admin * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -22,7 +22,7 @@ use phpOMS\Module\InstallerAbstract; /** * Organization install class. * - * @package Modules + * @package Modules\Organization\Admin * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 @@ -43,7 +43,8 @@ class Installer extends InstallerAbstract 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'organization_unit` ( `organization_unit_id` int(11) NOT NULL AUTO_INCREMENT, `organization_unit_name` varchar(50) DEFAULT NULL, - `organization_unit_description` varchar(255) DEFAULT NULL, + `organization_unit_description` text DEFAULT NULL, + `organization_unit_descriptionraw` text DEFAULT NULL, `organization_unit_parent` int(11) DEFAULT NULL, `organization_unit_status` int(3) DEFAULT NULL, PRIMARY KEY (`organization_unit_id`), @@ -60,7 +61,8 @@ class Installer extends InstallerAbstract 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'organization_department` ( `organization_department_id` int(11) NOT NULL AUTO_INCREMENT, `organization_department_name` varchar(30) DEFAULT NULL, - `organization_department_description` varchar(255) DEFAULT NULL, + `organization_department_description` text DEFAULT NULL, + `organization_department_descriptionraw` text DEFAULT NULL, `organization_department_parent` int(11) DEFAULT NULL, `organization_department_status` int(3) DEFAULT NULL, `organization_department_unit` int(11) NOT NULL, @@ -80,7 +82,8 @@ class Installer extends InstallerAbstract 'CREATE TABLE if NOT EXISTS `' . $dbPool->get()->prefix . 'organization_position` ( `organization_position_id` int(11) NOT NULL AUTO_INCREMENT, `organization_position_name` varchar(50) DEFAULT NULL, - `organization_position_description` varchar(255) DEFAULT NULL, + `organization_position_description` text DEFAULT NULL, + `organization_position_descriptionraw` text DEFAULT NULL, `organization_position_parent` int(11) DEFAULT NULL, `organization_position_department` int(11) DEFAULT NULL, `organization_position_status` int(3) DEFAULT NULL, diff --git a/Admin/Status.php b/Admin/Status.php index 16a7ed1..73c3249 100644 --- a/Admin/Status.php +++ b/Admin/Status.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization\Admin * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -21,7 +21,7 @@ use phpOMS\Module\InfoManager; /** * Navigation class. * - * @package Modules + * @package Modules\Organization\Admin * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 diff --git a/Admin/Uninstaller.php b/Admin/Uninstaller.php index c01f032..7fd81e9 100644 --- a/Admin/Uninstaller.php +++ b/Admin/Uninstaller.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization\Admin * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -22,7 +22,7 @@ use phpOMS\Module\InfoManager; /** * Navigation class. * - * @package Modules + * @package Modules\Organization\Admin * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 diff --git a/Admin/Updater.php b/Admin/Updater.php index 1adb094..3063f83 100644 --- a/Admin/Updater.php +++ b/Admin/Updater.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization\Admin * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -22,7 +22,7 @@ use phpOMS\Module\InfoManager; /** * Navigation class. * - * @package Modules + * @package Modules\Organization\Admin * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 diff --git a/Controller.php b/Controller.php index f960977..1902f4a 100644 --- a/Controller.php +++ b/Controller.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -28,6 +28,7 @@ use phpOMS\Module\ModuleAbstract; use phpOMS\Module\WebInterface; use phpOMS\Views\View; use phpOMS\Message\Http\RequestStatusCode; +use phpOMS\Utils\Parser\Markdown\Markdown; use phpOMS\Account\PermissionType; use Modules\Organization\Models\PermissionState; @@ -35,7 +36,7 @@ use Modules\Organization\Models\PermissionState; /** * Organization Controller class. * - * @package Modules + * @package Modules\Organization * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 @@ -459,7 +460,8 @@ class Controller extends ModuleAbstract implements WebInterface { $unit = UnitMapper::get((int) $request->getData('id')); $unit->setName((string) ($request->getData('name') ?? $unit->getName())); - $unit->setDescription((string) ($request->getData('description') ?? $unit->getDescription())); + $unit->setDescriptionRaw((string) ($request->getData('description') ?? $unit->getDescriptionRaw())); + $unit->setDescription(Markdown::parse((string) ($request->getData('description') ?? $unit->getDescriptionRaw()))); $parent = (int) $request->getData('parent'); $unit->setParent(!empty($parent) ? $parent : $unit->getParent()); @@ -551,7 +553,8 @@ class Controller extends ModuleAbstract implements WebInterface { $unit = new Unit(); $unit->setName((string) $request->getData('name')); - $unit->setDescription((string) ($request->getData('description') ?? '')); + $unit->setDescriptionRaw((string) ($request->getData('description') ?? '')); + $unit->setDescription(Markdwon::parse((string) ($request->getData('description') ?? ''))); $parent = (int) $request->getData('parent'); $unit->setParent(!empty($parent) ? $parent : null); @@ -695,7 +698,8 @@ class Controller extends ModuleAbstract implements WebInterface { $position = PositionMapper::get((int) $request->getData('id')); $position->setName((string) ($request->getData('name') ?? $position->getName())); - $position->setDescription((string) ($request->getData('description') ?? $position->getDescription())); + $position->setDescriptionRaw((string) ($request->getData('description') ?? $position->getDescriptionRaw())); + $position->setDescription(Markdown::parse((string) ($request->getData('description') ?? $position->getDescriptionRaw()))); $parent = (int) $request->getData('parent'); $position->setParent(!empty($parent) ? $parent : $position->getParent()); @@ -759,7 +763,8 @@ class Controller extends ModuleAbstract implements WebInterface $position = new Position(); $position->setName((string) ($request->getData('name'))); $position->setStatus((int) $request->getData('status')); - $position->setDescription((string) ($request->getData('description') ?? '')); + $position->setDescriptionRaw((string) ($request->getData('description') ?? '')); + $position->setDescription(Markdown::parse((string) ($request->getData('description') ?? ''))); $parent = (int) $request->getData('parent'); $position->setParent(!empty($parent) ? $parent : null); @@ -873,7 +878,8 @@ class Controller extends ModuleAbstract implements WebInterface { $department = DepartmentMapper::get((int) $request->getData('id')); $department->setName((string) ($request->getData('name') ?? $department->getName())); - $department->setDescription((string) ($request->getData('description') ?? $department->getDescription())); + $department->setDescriptionRaw((string) ($request->getData('description') ?? $department->getDescriptionRaw())); + $department->setDescription(Markdown::parse((string) ($request->getData('description') ?? $department->getDescriptionRaw()))); $parent = (int) $request->getData('parent'); $department->setParent(!empty($parent) ? $parent : $department->getParent()); @@ -973,7 +979,8 @@ class Controller extends ModuleAbstract implements WebInterface $parent = (int) $request->getData('parent'); $department->setParent(!empty($parent) ? $parent : null); $department->setUnit((int) ($request->getData('unit') ?? 1)); - $department->setDescription((string) ($request->getData('description') ?? '')); + $department->setDescriptionRaw((string) ($request->getData('description') ?? '')); + $department->setDescription(Markdown::parse((string) ($request->getData('description') ?? ''))); return $department; } diff --git a/Models/Department.php b/Models/Department.php index 38b9531..257b4f1 100644 --- a/Models/Department.php +++ b/Models/Department.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -14,75 +14,243 @@ declare(strict_types=1); namespace Modules\Organization\Models; -class Department +/** + * Organization department class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ +class Department implements ArrayableInterface, \JsonSerializable { + /** + * Article ID. + * + * @var int + * @since 1.0.0 + */ protected $id = 0; + /** + * Name. + * + * @var string + * @since 1.0.0 + */ protected $name = ''; + /** + * Parent + * + * @var mixed + * @since 1.0.0 + */ protected $parent = null; + /** + * Status + * + * @var int + * @since 1.0.0 + */ protected $status = Status::INACTIVE; + /** + * Unit this department belongs to + * + * @var mixed + * @since 1.0.0 + */ protected $unit = 1; + /** + * Description. + * + * @var string + * @since 1.0.0 + */ protected $description = ''; + /** + * Description. + * + * @var string + * @since 1.0.0 + */ + protected $descriptionRaw = ''; + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; } + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ public function getName() : string { return $this->name; } + /** + * Set name + * + * @param string $name Name + * + * @return void + * + * @since 1.0.0 + */ public function setName(string $name) { return $this->name = $name; } + /** + * Get parent + * + * @return mixed + * + * @since 1.0.0 + */ public function getParent() { return $this->parent ?? new NullDepartment(); } + /** + * Set parent + * + * @param mixed $parent Parent + * + * @return mixed + * + * @since 1.0.0 + */ public function setParent($parent) { $this->parent = $parent; } + /** + * Get status + * + * @return int + * + * @since 1.0.0 + */ public function getStatus() : int { return $this->status; } + /** + * Set status + * + * @param int $status Status + * + * @return void + * + * @since 1.0.0 + */ public function setStatus(int $status) { $this->status = $status; } + /** + * Get unit + * + * @return mixed + * + * @since 1.0.0 + */ public function getUnit() { return $this->unit ?? new NullUnit(); } + /** + * Set unit + * + * @param mixed $unit Unit + * + * @return mixed + * + * @since 1.0.0 + */ public function setUnit($unit) { $this->unit = $unit; } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ public function getDescription() : string { return $this->description; } + /** + * Set description + * + * @param int $desc Description + * + * @return void + * + * @since 1.0.0 + */ public function setDescription(string $desc) { $this->description = $desc; } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ + public function getDescriptionRaw() : string + { + return $this->descriptionRaw; + } + + /** + * Set description + * + * @param int $desc Description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescriptionRaw(string $desc) + { + $this->descriptionRaw = $desc; + } + + /** + * {@inheritdoc} + */ public function toArray() : array { return [ @@ -106,11 +274,7 @@ class Department } /** - * Json serialize. - * - * @return string - * - * @since 1.0.0 + * {@inheritdoc} */ public function jsonSerialize() { diff --git a/Models/DepartmentMapper.php b/Models/DepartmentMapper.php index 3c2f789..1ed0318 100644 --- a/Models/DepartmentMapper.php +++ b/Models/DepartmentMapper.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -16,6 +16,14 @@ namespace Modules\Organization\Models; use phpOMS\DataStorage\Database\DataMapperAbstract; +/** + * Organization department mapper class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class DepartmentMapper extends DataMapperAbstract { /** @@ -25,14 +33,21 @@ class DepartmentMapper extends DataMapperAbstract * @since 1.0.0 */ protected static $columns = [ - 'organization_department_id' => ['name' => 'organization_department_id', 'type' => 'int', 'internal' => 'id'], - 'organization_department_name' => ['name' => 'organization_department_name', 'type' => 'string', 'internal' => 'name'], - 'organization_department_description' => ['name' => 'organization_department_description', 'type' => 'string', 'internal' => 'description'], - 'organization_department_parent' => ['name' => 'organization_department_parent', 'type' => 'int', 'internal' => 'parent'], - 'organization_department_status' => ['name' => 'organization_department_status', 'type' => 'int', 'internal' => 'status'], - 'organization_department_unit' => ['name' => 'organization_department_unit', 'type' => 'int', 'internal' => 'unit'], + 'organization_department_id' => ['name' => 'organization_department_id', 'type' => 'int', 'internal' => 'id'], + 'organization_department_name' => ['name' => 'organization_department_name', 'type' => 'string', 'internal' => 'name'], + 'organization_department_description' => ['name' => 'organization_department_description', 'type' => 'string', 'internal' => 'description'], + 'organization_department_descriptionraw' => ['name' => 'organization_department_descriptionraw', 'type' => 'string', 'internal' => 'descriptionRaw'], + 'organization_department_parent' => ['name' => 'organization_department_parent', 'type' => 'int', 'internal' => 'parent'], + 'organization_department_status' => ['name' => 'organization_department_status', 'type' => 'int', 'internal' => 'status'], + 'organization_department_unit' => ['name' => 'organization_department_unit', 'type' => 'int', 'internal' => 'unit'], ]; + /** + * Belongs to. + * + * @var array + * @since 1.0.0 + */ protected static $belongsTo = [ 'unit' => [ 'mapper' => UnitMapper::class, diff --git a/Models/NullDepartment.php b/Models/NullDepartment.php index 980d3e8..61286e5 100644 --- a/Models/NullDepartment.php +++ b/Models/NullDepartment.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -14,6 +14,14 @@ declare(strict_types=1); namespace Modules\Organization\Models; +/** + * Organization null class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class NullDepartment extends Department { } diff --git a/Models/NullPosition.php b/Models/NullPosition.php index 295054f..c6b5652 100644 --- a/Models/NullPosition.php +++ b/Models/NullPosition.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -14,6 +14,14 @@ declare(strict_types=1); namespace Modules\Organization\Models; +/** + * Organization null class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class NullPosition extends Position { } diff --git a/Models/NullUnit.php b/Models/NullUnit.php index c1df1c6..c451768 100644 --- a/Models/NullUnit.php +++ b/Models/NullUnit.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -14,6 +14,14 @@ declare(strict_types=1); namespace Modules\Organization\Models; +/** + * Organization null class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class NullUnit extends Unit { } diff --git a/Models/PermissionState.php b/Models/PermissionState.php index 1a4a5ea..796ffd9 100644 --- a/Models/PermissionState.php +++ b/Models/PermissionState.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -19,7 +19,7 @@ use phpOMS\Stdlib\Base\Enum; /** * Permision state enum. * - * @package Tasks + * @package Modules\Organization * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 diff --git a/Models/Position.php b/Models/Position.php index 6088cd4..1a5f399 100644 --- a/Models/Position.php +++ b/Models/Position.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -16,75 +16,243 @@ namespace Modules\Organization\Models; use phpOMS\Contract\ArrayableInterface; +/** + * Organization position class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class Position implements ArrayableInterface, \JsonSerializable { + /** + * Article ID. + * + * @var int + * @since 1.0.0 + */ private $id = 0; + /** + * Name. + * + * @var string + * @since 1.0.0 + */ private $name = ''; + /** + * Parent + * + * @var mixed + * @since 1.0.0 + */ private $parent = null; + /** + * Department + * + * @var mixed + * @since 1.0.0 + */ private $department = null; + /** + * Description. + * + * @var string + * @since 1.0.0 + */ private $description = ''; + /** + * Description. + * + * @var string + * @since 1.0.0 + */ + private $descriptionRaw = ''; + + /** + * Status + * + * @var int + * @since 1.0.0 + */ protected $status = Status::INACTIVE; + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; } + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ public function getName() : string { return $this->name; } + /** + * Set name + * + * @param string $name Name + * + * @return void + * + * @since 1.0.0 + */ public function setName(string $name) { $this->name = $name; } + /** + * Get parent + * + * @return mixed + * + * @since 1.0.0 + */ public function getParent() { return $this->parent ?? new NullPosition(); } + /** + * Set parent + * + * @param mixed $parent Parent + * + * @return mixed + * + * @since 1.0.0 + */ public function setParent($parent) { $this->parent = $parent; } + /** + * Get parent + * + * @return mixed + * + * @since 1.0.0 + */ public function getDepartment() { return $this->department ?? new NullDepartment(); } + /** + * Set department + * + * @param mixed $department Department + * + * @return mixed + * + * @since 1.0.0 + */ public function setDepartment($department) { $this->department = $department; } + /** + * Get status + * + * @return int + * + * @since 1.0.0 + */ public function getStatus() : int { return $this->status; } + /** + * Set status + * + * @param int $status Status + * + * @return void + * + * @since 1.0.0 + */ public function setStatus(int $status) { $this->status = $status; } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ public function getDescription() : string { return $this->description; } + /** + * Set description + * + * @param int $desc Description + * + * @return void + * + * @since 1.0.0 + */ public function setDescription(string $desc) { $this->description = $desc; } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ + public function getDescriptionRaw() : string + { + return $this->descriptionRaw; + } + + /** + * Set description + * + * @param int $desc Description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescriptionRaw(string $desc) + { + $this->descriptionRaw = $desc; + } + + /** + * {@inheritdoc} + */ public function toArray() : array { return [ @@ -109,11 +277,7 @@ class Position implements ArrayableInterface, \JsonSerializable } /** - * Json serialize. - * - * @return string - * - * @since 1.0.0 + * {@inheritdoc} */ public function jsonSerialize() { diff --git a/Models/PositionMapper.php b/Models/PositionMapper.php index d655b76..c116b74 100644 --- a/Models/PositionMapper.php +++ b/Models/PositionMapper.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -16,6 +16,14 @@ namespace Modules\Organization\Models; use phpOMS\DataStorage\Database\DataMapperAbstract; +/** + * Organization position mapper class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class PositionMapper extends DataMapperAbstract { @@ -26,14 +34,21 @@ class PositionMapper extends DataMapperAbstract * @since 1.0.0 */ protected static $columns = [ - 'organization_position_id' => ['name' => 'organization_position_id', 'type' => 'int', 'internal' => 'id'], - 'organization_position_name' => ['name' => 'organization_position_name', 'type' => 'string', 'internal' => 'name'], - 'organization_position_description' => ['name' => 'organization_position_description', 'type' => 'string', 'internal' => 'description'], - 'organization_position_parent' => ['name' => 'organization_position_parent', 'type' => 'int', 'internal' => 'parent'], - 'organization_position_department' => ['name' => 'organization_position_department', 'type' => 'int', 'internal' => 'department'], - 'organization_position_status' => ['name' => 'organization_position_status', 'type' => 'int', 'internal' => 'status'], + 'organization_position_id' => ['name' => 'organization_position_id', 'type' => 'int', 'internal' => 'id'], + 'organization_position_name' => ['name' => 'organization_position_name', 'type' => 'string', 'internal' => 'name'], + 'organization_position_description' => ['name' => 'organization_position_description', 'type' => 'string', 'internal' => 'description'], + 'organization_position_descriptionraw' => ['name' => 'organization_position_descriptionraw', 'type' => 'string', 'internal' => 'descriptionRaw'], + 'organization_position_parent' => ['name' => 'organization_position_parent', 'type' => 'int', 'internal' => 'parent'], + 'organization_position_department' => ['name' => 'organization_position_department', 'type' => 'int', 'internal' => 'department'], + 'organization_position_status' => ['name' => 'organization_position_status', 'type' => 'int', 'internal' => 'status'], ]; + /** + * Belongs to. + * + * @var array + * @since 1.0.0 + */ protected static $belongsTo = [ 'parent' => [ 'mapper' => PositionMapper::class, diff --git a/Models/Status.php b/Models/Status.php index ea197a9..94ae97c 100644 --- a/Models/Status.php +++ b/Models/Status.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -19,7 +19,7 @@ use phpOMS\Stdlib\Base\Enum; /** * Accept status enum. * - * @package Calendar + * @package Modules\Organization * @license OMS License 1.0 * @link http://website.orange-management.de * @since 1.0.0 diff --git a/Models/Unit.php b/Models/Unit.php index 6019e64..f745d79 100644 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -16,63 +16,209 @@ namespace Modules\Organization\Models; use phpOMS\Contract\ArrayableInterface; +/** + * Organization unit class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class Unit implements ArrayableInterface, \JsonSerializable { + /** + * Article ID. + * + * @var int + * @since 1.0.0 + */ private $id = 0; + /** + * Name. + * + * @var string + * @since 1.0.0 + */ private $name = ''; + /** + * Parent + * + * @var mixed + * @since 1.0.0 + */ private $parent = null; + /** + * Description. + * + * @var string + * @since 1.0.0 + */ private $description = ''; + /** + * Description. + * + * @var string + * @since 1.0.0 + */ + protected $descriptionRaw = ''; + + /** + * Status + * + * @var int + * @since 1.0.0 + */ protected $status = Status::INACTIVE; + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ public function getId() : int { return $this->id; } + /** + * Get name + * + * @return string + * + * @since 1.0.0 + */ public function getName() : string { return $this->name; } - public function setName(string $name) + /** + * Set name + * + * @param string $name Name + * + * @return void + * + * @since 1.0.0 + */ + public function setName(string $name) /* : void */ { $this->name = $name; } + /** + * Get parent + * + * @return mixed + * + * @since 1.0.0 + */ public function getParent() { return $this->parent ?? new NullUnit(); } - public function setParent($parent) + /** + * Set parent + * + * @param mixed $parent Parent + * + * @return mixed + * + * @since 1.0.0 + */ + public function setParent($parent) /* : void */ { $this->parent = $parent; } + /** + * Get status + * + * @return int + * + * @since 1.0.0 + */ public function getStatus() : int { return $this->status; } - public function setStatus(int $status) + /** + * Set status + * + * @param int $status Status + * + * @return void + * + * @since 1.0.0 + */ + public function setStatus(int $status) /* : void */ { $this->status = $status; } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ public function getDescription() : string { return $this->description; } - public function setDescription(string $desc) + /** + * Set description + * + * @param int $desc Description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescription(string $desc) /* : void */ { $this->description = $desc; } + /** + * Get description + * + * @return string + * + * @since 1.0.0 + */ + public function getDescriptionRaw() : string + { + return $this->descriptionRaw; + } + + /** + * Set description + * + * @param int $desc Description + * + * @return void + * + * @since 1.0.0 + */ + public function setDescriptionRaw(string $desc) + { + $this->descriptionRaw = $desc; + } + + /** + * {@inheritdoc} + */ public function toArray() : array { return [ @@ -96,11 +242,7 @@ class Unit implements ArrayableInterface, \JsonSerializable } /** - * Json serialize. - * - * @return string - * - * @since 1.0.0 + * {@inheritdoc} */ public function jsonSerialize() { diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index e5488f0..5196049 100644 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -4,7 +4,7 @@ * * PHP Version 7.1 * - * @package TBD + * @package Modules\Organization * @copyright Dennis Eichhorn * @license OMS License 1.0 * @version 1.0.0 @@ -16,6 +16,14 @@ namespace Modules\Organization\Models; use phpOMS\DataStorage\Database\DataMapperAbstract; +/** + * Organization unit mapper class. + * + * @package Modules\Organization + * @license OMS License 1.0 + * @link http://website.orange-management.de + * @since 1.0.0 + */ class UnitMapper extends DataMapperAbstract { /** @@ -25,13 +33,20 @@ class UnitMapper extends DataMapperAbstract * @since 1.0.0 */ protected static $columns = [ - 'organization_unit_id' => ['name' => 'organization_unit_id', 'type' => 'int', 'internal' => 'id'], - 'organization_unit_name' => ['name' => 'organization_unit_name', 'type' => 'string', 'internal' => 'name'], - 'organization_unit_description' => ['name' => 'organization_unit_description', 'type' => 'string', 'internal' => 'description'], - 'organization_unit_parent' => ['name' => 'organization_unit_parent', 'type' => 'int', 'internal' => 'parent'], - 'organization_unit_status' => ['name' => 'organization_unit_status', 'type' => 'int', 'internal' => 'status'], + 'organization_unit_id' => ['name' => 'organization_unit_id', 'type' => 'int', 'internal' => 'id'], + 'organization_unit_name' => ['name' => 'organization_unit_name', 'type' => 'string', 'internal' => 'name'], + 'organization_unit_description' => ['name' => 'organization_unit_description', 'type' => 'string', 'internal' => 'description'], + 'organization_unit_descriptionraw' => ['name' => 'organization_unit_descriptionraw', 'type' => 'string', 'internal' => 'descriptionRaw'], + 'organization_unit_parent' => ['name' => 'organization_unit_parent', 'type' => 'int', 'internal' => 'parent'], + 'organization_unit_status' => ['name' => 'organization_unit_status', 'type' => 'int', 'internal' => 'status'], ]; + /** + * Belongs to. + * + * @var array + * @since 1.0.0 + */ protected static $belongsTo = [ 'account' => [ 'mapper' => UnitMapper::class,