定制 ras/flash-alert-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ras/flash-alert-bundle

Composer 安装命令:

composer require ras/flash-alert-bundle

包简介

FlashAlertBundle provides a simplified way to handle (add/display) Symfony flash messages. Client side scripts are written in pure JavaScript.

README 文档

README

Join the chat at https://gitter.im/rasanga/FlashAlertBundle FlashAlertBundle is an open source Bundle which simplifies displaying flash alerts such as success, error, info and warning

Build Status Scrutinizer Code Quality

Demo screenshot

Table of Contents

  1. Installation
  2. Download the FlashAlertBundle
  3. Enable the bundle
  4. Configure the bundle
  5. Usage
  6. Report flash alerts
  7. Display flash alerts
  8. Configuration
  9. Override view template
  10. Add custom styles
  11. Changelog
  12. License

Installation

Step 1: Download the FlashAlertBundle

Using Composer Add the following to the "require" section of your composer.json file:

    "ras/flash-alert-bundle": "dev-master"

And update your dependencies

    php composer.phar update

Using submodules Execute the following command on your project root:

$ git submodule add git@github.com:rasanga/FlashAlertBundle.git vendor/bundles/Ras/FlashAlertBundle
$ git submodule update --init

Step 2: Enable the bundle

Registers the bundle in your app/AppKernel.php:

<?php
...
public function registerBundles()
{
    $bundles = array(
        ...
        new Ras\Bundle\FlashAlertBundle\RasFlashAlertBundle(),
        ...
    );
...

Step Optional, if you are not using composer: Configure the Autoloader

Add the following to your autoload.php:

<?php
...
'Ras' => __DIR__.'/../vendor/bundles',

Usage

Report flash alerts

Add the following PHP code to report an alert message:

    $this->get('ras_flash_alert.alert_reporter')->addError("Access denied");

Note: You can choose one of the following functions to call from $this->get('ras_flash_alert.alert_reporter')

    addSuccess()
    addError()
    addWarning()
    addInfo()

Display flash alerts

Add the following twig code where you want to display alert messages:

    {{ render_flash_alerts() }}

Note 1: The parent twig template would be the best place for displaying flash alerts

Configuration

The following parameters can be overriden in your config.yml or similar:

ras_flash_alert:
    template: '::flashAlerts.html.twig'     # defaults to 'RasFlashAlertBundle::layout.html.twig'
    isAddStyles: false                      # defaults to true
    isAddJsAlertClose: false                # defaults to true

These can also be passed as parameters in the view when rendering alerts - for example:

    {{ render_flash_alerts({ 'template': '::flashAlerts.html.twig', 'isAddStyles': false }) }}

Override view template

  1. Create template in the /Resources/views/ or in your bundle
  2. Retrieve alerts into your template with {{ get_alert_publisher() }}
  3. Include template blocks in FlashAlertBundle/Resources/views/FlashAlert directory or define your own blocks (follow FlashAlertBundle/Resources/views/FlashAlert/flashAlerts.html.twig to see how you can define your own template)

Add custom styles

The bundle default template has styles defined by default. However, you can turn off default styles by configuring isAddStyles variable to false as shown in below.

    {{ render_flash_alerts({ 'isAddStyles': false }) }}

Then you can define your own styles to match alert classes such as alert, alert-close, alert-success, alert-error, alert-warning and alert-info

CHANGELOG

2.0

Add twig method for rendering alerts: `{{ render_flash_alerts() }}`
Add twig method for retrieving alerts: `{{ get_alert_publisher() }}`
Deprecated controller view render 

LICENSE

FlashAlertBundle is licensed under the MIT Open Source license.

Bitdeli Badge

ras/flash-alert-bundle 适用场景与选型建议

ras/flash-alert-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.32k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2014 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「bundle」 「message」 「notification」 「flash」 「alert」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ras/flash-alert-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ras/flash-alert-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 ras/flash-alert-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 23.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 22
  • 依赖项目数: 1
  • 推荐数: 1

GitHub 信息

  • Stars: 23
  • Watchers: 3
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-02