@@ 44-84 (lines=41) @@ | ||
41 | * @param string $formClass |
|
42 | * @return \PlaygroundGame\Entity\Game |
|
43 | */ |
|
44 | public function createOrUpdate(array $data, $game, $formClass) |
|
45 | { |
|
46 | $game = parent::createOrUpdate($data, $game, $formClass); |
|
47 | ||
48 | if ($game) { |
|
49 | $path = $this->getOptions()->getMediaPath() . DIRECTORY_SEPARATOR; |
|
50 | $media_url = $this->getOptions()->getMediaUrl() . '/'; |
|
51 | ||
52 | if (!empty($data['uploadBackImage']['tmp_name'])) { |
|
53 | ErrorHandler::start(); |
|
54 | $data['uploadBackImage']['name'] = $this->fileNewname( |
|
55 | $path, |
|
56 | $game->getId() . "-" . $data['uploadBackImage']['name'] |
|
57 | ); |
|
58 | move_uploaded_file( |
|
59 | $data['uploadBackImage']['tmp_name'], |
|
60 | $path . $data['uploadBackImage']['name'] |
|
61 | ); |
|
62 | $game->setBackImage($media_url . $data['uploadBackImage']['name']); |
|
63 | ErrorHandler::stop(true); |
|
64 | ||
65 | $game = $this->getGameMapper()->update($game); |
|
66 | } |
|
67 | ||
68 | if (isset($data['deleteBackImage']) && |
|
69 | $data['deleteBackImage'] && |
|
70 | empty($data['uploadBackImage']['tmp_name']) |
|
71 | ) { |
|
72 | ErrorHandler::start(); |
|
73 | $image = $game->getBackImage(); |
|
74 | $image = str_replace($media_url, '', $image); |
|
75 | unlink($path .$image); |
|
76 | $game->setBackImage(null); |
|
77 | ErrorHandler::stop(true); |
|
78 | ||
79 | $game = $this->getGameMapper()->update($game); |
|
80 | } |
|
81 | } |
|
82 | ||
83 | return $game; |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * @param array $data |
@@ 31-73 (lines=43) @@ | ||
28 | * @param string $formClass |
|
29 | * @return \PlaygroundGame\Entity\Game |
|
30 | */ |
|
31 | public function createOrUpdate(array $data, $game, $formClass) |
|
32 | { |
|
33 | $game = parent::createOrUpdate($data, $game, $formClass); |
|
34 | ||
35 | if ($game) { |
|
36 | $path = $this->getOptions()->getMediaPath() . DIRECTORY_SEPARATOR; |
|
37 | $media_url = $this->getOptions()->getMediaUrl() . '/'; |
|
38 | ||
39 | if (!empty($data['uploadScratchcardImage']['tmp_name'])) { |
|
40 | ErrorHandler::start(); |
|
41 | $data['uploadScratchcardImage']['name'] = $this->fileNewname( |
|
42 | $path, |
|
43 | $game->getId() . "-" . $data['uploadScratchcardImage']['name'] |
|
44 | ); |
|
45 | move_uploaded_file( |
|
46 | $data['uploadScratchcardImage']['tmp_name'], |
|
47 | $path . $data['uploadScratchcardImage']['name'] |
|
48 | ); |
|
49 | $game->setScratchcardImage($media_url . $data['uploadScratchcardImage']['name']); |
|
50 | ErrorHandler::stop(true); |
|
51 | ||
52 | $game = $this->getGameMapper()->update($game); |
|
53 | } |
|
54 | ||
55 | if (isset($data['deleteScratchcardImage']) && |
|
56 | $data['deleteScratchcardImage'] && |
|
57 | empty($data['uploadScratchcardImage']['tmp_name']) |
|
58 | ) { |
|
59 | ErrorHandler::start(); |
|
60 | $image = $game->getScratchcardImage(); |
|
61 | $image = str_replace($media_url, '', $image); |
|
62 | unlink($path .$image); |
|
63 | $game->setScratchcardImage(null); |
|
64 | ErrorHandler::stop(true); |
|
65 | } |
|
66 | ||
67 | if ($game->getScheduleOccurrenceAuto()) { |
|
68 | $this->scheduleOccurrences($game, $data); |
|
69 | } |
|
70 | } |
|
71 | ||
72 | return $game; |
|
73 | } |
|
74 | ||
75 | /** |
|
76 | * We can create Instant win occurrences dynamically |