* @package tao
*/
class tao_helpers_Feedback
{
/**
* @param $type
* @param $message
* @param array $settings
* @return string
*/
protected static function dispatch($type, $message, $settings = [])
{
$defaults = [
'delayToClose' => 2000,
'closer' => true,
'icon' => true,
'modal' => false
];
$settings = array_merge($defaults, $settings);
$closer = $settings['closer'] ? sprintf('', __('Remove Message')) : '';
if (is_string($settings['icon'])) {
$icon = sprintf('', $settings['icon']);
} elseif ($settings['icon'] === true) {
$icon = sprintf('', $type);
} else {
$icon = '';
}
return sprintf('
%s%s%s
', $type, $icon, $message, $closer);
}
/**
* @param $message
* @param array $settings
* @return string
*/
public static function error($message, $settings = [])
{
return self::dispatch(__FUNCTION__, $message, $settings);
}
/**
* @param $message
* @param array $settings
* @return string
*/
public static function info($message, $settings = [])
{
return self::dispatch(__FUNCTION__, $message, $settings);
}
/**
* @param $message
* @param array $settings
* @return string
*/
public static function success($message, $settings = [])
{
return self::dispatch(__FUNCTION__, $message, $settings);
}
/**
* @param $message
* @param array $settings
* @return string
*/
public static function warning($message, $settings = [])
{
return self::dispatch(__FUNCTION__, $message, $settings);
}
}