1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of dispositif/wikibot application |
4
|
|
|
* 2019 © Philippe M. <[email protected]> |
5
|
|
|
* For the full copyright and MIT license information, please view the LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
declare(strict_types=1); |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace App\Domain\Publisher; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class FigaroMapper |
16
|
|
|
* |
17
|
|
|
* @package App\Domain\Publisher |
18
|
|
|
*/ |
19
|
|
|
class FigaroMapper extends WebMapper |
20
|
|
|
{ |
21
|
|
|
const PERIODIQUE = '[[Le Figaro]]'; |
22
|
|
|
|
23
|
|
|
public function process($data): array |
24
|
|
|
{ |
25
|
|
|
if (!isset($data['JSON-LD'])) { |
26
|
|
|
return []; |
27
|
|
|
} |
28
|
|
|
$data = $data['JSON-LD']; |
29
|
|
|
|
30
|
|
|
foreach ($data as $dat) { |
31
|
|
|
if ('NewsArticle' === $dat['@type']) { |
32
|
|
|
$data = $dat; |
33
|
|
|
goto mapping; |
34
|
|
|
} |
35
|
|
|
// todo ('WebPage' == @type) ==> {{lien web}} ? |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return []; // exception ? |
39
|
|
|
|
40
|
|
|
mapping: |
41
|
|
|
|
42
|
|
|
return [ |
43
|
|
|
// 'langue' => 'fr', |
44
|
|
|
'périodique' => static::PERIODIQUE, |
45
|
|
|
// 'acces' => $data['isAccessibleForFree'], |
46
|
|
|
'titre' => html_entity_decode($data['headline']), |
47
|
|
|
'lire en ligne' => $data['mainEntityOfPage']['@id'], |
48
|
|
|
'date' => $this->convertDate($data['datePublished']), // 2020-03-19T19:13:01.000Z |
49
|
|
|
'auteur1' => $this->convertAuteur($data, 0), |
50
|
|
|
'auteur2' => $this->convertAuteur($data, 1), |
51
|
|
|
'auteur3' => $this->convertAuteur($data, 2), |
52
|
|
|
'auteur institutionnel' => $this->convertInstitutionnel($data), |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
} |
57
|
|
|
|