-
Notifications
You must be signed in to change notification settings - Fork 24
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
7cb9d9f
commit c73c5b0
Showing
5 changed files
with
55 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace ChessServer\Command\Binary; | ||
|
||
use Chess\Media\BoardToPng; | ||
use Chess\Variant\Classical\FEN\StrToBoard as ClassicalStrToBoard; | ||
use Chess\Variant\Classical\PGN\AN\Color; | ||
use ChessServer\Socket\AbstractSocket; | ||
use Spatie\Async\Task; | ||
|
||
class ImageAsyncTask extends Task | ||
{ | ||
private array $params; | ||
|
||
public function __construct(array $params) | ||
{ | ||
$this->params = $params; | ||
} | ||
|
||
public function configure() | ||
{ | ||
} | ||
|
||
public function run() | ||
{ | ||
$board = (new ClassicalStrToBoard($this->params['fen']))->create(); | ||
$filename = (new BoardToPng($board, $this->params['flip'] === Color::B)) | ||
->output(AbstractSocket::TMP_FOLDER); | ||
$contents = file_get_contents(AbstractSocket::TMP_FOLDER . "/$filename"); | ||
$base64 = base64_encode($contents); | ||
if (is_file(AbstractSocket::TMP_FOLDER . "/$filename")) { | ||
unlink(AbstractSocket::TMP_FOLDER . "/$filename"); | ||
} | ||
|
||
return $base64; | ||
} | ||
} |
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