54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
|
<?php
|
||
|
class Zend_View_Helper_DocParameter extends Zend_View_Helper_Abstract
|
||
|
{
|
||
|
protected $serviceTypes;
|
||
|
|
||
|
public function docParameter($params, $serviceTypes)
|
||
|
{
|
||
|
$this->serviceTypes = $serviceTypes;
|
||
|
$output = '';
|
||
|
if (count($params)>0) {
|
||
|
$output.= '<ul>';
|
||
|
foreach ($params as $param) {
|
||
|
$output.= $this->formatParam($param);
|
||
|
}
|
||
|
$output.= '</ul>';
|
||
|
}
|
||
|
return $output;
|
||
|
}
|
||
|
|
||
|
private function parseType($type)
|
||
|
{
|
||
|
$output = '';
|
||
|
if (array_key_exists($type, $this->serviceTypes)) {
|
||
|
$types = $this->serviceTypes[$type];
|
||
|
$output.= '<ul>';
|
||
|
foreach ($types as $param) {
|
||
|
$output.= $this->formatParam($param);
|
||
|
}
|
||
|
$output.= '</ul>';
|
||
|
}
|
||
|
return $output;
|
||
|
}
|
||
|
|
||
|
private function formatParam($param)
|
||
|
{
|
||
|
$output = '';
|
||
|
$output.= '<li>';
|
||
|
$output.= $param['type'] . ' ' . $param['name'];
|
||
|
if (isset($param['description']) && !empty($param['description'])) {
|
||
|
$output.= ' : '.$param['description'];
|
||
|
}
|
||
|
if (!in_array($param['type'], array(
|
||
|
'string', 'str',
|
||
|
'boolean', 'bool',
|
||
|
'interger', 'int',
|
||
|
'float', 'double',
|
||
|
'array', 'object', 'mixed'))) {
|
||
|
$output.= $this->parseType($param['type']);
|
||
|
}
|
||
|
$output.= '</li>';
|
||
|
return $output;
|
||
|
}
|
||
|
|
||
|
}
|