Class kartik\base\Config

Inheritancekartik\base\Config
Available since version1.0

Global configuration helper class for Krajee extensions

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 kartik\base\Config
initModule() Initializes and validates the module 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" kartik\base\Config
NAMESPACE_PREFIX "\\kartik\\" kartik\base\Config
VENDOR_NAME "kartik-v/" kartik\base\Config

Property Details

$_validDropdownInputs protected static property
protected static $_validDropdownInputs = ['listBox''dropDownList''checkboxList''radioList']
$_validHtmlInputs protected static property
protected static $_validHtmlInputs = ['hiddenInput''textInput''passwordInput''textArea''checkbox''radio''listBox''dropDownList''checkboxList''radioList''input''fileInput']
$_validInputWidgets protected static property
protected static $_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-daterange''\kartik\sortinput\SortableInput' => 'yii2-sortinput''\kartik\money\MaskMoney' => 'yii2-money''\kartik\checkbox\CheckboxX' => 'yii2-checkbox''\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 bool 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 mixed

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 void 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

public static kartik\base\Module getModule ( $m )
$m string

The module name

initModule() public static method

Initializes and validates the module

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 void isDropdownInput ( $type )
$type string

The type of input

isHtmlInput() public static method

Check if a input type is a valid Html Input

public static void 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 void 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 void 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
$reason
throws \yii\base\InvalidConfigException