Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Paging Class Reference
Inheritance diagram for Paging:
AbstractComponent DataObject UiComponentInterface BlockInterface

Public Member Functions

 getComponentName ()
 
 prepare ()
 
- Public Member Functions inherited from AbstractComponent
 __construct (ContextInterface $context, array $components=[], array $data=[])
 
 getContext ()
 
 getName ()
 
 prepare ()
 
 toHtml ()
 
 render ()
 
 addComponent ($name, UiComponentInterface $component)
 
 getComponent ($name)
 
 getChildComponents ()
 
 renderChildComponent ($name)
 
 getTemplate ()
 
 getConfiguration ()
 
 getJsConfig (UiComponentInterface $component)
 
 setData ($key, $value=null)
 
 getData ($key='', $index=null)
 
 prepareDataSource (array $dataSource)
 
 getDataSourceData ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Data Fields

const NAME = 'paging'
 

Protected Member Functions

 prepareOptions ()
 
 getOffset ($paging)
 
 getSize ($paging)
 
- Protected Member Functions inherited from AbstractComponent
 prepareChildComponent (UiComponentInterface $component)
 
 initObservers (array & $data=[])
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_data
 
- Protected Attributes inherited from AbstractComponent
 $context
 
 $components
 
 $componentData = []
 
 $dataSources = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

@api

Since
100.0.2

Definition at line 12 of file Paging.php.

Member Function Documentation

◆ getComponentName()

getComponentName ( )

Get component name

Returns
string

Implements UiComponentInterface.

Definition at line 55 of file Paging.php.

56  {
57  return static::NAME;
58  }

◆ getOffset()

getOffset (   $paging)
protected

Get offset

Parameters
array | null$paging
Returns
int

Definition at line 102 of file Paging.php.

103  {
104  $defaultPage = $this->getData('config/current') ?: 1;
105  return (int) (isset($paging['current']) ? $paging['current'] : $defaultPage);
106  }

◆ getSize()

getSize (   $paging)
protected

Get size

Parameters
array | null$paging
Returns
int

Definition at line 114 of file Paging.php.

115  {
116  $defaultLimit = $this->getData('config/pageSize') ?: 20;
117  return (int) (isset($paging['pageSize']) ? $paging['pageSize'] : $defaultLimit);
118  }

◆ prepare()

prepare ( )

Register component and apply paging settings to Data Provider

Returns
void

Implements UiComponentInterface.

Definition at line 65 of file Paging.php.

66  {
67  $this->prepareOptions();
68  $paging = $this->getContext()->getRequestParam('paging');
69  if (!isset($paging['notLimits'])) {
70  $this->getContext()
71  ->getDataProvider()
72  ->setLimit($this->getOffset($paging), $this->getSize($paging));
73  }
74 
75  parent::prepare();
76  }

◆ prepareOptions()

prepareOptions ( )
protected

Prepare paging options

Returns
void

Definition at line 83 of file Paging.php.

84  {
85  $config = $this->getData('config');
86  if (isset($config['options'])) {
87  $config['options'] = array_values($config['options']);
88  foreach ($config['options'] as &$item) {
89  $item['value'] = (int) $item['value'];
90  }
91  unset($item);
92  $this->setData('config', $config);
93  }
94  }
$config
Definition: fraud_order.php:17

Field Documentation

◆ $_data

$_data
protected
Initial value:
= [
'config' => [
'options' => [
'20' => [
'value' => 20,
'label' => 20
],
'30' => [
'value' => 30,
'label' => 30
],
'50' => [
'value' => 50,
'label' => 50
],
'100' => [
'value' => 100,
'label' => 100
],
'200' => [
'value' => 200,
'label' => 200
],
],
'pageSize' => 20,
'current' => 1
]
]

Definition at line 21 of file Paging.php.

◆ NAME

const NAME = 'paging'

Definition at line 14 of file Paging.php.


The documentation for this class was generated from the following file: