This commit is contained in:
@@ -66,7 +66,7 @@ class FacilityDto
|
||||
}
|
||||
}
|
||||
|
||||
public function fillFromObject(Facility $facilityEntity): void
|
||||
public function fillFromEntity(Facility $facilityEntity): void
|
||||
{
|
||||
if ($facilityEntity->getId() !== null)
|
||||
{
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ class FileDto
|
||||
if ($fileEntity->getSeason() !== null)
|
||||
{
|
||||
$seasonDto = new SeasonDto();
|
||||
$seasonDto->fillFromObject($fileEntity->getSeason());
|
||||
$seasonDto->fillFromEntity($fileEntity->getSeason());
|
||||
$this->seasonDto = $seasonDto;
|
||||
}
|
||||
if ($fileEntity->getGame() !== null)
|
||||
|
||||
+4
-4
@@ -93,25 +93,25 @@ class GameDto
|
||||
if ($gameEntity->getSeason() !== null)
|
||||
{
|
||||
$seasonDto = new SeasonDto();
|
||||
$seasonDto->fillFromObject($gameEntity->getSeason());
|
||||
$seasonDto->fillFromEntity($gameEntity->getSeason());
|
||||
$this->seasonDto = $seasonDto;
|
||||
}
|
||||
if ($gameEntity->getFacility() !== null)
|
||||
{
|
||||
$facilityDto = new FacilityDto();
|
||||
$facilityDto->fillFromObject($gameEntity->getFacility());
|
||||
$facilityDto->fillFromEntity($gameEntity->getFacility());
|
||||
$this->facilityDto = $facilityDto;
|
||||
}
|
||||
if ($gameEntity->getHomeTeam() !== null)
|
||||
{
|
||||
$teamDto = new TeamDto();
|
||||
$teamDto->fillFromObject($gameEntity->getHomeTeam());
|
||||
$teamDto->fillFromEntity($gameEntity->getHomeTeam());
|
||||
$this->homeTeamDto = $teamDto;
|
||||
}
|
||||
if ($gameEntity->getAwayTeam() !== null)
|
||||
{
|
||||
$teamDto = new TeamDto();
|
||||
$teamDto->fillFromObject($gameEntity->getAwayTeam());
|
||||
$teamDto->fillFromEntity($gameEntity->getAwayTeam());
|
||||
$this->awayTeamDto = $teamDto;
|
||||
}
|
||||
if ($gameEntity->getFiles() !== null)
|
||||
|
||||
@@ -155,7 +155,7 @@ class LeagueDto
|
||||
foreach ($leagueObj->getSeasons() as $seasonObj)
|
||||
{
|
||||
$seasonDto = new SeasonDto();
|
||||
$seasonDto->fillFromObject($seasonObj);
|
||||
$seasonDto->fillFromEntity($seasonObj);
|
||||
$this->seasonDtoList[] = $seasonDto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class PlayerDto
|
||||
if ($playerEntity->getTeam() !== null)
|
||||
{
|
||||
$teamDto = new TeamDto();
|
||||
$teamDto->fillFromObject($playerEntity->getTeam());
|
||||
$teamDto->fillFromEntity($playerEntity->getTeam());
|
||||
$this->teamDto = $teamDto;
|
||||
}
|
||||
if ($playerEntity->getFiles() !== null)
|
||||
|
||||
+56
-10
@@ -3,12 +3,14 @@
|
||||
namespace DMD\LaLigaApi\Dto;
|
||||
|
||||
use DMD\LaLigaApi\Entity\Season;
|
||||
use DMD\LaLigaApi\Entity\Team;
|
||||
use DMD\LaLigaApi\Exception\ValidationException;
|
||||
|
||||
class SeasonDto
|
||||
{
|
||||
public int $id;
|
||||
public \DateTime $dateStart;
|
||||
public \DateTime $createdAt;
|
||||
public array $teamDtoList;
|
||||
public array $facilityDtoList;
|
||||
public int $leagueId;
|
||||
@@ -22,6 +24,7 @@ class SeasonDto
|
||||
public array $seasonDataDtoList;
|
||||
public bool $active;
|
||||
public array $validationErrors;
|
||||
public int $matchesBetweenTeams;
|
||||
|
||||
public function createSeasonArray(): array
|
||||
{
|
||||
@@ -102,28 +105,71 @@ class SeasonDto
|
||||
}
|
||||
}
|
||||
|
||||
public function fillFromObject(Season $seasonObj): void
|
||||
public function fillFromEntity(Season $seasonEntity): void
|
||||
{
|
||||
if ($seasonObj->getId() !== null)
|
||||
if ($seasonEntity->getId() !== null)
|
||||
{
|
||||
$this->id = $seasonObj->getId();
|
||||
$this->id = $seasonEntity->getId();
|
||||
}
|
||||
if ($seasonObj->getDateStart() !== null)
|
||||
if ($seasonEntity->getDateStart() !== null)
|
||||
{
|
||||
$this->dateStart = new \DateTime($seasonObj->getDateStart()->format('Y-m'));
|
||||
$this->dateStart = $seasonEntity->getDateStart();
|
||||
}
|
||||
$leagueObj = $seasonObj->getLeague();
|
||||
$leagueObj = $seasonEntity->getLeague();
|
||||
if ($leagueObj !== null)
|
||||
{
|
||||
$this->leagueId = $leagueObj->getId();
|
||||
}
|
||||
if ($leagueObj->isActive() !== null)
|
||||
if ($seasonEntity->isActive() !== null)
|
||||
{
|
||||
$this->active = $leagueObj->isActive();
|
||||
$this->active = $seasonEntity->isActive();
|
||||
}
|
||||
if ($leagueObj->getGamesPerWeek() !== null)
|
||||
if ($seasonEntity->getTeams())
|
||||
{
|
||||
$this->gamesPerWeek = $leagueObj->getGamesPerWeek();
|
||||
foreach ($seasonEntity->getTeams() as $teamEntity)
|
||||
{
|
||||
$teamDto = new TeamDto();
|
||||
$teamDto->fillFromEntity($teamEntity);
|
||||
$this->teamDtoList[] = $teamDto;
|
||||
}
|
||||
}
|
||||
if ($seasonEntity->getFacilities())
|
||||
{
|
||||
foreach ($seasonEntity->getFacilities() as $facilityEntity)
|
||||
{
|
||||
$facilityDto = new FacilityDto();
|
||||
$facilityDto->fillFromEntity($facilityEntity);
|
||||
$this->facilityDtoList[] = $facilityDto;
|
||||
}
|
||||
}
|
||||
if ($seasonEntity->getGames())
|
||||
{
|
||||
foreach ($seasonEntity->getGames() as $gameEntity)
|
||||
{
|
||||
$gameDto = new GameDto();
|
||||
$gameDto->fillFromObject($gameEntity);
|
||||
$this->gameDtoList[] = $gameDto;
|
||||
}
|
||||
}
|
||||
if ($seasonEntity->getCreatedAt())
|
||||
{
|
||||
$this->createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $seasonEntity->getCreatedAt()->format('Y-m-d H:i:s'));
|
||||
}
|
||||
if ($seasonEntity->getPointsPerWin())
|
||||
{
|
||||
$this->pointsPerWin = $seasonEntity->getPointsPerWin();
|
||||
}
|
||||
if ($seasonEntity->getPointsPerLoss())
|
||||
{
|
||||
$this->pointsPerLoss = $seasonEntity->getPointsPerLoss();
|
||||
}
|
||||
if ($seasonEntity->getPointsPerDraw())
|
||||
{
|
||||
$this->pointsPerDraw = $seasonEntity->getPointsPerDraw();
|
||||
}
|
||||
if ($seasonEntity->getGamesPerWeek())
|
||||
{
|
||||
$this->gamesPerWeek = $seasonEntity->getGamesPerWeek();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-25
@@ -11,38 +11,25 @@ class TeamDto
|
||||
public int $id;
|
||||
public string $name;
|
||||
public string $dayOfWeekForHomeGame;
|
||||
public string $logo;
|
||||
public bool $active;
|
||||
public int $leagueId;
|
||||
public array $seasonDtoList;
|
||||
public array $playerDtoList;
|
||||
public array $validationErrors;
|
||||
public UserDto $captainDto;
|
||||
public \DateTimeImmutable $createdAt;
|
||||
public UserDto $captainDto;
|
||||
public array $validationErrors;
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$seasonList = [];
|
||||
$playerList = [];
|
||||
if (!empty($this->seasonDtoList))
|
||||
{
|
||||
foreach ($this->seasonDtoList as $seasonDto)
|
||||
{
|
||||
$seasonList = $seasonDto->toArray();
|
||||
}
|
||||
}
|
||||
if (!empty($this->playerDtoList))
|
||||
{
|
||||
foreach ($this->playerDtoList as $playerDto)
|
||||
{
|
||||
$playerList = $playerDto->toArray();
|
||||
}
|
||||
}
|
||||
return [
|
||||
'id' => $this->id ?? '',
|
||||
'name' => $this->name ?? '',
|
||||
'dayOfWeekForHomeGame' => $this->dayOfWeekForHomeGame ?? '',
|
||||
'playerList' => $playerList,
|
||||
'seasonList' => $seasonList,
|
||||
'captainId' => $this->captainDto?->id,
|
||||
'createdAt' => $this->createdAt->format('Y-m-d')
|
||||
'logo' => $this->logo ?? '',
|
||||
'captainName'=> isset($this->captainDto) ? $this->captainDto->firstName . ' ' . $this->captainDto->lastName : 'No asignado',
|
||||
'captainId'=> isset($this->captainDto) ? $this->captainDto->id : 'No asignado',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,6 +51,14 @@ class TeamDto
|
||||
{
|
||||
$this->active = $dataList['active'];
|
||||
}
|
||||
if (isset($dataList['logo']))
|
||||
{
|
||||
$this->logo = $dataList['logo'];
|
||||
}
|
||||
if (isset($dataList['leagueId']))
|
||||
{
|
||||
$this->leagueId = (int) $dataList['leagueId'];
|
||||
}
|
||||
if (!empty($dataList['seasonList']))
|
||||
{
|
||||
foreach ($dataList['seasonList'] as $seasonItem)
|
||||
@@ -94,7 +89,7 @@ class TeamDto
|
||||
}
|
||||
}
|
||||
|
||||
public function fillFromObject(Team $teamEntity): void
|
||||
public function fillFromEntity(Team $teamEntity): void
|
||||
{
|
||||
if ($teamEntity->getId())
|
||||
{
|
||||
@@ -104,9 +99,9 @@ class TeamDto
|
||||
{
|
||||
$this->name = $teamEntity->getName();
|
||||
}
|
||||
if ($teamEntity->getDayOfWeekForHomeGame())
|
||||
if ($teamEntity->getDayOfTheWeekForHomeGame())
|
||||
{
|
||||
$this->dayOfWeekForHomeGame = $teamEntity->getDayOfWeekForHomeGame();
|
||||
$this->dayOfWeekForHomeGame = $teamEntity->getDayOfTheWeekForHomeGame();
|
||||
}
|
||||
if ($teamEntity->getPlayers())
|
||||
{
|
||||
@@ -117,6 +112,15 @@ class TeamDto
|
||||
$this->playerDtoList[] = $playerDto;
|
||||
}
|
||||
}
|
||||
if ($teamEntity->getTeamLogo())
|
||||
{
|
||||
$this->logo = $teamEntity->getTeamLogo();
|
||||
}
|
||||
if ($teamEntity->getCaptain())
|
||||
{
|
||||
$this->captainDto = new UserDto;
|
||||
$this->captainDto->fillFromObject($teamEntity->getCaptain());
|
||||
}
|
||||
if ($teamEntity->getCreatedAt())
|
||||
{
|
||||
$this->createdAt = $teamEntity->getCreatedAt();
|
||||
|
||||
Reference in New Issue
Block a user