class BaseComponent implements ComponentInterface

Base component

Properties

protected string $name Component name
protected string $fullName Component full name
protected string $templateName Template, extension or components library name
protected string $templateUrl Template url
protected string $path Component path
protected integer $location Component Location
protected string $fullPath Component full path
protected string $filePath File path
protected string $language Language code
protected string $htmlCode Html code
protected string|null $error Component error code
protected string $basePath Base path
protected array $files Component files
protected string $viewPath View path
protected string $extensionsPath Extensions path
protected string $primaryTemplate Primary template name
protected string $componentType Component type
protected array $context Component context used in render
protected $hasHtmlContent Return true if compoent has html file
protected string|null $htmlFileName Html file name
protected string $url Component url
protected array $includedComponents Included compoents
protected array $options Options

Methods

__construct(string $name, string $basePath, string $language, string $viewPath, string $extensionsPath, string $primaryTemplate, string $componentType)

Constructor

void
init()

Init component

array
getOptions()

Get options

bool
resolve(array $params = [])

Resolve component

bool
isValid()

Return true if component is valid

void
addIncludedComponent(string $name, string $type)

Add included component

array
getIncludedComponents()

Get included components

mixed
create(string $name, string $language)

Create component

array
getContext()

Get context

void
setContext(array $context)

Set context

void
mergeContext(array $data)

Merge context

void
mergeRecursiveContext(array $data)

Merge recursive context

string|null
getIncludeFile(string $fileType)

Get include file url

void
setPrimaryTemplate(string $name)

Set primary template name

string
getPrimaryTemplate()

Get primary template

bool
hasParent()

Return true if component has child

string
getBasePath()

Return base path

string
getName()

Get component name

string|null
getFullName()

Get component full name

string|null
getTemplateFile()

Get template file

bool
hasError()

Return true if have error

bool
hasContent()

Return true if component have html content

void
resolveHtmlContent()

Resolev html content

bool
hasFiles(string|null $fileType = null)

Return true if component have files

array
getFiles(string|null $fileType = null)

Return files

string|null
getPath()

Get path

string
getFullPath()

Get full path

string
getComponentType()

Get component type

void
setComponentType(string $type)

Set component type

int
getLocation()

Get location

string|null
getTemplateName()

Get template or extension name

string
getLanguage()

Get language

string|null
getError()

Get error

string
getHtmlCode()

Get html code

void
setHtmlCode(string $code)

Set html code

void
setError(string $code)

Set error

void
clearContent()

Clear content

mixed
addComponentFile(string $fileExt)

Add component file

void
addFile(array $file, string $fileType)

Add file

void
parseName(string $name)

Parse component name

array
toArray()

Convert to array

string
url()

Get url

string
getRootPath(bool $relative = false)

Get root componetn path

string
getTemplatePath(string $template, int $location)

Get template path

string|false
getComponentFile(string $fileExt)

Get component file

string
getFileUrl(string $fileName)

Convert file path to url

string
getComponentFullPath(int $location, string $templateName)

Get component full path

void
resolvePath()

Resolve component path

string
getTemplateUrl()

Get template url

Details

at line 190
__construct(string $name, string $basePath, string $language, string $viewPath, string $extensionsPath, string $primaryTemplate, string $componentType)

Constructor

Parameters

string $name
string $basePath
string $language
string $viewPath
string $extensionsPath
string $primaryTemplate
string $componentType

at line 218
void init()

Init component

Return Value

void

at line 237
array getOptions()

Get options

Return Value

array

at line 248
bool resolve(array $params = [])

Resolve component

Parameters

array $params

Return Value

bool

at line 258
bool isValid()

Return true if component is valid

Return Value

bool

at line 270
void addIncludedComponent(string $name, string $type)

Add included component

Parameters

string $name
string $type

Return Value

void

at line 286
array getIncludedComponents()

Get included components

Return Value

array

at line 298
mixed create(string $name, string $language)

Create component

Parameters

string $name
string $language

Return Value

mixed

at line 315
array getContext()

Get context

Return Value

array

at line 326
void setContext(array $context)

Set context

Parameters

array $context

Return Value

void

at line 337
void mergeContext(array $data)

Merge context

Parameters

array $data

Return Value

void

at line 348
void mergeRecursiveContext(array $data)

Merge recursive context

Parameters

array $data

Return Value

void

at line 359
string|null getIncludeFile(string $fileType)

Get include file url

Parameters

string $fileType

Return Value

string|null

at line 372
void setPrimaryTemplate(string $name)

Set primary template name

Parameters

string $name

Return Value

void

at line 382
string getPrimaryTemplate()

Get primary template

Return Value

string

at line 392
bool hasParent()

Return true if component has child

Return Value

bool

at line 407
string getBasePath()

Return base path

Return Value

string

at line 417
string getName()

Get component name

Return Value

string

at line 427
string|null getFullName()

Get component full name

Return Value

string|null

at line 438
string|null getTemplateFile()

Get template file

Return Value

string|null

at line 448
bool hasError()

Return true if have error

Return Value

bool

at line 458
bool hasContent()

Return true if component have html content

Return Value

bool

at line 468
protected void resolveHtmlContent()

Resolev html content

Return Value

void

at line 479
bool hasFiles(string|null $fileType = null)

Return true if component have files

Parameters

string|null $fileType

Return Value

bool

at line 498
array getFiles(string|null $fileType = null)

Return files

Parameters

string|null $fileType

Return Value

array

at line 508
string|null getPath()

Get path

Return Value

string|null

at line 518
string getFullPath()

Get full path

Return Value

string

at line 528
string getComponentType()

Get component type

Return Value

string

at line 539
void setComponentType(string $type)

Set component type

Parameters

string $type

Return Value

void

at line 549
int getLocation()

Get location

Return Value

int

at line 559
string|null getTemplateName()

Get template or extension name

Return Value

string|null

at line 569
string getLanguage()

Get language

Return Value

string

at line 579
string|null getError()

Get error

Return Value

string|null

at line 589
string getHtmlCode()

Get html code

Return Value

string

at line 600
void setHtmlCode(string $code)

Set html code

Parameters

string $code

Return Value

void

at line 611
void setError(string $code)

Set error

Parameters

string $code

Return Value

void

at line 621
void clearContent()

Clear content

Return Value

void

at line 636
mixed addComponentFile(string $fileExt)

Add component file

Parameters

string $fileExt

Return Value

mixed

at line 662
void addFile(array $file, string $fileType)

Add file

Parameters

array $file
string $fileType

Return Value

void

at line 675
protected void parseName(string $name)

Parse component name

Parameters

string $name

Return Value

void

at line 733
array toArray()

Convert to array

Return Value

array

at line 743
string url()

Get url

Return Value

string

at line 754
string getRootPath(bool $relative = false)

Get root componetn path

Parameters

bool $relative

Return Value

string

at line 771
string getTemplatePath(string $template, int $location)

Get template path

Parameters

string $template
int $location

Return Value

string

at line 791
string|false getComponentFile(string $fileExt)

Get component file

Parameters

string $fileExt

Return Value

string|false

at line 804
string getFileUrl(string $fileName)

Convert file path to url

Parameters

string $fileName

Return Value

string

at line 815
string getComponentFullPath(int $location, string $templateName)

Get component full path

Parameters

int $location
string $templateName

Return Value

string

at line 828
protected void resolvePath()

Resolve component path

Return Value

void

at line 864
string getTemplateUrl()

Get template url

Return Value

string