This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LyricQuery.php
executable file
·71 lines (61 loc) · 1.96 KB
/
LyricQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Tekstove\ApiBundle\Model;
use Tekstove\ApiBundle\Model\Base\LyricQuery as BaseLyricQuery;
use Tekstove\ApiBundle\Model\Artist\Map\ArtistLyricTableMap;
/**
* Skeleton subclass for performing query and update operations on the 'lyric' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class LyricQuery extends BaseLyricQuery
{
use RepositoryTrait;
public function save(Lyric $lyric)
{
$lyric->setEventDispacher($this->eventDispacher);
$lyric->setValidator($this->validator);
$lyric->save();
}
/**
* @inheritDoc
* Also allow filtering by artistId
*/
public function filterByArtist($artist, $comparison = null)
{
if (is_numeric($artist)) {
$artistQuery = new ArtistQuery();
$artist = $artistQuery->findOneById($artist);
}
return parent::filterByArtist($artist, $comparison);
}
public function filterByArtistId($artistIds)
{
$artists = new \Propel\Runtime\Collection\ObjectCollection();
foreach ($artistIds as $artistId) {
$artist = new Artist();
$artist->setId($artistId);
$artists->append($artist);
}
$this->filterByArtist($artists, \Propel\Runtime\ActiveQuery\Criteria::IN);
$this->groupById();
$this->having(
"COUNT(" .
ArtistLyricTableMap::COL_LYRIC_ID .
") = " . count($artistIds)
);
return $this;
}
public function filterByUser($user, $comparison = null)
{
if (is_numeric($user)) {
$this->addAnd(Map\LyricTableMap::COL_SEND_BY, $user, \Propel\Runtime\ActiveQuery\Criteria::EQUAL);
return $this;
}
return parent::filterByUser($user, $comparison);
}
}