Config
in package
Global configuration helper class for Krajee extensions.
Tags
Table of Contents
Constants
- DEFAULT_REASON = 'for your selected functionality'
- default reason appended for exceptions
- NAMESPACE_PREFIX = '\kartik\\'
- Krajee extension namespace
- VENDOR_NAME = 'kartik-v/'
- Krajee repo vendor name
Properties
- $_validDropdownInputs : array<string|int, mixed>
- $_validHtmlInputs : array<string|int, mixed>
- $_validInputWidgets : array<string|int, mixed>
Methods
- checkDependencies() : mixed
- Validate multiple extension dependencies.
- checkDependency() : mixed
- Validate a single extension dependency
- fileExists() : bool
- Check if a file exists
- getCurrentDir() : string
- Get the current directory of the extended class object
- getInputWidgets() : array<string|int, mixed>
- Gets list of namespaced Krajee input widget classes as an associative array, where the array keys are the namespaced classes, and the array values are the names of the github repository to which these classes belong to.
- getLang() : string
- Convert a language string in yii\i18n format to a ISO-639 format (2 or 3 letter code).
- getModule() : Module
- Gets the module instance by validating the module name. The check is first done for a submodule of the same name and then the check is done for the module within the current Yii2 application.
- hasCssClass() : bool
- Check if HTML options has specified CSS class
- initModule() : Module
- Initializes and validates the module (deprecated since v1.9.0 - use `getModule` instead directly)
- isDropdownInput() : bool
- Check if a input type is a valid dropdown input
- isHtmlInput() : bool
- Check if a input type is a valid Html Input
- isInputWidget() : bool
- Check if a type of input is a valid input widget
- isValidInput() : bool
- Check if a type of input is any possible valid input (html or widget)
- validateInputWidget() : mixed
- Check if a namespaced widget is valid or installed.
Constants
DEFAULT_REASON
default reason appended for exceptions
public
mixed
DEFAULT_REASON
= 'for your selected functionality'
NAMESPACE_PREFIX
Krajee extension namespace
public
mixed
NAMESPACE_PREFIX
= '\kartik\\'
VENDOR_NAME
Krajee repo vendor name
public
mixed
VENDOR_NAME
= 'kartik-v/'
Properties
$_validDropdownInputs
protected
static array<string|int, mixed>
$_validDropdownInputs
= ['listBox', 'dropDownList', 'checkboxList', 'radioList', 'checkboxButtonGroup', 'radioButtonGroup']
list of valid dropdown inputs
$_validHtmlInputs
protected
static array<string|int, mixed>
$_validHtmlInputs
= ['hiddenInput', 'textInput', 'passwordInput', 'textArea', 'checkbox', 'radio', 'listBox', 'dropDownList', 'checkboxList', 'radioList', 'input', 'fileInput']
list of valid html inputs
$_validInputWidgets
protected
static array<string|int, mixed>
$_validInputWidgets
= [
'\kartik\typeahead\Typeahead' => ['yii2-widgets', 'yii2-widget-typeahead'],
'\kartik\select2\Select2' => ['yii2-widgets', 'yii2-widget-select2'],
'\kartik\depdrop\DepDrop' => ['yii2-widgets', 'yii2-widget-depdrop'],
'\kartik\touchspin\TouchSpin' => ['yii2-widgets', 'yii2-widget-touchspin'],
'\kartik\switchinput\SwitchInput' => ['yii2-widgets', 'yii2-widget-switchinput'],
'\kartik\rating\StarRating' => ['yii2-widgets', 'yii2-widget-rating'],
'\kartik\file\FileInput' => ['yii2-widgets', 'yii2-widget-fileinput'],
'\kartik\range\RangeInput' => ['yii2-widgets', 'yii2-widget-rangeinput'],
'\kartik\color\ColorInput' => ['yii2-widgets', 'yii2-widget-colorinput'],
'\kartik\date\DatePicker' => ['yii2-widgets', 'yii2-widget-datepicker'],
'\kartik\time\TimePicker' => ['yii2-widgets', 'yii2-widget-timepicker'],
'\kartik\datetime\DateTimePicker' => ['yii2-widgets', 'yii2-widget-datetimepicker'],
'\kartik\daterange\DateRangePicker' => 'yii2-date-range',
'\kartik\sortinput\SortableInput' => 'yii2-sortinput',
'\kartik\tree\TreeViewInput' => 'yii2-tree-manager',
'\kartik\money\MaskMoney' => 'yii2-money',
// deprecated and replaced by yii2-number
'\kartik\number\NumberControl' => 'yii2-number',
'\kartik\checkbox\CheckboxX' => 'yii2-checkbox-x',
'\kartik\slider\Slider' => 'yii2-slider',
]
list of valid Krajee input widgets
Methods
checkDependencies()
Validate multiple extension dependencies.
public
static checkDependencies([array<string|int, mixed> $extensions = [] ]) : mixed
Parameters
- $extensions : array<string|int, mixed> = []
-
the configuration of extensions with each array item setup as required in
checkDependency
method. The following keys can be setup:-
name
: string, the extension class name (without vendor namespace prefix) -
repo
: string, the extension package repository name (without vendor name prefix) -
reason
: string, a user friendly message for dependency validation failure
-
Tags
checkDependency()
Validate a single extension dependency
public
static checkDependency([string $name = '' ][, mixed $repo = '' ][, string $reason = self::DEFAULT_REASON ]) : mixed
Parameters
- $name : string = ''
-
the extension class name (without vendor namespace prefix)
- $repo : mixed = ''
-
the extension package repository names (without vendor name prefix)
- $reason : string = self::DEFAULT_REASON
-
a user friendly message for dependency validation failure
Tags
fileExists()
Check if a file exists
public
static fileExists(string $file) : bool
Parameters
- $file : string
-
the file with path in URL format
Return values
boolgetCurrentDir()
Get the current directory of the extended class object
public
static getCurrentDir(object $object) : string
Parameters
- $object : object
-
the called object instance
Return values
stringgetInputWidgets()
Gets list of namespaced Krajee input widget classes as an associative array, where the array keys are the namespaced classes, and the array values are the names of the github repository to which these classes belong to.
public
static getInputWidgets() : array<string|int, mixed>
Return values
array<string|int, mixed>getLang()
Convert a language string in yii\i18n format to a ISO-639 format (2 or 3 letter code).
public
static getLang(string $language) : string
Parameters
- $language : string
-
the input language string
Return values
stringgetModule()
Gets the module instance by validating the module name. The check is first done for a submodule of the same name and then the check is done for the module within the current Yii2 application.
public
static getModule(string $m[, string $class = '' ]) : Module
Parameters
- $m : string
-
the module identifier
- $class : string = ''
-
the module class name
Tags
Return values
ModulehasCssClass()
Check if HTML options has specified CSS class
public
static hasCssClass(array<string|int, mixed> $options, string $cssClass) : bool
Parameters
- $options : array<string|int, mixed>
-
the HTML options
- $cssClass : string
-
the css class to test
Return values
boolinitModule()
Initializes and validates the module (deprecated since v1.9.0 - use `getModule` instead directly)
public
static initModule(string $class) : Module
Parameters
- $class : string
-
the Module class name
Tags
Return values
ModuleisDropdownInput()
Check if a input type is a valid dropdown input
public
static isDropdownInput(string $type) : bool
Parameters
- $type : string
-
the type of input
Return values
boolisHtmlInput()
Check if a input type is a valid Html Input
public
static isHtmlInput(string $type) : bool
Parameters
- $type : string
-
the type of input
Return values
boolisInputWidget()
Check if a type of input is a valid input widget
public
static isInputWidget(string $type) : bool
Parameters
- $type : string
-
the type of input
Return values
boolisValidInput()
Check if a type of input is any possible valid input (html or widget)
public
static isValidInput(string $type) : bool
Parameters
- $type : string
-
the type of input
Return values
boolvalidateInputWidget()
Check if a namespaced widget is valid or installed.
public
static validateInputWidget(string $type[, string $reason = self::DEFAULT_REASON ]) : mixed
Parameters
- $type : string
-
the widget type
- $reason : string = self::DEFAULT_REASON
-
the message to be displayed for dependency failure