Piwik\API\DocumentationGenerator::getAllInterfaceString PHP Method

getAllInterfaceString() public method

For each module it will return a mini help with the method names, parameters to give, links to get the result in Xml/Csv/etc
public getAllInterfaceString ( boolean $outputExampleUrls = true, string $prefixUrls = '' ) : string
$outputExampleUrls boolean
$prefixUrls string
return string
    public function getAllInterfaceString($outputExampleUrls = true, $prefixUrls = '')
    {
        if (!empty($prefixUrls)) {
            $prefixUrls = 'http://demo.piwik.org/';
        }
        $str = $toc = '';
        foreach (Proxy::getInstance()->getMetadata() as $class => $info) {
            $moduleName = Proxy::getInstance()->getModuleNameFromClassName($class);
            $rClass = new ReflectionClass($class);
            if (!Piwik::hasUserSuperUserAccess() && $this->checkIfClassCommentContainsHideAnnotation($rClass)) {
                continue;
            }
            if ($this->checkIfCommentContainsInternalAnnotation($rClass)) {
                continue;
            }
            $toDisplay = $this->prepareModulesAndMethods($info, $moduleName);
            foreach ($toDisplay as $moduleName => $methods) {
                foreach ($methods as $index => $method) {
                    $reflectionMethod = new \ReflectionMethod($class, $method);
                    if ($this->checkIfCommentContainsInternalAnnotation($reflectionMethod)) {
                        unset($toDisplay[$moduleName][$index]);
                    }
                }
                if (empty($toDisplay[$moduleName])) {
                    unset($toDisplay[$moduleName]);
                }
            }
            foreach ($toDisplay as $moduleName => $methods) {
                $toc .= $this->prepareModuleToDisplay($moduleName);
                $str .= $this->prepareMethodToDisplay($moduleName, $info, $methods, $class, $outputExampleUrls, $prefixUrls);
            }
        }
        $str = "<div piwik-content-block content-title='Quick access to APIs' id='topApiRef' name='topApiRef'>\n\t\t\t\t{$toc}</div>\n\t\t\t\t{$str}";
        return $str;
    }

Usage Example

Example #1
0
 public function listAllAPI()
 {
     $view = new View("@API/listAllAPI");
     $this->setGeneralVariablesView($view);
     $ApiDocumentation = new DocumentationGenerator();
     $view->countLoadedAPI = Proxy::getInstance()->getCountRegisteredClasses();
     $view->list_api_methods_with_links = $ApiDocumentation->getAllInterfaceString();
     return $view->render();
 }