1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the xAPI package. |
5
|
|
|
* |
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xabbuh\XApi\Client; |
13
|
|
|
|
14
|
|
|
use Xabbuh\XApi\Client\Api\ActivityProfileApiClient; |
15
|
|
|
use Xabbuh\XApi\Client\Api\AgentProfileApiClient; |
16
|
|
|
use Xabbuh\XApi\Client\Api\ApiClient; |
17
|
|
|
use Xabbuh\XApi\Client\Api\StateApiClient; |
18
|
|
|
use Xabbuh\XApi\Client\Api\StatementsApiClient; |
19
|
|
|
use Xabbuh\XApi\Client\Request\HandlerInterface; |
20
|
|
|
use Xabbuh\XApi\Serializer\SerializerRegistryInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* An Experience API client. |
24
|
|
|
* |
25
|
|
|
* @author Christian Flothmann <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class XApiClient extends ApiClient implements XApiClientInterface |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var SerializerRegistryInterface |
31
|
|
|
*/ |
32
|
|
|
private $serializerRegistry; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param HandlerInterface $requestHandler The HTTP request handler |
36
|
|
|
* @param SerializerRegistryInterface $serializerRegistry The serializer registry |
37
|
|
|
* @param string $version The xAPI version |
38
|
|
|
*/ |
39
|
|
|
public function __construct(HandlerInterface $requestHandler, SerializerRegistryInterface $serializerRegistry, $version) |
40
|
|
|
{ |
41
|
|
|
$this->requestHandler = $requestHandler; |
42
|
|
|
$this->serializerRegistry = $serializerRegistry; |
43
|
|
|
$this->version = $version; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getSerializerRegistry() |
47
|
|
|
{ |
48
|
|
|
return $this->serializerRegistry; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritDoc} |
53
|
|
|
*/ |
54
|
|
|
public function getStatementsApiClient() |
55
|
|
|
{ |
56
|
|
|
return new StatementsApiClient( |
57
|
|
|
$this->requestHandler, |
58
|
|
|
$this->version, |
59
|
|
|
$this->serializerRegistry->getStatementSerializer(), |
60
|
|
|
$this->serializerRegistry->getStatementResultSerializer(), |
61
|
|
|
$this->serializerRegistry->getActorSerializer() |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritDoc} |
67
|
|
|
*/ |
68
|
|
|
public function getStateApiClient() |
69
|
|
|
{ |
70
|
|
|
return new StateApiClient( |
71
|
|
|
$this->requestHandler, |
72
|
|
|
$this->version, |
73
|
|
|
$this->serializerRegistry->getDocumentDataSerializer(), |
74
|
|
|
$this->serializerRegistry->getActorSerializer() |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritDoc} |
80
|
|
|
*/ |
81
|
|
|
public function getActivityProfileApiClient() |
82
|
|
|
{ |
83
|
|
|
return new ActivityProfileApiClient( |
84
|
|
|
$this->requestHandler, |
85
|
|
|
$this->version, |
86
|
|
|
$this->serializerRegistry->getDocumentDataSerializer() |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritDoc} |
92
|
|
|
*/ |
93
|
|
|
public function getAgentProfileApiClient() |
94
|
|
|
{ |
95
|
|
|
return new AgentProfileApiClient( |
96
|
|
|
$this->requestHandler, |
97
|
|
|
$this->version, |
98
|
|
|
$this->serializerRegistry->getDocumentDataSerializer(), |
99
|
|
|
$this->serializerRegistry->getActorSerializer() |
100
|
|
|
); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|