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

Adding Key support and Key Array support to flash messages #1

Merged
merged 11 commits into from Apr 14, 2015
Merged

Adding Key support and Key Array support to flash messages #1

merged 11 commits into from Apr 14, 2015

Conversation

geggleto
Copy link
Member

@geggleto geggleto commented Apr 1, 2015

In my apps, I find having different keys to store flash messages a critical component. Being able to flag [warn] or [error] messages for rendering in my UI is pretty critical. This PR attempts to add this functionality.

- Added Key support for storing messages
- Updated for Change To addMessage
Updated Usage for change in function parameters
- Add Multiple message per key support
- Updated test cases to support multiple values for a key
@geggleto geggleto changed the title Adding Key support to flash Messages Adding Key support and Key Array support to flash messages Apr 1, 2015
@gabriel403
Copy link

Should $key be a set of constants on the class (or a static array of key => key)?

const INFO = 'info';
public static $messageLevels = [Messages::INFO => 'info', ...];

And the class check that $key is valid before allowing it in (or retrieving it) ?

$flash->addMessage($flash::INFO, 'Toast');

function addMessage($key, $value)
{
    if (! in_array($key, static::$messageLevels)) {
        throw new Exception('sux');
    }
}

Just curious.

@codeguy
Copy link
Member

codeguy commented Apr 1, 2015

I guess you could have constants, but I'm not sure we need them. Up to you though.

@geggleto
Copy link
Member Author

geggleto commented Apr 1, 2015

I think it should be up to the app itself to maintain the set of constants.

@geggleto
Copy link
Member Author

geggleto commented Apr 2, 2015

/cc @codeguy @gabriel403 fixed it all up

codeguy added a commit that referenced this pull request Apr 14, 2015
Adding Key support and Key Array support to flash messages
@codeguy codeguy merged commit a4ae3fe into slimphp:master Apr 14, 2015
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.

None yet

3 participants