Affichage de la description retour

This commit is contained in:
Michael RICOIS 2017-03-09 16:26:22 +01:00
parent c1b1686296
commit 97055a0419
2 changed files with 28 additions and 25 deletions

View File

@ -25,11 +25,11 @@
<div class="panel-body"> <div class="panel-body">
<ol> <ol>
<?php foreach ($this->serviceMethods as $method) {?> <?php foreach ($this->serviceMethods as $method) {?>
<li> <li>
<b><?php echo $method['name'];?></b> <b><?php echo $method['name'];?></b>
<a href="#<?php echo $method['name'];?>"><i>Détail</i></a> <a href="#<?php echo $method['name'];?>"><i>Détail</i></a>
</li> </li>
<?php } ?> <?php }?>
</ol> </ol>
</div> </div>
</div> </div>
@ -60,6 +60,7 @@
<h5>Retour</h5> <h5>Retour</h5>
<div class="bs-callout bs-callout-php"> <div class="bs-callout bs-callout-php">
<?php if ($method['returnDesc'] != '') {?><?=$method['returnDesc']?><br/><br/><?php }?>
<?=$this->docReturn($method['return'], $this->serviceTypes);?> <?=$this->docReturn($method['return'], $this->serviceTypes);?>
</div> </div>

View File

@ -39,8 +39,7 @@ class Scores_Ws_Doc
private function parseService() private function parseService()
{ {
$class = new Zend_Server_Reflection(); $class = new Zend_Server_Reflection();
$methods = $class->reflectClass($this->serviceClass) $methods = $class->reflectClass($this->serviceClass)->getMethods();
->getMethods();
$methodsElement = array(); $methodsElement = array();
foreach ($methods as $method) { foreach ($methods as $method) {
$prototype = null; $prototype = null;
@ -56,9 +55,9 @@ class Scores_Ws_Doc
$paramsElement = array(); $paramsElement = array();
foreach ($prototype->getParameters() as $param) { foreach ($prototype->getParameters() as $param) {
$paramElement = array( $paramElement = array(
'type' => $param->getType(), 'type' => $param->getType(),
'name' => $param->getName(), 'name' => $param->getName(),
'description' => $param->getDescription(), 'description' => $param->getDescription(),
); );
if ($param->isOptional()) { if ($param->isOptional()) {
@ -68,11 +67,14 @@ class Scores_Ws_Doc
$paramsElement[] = $paramElement; $paramsElement[] = $paramElement;
} }
$return = $prototype->getReturnValue();
$methodElement = array( $methodElement = array(
'name' => $method->getName(), 'name' => $method->getName(),
'desc' => $method->getDescription(), 'desc' => $method->getDescription(),
'params' => $paramsElement, 'params' => $paramsElement,
'return' => $prototype->getReturnType(), 'return' => $prototype->getReturnType(),
'returnDesc' => $return->getDescription(),
); );
$methodsElement[] = $methodElement; $methodsElement[] = $methodElement;
@ -101,8 +103,8 @@ class Scores_Ws_Doc
$docBlock = preg_replace('/\n/', '', $property->getDocComment()); $docBlock = preg_replace('/\n/', '', $property->getDocComment());
if (preg_match('/\/\*\*(.+) \* @var\s+[^\s]+\s+(?:\*|@)/m', $docBlock, $docBlockMatches)) { if (preg_match('/\/\*\*(.+) \* @var\s+[^\s]+\s+(?:\*|@)/m', $docBlock, $docBlockMatches)) {
$comment.= preg_replace( $comment.= preg_replace(
array('/\r/', '/\*/' ), array('/\r/', '/\*/' ),
array('', ''), $docBlockMatches[1] array('', ''), $docBlockMatches[1]
); );
} }
@ -147,17 +149,17 @@ class Scores_Ws_Doc
switch ($ref[1]) { switch ($ref[1]) {
case 'fichier': case 'fichier':
$urlFichier = $view->url(array( $urlFichier = $view->url(array(
'controller' => 'ref', 'controller' => 'ref',
'action' => 'fichier', 'action' => 'fichier',
'q' => $ref[3], 'q' => $ref[3],
), null, true); ), null, true);
$comment.= '<a href="'.$urlFichier.'">'.$ref[2].'</a>'; $comment.= '<a href="'.$urlFichier.'">'.$ref[2].'</a>';
break; break;
case 'mysql': case 'mysql':
$urlMysql = $view->url(array( $urlMysql = $view->url(array(
'controller' => 'ref', 'controller' => 'ref',
'action' => 'table', 'action' => 'table',
'q' => $ref[3], 'q' => $ref[3],
), null, true); ), null, true);
$comment.= '<a href="'.$urlMysql.'">'.$ref[2].'</a>'; $comment.= '<a href="'.$urlMysql.'">'.$ref[2].'</a>';
break; break;
@ -166,9 +168,9 @@ class Scores_Ws_Doc
} }
} }
$paramElement = array( $paramElement = array(
'name' => $name, 'name' => $name,
'type' => $type, 'type' => $type,
'description' => trim($comment) 'description' => trim($comment)
); );
} }
$paramsElement[] = $paramElement; $paramsElement[] = $paramElement;