exploring/status 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

exploring/status

Composer 安装命令:

composer require exploring/status

包简介

Operation status announcer

README 文档

README

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

Installation (via composer)

To install StatusBundle with Composer just add the following to your composer.json file:

{
    // ...
    require: {
        "exploring/status": "dev-master"
    }
}

Please replace the dev-master with some concrete release tag, for example, 1.*

Then run:

php composer.phar update

And register the bundle within AppKernel.php

$bundles = array(
    ....
    new \Exploring\StatusBundle\ExploringStatusBundle(),
);

You are ready to roll.

Configuration

The bundle configuration is minimalistic. In order for it to work you just need:

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.

This can be configured by specifying engine config entry:

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.

PHP:

$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:

{# 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.

Message groups:

Status messages can be grouped. In fact, when you set the status message goes to Default group by default.

$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.

PHP:

// 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:

{# This prints first status message directly #}
{{ ExploringStatus_First('happiness') }}

{# This prints all status messages directly #}
{{ ExploringStatus_All('Fatal') }}

统计信息

  • 总下载量: 248
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-08-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固