mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 07:41:43 +03:00
Pass the data about field name and field class to template
This commit is contained in:
parent
86aaa5263b
commit
0a4e763049
@ -311,6 +311,7 @@ class ApiDocExtractor
|
||||
}
|
||||
}
|
||||
|
||||
$parameters = $this->setParentClasses($parameters);
|
||||
$parameters = $this->clearClasses($parameters);
|
||||
$parameters = $this->generateHumanReadableTypes($parameters);
|
||||
|
||||
@ -345,6 +346,7 @@ class ApiDocExtractor
|
||||
}
|
||||
}
|
||||
|
||||
$response = $this->setParentClasses($response);
|
||||
$response = $this->clearClasses($response);
|
||||
$response = $this->generateHumanReadableTypes($response);
|
||||
|
||||
@ -381,6 +383,7 @@ class ApiDocExtractor
|
||||
}
|
||||
}
|
||||
|
||||
$parameters = $this->setParentClasses($parameters);
|
||||
$parameters = $this->clearClasses($parameters);
|
||||
$parameters = $this->generateHumanReadableTypes($parameters);
|
||||
|
||||
@ -510,6 +513,32 @@ class ApiDocExtractor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent class to children
|
||||
*
|
||||
* @param array $array The source array.
|
||||
* @return array The updated array.
|
||||
*/
|
||||
protected function setParentClasses($array)
|
||||
{
|
||||
if (is_array($array)) {
|
||||
foreach ($array as $k => $v) {
|
||||
if (isset($v['children'])) {
|
||||
if (isset($v['class'])) {
|
||||
foreach ($v['children'] as $key => $item) {
|
||||
$array[$k]['children'][$key]['parentClass'] = $v['class'];
|
||||
$array[$k]['children'][$key]['field'] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
$array[$k]['children'] = $this->setParentClasses($array[$k]['children']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the temporary 'class' parameter from the parameters array before it is returned.
|
||||
*
|
||||
|
@ -119,6 +119,8 @@ abstract class AbstractFormatter implements FormatterInterface
|
||||
'untilVersion' => array_key_exists('untilVersion', $info) ? $info['untilVersion'] : null,
|
||||
'actualType' => array_key_exists('actualType', $info) ? $info['actualType'] : null,
|
||||
'subType' => array_key_exists('subType', $info) ? $info['subType'] : null,
|
||||
'parentClass' => array_key_exists('parentClass', $info) ? $info['parentClass'] : null,
|
||||
'field' => array_key_exists('field', $info) ? $info['field'] : null,
|
||||
);
|
||||
|
||||
if (isset($info['children']) && (!$info['readonly'] || !$ignoreNestedReadOnly)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user