Returns Paginator Presenter object if pagination is enabled

@param array $items
@return mixed
335536
private function _getPaginatorPresenter(array $items)
    {
        if (!$this->_paginate) {
            return null;
        }

        $params = Input::get();
        if (!empty($params)) {
            // There are parameters in the URL - pass them to paginator
            if (isset($params['page'])) {
                // We don't need that - paginator will add new one
                unset($params['page']);
            }
        }

        // Prepare paginator and pass it to presenter
        $paginator = new LengthAwarePaginator($items, $this->_totalItems, $this->_perPage, $this->_page, [
            'path' => Request::url(),
        ]);
        $paginator->appends($params);
        return new $this->_paginationPresenter($paginator);
    }
597051
public function getItemHelper(array $item): ItemHelper
    {
        if ($this->level !== 1 && $item['type'] === 'folder') {
            return new HeaderItemHelper($item);
        } elseif ($this->level === 2 || ($this->level > 1 && $this->getPageType() === 'folder')) {
            return new DropdownItemHelper($item);
        } else {
            return new NavItemHelper($item);
        }
    }
244671
protected function resolveItems(array &$items)
    {
        $resolver = function ($property) {
            return $this->resolve($property) ?: $property;
        };

        for ($i = 0; $i < count($items); $i++) {
            $items[$i]->fill(array_map($resolver, $items[$i]->getProperties()));
        }
    }
449595
public function getPresenter()
    {
        if (!isset($this->presenter)) {
            $this->presenter = new Presenter($this->getOutput()->getFormatter(), $this->forceArrayIndexes());
        }

        return $this->presenter;
    }
402243
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->fixPaths($item);
        }

        return $items;
    }
463669
protected function getItemsAsArray($items)
    {
        if (is_array($items)) {
            return $items;
        } elseif ($items instanceof self) {
            return $items->all();
        } elseif ($items instanceof Traversable) {
            return iterator_to_array($items);
        }

        return (array) $items;
    }
974133
protected function getArrayableItems($items): array
    {
        if (is_array($items)) {
            return $items;
        } elseif (is_callable($items)) {
            return call_user_func($items);
        } elseif ($items instanceof self) {
            return $items->all();
        } elseif ($items instanceof Iterator) {
            return $items;
        } elseif ($items instanceof Traversable) {
            return iterator_to_array($items);
        } elseif ($items instanceof IteratorAggregate) {
            return $items->getIterator();
        } elseif ($items instanceof JsonSerializable) {
            return $items->jsonSerialize();
        } elseif (method_exists($items, 'toJson')) {
            return json_decode($items->toJson(), true);
        } elseif (method_exists($items, 'toArray')) {
            return $items->toArray();
        }

        return (array) $items;
    }
9915
private function sortByPriorityAndFlatten(array $items)
    {
        if (!empty($items)) {
            \krsort($items);
            $items = \array_merge(...$items);
        }

        return $items;
    }
372377
public function paginate($items, $perPage = 10, $page = null, $options = [])
    {
        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
        $items = $items instanceof Collection ? $items : Collection::make($items);

        return new LengthAwarePaginator(
            $items->forPage($page, $perPage),
            $items->count(),
            $perPage,
            $page,
            $options
        );
    }
1002130
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->doClean($item);
        }

        return $items;
    }
547923
public static function parameters(array $items)
    {
        $parameters = array();
        $items = array_filter(Arr::flatten($items));

        foreach ($items as $item) {
            $itemParams = $item->getParameters();

            if ($itemParams !== null) {
                $parameters []= $itemParams;
            }
        }

        return Arr::flatten($parameters);
    }
1202987
protected function paginator($items, $total, $per_page, $current_page, array $options) {
        return new LengthAwarePaginator($items, $total, $per_page, $current_page, $options);
    }
865453
protected function getArrayableItems($items)
    {
        if (is_array($items)) {
            return $items;
        }

        if ($items instanceof Traversable) {
            return iterator_to_array($items);
        }

        return (array) $items;
    }
830778
public function process(array $items)
    {
        foreach ($items as $key => $item) {
            $items[$key] = $this->setImage($item);
        }

        return $items;
    }
819245
protected function _prepareItems($items)
    {
        if (is_integer($items)) {
            $id = $items;
            $cacheKey = "render({$id})";
            $items = static::cache($cacheKey);

            if ($items === null) {
                $items = TableRegistry::get('Menu.MenuLinks')
                    ->find('threaded')
                    ->where(['menu_id' => $id])
                    ->all();
                static::cache($cacheKey, $items);
            }
        } elseif (is_string($items)) {
            $slug = $items;
            $cacheKey = "render({$slug})";
            $items = static::cache($cacheKey);

            if ($items === null) {
                $items = [];
                $menu = TableRegistry::get('Menu.Menus')
                    ->find()
                    ->select(['id'])
                    ->where(['slug' => $slug])
                    ->first();

                if ($menu instanceof EntityInterface) {
                    $items = TableRegistry::get('Menu.MenuLinks')
                        ->find('threaded')
                        ->where(['menu_id' => $menu->id])
                        ->all();
                }
                static::cache($cacheKey, $items);
            }
        }

        return $items;
    }
766209
public function setDisabledItems($items)
    {
        $controller = Controller::curr();
        $code = $controller->data()->Code;
        $updated = [];
        if (is_array($items) && !empty($items)) {
            foreach ($items as $item) {
                array_push($updated, ProductPage::getGeneratedValue($code, $this->getName(), $item, 'value'));
            }
        }
        $this->disabledItems = $updated;

        return $this;
    }
457160
public function paginate(?int $itemsPerPage = null, array $options = [])
	{
		$count = $this->paginationCount();

		$pagination = static::getPaginationFactory()->create($count, $itemsPerPage, $options);

		if($count > 0)
		{
			$results = $this->limit($pagination->limit())->offset($pagination->offset())->all();
		}
		else
		{
			$results = $this->createResultSet([]);
		}

		$results->setPagination($pagination);

		return $results;
	}