HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/magento/module-ui/Component/Paging.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\Ui\Component;

/**
 * Class Paging
 *
 * @api
 * @since 100.0.2
 */
class Paging extends AbstractComponent
{
    const NAME = 'paging';

    /**
     * Default paging options
     *
     * @var array
     */
    private $defaultOptions = [
        '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
        ],
    ];

    /**
     * Default page size
     *
     * @var int
     */
    private $defaultPageSize = 20;

    /**
     * Default component data
     *
     * @var array
     */
    protected $_data = [
        'config' => [
            'current' => 1
        ]
    ];

    /**
     * Get component name
     *
     * @return string
     */
    public function getComponentName()
    {
        return static::NAME;
    }

    /**
     * Register component and apply paging settings to Data Provider
     *
     * @return void
     */
    public function prepare()
    {
        $this->prepareOptions();
        $this->preparePageSize();
        $paging = $this->getContext()->getRequestParam('paging');
        if (!isset($paging['notLimits'])) {
            $this->getContext()
                ->getDataProvider()
                ->setLimit($this->getOffset($paging), $this->getSize($paging));
        }
        parent::prepare();
    }

    /**
     * Prepare paging options
     *
     * @return void
     */
    protected function prepareOptions()
    {
        $config = $this->getData('config');
        if (!isset($config['options'])) {
            $config['options'] = $this->defaultOptions;
        }
        foreach ($config['options'] as &$item) {
            $item['value'] = (int)$item['value'];
        }
        unset($item);
        $this->setData('config', $config);
    }

    /**
     * Prepare page size
     *
     * @return void
     */
    private function preparePageSize()
    {
        $config = $this->getData('config');
        if (!isset($config['pageSize'])) {
            $config['pageSize'] = $this->defaultPageSize;
            $this->setData('config', $config);
        }
    }

    /**
     * Get offset
     *
     * @param array|null $paging
     * @return int
     */
    protected function getOffset($paging)
    {
        $defaultPage = $this->getData('config/current') ?: 1;
        return (int)(isset($paging['current']) ? $paging['current'] : $defaultPage);
    }

    /**
     * Get size
     *
     * @param array|null $paging
     * @return int
     */
    protected function getSize($paging)
    {
        return (int)(isset($paging['pageSize']) ? $paging['pageSize'] : $this->getData('config/pageSize'));
    }
}