Пример #1
0
 public function testFormatIsRespected()
 {
     $container = new MessageBag();
     $container->setFormat('<p>:message</p>');
     $container->add('foo', 'bar');
     $container->add('boom', 'baz');
     $this->assertEquals('<p>bar</p>', $container->first('foo'));
     $this->assertEquals(array('<p>bar</p>'), $container->get('foo'));
     $this->assertEquals(array('<p>bar</p>', '<p>baz</p>'), $container->all());
     $this->assertEquals('bar', $container->first('foo', ':message'));
     $this->assertEquals(array('bar'), $container->get('foo', ':message'));
     $this->assertEquals(array('bar', 'baz'), $container->all(':message'));
 }
Пример #2
0
 /**
  * @param string $key
  * @return array
  */
 public function getErrorMessages($key)
 {
     if ($this->errors !== null) {
         return $this->errors->get($key);
     }
     return [];
 }
Пример #3
0
 /**
  * Check for the key in the error manager session else return the messages 
  * from the message bag
  *
  * @param  string  $key
  * @param  string  $format
  * @return array
  */
 public function get($key, $format = null)
 {
     if (Session::has('errorManager.errors')) {
         $errors = new parent(Session::get('errorManager.errors'));
         if ($errors->has($key)) {
             return $errors->get($key);
         }
     }
     return parent::get($key);
 }
 /**
  * Constructor.
  *
  * @param int                           $httpStatusCode   HTTP status code
  * @param mixed                         $errorCode        Internal error code
  * @param string                        $errorTitle       Error description
  * @param Illuminate\Support\MessageBag $errors           Validation errors
  */
 public function __construct($httpStatusCode, $errorCode, $errorTitle, ValidationMessages $errors = NULL)
 {
     $data = ['errors' => []];
     if ($errors) {
         foreach ($errors->keys() as $field) {
             foreach ($errors->get($field) as $message) {
                 $data['errors'][] = ['status' => $httpStatusCode, 'code' => $errorCode, 'title' => 'Validation Fail', 'detail' => $message, 'meta' => ['field' => $field]];
             }
         }
     }
     parent::__construct($data, $httpStatusCode);
 }
 /**
  * Gets all the flash messages of a given type.
  * @param $key
  * @param $format
  * @return array
  */
 public function get($key, $format = null)
 {
     $message = parent::get($key, $format);
     $this->purge();
     return $message;
 }
Пример #6
0
 /**
  * Get error text from session in parent class
  *
  * @param  string $name
  *
  * @return string
  */
 private function getError($name = null)
 {
     return $this->local_errors->get($name);
 }
 /**
  * Get the warning messages for a form control.
  *
  * @param string $key
  * @return array of message strings
  */
 public function getWarnings($key)
 {
     return array_merge($this->warning_messages->get($key), $this->getWarningsFromAncestor($key));
 }