Trait yii\apidoc\templates\bootstrap\RendererTrait

Implemented byyii\apidoc\templates\bootstrap\ApiRenderer, yii\apidoc\templates\bootstrap\GuideRenderer
Source Code https://github.com/yiisoft/yii2-apidoc/blob/master/templates/bootstrap/RendererTrait.php

Common methods for renderers

Public Properties

Hide inherited properties

Property Type Description Defined By
$extensions array Official Yii extensions yii\apidoc\templates\bootstrap\RendererTrait

Public Methods

Hide inherited methods

Method Description Defined By
getNavTypes() Returns nav TypeDocs yii\apidoc\templates\bootstrap\RendererTrait

Protected Methods

Hide inherited methods

Method Description Defined By
filterTypes() Returns types of a given class yii\apidoc\templates\bootstrap\RendererTrait
getTypeCategory() Returns category of TypeDoc yii\apidoc\templates\bootstrap\RendererTrait

Property Details

Hide inherited properties

$extensions public property

Official Yii extensions

public array $extensions = [
    
'apidoc',
    
'authclient',
    
'bootstrap',
    
'codeception',
    
'composer',
    
'debug',
    
'elasticsearch',
    
'faker',
    
'gii',
    
'httpclient',
    
'imagine',
    
'jui',
    
'mongodb',
    
'redis',
    
'shell',
    
'smarty',
    
'sphinx',
    
'swiftmailer',
    
'twig',
]

Method Details

Hide inherited methods

filterTypes() protected method

Returns types of a given class

protected array filterTypes ( $types, $navClasses )
$types yii\apidoc\models\TypeDoc[]
$navClasses string

                protected function filterTypes($types, $navClasses)
{
    switch ($navClasses) {
        case 'app':
            $types = array_filter($types, function ($val) {
                return strncmp($val->name, 'yii\\', 4) !== 0;
            });
            break;
        case 'yii':
            $self = $this;
            $types = array_filter($types, function ($val) use ($self) {
                if ($val->name === 'Yii' || $val->name === 'YiiRequirementChecker') {
                    return true;
                }
                if (strlen($val->name) < 5) {
                    return false;
                }
                $subName = substr($val->name, 4, strpos($val->name, '\\', 5) - 4);
                return strncmp($val->name, 'yii\\', 4) === 0 && !in_array($subName, $self->extensions);
            });
            break;
        default:
            $types = array_filter($types, function ($val) use ($navClasses) {
                return strncmp($val->name, "yii\\$navClasses\\", strlen("yii\\$navClasses\\")) === 0;
            });
    }
    return $types;
}

            
getNavTypes() public method

Returns nav TypeDocs

public array getNavTypes ( $type, $types )
$type yii\apidoc\models\TypeDoc

Typedoc to take category from

$types yii\apidoc\models\TypeDoc[]

TypeDocs to filter

                public function getNavTypes($type, $types)
{
    if ($type === null) {
        return $types;
    }
    return $this->filterTypes($types, $this->getTypeCategory($type));
}

            
getTypeCategory() protected method

Returns category of TypeDoc

protected string getTypeCategory ( $type )
$type yii\apidoc\models\TypeDoc

                protected function getTypeCategory($type)
{
    $extensions = $this->extensions;
    $navClasses = 'app';
    if (isset($type)) {
        if ($type->name == 'Yii' || $type->name == 'YiiRequirementChecker') {
            $navClasses = 'yii';
        } elseif (strncmp($type->name, 'yii\\', 4) == 0) {
            $navClasses = 'yii';
            $subName = substr($type->name, 4);
            if (($pos = strpos($subName, '\\')) !== false) {
                $subNamespace = substr($subName, 0, $pos);
                if (in_array($subNamespace, $extensions)) {
                    $navClasses = $subNamespace;
                }
            }
        }
    }
    return $navClasses;
}