Vorschaubilder von Reiseprogrammen zuverlässig per Typ 2 laden.
Korrigiert das Doctrine-Mapping für travel_program_image.type und wählt in getPreviewImage() explizit das Box-/Suchbild statt eines beliebigen Bildes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
9d22a5fdc9
commit
64dce95f20
2 changed files with 119 additions and 79 deletions
|
|
@ -395,6 +395,7 @@ class TravelProgram
|
|||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TravelProgramImage", mappedBy="program")
|
||||
* @ORM\OrderBy({"id" = "ASC"})
|
||||
*/
|
||||
private $images;
|
||||
|
||||
|
|
@ -1278,8 +1279,7 @@ class TravelProgram
|
|||
*/
|
||||
public function getIsAvailWeekday($weekday)
|
||||
{
|
||||
if ($this->weekdays == null)
|
||||
{
|
||||
if ($this->weekdays == null) {
|
||||
return false;
|
||||
}
|
||||
return in_array($weekday, explode(',', $this->weekdays));
|
||||
|
|
@ -1752,23 +1752,25 @@ class TravelProgram
|
|||
private function assertTravelDateNotDefinedYet($key, $header = null)
|
||||
{
|
||||
if ($header) {
|
||||
if (isset($this->headerTravelDateByKey[$key]))
|
||||
{
|
||||
if (isset($this->headerTravelDateByKey[$key])) {
|
||||
return true; //throw new \Exception('Travel period with key '. $key .' already exists');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($this->travelDateByKey[$key]))
|
||||
{
|
||||
if (isset($this->travelDateByKey[$key])) {
|
||||
return true; //throw new \Exception('Travel period with key '. $key .' already exists');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addTravelDateFromNonSeasonTravelPeriod($key, TravelPeriod $travelPeriod,
|
||||
FlightPeriod $flightPeriod = null, $currencyFactor, $header = null)
|
||||
{
|
||||
public function addTravelDateFromNonSeasonTravelPeriod(
|
||||
$key,
|
||||
TravelPeriod $travelPeriod,
|
||||
FlightPeriod $flightPeriod = null,
|
||||
$currencyFactor,
|
||||
$header = null
|
||||
) {
|
||||
|
||||
$now = new \DateTime();
|
||||
|
||||
|
|
@ -1790,32 +1792,66 @@ class TravelProgram
|
|||
return $this->travelDateByKey[$key];
|
||||
}
|
||||
|
||||
public function addTravelDateFromSeasonTravelPeriod($key, TravelPeriod $travelPeriod, $index, \DateTime $start,
|
||||
\DateTime $end = null, FlightPeriod $flightPeriod = null, $currencyFactor, $header = null)
|
||||
{
|
||||
public function addTravelDateFromSeasonTravelPeriod(
|
||||
$key,
|
||||
TravelPeriod $travelPeriod,
|
||||
$index,
|
||||
\DateTime $start,
|
||||
\DateTime $end = null,
|
||||
FlightPeriod $flightPeriod = null,
|
||||
$currencyFactor,
|
||||
$header = null
|
||||
) {
|
||||
|
||||
if ($header) {
|
||||
if (!$this->assertTravelDateNotDefinedYet($key, $header)) {
|
||||
$this->isHeaderTravelDateMapTainted = true;
|
||||
$this->headerTravelDateByKey[$key] = TravelDate::createForSeasonTravelPeriod($key, $travelPeriod, $index, $start,
|
||||
$end, $flightPeriod, $currencyFactor);
|
||||
$this->headerTravelDateByKey[$key] = TravelDate::createForSeasonTravelPeriod(
|
||||
$key,
|
||||
$travelPeriod,
|
||||
$index,
|
||||
$start,
|
||||
$end,
|
||||
$flightPeriod,
|
||||
$currencyFactor
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!$this->assertTravelDateNotDefinedYet($key)) {
|
||||
$this->isTravelDateMapTainted = true;
|
||||
$this->travelDateByKey[$key] = TravelDate::createForSeasonTravelPeriod($key, $travelPeriod, $index, $start,
|
||||
$end, $flightPeriod, $currencyFactor);
|
||||
$this->travelDateByKey[$key] = TravelDate::createForSeasonTravelPeriod(
|
||||
$key,
|
||||
$travelPeriod,
|
||||
$index,
|
||||
$start,
|
||||
$end,
|
||||
$flightPeriod,
|
||||
$currencyFactor
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function addTravelDate($key, TravelPeriod $travelPeriod, FlightPeriod $flightPeriod = null, $currencyFactor,
|
||||
\DateTime $start = null, \DateTime $end = null, $index = null)
|
||||
{
|
||||
public function addTravelDate(
|
||||
$key,
|
||||
TravelPeriod $travelPeriod,
|
||||
FlightPeriod $flightPeriod = null,
|
||||
$currencyFactor,
|
||||
\DateTime $start = null,
|
||||
\DateTime $end = null,
|
||||
$index = null
|
||||
) {
|
||||
if (!$this->assertTravelDateNotDefinedYet($key)) {
|
||||
$this->isTravelDateMapTainted = true;
|
||||
$this->travelDateByKey[$key] = new TravelDate($key, $travelPeriod, $flightPeriod, $currencyFactor, $start, $end,
|
||||
$index);
|
||||
$this->travelDateByKey[$key] = new TravelDate(
|
||||
$key,
|
||||
$travelPeriod,
|
||||
$flightPeriod,
|
||||
$currencyFactor,
|
||||
$start,
|
||||
$end,
|
||||
$index
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1841,16 +1877,14 @@ class TravelProgram
|
|||
public function getTravelDates($header = null)
|
||||
{
|
||||
if ($header) {
|
||||
if ($this->isHeaderTravelDateMapTainted)
|
||||
{
|
||||
if ($this->isHeaderTravelDateMapTainted) {
|
||||
ksort($this->headerTravelDateByKey);
|
||||
$this->isHeaderTravelDateMapTainted = false;
|
||||
}
|
||||
return $this->headerTravelDateByKey;
|
||||
}
|
||||
|
||||
if ($this->isTravelDateMapTainted)
|
||||
{
|
||||
if ($this->isTravelDateMapTainted) {
|
||||
ksort($this->travelDateByKey);
|
||||
$this->isTravelDateMapTainted = false;
|
||||
}
|
||||
|
|
@ -1861,7 +1895,6 @@ class TravelProgram
|
|||
{
|
||||
if ($header) {
|
||||
return !empty($this->headerTravelDateByKey);
|
||||
|
||||
}
|
||||
return !empty($this->travelDateByKey);
|
||||
}
|
||||
|
|
@ -1875,14 +1908,12 @@ class TravelProgram
|
|||
public function getLowestPrice()
|
||||
{
|
||||
$lowestPrice = -1;
|
||||
foreach ($this->getTravelDates() as $travelDate)
|
||||
{
|
||||
foreach ($this->getTravelDates() as $travelDate) {
|
||||
if ($travelDate->getStatus() == 0) {
|
||||
continue;
|
||||
}
|
||||
$curLowestPrice = $travelDate->getLowestPrice();
|
||||
if ($lowestPrice < 0 || $curLowestPrice < $lowestPrice)
|
||||
{
|
||||
if ($lowestPrice < 0 || $curLowestPrice < $lowestPrice) {
|
||||
$lowestPrice = $curLowestPrice;
|
||||
}
|
||||
}
|
||||
|
|
@ -1925,14 +1956,23 @@ class TravelProgram
|
|||
|
||||
public function getPreviewImage()
|
||||
{
|
||||
foreach ($this->getImages() as $image)
|
||||
{
|
||||
if ($image->getType() == 2)
|
||||
{
|
||||
return $image;
|
||||
$images = $this->getImages();
|
||||
if ($images->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$previewImage = null;
|
||||
foreach ($images as $image) {
|
||||
if ((int) $image->getType() === 2) {
|
||||
$previewImage = $image;
|
||||
}
|
||||
}
|
||||
return $this->getImages()[0];
|
||||
|
||||
if ($previewImage !== null) {
|
||||
return $previewImage;
|
||||
}
|
||||
|
||||
return $images->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ class TravelProgramImage
|
|||
private $description;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @var int|null 1=Gallery, 2=Box/Suche, 3=Header, 4=Slider
|
||||
*
|
||||
* @ORM\Column(name="type", type="boolean", nullable=true)
|
||||
* @ORM\Column(name="type", type="smallint", nullable=true)
|
||||
*/
|
||||
private $type;
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ class TravelProgramImage
|
|||
/**
|
||||
* Set type
|
||||
*
|
||||
* @param boolean $type
|
||||
* @param int|null $type
|
||||
*
|
||||
* @return TravelProgramImage
|
||||
*/
|
||||
|
|
@ -158,7 +158,7 @@ class TravelProgramImage
|
|||
/**
|
||||
* Get type
|
||||
*
|
||||
* @return boolean
|
||||
* @return int|null
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue