Type of Flash Messenger in Zend

后端 未结 4 552
遥遥无期
遥遥无期 2021-02-02 15:25

Is it possible or How can i give a type to a FlashMessage in Zend?

For example

/* This is a \"Success\" message */
$this -> _helper -> FlashMesseng         


        
4条回答
  •  难免孤独
    2021-02-02 15:47

    Method signatures in Zend Framework 1.12.x for FlashMessenger:

    public function addMessage($message, $namespace = null)
    public function getMessages($namespace = null)
    public function hasMessages($namespace = null)
    public function clearMessages($namespace = null)
    

    So to set messages the following will work:

    /* success message */
    $this->_helper->flashMessenger()->addMessage('Post created!', 'success');
    
    /* error message */
    $this->_helper->flashMessenger()->addMessage('You have no permissions', 'error');
    

    And for the view, the following should work:

    hasMessages('success')): ?>
        
    getMessages('success') as $msg): ?>
    hasMessages('error')): ?>
    getMessages('error') as $msg): ?>

提交回复
热议问题