-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure logo path is present when loading teams
- Loading branch information
1 parent
d99ce00
commit 83fb441
Showing
10 changed files
with
123 additions
and
64 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,23 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace HexagonalPlayground\Infrastructure\API\Logos; | ||
|
||
use HexagonalPlayground\Application\Repository\TeamRepositoryInterface; | ||
use HexagonalPlayground\Application\TypeAssert; | ||
use HexagonalPlayground\Domain\Team; | ||
|
||
trait TeamFinderTrait | ||
{ | ||
private TeamRepositoryInterface $teamRepository; | ||
|
||
private function findTeam(array $queryParams): Team | ||
{ | ||
TypeAssert::assertString($queryParams['teamId'], 'teamId'); | ||
|
||
/** @var Team $team */ | ||
$team = $this->teamRepository->find($queryParams['teamId']); | ||
|
||
return $team; | ||
} | ||
} |
This file was deleted.
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
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,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace HexagonalPlayground\Infrastructure\Filesystem; | ||
|
||
use HexagonalPlayground\Domain\Util\Uuid; | ||
use HexagonalPlayground\Infrastructure\Config; | ||
use Psr\Http\Message\UploadedFileInterface; | ||
|
||
class TeamLogoRepository | ||
{ | ||
public function delete(string $logoId): void | ||
{ | ||
unlink($this->generateStoragePath($logoId)); | ||
} | ||
|
||
public function generatePublicPath(string $logoId): string | ||
{ | ||
return join('/', [Config::getInstance()->appLogosPublicPath, "$logoId.webp"]); | ||
} | ||
|
||
private function generateStoragePath(string $logoId): string | ||
{ | ||
return join(DIRECTORY_SEPARATOR, [Config::getInstance()->appLogosPath, "$logoId.webp"]); | ||
} | ||
|
||
public function save(UploadedFileInterface $uploadedFile): string | ||
{ | ||
$logoId = Uuid::create(); | ||
|
||
$uploadedFile->moveTo($this->generateStoragePath($logoId)); | ||
|
||
return $logoId; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace HexagonalPlayground\Infrastructure\Persistence\Read; | ||
|
||
use HexagonalPlayground\Infrastructure\Filesystem\TeamLogoRepository; | ||
|
||
class TeamHydrator extends Hydrator | ||
{ | ||
private TeamLogoRepository $teamLogoRepository; | ||
|
||
public function __construct(iterable $fields, TeamLogoRepository $teamLogoRepository) | ||
{ | ||
parent::__construct($fields); | ||
$this->teamLogoRepository = $teamLogoRepository; | ||
} | ||
|
||
protected function hydrate(array $row): array | ||
{ | ||
$team = parent::hydrate($row); | ||
if ($team['logo_id'] !== null) { | ||
$team['logo_path'] = $this->teamLogoRepository->generatePublicPath($team['logo_id']); | ||
} | ||
|
||
return $team; | ||
} | ||
} |
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