Refactor API notification usage

- Remove "mapFields()" from BaseModel
- Add new Notification API entity (including collection)
- Add new NotificationFactory method "getApiList()"
This commit is contained in:
nupplaPhil 2020-01-28 21:28:57 +01:00
parent 4a3544582c
commit 582f6bd4a3
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
9 changed files with 164 additions and 109 deletions

View file

@ -12,7 +12,7 @@ use Psr\Log\LoggerInterface;
*
* @property int id
*/
abstract class BaseModel
abstract class BaseModel extends BaseEntity
{
/** @var Database */
protected $dba;
@ -48,23 +48,9 @@ abstract class BaseModel
$this->originalData = $data;
}
/**
* Maps a data array (original/current) to a known field list of the chosen model
*
* This is useful to filter out additional attributes, which aren't part of the db-table (like readonly cached fields)
*
* @param array $data The data array to map to db-fields
*
* @return array the mapped data array
*/
protected function mapFields(array $data)
{
return $data;
}
public function getOriginalData()
{
return $this->mapFields($this->originalData);
return $this->originalData;
}
public function resetOriginalData()
@ -129,16 +115,9 @@ abstract class BaseModel
$this->data[$name] = $value;
}
/**
* Returns the values of the current model as an array
*
* @param bool $dbOnly True, if just the db-relevant fields should be returned
*
* @return array The values of the current model
*/
public function toArray(bool $dbOnly = false)
public function toArray()
{
return $dbOnly ? $this->mapFields($this->data) : $this->data;
return $this->data;
}
protected function checkValid()