]> git.mxchange.org Git - friendica.git/blobdiff - src/BaseModel.php
Merge pull request #8968 from annando/fix-fatal
[friendica.git] / src / BaseModel.php
index decc627521e50309a69dfe9195a1705ceab92b7d..8f9370bb09aa4f2b1574e49ec2c02918b4959fa1 100644 (file)
@@ -1,4 +1,23 @@
 <?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;
 
@@ -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()
@@ -129,16 +134,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()