PHP Class Bluz\Grid\Grid

Author: Anton Shevchuk
Inheritance: use trait Bluz\Common\Options, use trait Bluz\Common\Helper
Show file Open project: bluzphp/framework

Protected Properties

Property Type Description
$adapter instance of Source
$aliases array List of aliases for columns in DB
$allowFilters array Example ['id', 'status' => ['active', 'disable']]
$allowOrders list of allow orders
$controller location of Grid
$data instance of Data
$defaultLimit default value of page limit
$defaultOrder default order
$filters list of filters
$limit limit per page
$module location of Grid
$orders array Example 'first' => 'ASC', 'last' => 'ASC'
$page start from first page
$params custom array params
$prefix unique prefix of grid
$uid unique identification of grid

Public Methods

Method Description
__construct ( array $options = null ) Grid constructor
addAlias ( string $key, string $value ) : void Add alias
addFilter ( string $column, string $filter, string $value ) : void Add filter
addOrder ( string $column, string $order = Grid::ORDER_ASC ) : void Add order rule
addOrders ( array $orders ) : void Add order rules
checkFilter ( string $filter ) : boolean Check filter
getAdapter ( ) : Bluz\Grid\Source\AbstractSource Get source adapter
getAllowFilters ( ) : array Get allow filters
getAllowOrders ( ) : array Get allow orders
getController ( ) : string Get controller
getData ( ) : Bluz\Grid\Data Get data
getDefaultLimit ( ) : integer Get default limit
getDefaultOrder ( ) : array Get default order
getFilter ( string $column, string $filter = null ) : mixed Get filter
getFilters ( ) : array Get filters
getLimit ( ) : integer Get limit per page
getModule ( ) : string Get module
getOrders ( ) : array Get orders
getPage ( ) : integer Get page
getParams ( array $rewrite = [] ) : array Return params prepared for url builder
getPrefix ( ) : string Get prefix
getSettings ( ) : array Get settings
getUid ( ) : string Get unique Grid Id
getUrl ( array $params ) : string Get Url
init ( ) : Grid Initialize Grid
processRequest ( ) : Grid Process request
processSource ( ) : self Process source
setAdapter ( Bluz\Grid\Source\AbstractSource $adapter ) : void Set source adapter
setAliases ( array $aliases ) : void Set aliases
setAllowFilters ( array $filters = [] ) : void Set allowed filters
setAllowOrders ( array $orders = [] ) : void Set allow orders
setController ( string $controller ) : void Set controller
setDefaultLimit ( integer $limit ) : void Set default limit
setDefaultOrder ( string $column, string $order = Grid::ORDER_ASC ) : void Set default order
setLimit ( integer $limit ) : void Set limit per page
setModule ( string $module ) : void Set module
setOrder ( string $column, string $order = Grid::ORDER_ASC ) : void Set order
setOrders ( array $orders ) : void Set orders
setPage ( integer $page = 1 ) : void Set page
setParams ( $params ) : void Setup params

Protected Methods

Method Description
applyAlias ( string $key ) : string Apply Alias

Method Details

__construct() public method

Grid constructor
public __construct ( array $options = null )
$options array

addAlias() public method

Add alias
public addAlias ( string $key, string $value ) : void
$key string
$value string
return void

addFilter() public method

Add filter
public addFilter ( string $column, string $filter, string $value ) : void
$column string
$filter string
$value string
return void

addOrder() public method

Add order rule
public addOrder ( string $column, string $order = Grid::ORDER_ASC ) : void
$column string
$order string
return void

addOrders() public method

Add order rules
public addOrders ( array $orders ) : void
$orders array
return void

applyAlias() protected method

Apply Alias
protected applyAlias ( string $key ) : string
$key string
return string

checkFilter() public method

Check filter
public checkFilter ( string $filter ) : boolean
$filter string
return boolean

getAdapter() public method

Get source adapter
public getAdapter ( ) : Bluz\Grid\Source\AbstractSource
return Bluz\Grid\Source\AbstractSource

getAllowFilters() public method

Get allow filters
public getAllowFilters ( ) : array
return array

getAllowOrders() public method

Get allow orders
public getAllowOrders ( ) : array
return array

getController() public method

Get controller
public getController ( ) : string
return string

getData() public method

Get data
public getData ( ) : Bluz\Grid\Data
return Bluz\Grid\Data

getDefaultLimit() public method

Get default limit
public getDefaultLimit ( ) : integer
return integer

getDefaultOrder() public method

Get default order
public getDefaultOrder ( ) : array
return array

getFilter() public method

Get filter
public getFilter ( string $column, string $filter = null ) : mixed
$column string
$filter string
return mixed

getFilters() public method

Get filters
public getFilters ( ) : array
return array

getLimit() public method

Get limit per page
public getLimit ( ) : integer
return integer

getModule() public method

Get module
public getModule ( ) : string
return string

getOrders() public method

Get orders
public getOrders ( ) : array
return array

getPage() public method

Get page
public getPage ( ) : integer
return integer

getParams() public method

Return params prepared for url builder
public getParams ( array $rewrite = [] ) : array
$rewrite array
return array

getPrefix() public method

Get prefix
public getPrefix ( ) : string
return string

getSettings() public method

Get settings
public getSettings ( ) : array
return array

getUid() public method

Get unique Grid Id
public getUid ( ) : string
return string

getUrl() public method

Get Url
public getUrl ( array $params ) : string
$params array
return string

init() abstract public method

Initialize Grid
abstract public init ( ) : Grid
return Grid

processRequest() public method

Example of request url - http://domain.com/pages/grid/ - http://domain.com/pages/grid/page/2/ - http://domain.com/pages/grid/page/2/order-alias/desc/ - http://domain.com/pages/grid/page/2/order-created/desc/order-alias/asc/ with prefix for support more than one grid on page - http://domain.com/users/grid/users-page/2/users-order-created/desc/ - http://domain.com/users/grid/users-page/2/users-filter-status/active/ hash support - http://domain.com/pages/grid/#/page/2/order-created/desc/order-alias/asc/
public processRequest ( ) : Grid
return Grid

processSource() public method

Process source
public processSource ( ) : self
return self

setAdapter() public method

Set source adapter
public setAdapter ( Bluz\Grid\Source\AbstractSource $adapter ) : void
$adapter Bluz\Grid\Source\AbstractSource
return void

setAliases() public method

Set aliases
public setAliases ( array $aliases ) : void
$aliases array
return void

setAllowFilters() public method

Set allowed filters
public setAllowFilters ( array $filters = [] ) : void
$filters array
return void

setAllowOrders() public method

Set allow orders
public setAllowOrders ( array $orders = [] ) : void
$orders array
return void

setController() public method

Set controller
public setController ( string $controller ) : void
$controller string
return void

setDefaultLimit() public method

Set default limit
public setDefaultLimit ( integer $limit ) : void
$limit integer
return void

setDefaultOrder() public method

Set default order
public setDefaultOrder ( string $column, string $order = Grid::ORDER_ASC ) : void
$column string
$order string ASC or DESC
return void

setLimit() public method

Set limit per page
public setLimit ( integer $limit ) : void
$limit integer
return void

setModule() public method

Set module
public setModule ( string $module ) : void
$module string
return void

setOrder() public method

Set order
public setOrder ( string $column, string $order = Grid::ORDER_ASC ) : void
$column string
$order string ASC or DESC
return void

setOrders() public method

Set orders
public setOrders ( array $orders ) : void
$orders array
return void

setPage() public method

Set page
public setPage ( integer $page = 1 ) : void
$page integer
return void

setParams() public method

Setup params
public setParams ( $params ) : void
$params
return void

Property Details

$adapter protected property

instance of Source
protected $adapter

$aliases protected property

List of aliases for columns in DB
protected array $aliases
return array

$allowFilters protected property

Example ['id', 'status' => ['active', 'disable']]
See also: Grid::$filters
protected array $allowFilters
return array

$allowOrders protected property

list of allow orders
See also: Grid::$orders
protected $allowOrders

$controller protected property

location of Grid
protected $controller

$data protected property

instance of Data
protected $data

$defaultLimit protected property

default value of page limit
See also: Grid::$limit
protected $defaultLimit

$defaultOrder protected property

default order
See also: Grid::$orders
protected $defaultOrder

$filters protected property

list of filters
protected $filters

$limit protected property

limit per page
protected $limit

$module protected property

location of Grid
protected $module

$orders protected property

Example 'first' => 'ASC', 'last' => 'ASC'
protected array $orders
return array

$page protected property

start from first page
protected $page

$params protected property

custom array params
protected $params

$prefix protected property

unique prefix of grid
protected $prefix

$uid protected property

unique identification of grid
protected $uid