bigfoot/core-bundle
Composer 安装命令:
composer require bigfoot/core-bundle
包简介
Bigfoot core bundle
README 文档
README
This is the core bundle for the Bigfoot administration interface. Provides core features and helpers to integrate BackOffice features through bundles.
Installation
Use composer :
php composer.phar require bigfoot/core-bundle
Register the bundle in your app/AppKernel.php file :
$bundles = array(
...
new Bigfoot\Bundle\CoreBundle\BigfootCoreBundle(),
...
);
Usage
The administration interface is then available at /admin. For now, it does nothing. Add Bigfoot bundles or create your own to really get started !
How to create a widget
Create a class extends Bigfoot\Bundle\CoreBundle\Model\AbstractWidget.
Define in your new class the method 'renderContent()'. This method must return html code of your widget.
Add a record in widget_backoffice table with corresponding values : name : Fullname of your class title : Title display in widget header, this field is translatable
Add 2 records in widget_backoffice_parameter table. One with these values : name: order value: Order number you want for your widget widget_id: Record ID of your widget in widget_backoffice table user_id: (Optionnal) If defined, this parameter will be used only for this user
Another with these values : name: width value: number of columns use by your widget widget_id: Record ID of your widget in widget_backoffice table user_id: (Optionnal) If defined, this parameter will be used only for this user
How to overload Symfony Router
Add these following lines to your front config:
bigfoot_core: routing: replace_symfony_router: true routers_by_id: router.default : 300 bigfoot_core.router: 400
BigfootFile annotation :
BigfootFile uses symfony's file upload system with its 2 properties for one file.
@Bigfoot\Bundle\CoreBundle\Annotation\Bigfoot\File : apply this annotation on the property that represents the form field. Use its filePathProperty option (required) to connect the other property.
Don't forget to create an "updated" field, and to update it before flushing with a PreFlush listener. Otherwise the file won't update if you don't change anything else in the form.
Exemple :
<?php namespace Entity; use Doctrine\ORM\Mapping as ORM; use Bigfoot\Bundle\CoreBundle\Annotation\Bigfoot; /** * @ORM\Table(name="items") * @ORM\HasLifecycleCallbacks() */ class Item { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * @ORM\Column(name="path", type="string", length=255, nullable=true) */ private $path /** * @Assert\File(maxSize="6000000") * @Bigfoot\File(filePathProperty="path") */ public $file; /** * @var string * @ORM\Column(name="updated", type="datetime", nullable=true) */ private $updated; /** * @ORM\PreFlush() */ public function refreshUpdated() { if ($this->file) { $this->updated = new \DateTime("now"); } } }
Use it in your Form :
class ItemType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('file', 'bigfoot_file', array( 'required' => false, 'label' => 'Your file', 'filePathProperty' => 'path', 'deleteRoute' => 'entity_delete_file' )); } }
If you don't define any deleteRoute, the deleteLink won't appear
Get the file in front :
The second parameter(default false) defines whether or not the filter returns an absolute path
{{ item|bigfoot_file('path', false) }}
Generate a csv in Crud Index page :
Add the method getCsvFields into your extended CrudController controller:
protected function getCsvFields() { return array( 'name' => array( 'label' => 'Name' ), 'region.name' => array( 'label' => 'Region', ), 'services.codeDetail' => array( 'label' => 'Services', 'multiple' => true ) ); }
If you want to display a field of your entity, use:
protected function getCsvFields() { return array( 'name' => array( 'label' => 'Name' ), ....
If you want to display a field of an external entity, use:
protected function getCsvFields() { return array( 'region.name' => array( 'label' => 'Region' ), .... );
If you want to display a field of OneToMany relation, use:
protected function getCsvFields() { return array( 'services.codeDetail' => array( 'label' => 'Services', 'multiple' => true ) .... );
Improve the speed of your 'Edit forms' by setting a form by tab:
Add the method getFormTypes into your extended CrudController controller which return an array compound of arrays of 'label' (labels of tabs) and 'form', names of the FormType services.
protected function getFormTypes() { return array( array( 'label' => 'Hotel', // Label of the first tab 'form' => 'rc_hotel_0' // Service name of the HotelType ), array( 'label' => 'Rooms', // Label of the second tab 'form' => 'rc_hotel_1' // Service name of the RoomsType ) ); }
Make sure you added an index parameter to your editAction of your controller:
public function editAction(Request $request, $id, $index = null) { return $this->doEdit($request, $id, $index); }
That's it!
bigfoot/core-bundle 适用场景与选型建议
bigfoot/core-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.32k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2013 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bigfoot/core-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bigfoot/core-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 14.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 11
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-07-10