Example #1
0
$keys = array('protocol', 'domain', 'url');
$url_prefix = rtrim(vsprintf('%s://%s%s', array_filter(array_map(function ($k) use($config) {
    return $config['url'][$k];
}, $keys))), '/');
if (!$config || !is_assoc($config) || !$url_prefix) {
    throw new Exception('Must pass in api configuration array {url: {protocol, domain uri}}');
}
$docs = new Sky\Api\Documentor($api);
$qf = $this->queryfolders;
list($resource, $endpoint) = $qf;
$this->title = $qf ? implode('/', $qf) : $title;
if ($resource) {
    try {
        $method = $docs->getResourceDoc($resource, $endpoint);
        $method['url'] = array('prefix' => $url_prefix, 'rest' => rtrim(sprintf('/%s/%s/%s', $resource, $method['aspects'] || !$endpoint ? 'ID' : $endpoint, $method['aspects'] ? $endpoint : ''), '/'));
        $doc = trim(Markdown(\Sky\DocParser::docAsString($method['doc'])));
        $method['doc'] = $doc ? array('content' => $doc) : null;
        $method['params'] = $method['params'] ? array('list' => array_map(function ($ea) {
            $ea['description'] = Markdown(implode(PHP_EOL, $ea['description']));
            return $ea;
        }, $method['params'])) : array();
    } catch (\Exception $e) {
        include 'pages/404.php';
        return;
    }
} else {
    $method = null;
}
$parsed = $docs->walkResources();
ksort($parsed);
$d = array();
 /**
  * Gets api docblock info from the Method
  * @param   \ReflectionMethod   $re
  * @return  array
  */
 protected static function getParsedArray(\ReflectionMethod $re)
 {
     $docs = \Sky\DocParser::parse($re->getDocComment());
     return array('params' => static::parseParamDoc($docs->apiParam), 'doc' => $docs->apiDoc);
 }