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; |
||
| 13 | |||
| 14 | use Riesenia\Pohoda\IntParam\Settings; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @property array{ |
||
| 18 | * name: string, |
||
| 19 | * description?: string, |
||
| 20 | * parameterType: string, |
||
| 21 | * parameterSettings?: Settings, |
||
| 22 | * } $data |
||
| 23 | */ |
||
| 24 | class IntParam extends AbstractAgenda |
||
| 25 | { |
||
| 26 | /** @var string[] */ |
||
| 27 | protected array $elements = ['name', 'description', 'parameterType', 'parameterSettings']; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * {@inheritdoc} |
||
| 31 | */ |
||
| 32 | 3 | public function setData(array $data): parent |
|
| 33 | { |
||
| 34 | // prepare empty parameter list for list |
||
| 35 | 3 | if ('listValue' == $data['parameterType']) { |
|
| 36 | 1 | $data['parameterSettings'] = ['parameterList' => []]; |
|
| 37 | } |
||
| 38 | |||
| 39 | // process settings |
||
| 40 | 3 | if (isset($data['parameterSettings'])) { |
|
| 41 | 3 | $parameterSettings = new Settings($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory); |
|
| 42 | 3 | $parameterSettings->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['parameterSettings']); |
|
| 43 | 3 | $data['parameterSettings'] = $parameterSettings; |
|
| 44 | } |
||
| 45 | |||
| 46 | 3 | return parent::setData($data); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 47 | } |
||
| 48 | |||
| 49 | 1 | public function getImportRoot(): string |
|
| 50 | { |
||
| 51 | 1 | return 'lst:intParamDetail'; |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc} |
||
| 56 | */ |
||
| 57 | 2 | public function getXML(): \SimpleXMLElement |
|
| 58 | { |
||
| 59 | 2 | $xml = $this->createXML()->addChild('ipm:intParamDetail', '', $this->namespace('ipm')); |
|
| 60 | 2 | $xml->addAttribute('version', '2.0'); |
|
| 61 | |||
| 62 | 2 | $param = $xml->addChild('ipm:intParam'); |
|
| 63 | 2 | $this->addElements($param, $this->elements, 'ipm'); |
|
| 64 | |||
| 65 | 2 | return $xml; |
|
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * {@inheritdoc} |
||
| 70 | */ |
||
| 71 | 1 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
| 72 | { |
||
| 73 | // available options |
||
| 74 | 1 | $resolver->setDefined($this->elements); |
|
| 75 | |||
| 76 | // validate / format options |
||
| 77 | 1 | $resolver->setRequired('name'); |
|
| 78 | 1 | $resolver->setRequired('parameterType'); |
|
| 79 | 1 | $resolver->setAllowedValues('parameterType', ['textValue', 'currencyValue', 'booleanValue', 'numberValue', 'integerValue', 'datetimeValue', 'unit', 'listValue']); |
|
| 80 | } |
||
| 81 | } |
||
| 82 |