Ajoute la date de mise en ligne

Fix #1
This commit is contained in:
Clement Desmidt 2017-09-30 15:41:23 +02:00
parent 2750443612
commit 29ea8882fe

View File

@ -29,6 +29,8 @@ class Deal
protected $image1; protected $image1;
/** @var string */ /** @var string */
protected $image2; protected $image2;
/** @var \DateTime */
protected $datecreation;
/** /**
* Deal constructor. * Deal constructor.
@ -50,6 +52,13 @@ class Deal
$deal->setType(self::TYPE_OFFER); $deal->setType(self::TYPE_OFFER);
$deal->setBody($crawler->filter('.properties_description')->first()->filter('p')->eq(1)->text()); $deal->setBody($crawler->filter('.properties_description')->first()->filter('p')->eq(1)->text());
$deal->setPrice($crawler->filter('[itemprop=price]')->first()->attr('content')); $deal->setPrice($crawler->filter('[itemprop=price]')->first()->attr('content'));
$date_node = $crawler->filter('[itemprop=availabilityStarts]')->first();
$date = \DateTime::createFromFormat('Y-m-d', $date_node->attr('content'));
$hours = current($date_node->extract(['_text']));
$hours = substr($hours, strpos($hours, 'à')+2);
list($hour, $min) = explode(':', $hours);
$date->setTime((int) $hour, (int) $min);
$deal->setDateCreation($date);
if ($crawler->filter('.item_photo')->count() > 0) { if ($crawler->filter('.item_photo')->count() > 0) {
$script = $crawler ->filter('.item_photo')->first()->nextAll() $script = $crawler ->filter('.item_photo')->first()->nextAll()
->filter('script')->first()->html(); ->filter('script')->first()->html();
@ -236,6 +245,24 @@ class Deal
return $this; return $this;
} }
/**
* @return \DateTime
*/
public function getDateCreation()
{
return $this->datecreation;
}
/**
* @param \DateTime $price
* @return Deal
*/
public function setDateCreation($datecreation)
{
$this->datecreation = $datecreation;
return $this;
}
/** /**
* @return Account * @return Account
*/ */