|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: PBX_g33k |
|
5
|
|
|
* Date: 22-May-16 |
|
6
|
|
|
* Time: 22:14 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Pbxg33k\MusicInfo\Service\VocaDB\Endpoint; |
|
10
|
|
|
|
|
11
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
12
|
|
|
use Pbxg33k\MusicInfo\Model\Artist as ArtistModel; |
|
13
|
|
|
use Pbxg33k\MusicInfo\Model\IMusicServiceEndpoint; |
|
14
|
|
|
use Pbxg33k\VocaDB\Artist as ArtistEndpoint; |
|
15
|
|
|
|
|
16
|
|
|
class Artist extends ArtistEndpoint implements IMusicServiceEndpoint |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
const DATA_SOURCE = 'vocadb'; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @return mixed |
|
25
|
|
|
*/ |
|
26
|
|
|
public function getParent() |
|
27
|
|
|
{ |
|
28
|
|
|
// TODO: Implement getApiService() method. |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Aliases getById |
|
33
|
|
|
* |
|
34
|
|
|
* @param $guid |
|
35
|
|
|
* |
|
36
|
|
|
* @return mixed |
|
37
|
|
|
*/ |
|
38
|
|
|
public function getByGuid($guid) |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->getById($guid); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return mixed |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setParent($apiService) |
|
47
|
|
|
{ |
|
48
|
|
|
// TODO: Implement setApiService() method. |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
3 |
|
public function getByName($name) |
|
52
|
|
|
{ |
|
53
|
3 |
|
return $this->transform(parent::getByName($name)); // TODO: Change the autogenerated stub |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param $raw |
|
58
|
|
|
* |
|
59
|
|
|
* @return ArtistModel |
|
60
|
|
|
*/ |
|
61
|
3 |
|
public function transformSingle($raw) |
|
62
|
|
|
{ |
|
63
|
3 |
|
$object = new ArtistModel; |
|
64
|
|
|
$object |
|
65
|
3 |
|
->setId($raw->getId()) |
|
66
|
3 |
|
->setName($raw->getName()) |
|
67
|
3 |
|
->setType($raw->getArtistType()) |
|
68
|
3 |
|
->setDataSource(self::DATA_SOURCE) |
|
69
|
3 |
|
->setRawData($raw); |
|
70
|
|
|
|
|
71
|
3 |
|
return $object; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param $raw |
|
76
|
|
|
* |
|
77
|
|
|
* @return ArrayCollection |
|
78
|
|
|
*/ |
|
79
|
3 |
|
public function transformCollection($raw) |
|
80
|
|
|
{ |
|
81
|
3 |
|
$collection = new ArrayCollection(); |
|
82
|
3 |
|
foreach ($raw->collection as $artist) { |
|
83
|
3 |
|
$collection->add($this->transformSingle($artist)); |
|
84
|
3 |
|
} |
|
85
|
|
|
|
|
86
|
3 |
|
return $collection; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param $raw |
|
91
|
|
|
* |
|
92
|
|
|
* @return ArrayCollection |
|
93
|
|
|
*/ |
|
94
|
3 |
|
public function transform($raw) |
|
95
|
|
|
{ |
|
96
|
3 |
|
return $this->transformCollection($raw); |
|
97
|
|
|
} |
|
98
|
|
|
} |