Add doc to parseAttribute
This commit is contained in:
parent
b01db503d9
commit
ff1500369c
1 changed files with 15 additions and 0 deletions
|
|
@ -43,6 +43,21 @@ class ArrayHelper extends \yii\helpers\ArrayHelper
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value form the model and returns a config of the arrtibute
|
||||||
|
*
|
||||||
|
* The function will return an ArrayObject with four attributes
|
||||||
|
* - format The format of the attribute.
|
||||||
|
* - value The formatted value of the attribute.
|
||||||
|
* - lable The lable of the attribute form the model
|
||||||
|
* - raw The value of the attribute with no formatting
|
||||||
|
*
|
||||||
|
* @param mixed $model The model of the attribute to parse
|
||||||
|
* @param string $attribute The you want to parse
|
||||||
|
* @param array $defalts Array of defalt values
|
||||||
|
*
|
||||||
|
* @return ArrayObject The parsed config
|
||||||
|
*/
|
||||||
public static function parseAttribute( $model, $attribute, $defalts = [ 'format' => "text", 'value' => '( NOT SET )' ] )
|
public static function parseAttribute( $model, $attribute, $defalts = [ 'format' => "text", 'value' => '( NOT SET )' ] )
|
||||||
{
|
{
|
||||||
if ( !preg_match( '/^([^:]+)(:(\w*))?(:(.*))?$/', $attribute, $matches ) ) {
|
if ( !preg_match( '/^([^:]+)(:(\w*))?(:(.*))?$/', $attribute, $matches ) ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue