mirror of
				https://github.com/yiisoft/yii2.git
				synced 2025-11-04 22:57:40 +08:00 
			
		
		
		
	Multiple flash messages per type support
This commit is contained in:
		@ -717,7 +717,13 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $counters = $this->get($this->flashParam, []);
 | 
					        $counters = $this->get($this->flashParam, []);
 | 
				
			||||||
        $counters[$key] = $removeAfterAccess ? -1 : 0;
 | 
					        $counters[$key] = $removeAfterAccess ? -1 : 0;
 | 
				
			||||||
        $_SESSION[$key] = $value;
 | 
					
 | 
				
			||||||
 | 
					        if (!empty($_SESSION[$key])) {
 | 
				
			||||||
 | 
					            $_SESSION[$key][] = $value;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $_SESSION[$key] = [$value];
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $_SESSION[$this->flashParam] = $counters;
 | 
					        $_SESSION[$this->flashParam] = $counters;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -760,9 +766,9 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Returns a value indicating whether there is a flash message associated with the specified key.
 | 
					     * Returns a value indicating whether there are flash messages associated with the specified key.
 | 
				
			||||||
     * @param string $key key identifying the flash message
 | 
					     * @param string $key key identifying the flash message type
 | 
				
			||||||
     * @return boolean whether the specified flash message exists
 | 
					     * @return boolean whether any flash messages exist under specified key
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function hasFlash($key)
 | 
					    public function hasFlash($key)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user