2017 © Pedro Peláez
 

library status

Operation status announcer

image

exploring/status

Operation status announcer

  • Tuesday, April 12, 2016
  • by jperovic
  • Repository
  • 1 Watchers
  • 0 Stars
  • 46 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 12 % Grown

The README.md

ExploringStatusBundle

This bundle aims to help with setting controller's operation status by elimination cumbersome checking of session flash bag., (*1)

Installation (via composer)

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)

Configuration

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

Setting the operation status:

$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 :(');

Retrieving the operation status:

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)

Message groups:

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') }}

The Versions

12/04 2016

dev-master

9999999-dev

Operation status announcer

  Sources   Download

MIT

The Requires

 

12/04 2016

1.2

1.2.0.0

Operation status announcer

  Sources   Download

MIT

The Requires

 

31/08 2014

1.1

1.1.0.0

Operation status announcer

  Sources   Download

MIT

The Requires

 

14/06 2014

1.0

1.0.0.0

Operation status announcer

  Sources   Download

MIT

The Requires