Beispiel #1
0
 /**
  * Flash data to the session. Data is only available for
  * to the next page load.
  *
  * If called without a second paramer, data is returned.
  * If called with a second parameter, data is set.
  *
  * @param string $key
  * @param mixed optional $value to set
  */
 function flash($key, $setValue = '')
 {
     $flash = Flash::getInstance();
     if ($setValue) {
         $flash::set($key, $setValue);
         return $setValue;
     } else {
         return $flash::get($key);
     }
 }
Beispiel #2
0
 /**
  * Create a new instance
  *
  * @param  array  $data
  * @return void
  */
 public function __construct($data = [])
 {
     // Instantiate the Flash instance
     $this->flash = Flash::getInstance();
     // Register the fields
     foreach ($data as $field => $options) {
         $this->addField($field, $options);
     }
     // Prepopulate the fields with old input data, if it exists
     foreach ($this->fields as $field => $attributes) {
         $this->data[$field] = htmlspecialchars(get($field));
     }
     // Get any errors from the Flash
     $this->errors = $this->errors();
 }
Beispiel #3
0
 /**
  * Get all errors
  *
  * @return  array
  */
 public function errors()
 {
     return $this->flash->get(self::FLASH_KEY_ERRORS, []);
 }