Upgrade LBCAlerte to version 3.3

Add upgrade script
This commit is contained in:
Jimmy Monin
2016-11-26 19:19:16 +01:00
parent a7c054b535
commit 58ffd500e6
89 changed files with 6436 additions and 758 deletions

View File

@ -0,0 +1,44 @@
<?php
$ad = new App\Ad\Ad();
$link = "";
if (empty($_POST["link"])) {
return array(
"data" => $_POST,
"errors" => array(
"link" => "Ce champ est obligatoire."
)
);
}
$link = $_POST["link"];
try {
$siteConfig = \AdService\SiteConfigFactory::factory($link);
$parser = \AdService\ParserFactory::factory($link);
} catch (\Exception $e) {
return array(
"data" => $_POST,
"errors" => array(
"link" => "Cette adresse ne semble pas valide."
)
);
}
$ad = $parser->processAd(
$client->request($link),
parse_url($link, PHP_URL_SCHEME)
);
$ad_stored = $storage->fetchById($ad->getId());
if (!$ad_stored) {
$ad_stored = new \App\Ad\Ad();
}
$ad_stored->setFromArray($ad->toArray());
$storage->save($ad_stored);
$adPhoto = new App\Storage\AdPhoto($userAuthed);
$adPhoto->import($ad_stored);
return $ad_stored->toArray();