glavweb/datagrid-bundle

本包的最新版本(v3.1.1)没有提供许可证信息。

GLAVWEB DatagridBundle

v3.1.1 2023-06-28 08:36 UTC

README

使用composer获取此扩展包

通过在您的Symfony项目的根目录终端运行此命令来添加GlavwebDatagridBundle

php composer.phar require glavweb/datagrid-bundle

启用扩展包

要开始使用扩展包,请在您的应用程序的kernel类中注册扩展包

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Glavweb\DatagridBundle\GlavwebDatagridBundle(),
        // ...
    );
}

配置扩展包

本扩展包旨在直接使用。为了使此扩展包正常运行,您只需配置映射即可。

基本用法

定义数据架构

# app/config/data_schema/article.schema.yml

schema:
    class: AppBundle\Entity\Article
    properties:
        id:
        name:
        slug:
        body:

定义范围

# app/config/scopes/article/short.yml

scope:
    name: 

在控制器中使用

$datagridBuilder = $this->get('glavweb_datagrid.doctrine_datagrid_builder')
    ->setEntityClassName('AppBundle\Entity\Article')
    ->setAlias('t')
    ->setDataSchema('article.schema.yml', 'article/short.yml')
    ->setFirstResult(0)
    ->setMaxResults(2)
    ->setOrderings(['name' => 'ASC'])
;

// Define filters
$datagridBuilder
    ->addFilter('name')
;

$datagrid = $this->datagridBuilder->build(['name' => 'Article 1']);
$list = $datagrid->getList();