Compare commits
No commits in common. "da67fbc7b0e9e8c0a353bf3f6da4ac1a299fb13a" and "ab4ebe93a3713d218d25d75f4c4eb095e2ce107a" have entirely different histories.
da67fbc7b0
...
ab4ebe93a3
4 changed files with 19 additions and 69 deletions
|
@ -15,8 +15,6 @@ class Game
|
||||||
private int|null $id;
|
private int|null $id;
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private string $name;
|
private string $name;
|
||||||
#[ORM\Column(nullable: true)]
|
|
||||||
private string|null $internalName;
|
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
|
@ -28,22 +26,11 @@ class Game
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInternalName(): string
|
|
||||||
{
|
|
||||||
return $this->internalName ?? $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setInternalName(string $internalName): void
|
|
||||||
{
|
|
||||||
$this->internalName = $internalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*/
|
*/
|
||||||
public function __construct(string $internalName, string $name)
|
public function __construct(string $name)
|
||||||
{
|
{
|
||||||
$this->internalName = $internalName;
|
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,17 +3,14 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace GamesShop\Importer;
|
namespace GamesShop\Importer;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\Criteria;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Exception;
|
use Exception;
|
||||||
use GamesShop\ContainerHandler;
|
|
||||||
use GamesShop\Entities\Account\User;
|
use GamesShop\Entities\Account\User;
|
||||||
use GamesShop\Entities\Games\Game;
|
use GamesShop\Entities\Games\Game;
|
||||||
use GamesShop\Entities\Games\Key;
|
use GamesShop\Entities\Games\Key;
|
||||||
use GamesShop\Entities\Games\KeyAttribute;
|
use GamesShop\Entities\Games\KeyAttribute;
|
||||||
use GamesShop\Entities\Games\Store;
|
use GamesShop\Entities\Games\Store;
|
||||||
use GamesShop\Entities\GamesList;
|
use GamesShop\Entities\GamesList;
|
||||||
use Monolog\Logger;
|
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
|
|
||||||
final class GameImporter
|
final class GameImporter
|
||||||
|
@ -130,26 +127,18 @@ final class GameImporter
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$internalName = $this->prepareGameName($values['name']);
|
$game = array_key_exists($values['name'], $foundGames) ? $foundGames[$values['name']] : null;
|
||||||
$game = array_key_exists($internalName, $foundGames) ? $foundGames[$internalName] : null;
|
|
||||||
|
|
||||||
ContainerHandler::get(Logger::class)->debug('importing game ' . $internalName);
|
|
||||||
|
|
||||||
if ($game === null) {
|
if ($game === null) {
|
||||||
$game = $this->entityManager->getRepository(Game::class)->matching(
|
$game = $this->entityManager->getRepository(Game::class)->findOneBy([ 'name' => $values['name'] ]);
|
||||||
Criteria::create()
|
|
||||||
->where(Criteria::expr()->eq('name', $values['name']))
|
|
||||||
->orWhere(Criteria::expr()->eq('internalName', $internalName))
|
|
||||||
)->first();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($game === false) {
|
if ($game === null) {
|
||||||
$game = new Game($internalName, $values['name']);
|
$game = new Game($values['name']);
|
||||||
$this->entityManager->persist($game);
|
$this->entityManager->persist($game);
|
||||||
}
|
}
|
||||||
|
|
||||||
$foundGames[$internalName] = $game;
|
$foundGames[$values['name']] = $game;
|
||||||
$game->setInternalName($internalName);
|
|
||||||
|
|
||||||
$key = new Key(
|
$key = new Key(
|
||||||
$game,
|
$game,
|
||||||
|
@ -185,20 +174,4 @@ final class GameImporter
|
||||||
|
|
||||||
return Store::EXTERNAL;
|
return Store::EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function prepareGameName(string $name): string
|
|
||||||
{
|
|
||||||
$replacements = [
|
|
||||||
':' => '',
|
|
||||||
'-' => '',
|
|
||||||
',' => '',
|
|
||||||
'!' => '',
|
|
||||||
'?' => '',
|
|
||||||
' ' => ' ',
|
|
||||||
' ' => '_',
|
|
||||||
];
|
|
||||||
|
|
||||||
$name = strtoupper($name);
|
|
||||||
return str_replace(array_keys($replacements), array_values($replacements), $name);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -45,16 +45,5 @@ $resource = $resources->getResource($resourceEntry);
|
||||||
<span class="h1">PROTOTYPE / POC</span>
|
<span class="h1">PROTOTYPE / POC</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="position-fixed bottom-0 start-0 m-3 fs-6">
|
|
||||||
<a href="https://git.php.fail/neintonine/gamesshop/issues/new" class="nav-link text-muted mb-3">
|
|
||||||
<i class="fa-solid fa-bug fa-xl me-3"></i>
|
|
||||||
You found a bug? Please report it.
|
|
||||||
</a>
|
|
||||||
<a href="https://git.php.fail/neintonine/gamesshop" class="nav-link text-muted">
|
|
||||||
<i class="fa-brands fa-git-alt me-3 fa-xl"></i>
|
|
||||||
Interested to help? Checkout the git repository.
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -29,13 +29,17 @@ $currentPermission = $activeUser === null ? UserPermission::NONE : $activeUser->
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<li class="nav-link">
|
<li class="nav-link">
|
||||||
<a href="<?= $header->link ?>" class="nav-link"><?= $header->title ?></a>
|
<a href="<?= $header->link ?>" class="nav-link"><?= $header->title ?></a>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="d-flex mode-switch me-4">
|
<?= $this->insert('layout/accountDisplay'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex mode-switch me-3">
|
||||||
<button title="Use dark mode" id="dark" class="btn btn-sm btn-default text-secondary">
|
<button title="Use dark mode" id="dark" class="btn btn-sm btn-default text-secondary">
|
||||||
<i class="fa-regular fa-moon"></i>
|
<i class="fa-regular fa-moon"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -46,7 +50,4 @@ $currentPermission = $activeUser === null ? UserPermission::NONE : $activeUser->
|
||||||
<i class="fa-solid fa-display"></i>
|
<i class="fa-solid fa-display"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<?= $this->insert('layout/accountDisplay'); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
</nav>
|
Loading…
Reference in a new issue