PHPDocMD\Generator::classLink PHP Method

    static function classLink($className, $label = null)
    {
        $classDefinitions = $GLOBALS['PHPDocMD_classDefinitions'];
        $linkTemplate = $GLOBALS['PHPDocMD_linkTemplate'];
        $returnedClasses = [];
        foreach (explode('|', $className) as $oneClass) {
            $oneClass = trim($oneClass, '\\ ');
            if (!$label) {
                $label = $oneClass;
            }
            if (!isset($classDefinitions[$oneClass])) {
                $returnedClasses[] = $oneClass;
            } else {
                $link = str_replace('\\', '-', $oneClass);
                $link = strtr($linkTemplate, ['%c' => $link]);
                $returnedClasses[] = sprintf("[%s](%s)", $label, $link);
            }
        }
        return implode('|', $returnedClasses);
    }

Usage Example

コード例 #1
0
ファイル: Generator.php プロジェクト: xqus/phpdoc-md
 /**
  * Creates an index of classes and namespaces.
  *
  * I'm generating the actual markdown output here, which isn't great.. but
  * it will have to do. If I don't want to make things too complicated.
  *
  * @return array
  */
 protected function createIndex()
 {
     $tree = array();
     foreach ($this->classDefinitions as $className => $classInfo) {
         $current =& $tree;
         foreach (explode('\\', $className) as $part) {
             if (!isset($current[$part])) {
                 $current[$part] = array();
             }
             $current =& $current[$part];
         }
     }
     $treeOutput = '';
     $treeOutput = function ($item, $fullString = '', $depth = 0) use(&$treeOutput) {
         $output = '';
         foreach ($item as $name => $subItems) {
             $fullName = $fullString ? $fullString . "\\" . $name : $name;
             $output .= str_repeat(' ', $depth * 4) . '* ' . Generator::classLink($fullName, $name) . "\n";
             $output .= $treeOutput($subItems, $fullName, $depth + 1);
         }
         return $output;
     };
     return $treeOutput($tree);
 }
All Usage Examples Of PHPDocMD\Generator::classLink