1 | <?php |
||
17 | class SportProxy extends Proxy implements SportInterface { |
||
18 | |||
19 | /** |
||
20 | * {@inheritdoc} |
||
21 | */ |
||
22 | 1 | public function load() { |
|
23 | 1 | $this->loadLeagues(); |
|
24 | 1 | } |
|
25 | |||
26 | /** |
||
27 | * Lazy loads the leagues for this sport. |
||
28 | * |
||
29 | * @throws \Exception |
||
30 | * When the leagues cannot be loaded. |
||
31 | * |
||
32 | * @return void |
||
33 | */ |
||
34 | 1 | protected function loadLeagues() { |
|
35 | 1 | $leagueData = $this->sportsDbClient->doRequest('search_all_leagues.php', array('s' => $this->properties->id)); |
|
36 | 1 | if (isset($leagueData->countrys)) { |
|
37 | 1 | $this->update($this->entityManager->mapProperties((object) array('leagues' => $leagueData->countrys), $this->getEntityType())); |
|
38 | 1 | return; |
|
39 | } |
||
40 | 1 | throw new \Exception('Could not fully load sport with id ' . $this->properties->id . '.'); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 1 | public function getId() { |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 1 | public function getLeagues() { |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 1 | public function getName() { |
|
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | 1 | public function addLeague(LeagueInterface $league) { |
|
79 | |||
80 | } |
||
81 |