You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.0 KiB

6 years ago
<?php
/**
* Created by Error202
* Date: 29.07.2018
*/
namespace common\modules\forms\helpers;
use common\modules\forms\entities\Form;
3 years ago
use Exception;
6 years ago
use Yii;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
class FormHelper {
public static function statusList(): array
{
return [
Form::STATUS_DRAFT => Yii::t('forms', 'Draft'),
Form::STATUS_ACTIVE => Yii::t('forms', 'Active'),
6 years ago
];
}
3 years ago
/**
* @param $status
* @return string
* @throws Exception
*/
6 years ago
public static function statusName($status): string
{
return ArrayHelper::getValue(self::statusList(), $status);
}
3 years ago
/**
* @param $status
* @return string
* @throws Exception
*/
6 years ago
public static function statusLabel($status): string
{
3 years ago
$class = match ($status) {
Form::STATUS_DRAFT => 'label label-default',
Form::STATUS_ACTIVE => 'label label-success',
default => 'label label-default',
};
6 years ago
return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [
'class' => $class,
]);
}
3 years ago
}