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