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\StockTransfer; |
13
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\AbstractAgenda; |
15
|
|
|
use Riesenia\Pohoda\Common; |
16
|
|
|
use Riesenia\Pohoda\Type\StockItem; |
17
|
|
|
|
18
|
|
|
class Item extends AbstractAgenda |
19
|
|
|
{ |
20
|
|
|
/** @var string[] */ |
21
|
|
|
protected array $elements = ['quantity', 'stockItem', 'note']; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
1 |
|
public function setData(array $data): parent |
27
|
|
|
{ |
28
|
|
|
// process stock item |
29
|
1 |
|
if (isset($data['stockItem'])) { |
30
|
1 |
|
$stockItem = new StockItem($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory); |
31
|
1 |
|
$stockItem->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['stockItem']); |
32
|
1 |
|
$data['stockItem'] = $stockItem; |
33
|
|
|
} |
34
|
|
|
|
35
|
1 |
|
return parent::setData($data); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* {@inheritdoc} |
40
|
|
|
*/ |
41
|
1 |
|
public function getXML(): \SimpleXMLElement |
42
|
|
|
{ |
43
|
1 |
|
$xml = $this->createXML()->addChild('pre:prevodkaItem', '', $this->namespace('pre')); |
44
|
|
|
|
45
|
1 |
|
$this->addElements($xml, $this->elements, 'pre'); |
46
|
|
|
|
47
|
1 |
|
return $xml; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
54
|
|
|
{ |
55
|
|
|
// available options |
56
|
1 |
|
$resolver->setDefined($this->elements); |
57
|
|
|
|
58
|
|
|
// validate / format options |
59
|
1 |
|
$resolver->setNormalizer('quantity', $this->normalizerFactory->getClosure('float')); |
60
|
1 |
|
$resolver->setNormalizer('note', $this->normalizerFactory->getClosure('string90')); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|