Exemplo n.º 1
0
 protected static function createMessage($message, $name = null)
 {
     if (is_array($message)) {
         $type = $message['type'];
         $message = $message['text'];
     } else {
         $type = $name;
     }
     // Adjust the alert Type.
     switch ($type) {
         case 'info':
         case 'success':
         case 'warning':
         case 'danger':
             break;
         default:
             $type = 'success';
             break;
     }
     // Handle the multiple line messages.
     if ($message instanceof MessageBag) {
         $message = $message->all();
     }
     // Handle the array messages.
     if (is_array($message)) {
         if (count($message) > 1) {
             $message = '<ul><li>' . implode('</li><li>', $message) . '</li></ul>';
         } else {
             if (!empty($message)) {
                 $message = array_shift($message);
             } else {
                 // An empty array?
                 $message = '';
             }
         }
     }
     // Fetch the associated Template Fragment and return the result.
     return Template::make('message', compact('type', 'message'))->render();
 }
Exemplo n.º 2
0
 /**
  * Return a Layout instance.
  *
  * @param string|null $layout
  * @param array $data
  *
  * @return \Template\Template|\View\View
  * @throws \BadMethodCallException
  */
 public function getLayout($layout = null, array $data = array())
 {
     // Adjust the current used Layout.
     $layout = $layout ?: $this->layout;
     if ($layout instanceof View) {
         return $layout->with($data);
     } else {
         if (is_string($layout)) {
             return Template::make($layout, $data, $this->template);
         }
     }
     throw new BadMethodCallException('Method not available for the current Layout');
 }
Exemplo n.º 3
0
 /**
  * Create a new Error Response instance.
  *
  * The Response Status code will be set using the specified code.
  *
  * The specified error should match a View in your Views/Error directory.
  *
  * <code>
  *      // Create a 404 response.
  *      return Response::error('404');
  *
  *      // Create a 404 response with data.
  *      return Response::error('404', array('message' => 'Not Found'));
  * </code>
  *
  * @param  int       $code
  * @param  array     $data
  * @return Response
  */
 public static function error($status, array $data = array(), $headers = array())
 {
     $view = Template::make('default')->shares('title', 'Error ' . $status)->nest('content', 'Error/' . $status, $data);
     return static::make($view, $status, $headers);
 }