|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Music app |
|
5
|
|
|
* |
|
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
7
|
|
|
* later. See the COPYING file. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Gavin E <[email protected]> |
|
10
|
|
|
* @author Pauli Järvinen <[email protected]> |
|
11
|
|
|
* @copyright Gavin E 2020 |
|
12
|
|
|
* @copyright Pauli Järvinen 2020 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace OCA\Music\BusinessLayer; |
|
16
|
|
|
|
|
17
|
|
|
use \OCA\Music\AppFramework\BusinessLayer\BusinessLayer; |
|
18
|
|
|
use \OCA\Music\AppFramework\Core\Logger; |
|
19
|
|
|
|
|
20
|
|
|
use \OCA\Music\Db\BaseMapper; |
|
21
|
|
|
use \OCA\Music\Db\BookmarkMapper; |
|
22
|
|
|
use \OCA\Music\Db\Bookmark; |
|
23
|
|
|
|
|
24
|
|
|
use \OCA\Music\Utility\Util; |
|
25
|
|
|
|
|
26
|
|
|
use \OCP\AppFramework\Db\DoesNotExistException; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
class BookmarkBusinessLayer extends BusinessLayer { |
|
30
|
|
|
private $logger; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct( |
|
33
|
|
|
BookmarkMapper $bookmarkMapper, |
|
34
|
|
|
Logger $logger) { |
|
35
|
|
|
parent::__construct($bookmarkMapper); |
|
36
|
|
|
$this->logger = $logger; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param string $userId |
|
41
|
|
|
* @param int $trackId |
|
42
|
|
|
* @param int $position |
|
43
|
|
|
* @param string|null $comment |
|
44
|
|
|
* @return Bookmark |
|
45
|
|
|
*/ |
|
46
|
|
|
public function addOrUpdate($userId, $trackId, $position, $comment) { |
|
47
|
|
|
$updateTime = new \DateTime(); |
|
48
|
|
|
$updateTime = $updateTime->format(BaseMapper::SQL_DATE_FORMAT); |
|
49
|
|
|
|
|
50
|
|
|
try { |
|
51
|
|
|
$bookmark = $this->findByTrack($trackId, $userId); |
|
52
|
|
|
} catch (DoesNotExistException $e) { |
|
53
|
|
|
$bookmark = new Bookmark(); |
|
54
|
|
|
$bookmark->setCreated($updateTime); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$bookmark->setUserId($userId); |
|
58
|
|
|
$bookmark->setTrackId($trackId); |
|
59
|
|
|
$bookmark->setPosition($position); |
|
60
|
|
|
$bookmark->setComment(Util::truncate($comment, 256)); |
|
61
|
|
|
$bookmark->setUpdated($updateTime); |
|
62
|
|
|
|
|
63
|
|
|
return $this->mapper->insertOrUpdate($bookmark); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param int $trackId |
|
68
|
|
|
* @param string $userId |
|
69
|
|
|
* @throws DoesNotExistException if such bookmark does not exist |
|
70
|
|
|
* @return Bookmark |
|
71
|
|
|
*/ |
|
72
|
|
|
public function findByTrack($trackId, $userId) { |
|
73
|
|
|
return $this->mapper->findByTrack($trackId, $userId); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths