alex-kalanis /
pohoda
| 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\PrintRequest; |
||
| 13 | |||
| 14 | use Riesenia\Pohoda\AbstractAgenda; |
||
| 15 | use Riesenia\Pohoda\Common; |
||
| 16 | |||
| 17 | class Parameters extends AbstractAgenda |
||
| 18 | { |
||
| 19 | /** @var string[] */ |
||
| 20 | protected array $elements = [ |
||
| 21 | 'copy', |
||
| 22 | 'datePrint', |
||
| 23 | ]; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * {@inheritdoc} |
||
| 27 | */ |
||
| 28 | 3 | public function setData(array $data): parent |
|
| 29 | { |
||
| 30 | 3 | $parameterFactory = $this->dependenciesFactory->getParametersFactory(); |
|
| 31 | 3 | $parameterInstances = $this->dependenciesFactory->getParameterInstances(); |
|
| 32 | |||
| 33 | 3 | foreach ($parameterInstances->getKeys() as $key) { |
|
| 34 | // fill elements from factory |
||
| 35 | 3 | $this->elements[] = $key; |
|
| 36 | // add instance to data |
||
| 37 | 3 | if (isset($data[$key])) { |
|
| 38 | 3 | $data[$key] = $parameterFactory |
|
| 39 | 3 | ->getByClassName($parameterInstances->getByKey($key)) |
|
| 40 | 3 | ->setDirectionalVariable($this->useOneDirectionalVariables) |
|
| 41 | 3 | ->setResolveOptions($this->resolveOptions) |
|
| 42 | 3 | ->setData($data[$key]); |
|
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | 3 | return parent::setData($data); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * {@inheritdoc} |
||
| 51 | */ |
||
| 52 | 2 | public function getXML(): \SimpleXMLElement |
|
| 53 | { |
||
| 54 | 2 | $xml = $this->createXML()->addChild('prn:parameters', '', $this->namespace('prn')); |
|
| 55 | |||
| 56 | 2 | $this->addElements($xml, $this->elements, 'prn'); |
|
| 57 | |||
| 58 | 2 | return $xml; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * {@inheritdoc} |
||
| 63 | */ |
||
| 64 | 1 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
| 65 | { |
||
| 66 | // available options |
||
| 67 | 1 | $resolver->setDefined($this->elements); |
|
| 68 | |||
| 69 | 1 | $resolver->setNormalizer('copy', $this->dependenciesFactory->getNormalizerFactory()->getClosure('int')); |
|
| 70 | 1 | $resolver->setNormalizer('datePrint', $this->dependenciesFactory->getNormalizerFactory()->getClosure('string')); |
|
| 71 | } |
||
| 72 | } |
||
| 73 |