initial commit
This commit is contained in:
commit
0db3e92ee6
59 changed files with 3384 additions and 0 deletions
113
src/DomainObjects/Spitex.php
Normal file
113
src/DomainObjects/Spitex.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace VeruA\DomainObjects;
|
||||
|
||||
use VeruA\Log;
|
||||
use VeruA\DomainObjects\ValueObjects\{
|
||||
IntKey,
|
||||
Varchar,
|
||||
Boolean,
|
||||
EAN13,
|
||||
Integer,
|
||||
Image
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A Spitex Business from the spitex table
|
||||
*
|
||||
* @property ValueObjects\Integer $id The primary key of the spitex table
|
||||
* @property ValueObjects\Image $logo The logo-image of the spitex
|
||||
* @property ValueObjects\Varchar $name The name of the spitex
|
||||
* @property ValueObjects\EAN13 $gln Spitex GLN-Number
|
||||
* @property bool $isSpitex always returns true
|
||||
* @property Address $address adress Object? not implemented in mapper yet
|
||||
*/
|
||||
class Spitex extends DomainObject implements Business
|
||||
{
|
||||
use Log;
|
||||
|
||||
protected function fields(array ...$superFields): array
|
||||
{
|
||||
return parent::fields([
|
||||
'id' => IntKey::class,
|
||||
'logo' => Image::class,
|
||||
'name' => Varchar::class,
|
||||
'gln' => EAN13::class,
|
||||
'billcare' => Integer::class,
|
||||
'address' => Address::class,
|
||||
|
||||
// Modules - todo: normalize in additional table
|
||||
'bcModule' => Integer::class,
|
||||
'xmlModule' => Boolean::class,
|
||||
'ekarusModule' => Boolean::class,
|
||||
'popModule' => Boolean::class,
|
||||
'qrModule' => Boolean::class,
|
||||
'dpModule' => Boolean::class,
|
||||
'tpModule' => Boolean::class,
|
||||
], ...$superFields);
|
||||
}
|
||||
|
||||
public function __get(string $field)
|
||||
{
|
||||
switch ($field) {
|
||||
case 'isSpitex': return $this->isSpitex();
|
||||
case 'logo': return $this->logo();
|
||||
}
|
||||
return parent::__get($field);
|
||||
}
|
||||
|
||||
public function name()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function logo()
|
||||
{
|
||||
$logo = $this->data['logo'];
|
||||
|
||||
if (! $logo->isReadable()) {
|
||||
$logo->in('logo_leer/logo_leer.jpg');
|
||||
}
|
||||
return $logo;
|
||||
}
|
||||
|
||||
public function isSpitex(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate / Deactivate Modules
|
||||
* @todo put moduels in a separate table. Do not use the fields directly to change state, to ease
|
||||
* migration
|
||||
* @param modules 'field' => true|false
|
||||
*/
|
||||
public function modules(Array $modules)
|
||||
{
|
||||
foreach ($modules as $module => $value) {
|
||||
$this->{$module.'Module'} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function isModuleActive(string $module): bool
|
||||
{
|
||||
return $this->{$module.'Module'};
|
||||
}
|
||||
|
||||
public function areModulesActive(array $modules): bool
|
||||
{
|
||||
$areActive = true;
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
if (!$this->{$module.'Module'} === true) {
|
||||
$areActive = false;
|
||||
}
|
||||
}
|
||||
return $areActive;
|
||||
}
|
||||
}
|
||||
|
||||
/* jEdit buffer local properties {{{
|
||||
* :folding=explicit:collapseFolds=1:
|
||||
}}}*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue