if ($show_in_notification_page) {
$notification = DI::notify()->insert([
'name' => $params['source_name'],
+ 'name_cache' => strip_tags(BBCode::convert($params['source_name'])),
'url' => $params['source_link'],
'photo' => $params['source_photo'],
'uid' => $params['uid'],
$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->originalData;
+ return $this->mapFields($this->originalData);
}
public function resetOriginalData()
public function toArray()
{
- return $this->data;
+ return $this->mapFields($this->data);
}
protected function checkValid()
return $message;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function mapFields(array $data)
+ {
+ return [
+ 'hash' => $data['hash'] ?? '',
+ 'type' => $data['type'] ?? 0,
+ 'name' => $data['name'] ?? '',
+ 'url' => $data['url'] ?? '',
+ 'photo' => $data['photo'] ?? '',
+ 'date' => $data['date'] ?? DateTimeFormat::utcNow(),
+ 'msg' => $data['msg'] ?? '',
+ 'uid' => $data['uid'] ?? 0,
+ 'link' => $data['link'] ?? '',
+ 'iid' => $data['iid'] ?? 0,
+ 'parent' => $data['parent'] ?? 0,
+ 'seen' => $data['seen'] ?? false,
+ 'verb' => $data['verb'] ?? '',
+ 'otype' => $data['otype'] ?? '',
+ 'name_cache' => $data['name_cache'] ?? null,
+ 'msg_cache' => $data['msg_cache'] ?? null,
+ ];
+ }
}
return null;
}
+ unset($fields['abort']);
+
$this->logger->debug('adding notification entry', ['fields' => $fields]);
return parent::insert($fields);