From 81274509da8593bafb13c956cb9cddb450cd2ecb Mon Sep 17 00:00:00 2001 From: Vitaliy Chesnokov Date: Wed, 24 Apr 2019 16:46:11 +0300 Subject: [PATCH] Allow to define the input name for the JmsMetadataParser --- Parser/JmsMetadataParser.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Parser/JmsMetadataParser.php b/Parser/JmsMetadataParser.php index b73310b..dc10658 100644 --- a/Parser/JmsMetadataParser.php +++ b/Parser/JmsMetadataParser.php @@ -87,7 +87,30 @@ class JmsMetadataParser implements ParserInterface, PostParserInterface $className = $input['class']; $groups = $input['groups']; - return $this->doParse($className, array(), $groups); + $result = $this->doParse($className, array(), $groups); + + if (!isset($input['name']) || empty($input['name'])) { + return $result; + } + + if (class_exists($className)) { + $parts = explode('\\', $className); + $dataType = sprintf('object (%s)', end($parts)); + } else { + $dataType = sprintf('object (%s)', $className); + } + + return array( + $input['name'] => array( + 'required' => null, + 'readonly' => null, + 'default' => null, + 'dataType' => $dataType, + 'actualType' => DataTypes::MODEL, + 'subType' => $dataType, + 'children' => $result, + ), + ); } /**