<?php
+/**
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica;
*
* @property int id
*/
-abstract class BaseModel
+abstract class BaseModel extends BaseEntity
{
/** @var Database */
protected $dba;
$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()
$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()