1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of riesenia/pohoda package. |
||
5 | * |
||
6 | * Licensed under the MIT License |
||
7 | * (c) RIESENIA.com |
||
8 | */ |
||
9 | |||
10 | declare(strict_types=1); |
||
11 | |||
12 | namespace Riesenia\Pohoda; |
||
13 | |||
14 | class Supplier extends AbstractAgenda |
||
15 | { |
||
16 | 1 | public function getImportRoot(): string |
|
17 | { |
||
18 | 1 | return 'lst:supplier'; |
|
19 | } |
||
20 | |||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | 2 | public function setData(array $data): parent |
|
25 | { |
||
26 | // process stockItem |
||
27 | 2 | if (isset($data['stockItem'])) { |
|
28 | 2 | $stockItem = new Supplier\StockItem($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
29 | 2 | $data['stockItem'] = $stockItem->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['stockItem']); |
|
30 | } |
||
31 | |||
32 | // process suppliers |
||
33 | 2 | if (isset($data['suppliers']) && is_array($data['suppliers'])) { |
|
34 | 2 | $data['suppliers'] = \array_map(function ($supplier) { |
|
35 | 2 | $SupplierItem = new Supplier\SupplierItem($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
36 | 2 | return $SupplierItem->setDirectionalVariable($this->useOneDirectionalVariables)->setData($supplier['supplierItem']); |
|
37 | 2 | }, $data['suppliers']); |
|
38 | } |
||
39 | |||
40 | 2 | return parent::setData($data); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 1 | public function getXML(): \SimpleXMLElement |
|
47 | { |
||
48 | 1 | $xml = $this->createXML()->addChild('sup:supplier', '', $this->namespace('sup')); |
|
49 | 1 | $xml->addAttribute('version', '2.0'); |
|
50 | |||
51 | 1 | $this->addElements($xml, ['stockItem', 'suppliers'], 'sup'); |
|
52 | |||
53 | 1 | return $xml; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | 1 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
60 | { |
||
61 | // available options |
||
62 | 1 | $resolver->setDefined(['stockItem', 'suppliers']); |
|
63 | } |
||
64 | } |
||
65 |