mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-02-16 08:18:40 +00:00
fixes Orange-Management/phpOMS#224 and fixes Orange-Management/phpOMS#212
This commit is contained in:
parent
f9c943466a
commit
01e44c0e98
|
|
@ -16,13 +16,16 @@ namespace Modules\Organization\Controller;
|
||||||
|
|
||||||
use Modules\Organization\Models\Department;
|
use Modules\Organization\Models\Department;
|
||||||
use Modules\Organization\Models\DepartmentMapper;
|
use Modules\Organization\Models\DepartmentMapper;
|
||||||
|
use Modules\Organization\Models\NullDepartment;
|
||||||
|
use Modules\Organization\Models\NullPosition;
|
||||||
|
use Modules\Organization\Models\NullUnit;
|
||||||
use Modules\Organization\Models\Position;
|
use Modules\Organization\Models\Position;
|
||||||
use Modules\Organization\Models\PositionMapper;
|
use Modules\Organization\Models\PositionMapper;
|
||||||
use Modules\Organization\Models\SettingsEnum;
|
use Modules\Organization\Models\SettingsEnum;
|
||||||
use Modules\Organization\Models\Status;
|
use Modules\Organization\Models\Status;
|
||||||
|
|
||||||
use Modules\Organization\Models\Unit;
|
use Modules\Organization\Models\Unit;
|
||||||
use Modules\Organization\Models\UnitMapper;
|
use Modules\Organization\Models\UnitMapper;
|
||||||
|
|
||||||
use phpOMS\Account\GroupStatus;
|
use phpOMS\Account\GroupStatus;
|
||||||
use phpOMS\Message\Http\HttpRequest;
|
use phpOMS\Message\Http\HttpRequest;
|
||||||
use phpOMS\Message\NotificationLevel;
|
use phpOMS\Message\NotificationLevel;
|
||||||
|
|
@ -204,7 +207,7 @@ final class ApiController extends Controller
|
||||||
$unit->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
|
$unit->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
|
||||||
|
|
||||||
$parent = (int) $request->getData('parent');
|
$parent = (int) $request->getData('parent');
|
||||||
$unit->setParent(!empty($parent) ? $parent : null);
|
$unit->setParent(!empty($parent) ? new NullUnit($parent) : null);
|
||||||
$unit->setStatus((int) $request->getData('status'));
|
$unit->setStatus((int) $request->getData('status'));
|
||||||
|
|
||||||
return $unit;
|
return $unit;
|
||||||
|
|
@ -376,10 +379,10 @@ final class ApiController extends Controller
|
||||||
$position->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
|
$position->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
|
||||||
|
|
||||||
$parent = (int) $request->getData('parent');
|
$parent = (int) $request->getData('parent');
|
||||||
$position->setParent(!empty($parent) ? $parent : null);
|
$position->setParent(!empty($parent) ? new NullPosition($parent) : null);
|
||||||
|
|
||||||
$department = (int) $request->getData('department');
|
$department = (int) $request->getData('department');
|
||||||
$position->setDepartment(!empty($department) ? $department : null);
|
$position->setDepartment(!empty($department) ? new NullDepartment($department) : null);
|
||||||
|
|
||||||
return $position;
|
return $position;
|
||||||
}
|
}
|
||||||
|
|
@ -547,8 +550,8 @@ final class ApiController extends Controller
|
||||||
$department->setStatus((int) $request->getData('status'));
|
$department->setStatus((int) $request->getData('status'));
|
||||||
|
|
||||||
$parent = (int) $request->getData('parent');
|
$parent = (int) $request->getData('parent');
|
||||||
$department->setParent(!empty($parent) ? $parent : null);
|
$department->setParent(!empty($parent) ? new NullDepartment($parent) : null);
|
||||||
$department->setUnit((int) ($request->getData('unit') ?? 1));
|
$department->setUnit(new NullUnit((int) ($request->getData('unit') ?? 1)));
|
||||||
$department->setDescriptionRaw((string) ($request->getData('description') ?? ''));
|
$department->setDescriptionRaw((string) ($request->getData('description') ?? ''));
|
||||||
$department->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
|
$department->setDescription(Markdown::parse((string) ($request->getData('description') ?? '')));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Department implements ArrayableInterface, \JsonSerializable
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $parent = null;
|
protected ?self $parent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status
|
* Status
|
||||||
|
|
@ -61,10 +61,10 @@ class Department implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Unit this department belongs to
|
* Unit this department belongs to
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var Unit
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $unit = 1;
|
protected Unit $unit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* Description.
|
||||||
|
|
@ -135,11 +135,11 @@ class Department implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get parent
|
* Get parent
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Department
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent() : self
|
||||||
{
|
{
|
||||||
return $this->parent ?? new NullDepartment();
|
return $this->parent ?? new NullDepartment();
|
||||||
}
|
}
|
||||||
|
|
@ -147,13 +147,13 @@ class Department implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Set parent
|
* Set parent
|
||||||
*
|
*
|
||||||
* @param mixed $parent Parent
|
* @param null|self $parent Parent
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setParent($parent) : void
|
public function setParent(?self $parent) : void
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
@ -187,11 +187,11 @@ class Department implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get unit
|
* Get unit
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Unit
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getUnit()
|
public function getUnit() : Unit
|
||||||
{
|
{
|
||||||
return $this->unit ?? new NullUnit();
|
return $this->unit ?? new NullUnit();
|
||||||
}
|
}
|
||||||
|
|
@ -199,13 +199,13 @@ class Department implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Set unit
|
* Set unit
|
||||||
*
|
*
|
||||||
* @param mixed $unit Unit
|
* @param Unit $unit Unit
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setUnit($unit) : void
|
public function setUnit(Unit $unit) : void
|
||||||
{
|
{
|
||||||
$this->unit = $unit;
|
$this->unit = $unit;
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +271,7 @@ class Department implements ArrayableInterface, \JsonSerializable
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'unit' => $this->unit,
|
'unit' => $this->unit ?? new NullUnit(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,15 @@ namespace Modules\Organization\Models;
|
||||||
*/
|
*/
|
||||||
final class NullDepartment extends Department
|
final class NullDepartment extends Department
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,15 @@ namespace Modules\Organization\Models;
|
||||||
*/
|
*/
|
||||||
final class NullPosition extends Position
|
final class NullPosition extends Position
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,15 @@ namespace Modules\Organization\Models;
|
||||||
*/
|
*/
|
||||||
final class NullUnit extends Unit
|
final class NullUnit extends Unit
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $id Model id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function __construct(int $id = 0)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,18 +45,18 @@ class Position implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Parent
|
* Parent
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var null|Position
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $parent = null;
|
private ?self $parent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Department
|
* Department
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var null|Department
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $department = null;
|
private ?Department $department = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* Description.
|
||||||
|
|
@ -123,11 +123,11 @@ class Position implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get parent
|
* Get parent
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Position
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent() : self
|
||||||
{
|
{
|
||||||
return $this->parent ?? new NullPosition();
|
return $this->parent ?? new NullPosition();
|
||||||
}
|
}
|
||||||
|
|
@ -135,13 +135,13 @@ class Position implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Set parent
|
* Set parent
|
||||||
*
|
*
|
||||||
* @param mixed $parent Parent
|
* @param null|Position $parent Parent
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setParent($parent) : void
|
public function setParent(?self $parent) : void
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
@ -149,11 +149,11 @@ class Position implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get parent
|
* Get parent
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Department
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getDepartment()
|
public function getDepartment() : Department
|
||||||
{
|
{
|
||||||
return $this->department ?? new NullDepartment();
|
return $this->department ?? new NullDepartment();
|
||||||
}
|
}
|
||||||
|
|
@ -161,13 +161,13 @@ class Position implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Set department
|
* Set department
|
||||||
*
|
*
|
||||||
* @param mixed $department Department
|
* @param null|Department $department Department
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setDepartment($department) : void
|
public function setDepartment(?Department $department) : void
|
||||||
{
|
{
|
||||||
$this->department = $department;
|
$this->department = $department;
|
||||||
}
|
}
|
||||||
|
|
@ -259,7 +259,7 @@ class Position implements ArrayableInterface, \JsonSerializable
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'description' => $this->description,
|
'description' => $this->description,
|
||||||
'department' => $this->department,
|
'department' => $this->department ?? new NullDepartment(),
|
||||||
'parent' => $this->parent,
|
'parent' => $this->parent,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class Unit implements ArrayableInterface, \JsonSerializable
|
||||||
* @var int
|
* @var int
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private int $id = 0;
|
protected int $id = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name.
|
* Name.
|
||||||
|
|
@ -45,10 +45,10 @@ class Unit implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Parent
|
* Parent
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var null|Unit
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $parent = null;
|
private ?self $parent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description.
|
* Description.
|
||||||
|
|
@ -115,11 +115,11 @@ class Unit implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Get parent
|
* Get parent
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return Unit
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent() : self
|
||||||
{
|
{
|
||||||
return $this->parent ?? new NullUnit();
|
return $this->parent ?? new NullUnit();
|
||||||
}
|
}
|
||||||
|
|
@ -127,13 +127,13 @@ class Unit implements ArrayableInterface, \JsonSerializable
|
||||||
/**
|
/**
|
||||||
* Set parent
|
* Set parent
|
||||||
*
|
*
|
||||||
* @param mixed $parent Parent
|
* @param null|Unit $parent Parent
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function setParent($parent) : void
|
public function setParent(?self $parent) : void
|
||||||
{
|
{
|
||||||
$this->parent = $parent;
|
$this->parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user