-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UCRM 5991 - Barcode plugin - Install hook and composer update
- Loading branch information
1 parent
1fa1675
commit 19147ad
Showing
7 changed files
with
201 additions
and
40 deletions.
There are no files selected for viewing
Binary file not shown.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Monolog\Handler\StreamHandler; | ||
use Monolog\Logger; | ||
use UBarcode\Service\TokenInstaller; | ||
use Ubnt\UcrmPluginSdk\Service\PluginLogManager; | ||
|
||
chdir(__DIR__); | ||
|
||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
$logger = new Logger('UBarcode'); | ||
$logger->pushHandler(new StreamHandler('data/plugin.log')); | ||
|
||
$logManager = PluginLogManager::create(); | ||
|
||
(new TokenInstaller())->install(); | ||
|
||
$logger->info('Security token has been generated. Use it as a part of request string.'); |
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
30 changes: 30 additions & 0 deletions
30
plugins/barcode-generator/src/src/Service/TokenInstaller.php
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace UBarcode\Service; | ||
|
||
use Nette\Utils\Json; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use UBarcode\Util\Strings; | ||
|
||
final class TokenInstaller | ||
{ | ||
private string $token; | ||
|
||
private Filesystem $filesystem; | ||
|
||
public function __construct() | ||
{ | ||
$this->filesystem = new Filesystem(); | ||
$this->token = Strings::generateUuidWithDashes(); | ||
} | ||
|
||
public function install(): void | ||
{ | ||
$this->filesystem->dumpFile('data/config.json', Json::encode([ | ||
'token' => $this->token, | ||
])); | ||
} | ||
} |
Oops, something went wrong.