Wire::getFuel PHP Method

getFuel() public static method

Get the Fuel specified by $name or NULL if it doesn't exist
Deprecation:
public static getFuel ( string $name = '' ) : mixed | null
$name string
return mixed | null
    public static function getFuel($name = '')
    {
        if (empty($name)) {
            return self::$fuel;
        }
        return self::$fuel->{$name};
    }

Usage Example

Ejemplo n.º 1
0
/**
 * Perform a language translation
 * 
 * @param string $text Text for translation. 
 * @param string $textdomain Textdomain for the text, may be class name, filename, or something made up by you. If ommitted, a debug backtrace will attempt to determine it automatically.
 * @param string $context Name of context - DO NOT USE with this function for translation as it won't be parsed for translation. Use only with the _x() function, which will be parsed. 
 * @return string Translated text or original text if translation not available.
 *
 *
 */
function __($text, $textdomain = null, $context = '')
{
    if (!Wire::getFuel('languages')) {
        return $text;
    }
    if (!($language = Wire::getFuel('user')->language)) {
        return $text;
    }
    if (!$language->id) {
        return $text;
    }
    if (is_null($textdomain)) {
        $traces = @debug_backtrace(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? DEBUG_BACKTRACE_IGNORE_ARGS : false);
        if (isset($traces[0]) && $traces[0]['file'] != __FILE__) {
            $textdomain = $traces[0]['file'];
        } else {
            if (isset($traces[1]) && $traces[1]['file'] != __FILE__) {
                $textdomain = $traces[1]['file'];
            }
        }
        if (is_null($textdomain)) {
            $textdomain = 'site';
        }
    }
    return htmlspecialchars($language->translator()->getTranslation($textdomain, $text, $context), ENT_QUOTES, 'UTF-8');
}
All Usage Examples Of Wire::getFuel