Add doc to parseAttribute

This commit is contained in:
Ade Attwood 2017-06-23 18:35:58 +01:00
parent b01db503d9
commit ff1500369c

View file

@ -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 ) ) {