dev-master
9999999-devOperation status announcer
MIT
The Requires
- php >=5.3.3
- twig/twig ~1.12
- symfony/http-foundation 2.*|3.*
1.2
1.2.0.0Operation status announcer
MIT
The Requires
- php >=5.3.3
- symfony/http-foundation 2.*|3.*
- twig/twig ~1.12
Wallogit.com
2017 © Pedro Peláez
Operation status announcer
This bundle aims to help with setting controller's operation status by elimination cumbersome checking of session flash bag., (*1)
To install StatusBundle with Composer just add the following to your composer.json file:, (*2)
{
// ...
require: {
"exploring/status": "dev-master"
}
}
Please replace the dev-master with some concrete release tag, for example, 1.*, (*3)
Then run:, (*4)
php composer.phar update
And register the bundle within AppKernel.php, (*5)
$bundles = array(
....
new \Exploring\StatusBundle\ExploringStatusBundle(),
);
You are ready to roll., (*6)
The bundle configuration is minimalistic. In order for it to work you just need:, (*7)
exploring_status: ~
Operation status can be stored either in session (default) or apc. In order to use apc mode, depending of your php version, you might need to install it first., (*8)
This can be configured by specifying engine config entry:, (*9)
exploring_status:
engine: apc
$manager = $this->get('exploring_status.manager');
$manager->success('Yey, you did it!');
$manager->warning('Ok, everything went ok, but there is something fishy going on here.');
$manager->error('Couldn\'t do it :(');
You can do it from within controller or from Twig directly., (*10)
PHP:, (*11)
$manager = $this->get('exploring_status.manager');
// Get first status, if exists
// This returns object of `StatusObject` type
$status = $manager->first();
// Get all status messages
// This returns `array` of `StatusObject` objects
$all = $manager->all();
Twig:, (*12)
{# This prints first status message directly #}
{{ ExploringStatus_First() }}
{# This prints all status messages directly #}
{{ ExploringStatus_All() }}
Twig templates can be overridden easily. Please see the official documentation for how-to., (*13)
Status messages can be grouped. In fact, when you set the status message goes to Default group by default., (*14)
$manager = $this->get('exploring_status.manager');
// This message will go into `happiness` group
$manager->success('Yey, you did it!', 'happiness');
// This one goes into `Default`
$manager->warning('Ok, everything went ok, but there is something fishy going on here.');
// This one goes into `Fatal`
$manager->error('Couldn\'t do it :(', 'Fatal');
As for retrieving same rule applies as defined above - you only need to pass group name as argument., (*15)
PHP:, (*16)
// Get first status from group `happiness`
// This returns object of `StatusObject` type
$status = $manager->first('happiness');
// Get all status messages from group `Fatal`
// This returns `array` of `StatusObject` objects
$all = $manager->all('Fatal');
Twig:, (*17)
{# This prints first status message directly #}
{{ ExploringStatus_First('happiness') }}
{# This prints all status messages directly #}
{{ ExploringStatus_All('Fatal') }}
Operation status announcer
MIT
Operation status announcer
MIT