digitalstate/platform-widget-bundle
Composer 安装命令:
composer require digitalstate/platform-widget-bundle
包简介
DigitalState Widget Bundle
关键字:
README 文档
README
The Widget bundle provides the developers a way to define widgets in the user interface.
Table of Contents
Widget Entity
A widget consists of a title and content meant to be displayed in a template in a specific position. Essentially, it allows the developer to customise templates without directly modifying the template files. Widgets are comparable to ORO Placeholders with two additional features: the capability of adding a title and the context filter.
Note: Eventually, if possible, we will merge the concept of widgets to ORO Placeholders with our additional features.
Creating a Widget
Widgets can be created in any bundle. They are defined the same way as any other services in Symfony using the Service Container. The developer will need to tag the service with the ds.widget tag in order for the system to pick it up as a widget. Finally, the developer will need to define a position in a template file, where the widget should be displayed.
The widget class src/Gov/Bundle/BlogBundle/Widget/LatestPostsWidget.php:
<?php namespace Gov\Bundle\BlogBundle\Widget; use Ds\Bundle\WidgetBundle\Widget\Widget; class LatestPostsWidget extends Widget { public function getTitle() { return 'Latest Posts'; } public function getContent(array $data = []) { return '<ul><li><a href="">Post 1</a></li><li><a href="">Post 2</a></li></ul>'; } }
The widget service src/Acme/Bundle/TestBundle/Resources/config/services.yml:
services: gov.blog.widget.latest_posts: parent: ds.widget.widget.abstract class: Gov\Bundle\BlogBundle\Widget\LatestPostsWidget tags: - { name: ds.widget, position: aside }
The template position:
<html> <body> <aside> {% for widget in ds_widgets({ position: 'aside' }) %} <h3>{{ widget.title }}</h3> {{ widget.content|raw }} {% endfor %} </aside> </body> </html>
Context Filter
The context filter is an optional parameter allowing the developer to define when a Widget should be rendered.
Let's use a real world example to explain the concept:
The DigitalState-Platform introduces the concept of Government Services through the DsServiceBundle. This bundle provides, at its core, the base actions for creating, editing, and deleting Generic Services. The editing action uses of the Widget concept for displaying the core form fields for the Generic Service.
The DigitalState-Platform also introduces the concept of BPM Services through the DsServiceBpmBundle. This bundle grafts itself on top of the DsServiceBundle to provide additional BPM-related functionality for when a business user wishes to create a BPM-based Service. A BPM Service is the same as a Generic Service, with additional fields to map the BPM process definition id and other BPM specific configurations. The DsServiceBpmBundle defines an additional Widget for the additional form fields and flags the context of the widget as bpm, meaning this Widget should only be displayed the specific context of BPM.
The template position with context defined:
<html> <body> <main> <form> {% for widget in ds_widgets({ position: 'main', context: 'bpm' }) %} <h3>{{ widget.title }}</h3> {{ widget.content|raw }} {% endfor %} </form> </main> </body> </html>
Todo
Introduce custom twig tag for widget positions.
Example 1:
{% position *position_name* with { variable: value } %}
Example 2:
{% position *position_name* %}
{{ widget.title }}
{{ widget.content|raw }}
{% endposition %}
Enable widgets to be defined as template or callbacks, instead of classes.
digitalstate/platform-widget-bundle 适用场景与选型建议
digitalstate/platform-widget-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 155 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 12 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「communication」 「ORO」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 digitalstate/platform-widget-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 digitalstate/platform-widget-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 digitalstate/platform-widget-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dispatcher to handle e-mail and instant notifications.
Basic configuration, helper and tools for an oro application
Back-office dashboard with embedded Google Data Studio report
Package to publish/consume domain events messages from Laravel apps
Allows to control the quality of images using the UI. Optimizes images thereby reducing the overall storage size.
Manage Node resources from PHP
统计信息
- 总下载量: 155
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-29