methodDetails.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. use yii\apidoc\helpers\ApiMarkdown;
  3. use yii\apidoc\models\ClassDoc;
  4. use yii\apidoc\models\TraitDoc;
  5. use yii\helpers\ArrayHelper;
  6. /* @var $type ClassDoc|TraitDoc */
  7. /* @var $this yii\web\View */
  8. /* @var $renderer \yii\apidoc\templates\html\ApiRenderer */
  9. $renderer = $this->context;
  10. $methods = $type->getNativeMethods();
  11. if (empty($methods)) {
  12. return;
  13. }
  14. ArrayHelper::multisort($methods, 'name');
  15. ?>
  16. <h2>Method Details</h2>
  17. <div class="method-doc">
  18. <?php foreach ($methods as $method): ?>
  19. <div class="detail-header h3" id="<?= $method->name . '()-detail' ?>">
  20. <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
  21. <?= $renderer->createSubjectLink($method, '<span class="glyphicon icon-hash"></span>', [
  22. 'title' => 'direct link to this method',
  23. 'class' => 'tool-link hash',
  24. ]) ?>
  25. <?php if (($sourceUrl = $renderer->getSourceUrl($method->definedBy, $method->startLine)) !== null): ?>
  26. <a href="<?= str_replace('/blob/', '/edit/', $sourceUrl) ?>" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
  27. <a href="<?= $sourceUrl ?>" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
  28. <?php endif; ?>
  29. <?= $method->name ?>()
  30. <span class="detail-header-tag small">
  31. <?= $method->visibility ?>
  32. <?= $method->isAbstract ? 'abstract' : '' ?>
  33. <?= $method->isStatic ? 'static' : '' ?>
  34. method
  35. <?php if (!empty($method->since)): ?>
  36. (available since version <?= $method->since ?>)
  37. <?php endif; ?>
  38. </span>
  39. </div>
  40. <?php if (!empty($method->deprecatedSince) || !empty($method->deprecatedReason)): ?>
  41. <div class="doc-description deprecated">
  42. <strong>Deprecated <?php
  43. if (!empty($method->deprecatedSince)) { echo 'since version ' . $method->deprecatedSince . ': '; }
  44. if (!empty($method->deprecatedReason)) { echo ApiMarkdown::process($method->deprecatedReason, $type, true); }
  45. ?></strong>
  46. </div>
  47. <?php endif; ?>
  48. <div class="doc-description">
  49. <p><strong><?= ApiMarkdown::process($method->shortDescription, $type, true) ?></strong></p>
  50. <?= ApiMarkdown::process($method->description, $type) ?>
  51. <?= $this->render('seeAlso', ['object' => $method]) ?>
  52. </div>
  53. <table class="detail-table table table-striped table-bordered table-hover">
  54. <tr><td colspan="3" class="signature"><?= $renderer->renderMethodSignature($method, $type) ?></td></tr>
  55. <?php if (!empty($method->params) || !empty($method->return) || !empty($method->exceptions)): ?>
  56. <?php foreach ($method->params as $param): ?>
  57. <tr>
  58. <td class="param-name-col"><?= ApiMarkdown::highlight($param->name, 'php') ?></td>
  59. <td class="param-type-col"><?= $renderer->createTypeLink($param->types) ?></td>
  60. <td class="param-desc-col"><?= ApiMarkdown::process($param->description, $type) ?></td>
  61. </tr>
  62. <?php endforeach; ?>
  63. <?php if (!empty($method->return)): ?>
  64. <tr>
  65. <th class="param-name-col">return</th>
  66. <td class="param-type-col"><?= $renderer->createTypeLink($method->returnTypes, $type) ?></td>
  67. <td class="param-desc-col"><?= ApiMarkdown::process($method->return, $type) ?></td>
  68. </tr>
  69. <?php endif; ?>
  70. <?php foreach ($method->exceptions as $exception => $description): ?>
  71. <tr>
  72. <th class="param-name-col">throws</th>
  73. <td class="param-type-col"><?= $renderer->createTypeLink($exception) ?></td>
  74. <td class="param-desc-col"><?= ApiMarkdown::process($description, $type) ?></td>
  75. </tr>
  76. <?php endforeach; ?>
  77. <?php endif; ?>
  78. </table>
  79. <!-- --><?php //$this->renderPartial('sourceCode',array('object'=>$method)); ?>
  80. <?php endforeach; ?>
  81. </div>