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.

64 lines
1.3 KiB

<?php
/**
* Created by Error202
* Date: 21.08.2018
*/
namespace common\modules\languages\helpers;
use common\modules\languages\entities\Language;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use Yii;
class LanguageHelper
{
public static function defaultLabel($default): string
{
switch ($default) {
case Language::DEFAULT_FALSE:
$class = 'text-gray';
break;
case Language::DEFAULT_TRUE:
$class = 'text-yellow';
break;
default:
$class = 'text-gray';
}
return '<i class="fa fa-star '.$class.'" aria-hidden="true"></i>';
}
public static function statusList(): array
{
return [
Language::STATUS_DRAFT => Yii::t('languages', 'Draft'),
Language::STATUS_ACTIVE => Yii::t('languages', 'Active'),
];
}
public static function statusName($status): string
{
return ArrayHelper::getValue(self::statusList(), $status);
}
public static function statusLabel($status): string
{
switch ($status) {
case Language::STATUS_DRAFT:
$class = 'label label-default';
break;
case Language::STATUS_ACTIVE:
$class = 'label label-success';
break;
default:
$class = 'label label-default';
}
return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [
'class' => $class,
]);
}
}