X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FBaseModel.php;h=41320d8bd5bcf528529b9a6f623babf9bfe84508;hb=6001c34525867a0aa614dbc020dcbc485e515345;hp=791d6887c1702d088308bed27a4870b9c1766e0b;hpb=443e106105b7d4ff9b97d21491a3d0eb89aa9dfe;p=friendica.git diff --git a/src/BaseModel.php b/src/BaseModel.php index 791d6887c1..41320d8bd5 100644 --- a/src/BaseModel.php +++ b/src/BaseModel.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica; @@ -12,7 +31,7 @@ use Psr\Log\LoggerInterface; * * @property int id */ -abstract class BaseModel +abstract class BaseModel extends BaseEntity { /** @var Database */ protected $dba; @@ -48,23 +67,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() @@ -131,12 +136,12 @@ abstract class BaseModel public function toArray() { - return $this->mapFields($this->data); + return $this->data; } protected function checkValid() { - if (empty($this->data['id'])) { + if (!isset($this->data['id']) || is_null($this->data['id'])) { throw new HTTPException\InternalServerErrorException(static::class . ' record uninitialized'); } }