amnah\yii2\user\models\User::statusDropdown PHP Méthode

statusDropdown() public static méthode

Get list of statuses for creating dropdowns
public static statusDropdown ( ) : array
Résultat array
    public static function statusDropdown()
    {
        // get data if needed
        static $dropdown;
        $constPrefix = "STATUS_";
        if ($dropdown === null) {
            // create a reflection class to get constants
            $reflClass = new ReflectionClass(get_called_class());
            $constants = $reflClass->getConstants();
            // check for status constants (e.g., STATUS_ACTIVE)
            foreach ($constants as $constantName => $constantValue) {
                // add prettified name to dropdown
                if (strpos($constantName, $constPrefix) === 0) {
                    $prettyName = str_replace($constPrefix, "", $constantName);
                    $prettyName = Inflector::humanize(strtolower($prettyName));
                    $dropdown[$constantValue] = $prettyName;
                }
            }
        }
        return $dropdown;
    }