Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Add "All Getters" for "Flash" values and "Add" #52

Open
wants to merge 4 commits into
base: 4.x
Choose a base branch
from

Conversation

jakejohns
Copy link
Member

This is just #47 for 3.x.
It looks like there was already a getAll equivalent: getSegment.

@jakejohns jakejohns changed the title [3.x] Add All getters for "Flash" values [3.x] Add "All Getters" for "Flash" values Apr 10, 2016
public function getFlashAll($alt = array())
{
$this->resumeSession();
return isset($_SESSION[Session::FLASH_NOW][$this->name])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't flash all means flash now + next ?

@jakejohns
Copy link
Member Author

Fair point, @harikt. Perhaps the name is a little terse.
Perhaps getAllCurrentFlash(), and getAllNextFlash() would be better?

@harikt
Copy link
Member

harikt commented Apr 11, 2016

Let's wait to hear from pmjones thoughts.

- Segment::getFlashAll();
- Segment::getFlashNextAll();
@jakejohns jakejohns changed the title [3.x] Add "All Getters" for "Flash" values [3.x] Add "All Getters" for "Flash" values and "Add" Apr 11, 2016
@jakejohns
Copy link
Member Author

I added "add" methods here as well.
I should have perhaps done this as a separate PR, but the intention is that the getAll and add stuff would be complimentary.

@harikt, I just noticed that you said to wait on pmj, but i'm pretty sure you're right, so I had already gone and changed it. Obviously can always change to something else.

As an illustration of my intended use case:

<?php
// @codingStandardsIgnoreFile

abstract class MyAbstractResponder
{
    protected $msgSegment = 'My\\Messages';

    protected function addMessage($msg, $level = 'info')
    {
        $this->getSession()
            ->getSegment($this->msgSegment)
            ->addFlash(['lvl' => $level, 'msg' => $msg]);
    }

    protected function getMessages()
    {
        return $this->getSession()
            ->getSegment($this->msgSegment)
            ->getAllCurrentFlash([]);
    }

    protected function render()
    {
        $view = $this->getView();
        $view->addData(['messages' => $this->getMessages()]);
        $this->response->getBody()->write($view());
    }

    protected function updated()
    {
        $this->addMessage('Successfully updated thing', 'success');
        $this->redirect();
    }

    //...
}

@harikt harikt changed the base branch from 3.x to 4.x September 13, 2023 06:17
@harikt harikt changed the title [3.x] Add "All Getters" for "Flash" values and "Add" [4.x] Add "All Getters" for "Flash" values and "Add" Sep 13, 2023
@harikt
Copy link
Member

harikt commented Sep 23, 2023

@jakejohns Sorry that this is not merged. I am going to release a 4.x for session to make it compatible with 8.x . Newer feature is not incorported for now. So this is currently put on hold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants