blast-project/utils-bundle
Composer 安装命令:
composer require blast-project/utils-bundle
包简介
All kinds of goodies for the BlastCoreBundle
README 文档
README
Features
Blast Choices
Documentation to be writen
Blast Hooks
This bundle introduce a hook feature that is really basic hook management.
You can define in your views any hook you want.
Declare the hook target location in a view
{# myTemplate.html.twig #}
<div>
<h1>Here my custom hook</h1>
{{ blast_hook('my.custom.hook', {'someParameters': myVar}) }}
</div>
A hook can be declared without using any parameters. If so, the « hook block » won't have any parameters defined in handleParameters's method parameter (var $hookParameters will be an empty array).
Declare your Hook class
This class will manage rendering of the hook content by setting view parameters (act as a controller)
<?php namespace MyBundle\Hook\MyCustomHook; use Blast\UtilsBundle\Hook\AbstractHook; class MyCustomHookExample extends AbstractHook { protected $hookName = 'my.custom.hook'; protected $template = 'MyBundle:Hook:my_custom_hook_example.html.twig'; public function handleParameters($hookParameters) { $this->templateParameters = [ 'someViewParameter' => 'a value that will be passed to the twig view' ]; } }
Note: you can get the current hook name (configured in service definition) in attribute AbstractHook::hookName ans the configured template in AbstractHook::template
Register the hook class as service
my_bundle.hook.my_custom_hook_example: class: MyBundle\Hook\MyCustomHook\MyCustomHookExample tags: - { name: blast.hook, hook: my.custom.hook, template: MyBundle:Hook:my_custom_hook_example.html.twig }
The hook configuration are sets in the service tag :
name: the service tag name (must beblast.hook)hook: the target hook where the « block » will be renderedtemplate: the twig template of the « block »
Please don't forget the tag blast.hook in order to register your service as a hook
Create your hook template
{# MyBundle:Hook:my_custom_hook_example.html.twig #}
<p>
Here's my first custom hook, with a view var : {{ someViewParameter }} !
</p>
And voila, you should have this rendered content :
<div> <h1>Here my custom hook</h1> <p> Here's my first custom hook, with a view var : a value that will be passed to the twig view ! </p> </div>
Blast Custom Filters
Enable the feature in config.yml
# app/config/config.yml blast_utils: features: customFilters: enabled: true
Optionnaly, you can define your own customFilter entity by setting it as below (don't forget to set the associated repository in order to override createNewCustomFilter method) :
# app/config/config.yml blast_utils: features: customFilters: enabled: true class: MyBundle\Entity\MyCustomFilter
You only have to set your User class entity in application config.yml (see https://symfony.com/doc/current/doctrine/resolve_target_entity.html for more informations)
# app/config/config.yml doctrine: # ... orm: # ... resolve_target_entities: Blast\CoreBundle\Model\UserInterface: MyBundle\Entity\MyUser
If you're using Sylius, setting the doctrine.orm resolve_target_entities key will not work because Sylius is already using this system. You can declare your Interface / Entity replacement within SyliusResource configuration :
# app/config/config.yml sylius_resource: resources: blast.utils: # this is an arbitrary key classes: model: MyBundle\Entity\MyUser interface: Blast\CoreBundle\Model\UserInterface
Blast User Interface
In order to set User mapping with utils entity, the mapping with Interface is used.
There are 2 ways for configuring the real class that will replace the UserInterface :
Using Sylius
declare, via resources, the class that will replace the model interface
sylius_resource: resources: blast.utils: classes: model: MyBundle\Entity\MyRealUser interface: Blast\CoreBundle\Model\UserInterface
Using Syfony's Doctrine target entity resolver :
doctrine: # ... orm: #... resolve_target_entities: Blast\CoreBundle\Model\UserInterface: MyBundle\Entity\MyRealUser
blast-project/utils-bundle 适用场景与选型建议
blast-project/utils-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.42k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「sonata」 「utils」 「blast」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 blast-project/utils-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blast-project/utils-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blast-project/utils-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A set of useful PHP classes.
Sonata Extra admin features
ACL list filtering for SonataAdmin
n2n test utils
The bundle for easy using json-rpc api on your project
A collection of enhancements and utilities for the Silverstripe UserForms module
统计信息
- 总下载量: 5.42k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2016-12-02