Add the hash generator and command to test hash generator. #640
This commit is contained in:
parent
ee07c9cc84
commit
0e5824af29
5 changed files with 973 additions and 761 deletions
|
|
@ -2,18 +2,30 @@
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"license": "proprietary",
|
"license": "proprietary",
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{ "type": "vcs", "url": "git@gitlab.com:jankstudio-catalyst/auth-bundle.git" },
|
{
|
||||||
{ "type": "vcs", "url": "git@gitlab.com:jankstudio-catalyst/menu-bundle.git" }
|
"type": "vcs",
|
||||||
|
"url": "git@gitlab.com:jankstudio-catalyst/auth-bundle.git"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "git@gitlab.com:jankstudio-catalyst/menu-bundle.git"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^7.1.3",
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
"catalyst/auth-bundle": "dev-master",
|
"catalyst/auth-bundle": "dev-master",
|
||||||
"catalyst/menu-bundle": "dev-master",
|
"catalyst/menu-bundle": "dev-master",
|
||||||
|
"composer/package-versions-deprecated": "1.11.99.4",
|
||||||
"creof/doctrine2-spatial": "^1.2",
|
"creof/doctrine2-spatial": "^1.2",
|
||||||
"data-dog/audit-bundle": "^0.1.10",
|
"data-dog/audit-bundle": "^0.1.10",
|
||||||
|
"doctrine/common": "^2",
|
||||||
|
"doctrine/doctrine-bundle": "^2",
|
||||||
|
"doctrine/doctrine-migrations-bundle": "^2",
|
||||||
|
"doctrine/orm": "^2",
|
||||||
"edwinhoksberg/php-fcm": "^1.0",
|
"edwinhoksberg/php-fcm": "^1.0",
|
||||||
"guzzlehttp/guzzle": "^6.3",
|
"guzzlehttp/guzzle": "^6.3",
|
||||||
|
"hashids/hashids": "^4.1",
|
||||||
"microsoft/azure-storage-blob": "^1.5",
|
"microsoft/azure-storage-blob": "^1.5",
|
||||||
"predis/predis": "^1.1",
|
"predis/predis": "^1.1",
|
||||||
"sensio/framework-extra-bundle": "^5.1",
|
"sensio/framework-extra-bundle": "^5.1",
|
||||||
|
|
@ -26,9 +38,7 @@
|
||||||
"symfony/framework-bundle": "^4.0",
|
"symfony/framework-bundle": "^4.0",
|
||||||
"symfony/maker-bundle": "^1.0",
|
"symfony/maker-bundle": "^1.0",
|
||||||
"symfony/monolog-bundle": "^3.7",
|
"symfony/monolog-bundle": "^3.7",
|
||||||
"symfony/orm-pack": "^1.0",
|
|
||||||
"symfony/process": "^4.0",
|
"symfony/process": "^4.0",
|
||||||
"symfony/profiler-pack": "^1.0",
|
|
||||||
"symfony/security-bundle": "^4.0",
|
"symfony/security-bundle": "^4.0",
|
||||||
"symfony/translation": "^4.0",
|
"symfony/translation": "^4.0",
|
||||||
"symfony/twig-bundle": "^4.0",
|
"symfony/twig-bundle": "^4.0",
|
||||||
|
|
@ -38,7 +48,9 @@
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/doctrine-fixtures-bundle": "^3.0",
|
"doctrine/doctrine-fixtures-bundle": "^3.0",
|
||||||
"symfony/dotenv": "^4.0",
|
"symfony/dotenv": "^4.0",
|
||||||
"symfony/thanks": "^1.0"
|
"symfony/stopwatch": "^4.0",
|
||||||
|
"symfony/thanks": "^1.0",
|
||||||
|
"symfony/web-profiler-bundle": "^4.0"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": {
|
"preferred-install": {
|
||||||
|
|
|
||||||
1631
composer.lock
generated
1631
composer.lock
generated
File diff suppressed because it is too large
Load diff
44
src/Command/TestHashGeneratorCommand.php
Normal file
44
src/Command/TestHashGeneratorCommand.php
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
use App\Service\HashGenerator;
|
||||||
|
|
||||||
|
class TestHashGeneratorCommand extends Command
|
||||||
|
{
|
||||||
|
protected $hash;
|
||||||
|
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this->setName('test:hash')
|
||||||
|
->setDescription('Test hash generator.')
|
||||||
|
->setHelp('Test hash generator service.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __construct(HashGenerator $hash)
|
||||||
|
{
|
||||||
|
$this->hash = $hash;
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$orig_id = 39095;
|
||||||
|
error_log('original id - ' . $orig_id);
|
||||||
|
|
||||||
|
$hash_id = $this->hash->getHash($orig_id);
|
||||||
|
error_log('hash id - ' . $hash_id);
|
||||||
|
|
||||||
|
$id = $this->hash->getID($hash_id);
|
||||||
|
error_log('id - ' . $id);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
28
src/Service/HashGenerator.php
Normal file
28
src/Service/HashGenerator.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use Hashids\Hashids;
|
||||||
|
|
||||||
|
class HashGenerator
|
||||||
|
{
|
||||||
|
// TODO: set in env file and set in constructor
|
||||||
|
protected $salt = 'salt that should be in the env file 230498';
|
||||||
|
protected $length = 15;
|
||||||
|
|
||||||
|
public function getHash($id)
|
||||||
|
{
|
||||||
|
$hi = new Hashids($this->salt, $this->length);
|
||||||
|
return $hi->encode($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getID($hash)
|
||||||
|
{
|
||||||
|
$hi = new Hashids($this->salt, $this->length);
|
||||||
|
$id_array = $hi->decode($hash);
|
||||||
|
|
||||||
|
// first one should be the id
|
||||||
|
return $id_array[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -110,6 +110,9 @@
|
||||||
"guzzlehttp/psr7": {
|
"guzzlehttp/psr7": {
|
||||||
"version": "1.4.2"
|
"version": "1.4.2"
|
||||||
},
|
},
|
||||||
|
"hashids/hashids": {
|
||||||
|
"version": "4.1.0"
|
||||||
|
},
|
||||||
"jdorn/sql-formatter": {
|
"jdorn/sql-formatter": {
|
||||||
"version": "v1.2.17"
|
"version": "v1.2.17"
|
||||||
},
|
},
|
||||||
|
|
@ -269,9 +272,6 @@
|
||||||
"config/packages/test/monolog.yaml"
|
"config/packages/test/monolog.yaml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"symfony/orm-pack": {
|
|
||||||
"version": "v1.0.5"
|
|
||||||
},
|
|
||||||
"symfony/polyfill-ctype": {
|
"symfony/polyfill-ctype": {
|
||||||
"version": "v1.9.0"
|
"version": "v1.9.0"
|
||||||
},
|
},
|
||||||
|
|
@ -290,9 +290,6 @@
|
||||||
"symfony/process": {
|
"symfony/process": {
|
||||||
"version": "v4.4.9"
|
"version": "v4.4.9"
|
||||||
},
|
},
|
||||||
"symfony/profiler-pack": {
|
|
||||||
"version": "v1.0.3"
|
|
||||||
},
|
|
||||||
"symfony/property-access": {
|
"symfony/property-access": {
|
||||||
"version": "v4.0.2"
|
"version": "v4.0.2"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue