Get subsidiaries.
@param $name Subsidiary name, case insensitive.
@param string $limit
@param int $page
@return null
518338
public function getSubsidiaries($name, $limit = 'all', $page = 0)
    {
        $class = $this->getSubsidiaryClass($name);
        if (empty($class)) {
            return null;
        }
        $query = $class::find();
        if (!method_exists($query, 'createdBy')) {
            return null;
        }
        return $query->createdBy($this)->page($limit, $page)->all();
    }
191774
public static function pageHas(string $name, ?string $page = null): bool
    {
        if ($page === null) {
            $page = $_SERVER['PHP_SELF'];
        }
        return self::has($name, $page);
    }
1289798
public function findCurrentOfferedProducts($locale, $limit = 20, $page = 1)
    {
        $specialPrices = $this->specialPriceRepository->findAllCurrent($limit, $page);
        $products = [];
        foreach ($specialPrices as $specialPrice) {
            $product = $this->productFactory->createApiEntity($specialPrice->getProduct(), $locale);
            $this->createProductMedia($product, $locale);
            $products['product'][] = $product;
        }
        $products['pagerfanta'] = $specialPrices;

        return $products;
    }
225215
public function paginate($page, $limit)
    {
        if (!$this->getModelClass()) {
            throw new ModelNotFoundException('setModelClass');
        }

        /** @var EntityRepository $repository */
        $repository = $this->getManager()->getRepository($this->getModelClass());
        $queryBuilder = $repository->createQueryBuilder(Constants::MODEL_ALIAS);

        $filterList = new FilterQueryEvent();
        $filterList->setQueryBuilder($queryBuilder);
        $filterList->setAlias(Constants::MODEL_ALIAS);
        $filterList->setModelClass($this->getModelClass());

        $this->getEventSubscriber()->subscribe(Constants::FILTER_LIST, $filterList);

        $query = $filterList->getQueryBuilder()->getQuery();
        $query->useQueryCache(true);
        $query->useResultCache(true, $this->cacheLifetime, sprintf('%s_%s', $this->getModelClass(), serialize($query->getParameters()->toArray())));

        return $this->getPaginator()->paginate($query, $page, $limit);
    }
455235
public function getPage(string $name): Page
    {
        if ($this->page_object_factory === null) {
            throw new RuntimeException('[W406] To create pages you need to pass a factory with setPageObjectFactory()');
        }

        return $this->page_object_factory->createPage($name);
    }
1271749
private function hasNextPage(\Countable $queryResult, $limit, $page, $pageSize)
    {
        $count = $queryResult->count();
        if ($limit && $limit < $count) {
            $count = $limit;
        }

        return $count > ($page * $pageSize);
    }
449622
public function get(int $page, int $limit = 10): \Illuminate\Pagination\LengthAwarePaginator
    {
        if (!$this->_columns && !$this->_query) {
            return null;
        }
        $countTotal = $this->_query->count();
        $this->_query->skip(($limit * $page) - $limit);
        $this->_query->limit($limit);
        $data = collect();
        foreach ($this->_query->get() as $key => $instance) {
            if ($instance instanceof \Illuminate\Database\Eloquent\Model) {
                $_listRow = [];
                foreach ($this->_columns->getColumns() as $column) {
                    $_listRow[$column->getKey()] = $column->getValues($instance);
                }
                $buttons = $this->_columns->filterActions($instance);
                if (count($buttons)) {
                    $_listRow = array_merge($_listRow, [Column::ACTION_NAME => implode('', $buttons)]);
                }
                $data->offsetSet($key, $_listRow);
            }
        }
        $this->_data = new \Illuminate\Pagination\LengthAwarePaginator($data, $countTotal, $limit, $page, [
            'path'     => \Illuminate\Pagination\Paginator::resolveCurrentPath(),
            'pageName' => 'page',
        ]);

        return $this->_data;
    }
807155
public function getPagedResults($limit = 50, $page = 0)
    {
        $dql = sprintf(self::DQL_GET_USERS, User::class);

        return $this->getPaginator($dql, $limit, $page);
    }
1329610
public function getParameters($page = null, $limit = null)
    {
        $params = $this->params;

        $params[$this->pageParam]  = null == $page  ? $this->getPage()  : $page;
        $params[$this->limitParam] = null == $limit ? $this->getLimit() : $limit;

        return $params;
    }
678666
public function getRecords($limit = null, $name = null)
    {
        $modelName = $this->getModelName();

        $activity = $modelName::with('subject');

        if ( ! is_null($limit))
        {
            $activity->limit($limit);
        }

        if ($name)
        {
            if ( ! is_array($name))
            {
                $name = [$name];
            }

            $activity->whereIn('name', $name);
        }

        return $activity->latest()->get();
    }
727433
private function getPagination($page)
    {
        $limit = 5;
        if ($page !== null) {
            if ($page === 'all') {
                $limit = null;
                $page = null;
            } else {
                $page = (int) $page;
            }
        } else {
            $page = 1;
        }

        return ['page' => $page, 'limit' => $limit];
    }
1182310
public function findAncestors(Page $root, Page $page) : ObjectCollection
    {
        $pages = new ObjectCollection;

        foreach ($root->getDescendants() as $item)
        {
            if (!($item->getLeftValue() >= $page->getLeftValue() && $item->getRightValue() <= $page->getRightValue()))
            {
                $pages->append($item);
            }
        }

        $tree = $this->nestedSet->getTree($pages, $root->getTreeLeft(), $root->getTreeRight());
        $pages = $this->nestedSet->getFlatCollection($tree);

        return $pages;
    }
612023
public function getCompanies($offset = 0, $limit = 25)
    {
        list($offset, $limit) = $this->normalizeOffsetAndLimit($offset, $limit);

        return $this->request('companies', [
            'offset' => $offset,
            'limit' => $limit,
        ]);
    }
306921
public function monthly($year, $month, $page = 1, $limit = 25)
    {
        return $this->client->call("expenses/in_month/{$year}/{$month}", [
            'page' => $page,
            'per_page' => $limit
        ], 'GET');
    }
2740
public function getTranslatedPageID($page)
    {
        $ids = static::getIDList();
        if (in_array($page->getCollectionID(), $ids)) {
            return $this->locale->getSiteTree()->getSiteHomePageID();
        }

        $mpRelationID = self::getMultilingualPageRelationID($page->getCollectionID());

        if ($mpRelationID) {
            $cID = self::getCollectionIDForLocale($mpRelationID, $this->getLocale());

            return $cID;
        }
    }
1237558
public function paginate($limit, $useMaster = false, $page = null)
    {
        is_int($page) || $page = Input::requestInt(Config::get('var_page'), 1);
        $page < 1 && $page = 1;
        return call_user_func_array([$this, 'select'], [($page - 1) * $limit, $limit, $useMaster]);
    }
670402
protected function createPage($name, $hierarchy, Page $parent = null): Page
    {
        $page = new Page();
        $page->setParent($parent);
        $page->setHierarchy($hierarchy);
        $page->setPublish(1);
        $page->setRedirectType(0);
        $page->setSection('');
        $page->addShop($this->shop);
        foreach ($this->getLocales() as $locale) {
            /** @var PageTranslation $translation */
            $translation = $page->translate($locale->getCode());
            $translation->setName($name);
            $translation->setSlug(Helper::urlize($name));
            $translation->setContent($this->defaultText);
        }
        
        $page->mergeNewTranslations();
        
        $this->manager->persist($page);
        
        return $page;
    }