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