<?php
 namespace Extension;
 use TCMS\ControlExtension;
 class MessageDefault extends ControlExtension {
 public $option = [ 'flash_key' => 'message' ];
 public function render($fields, $option = null) {
 copy_option($this->option, $option);
 $data = \Session::flash($this->option['flash_key']);
 if ($data !== false) {
 $alertType = 'success';
 switch ($data->type) {
 case 'success': $alertType = 'success';
 break;
 case 'error': $alertType = 'danger';
 break;
 case 'info': $alertType = 'info';
 break;
 case 'warning': $alertType = 'warning';
 break;
 }
 echo '<div class="alert alert-' . $alertType . ' alert-dismissible fade show" role="alert">' . $data->message . '.' . '<button type="button" class="close" data-dismiss="alert" aria-label="Close">' . '<span aria-hidden="true">&times;</span>' . '</button>' . '</div>';
 }
 }
 }
 