Class kartik\base\Config

Inheritancekartik\base\Config

Global configuration helper class for Krajee extensions.

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_validDropdownInputs array List of valid dropdown inputs kartik\base\Config
$_validHtmlInputs array List of valid html inputs kartik\base\Config
$_validInputWidgets array List of valid Krajee input widgets kartik\base\Config

Public Methods

Hide inherited methods

MethodDescriptionDefined By
checkDependencies() Validate multiple extension dependencies. kartik\base\Config
checkDependency() Validate a single extension dependency kartik\base\Config
fileExists() Check if a file exists kartik\base\Config
getCurrentDir() Get the current directory of the extended class object kartik\base\Config
getInputWidgets() 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. kartik\base\Config
getLang() Convert a language string in yii\i18n format to a ISO-639 format (2 or 3 letter code). kartik\base\Config
getModule() 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. kartik\base\Config
hasCssClass() Check if HTML options has specified CSS class kartik\base\Config
initModule() Initializes and validates the module (deprecated since v1.9.0 - use getModule instead directly) kartik\base\Config
isDropdownInput() Check if a input type is a valid dropdown input kartik\base\Config
isHtmlInput() Check if a input type is a valid Html Input kartik\base\Config
isInputWidget() Check if a type of input is a valid input widget kartik\base\Config
isValidInput() Check if a type of input is any possible valid input (html or widget) kartik\base\Config
validateInputWidget() Check if a namespaced widget is valid or installed. kartik\base\Config

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
DEFAULT_REASON 'for your selected functionality' Default reason appended for exceptions kartik\base\Config
NAMESPACE_PREFIX '\\kartik\\' Krajee extension namespace kartik\base\Config
VENDOR_NAME 'kartik-v/' Krajee repo vendor name kartik\base\Config

Property Details

$_validDropdownInputs protected static property

List of valid dropdown inputs

protected static array $_validDropdownInputs = [
    'listBox''dropDownList''checkboxList''radioList''checkboxButtonGroup''radioButtonGroup'
]
$_validHtmlInputs protected static property

List of valid html inputs

protected static array $_validHtmlInputs = [
    'hiddenInput''textInput''passwordInput''textArea''checkbox''radio''listBox''dropDownList''checkboxList''radioList''input''fileInput'
]
$_validInputWidgets protected static property

List of valid Krajee input widgets

protected static array $_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''\kartik\number\NumberControl' => 'yii2-number''\kartik\checkbox\CheckboxX' => 'yii2-checkbox-x''\kartik\slider\Slider' => 'yii2-slider'
]

Method Details

checkDependencies() public static method

Validate multiple extension dependencies.

public static void checkDependencies ( $extensions = [] )
$extensions array

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
throws yii\base\InvalidConfigException

if extension fails dependency validation

checkDependency() public static method

Validate a single extension dependency

public static void checkDependency ( $name '', $repo '', $reason self::DEFAULT_REASON )
$name string

The extension class name (without vendor namespace prefix)

$repo mixed

The extension package repository names (without vendor name prefix)

$reason string

A user friendly message for dependency validation failure

throws yii\base\InvalidConfigException

if extension fails dependency validation

fileExists() public static method

Check if a file exists

public static boolean fileExists ( $file )
$file string

The file with path in URL format

getCurrentDir() public static method

Get the current directory of the extended class object

public static string getCurrentDir ( $object )
$object object

The called object instance

getInputWidgets() public static method

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 array getInputWidgets ( )
getLang() public static method

Convert a language string in yii\i18n format to a ISO-639 format (2 or 3 letter code).

public static string getLang ( $language )
$language string

The input language string

getModule() public static method

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 \kartik\base\yii\base\Module getModule ( $m, $class '' )
$m string

The module identifier

$class string

The module class name

throws yii\base\InvalidConfigException
hasCssClass() public static method

Check if HTML options has specified CSS class

public static boolean hasCssClass ( $options, $cssClass )
$options array

The HTML options

$cssClass string

The css class to test

initModule() public static method

Initializes and validates the module (deprecated since v1.9.0 - use getModule instead directly)

public static yii\base\Module initModule ( $class )
$class string

The Module class name

throws yii\base\InvalidConfigException
isDropdownInput() public static method

Check if a input type is a valid dropdown input

public static boolean isDropdownInput ( $type )
$type string

The type of input

isHtmlInput() public static method

Check if a input type is a valid Html Input

public static boolean isHtmlInput ( $type )
$type string

The type of input

isInputWidget() public static method

Check if a type of input is a valid input widget

public static boolean isInputWidget ( $type )
$type string

The type of input

isValidInput() public static method

Check if a type of input is any possible valid input (html or widget)

public static boolean isValidInput ( $type )
$type string

The type of input

validateInputWidget() public static method

Check if a namespaced widget is valid or installed.

public static void validateInputWidget ( $type, $reason self::DEFAULT_REASON )
$type string

The widget type

$reason string

The message to be displayed for dependency failure

throws yii\base\InvalidConfigException