Refacto all project #1
@ -65,7 +65,6 @@ class BookmarkMapper extends ReaderMapper {
|
|||||||
* @return ReaderEntity the newly created or updated bookmark
|
* @return ReaderEntity the newly created or updated bookmark
|
||||||
*/
|
*/
|
||||||
public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): ReaderEntity {
|
public function set(int $fileId, string $name, string $value, ?string $type = null, ?string $content = null): ReaderEntity {
|
||||||
/** @var Bookmark[] $result */
|
|
||||||
$result = $this->get($fileId, $name);
|
$result = $this->get($fileId, $name);
|
||||||
|
|
||||||
if(empty($result)) {
|
if(empty($result)) {
|
||||||
@ -88,12 +87,14 @@ class BookmarkMapper extends ReaderMapper {
|
|||||||
$bookmark->setContent($content ?? '');
|
$bookmark->setContent($content ?? '');
|
||||||
|
|
||||||
$this->insert($bookmark);
|
$this->insert($bookmark);
|
||||||
} else {
|
} elseif ($result[0] instanceof Bookmark) {
|
||||||
$bookmark = $result[0];
|
$bookmark = $result[0];
|
||||||
$bookmark->setValue($value);
|
$bookmark->setValue($value);
|
||||||
$bookmark->setContent($content ?? '');
|
$bookmark->setContent($content ?? '');
|
||||||
|
|
||||||
$this->update($bookmark);
|
$this->update($bookmark);
|
||||||
|
} else {
|
||||||
|
$bookmark = new Bookmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bookmark;
|
return $bookmark;
|
||||||
|
@ -57,7 +57,6 @@ class PreferenceMapper extends ReaderMapper {
|
|||||||
* @return ReaderEntity the newly created or updated preference
|
* @return ReaderEntity the newly created or updated preference
|
||||||
*/
|
*/
|
||||||
public function set(string $scope, int $fileId, string $name, string $value): ReaderEntity {
|
public function set(string $scope, int $fileId, string $name, string $value): ReaderEntity {
|
||||||
/** @var Preference[] $result */
|
|
||||||
$result = $this->get($scope, $fileId, $name);
|
$result = $this->get($scope, $fileId, $name);
|
||||||
|
|
||||||
if(empty($result)) {
|
if(empty($result)) {
|
||||||
@ -69,11 +68,13 @@ class PreferenceMapper extends ReaderMapper {
|
|||||||
$preference->setValue($value);
|
$preference->setValue($value);
|
||||||
|
|
||||||
$this->insert($preference);
|
$this->insert($preference);
|
||||||
} else {
|
} elseif ($result[0] instanceof Preference) {
|
||||||
$preference = $result[0];
|
$preference = $result[0];
|
||||||
$preference->setValue($value);
|
$preference->setValue($value);
|
||||||
|
|
||||||
$this->update($preference);
|
$this->update($preference);
|
||||||
|
} else {
|
||||||
|
$preference = new Preference();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $preference;
|
return $preference;
|
||||||
|
Reference in New Issue
Block a user