1 | <?php |
||
16 | class SeasonProxy extends Proxy implements SeasonInterface { |
||
17 | |||
18 | /** |
||
19 | * {@inheritdoc} |
||
20 | */ |
||
21 | 1 | public function load() { |
|
22 | 1 | $this->loadEvents(); |
|
23 | 1 | } |
|
24 | |||
25 | /** |
||
26 | * Lazy loads the events for this season. |
||
27 | * |
||
28 | * @throws \Exception |
||
29 | * When the events cannot be loaded. |
||
30 | * |
||
31 | * @return void |
||
32 | */ |
||
33 | 1 | protected function loadEvents() { |
|
34 | 1 | $id = explode('|', $this->getId()); |
|
35 | 1 | $eventData = $this->sportsDbClient->doRequest('eventsseason.php', array('id' => $this->getLeague()->getId(), 's' => reset($id))); |
|
36 | 1 | if (isset($eventData->events)) { |
|
37 | 1 | $this->update($this->entityManager->mapProperties((object) array('events' => $eventData->events), $this->getEntityType())); |
|
38 | 1 | return; |
|
39 | } |
||
40 | throw new \Exception('Could not fully load season with id ' . $this->getId() . '.'); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 1 | public function getId() { |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 1 | public function getName() { |
|
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | 1 | public function getEvents() { |
|
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | 1 | public function getLeague() { |
|
70 | |||
71 | } |
||
72 |