Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to paginate getChildren calls #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/DataObjects/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public function getCheckedOutDocs(OperationContextInterface $context = null)
* @param OperationContextInterface|null $context
* @return CmisObjectInterface[] A list of the child objects for the specified folder.
*/
public function getChildren(OperationContextInterface $context = null)
public function getChildren(OperationContextInterface $context = null, $skipCount = 0)
{
$context = $this->ensureContext($context);
$children = $this->getBinding()->getNavigationService()->getChildren(
Expand All @@ -336,7 +336,9 @@ public function getChildren(OperationContextInterface $context = null)
$context->isIncludeAllowableActions(),
$context->getIncludeRelationships(),
$context->getRenditionFilterString(),
$context->isIncludePathSegments()
$context->isIncludePathSegments(),
$context->getMaxItemsPerPage(),
$skipCount
);

$result = [];
Expand All @@ -350,6 +352,30 @@ public function getChildren(OperationContextInterface $context = null)
return $result;
}

/**
* Returns the number of children of this folder using the given OperationContext.
*
* @param OperationContextInterface|null $context
* @return int Total number of children.
*/
public function getNumChildren(OperationContextInterface $context = null)
{
$context = $this->ensureContext($context);
$children = $this->getBinding()->getNavigationService()->getChildren(
$this->getRepositoryId(),
$this->getId(),
$context->getQueryFilterString(),
$context->getOrderBy(),
$context->isIncludeAllowableActions(),
$context->getIncludeRelationships(),
$context->getRenditionFilterString(),
$context->isIncludePathSegments(),
1
);

return $children->getNumItems();
}

/**
* Gets the folder descendants starting with this folder.
*
Expand Down