-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2bc443
commit 3cb847b
Showing
12 changed files
with
156 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
|
||
namespace PServerCMS\Service; | ||
|
||
use PServerCMS\Entity\UserInterface; | ||
|
||
class Coin extends InvokableBase | ||
{ | ||
|
||
/** | ||
* @param $data | ||
* @param $user | ||
* @return bool | ||
*/ | ||
public function addCoinsForm($data, $userId) | ||
{ | ||
$form = $this->getForm(); | ||
$form->setData($data); | ||
|
||
if(!$form->isValid()){ | ||
return false; | ||
} | ||
$user = $this->getUser4Id($userId); | ||
|
||
if ($user) { | ||
$data = $form->getData(); | ||
$this->addCoins($user, $data['coins']); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @param UserInterface $user | ||
* @return int | ||
*/ | ||
public function getCoinsOfUser( UserInterface $user ) | ||
{ | ||
return $this->getGameBackendService()->getCoins($user); | ||
} | ||
|
||
/** | ||
* @param UserInterface $user | ||
* @param $amount | ||
* @return bool | ||
*/ | ||
public function addCoins( UserInterface $user, $amount ) | ||
{ | ||
return $this->getGameBackendService()->setCoins($user, $amount); | ||
} | ||
|
||
/** | ||
* @return \ZfcBase\Form\ProvidesEventsForm | ||
*/ | ||
public function getForm() | ||
{ | ||
return $this->getService('pserver_admin_coin_form'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.