本文整理汇总了PHP中Sabre\DAV\INode::getChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP INode::getChildren方法的具体用法?PHP INode::getChildren怎么用?PHP INode::getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre\DAV\INode
的用法示例。
在下文中一共展示了INode::getChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyNode
/**
* copyNode
*
* @param INode $source
* @param ICollection $destinationParent
* @param string $destinationName
* @return void
*/
protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null)
{
if (!$destinationName) {
$destinationName = $source->getName();
}
if ($source instanceof IFile) {
$data = $source->get();
// If the body was a string, we need to convert it to a stream
if (is_string($data)) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, $data);
rewind($stream);
$data = $stream;
}
$destinationParent->createFile($destinationName, $data);
$destination = $destinationParent->getChild($destinationName);
} elseif ($source instanceof ICollection) {
$destinationParent->createDirectory($destinationName);
$destination = $destinationParent->getChild($destinationName);
foreach ($source->getChildren() as $child) {
$this->copyNode($child, $destination);
}
}
if ($source instanceof IProperties && $destination instanceof IProperties) {
$props = $source->getProperties([]);
$propPatch = new PropPatch($props);
$destination->propPatch($propPatch);
$propPatch->commit();
}
}
示例2: handleGetProperties
/**
* Adds tags and favorites properties to the response,
* if requested.
*
* @param PropFind $propFind
* @param \Sabre\DAV\INode $node
* @return void
*/
public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
{
if (!$node instanceof \OCA\DAV\Connector\Sabre\Node) {
return;
}
// need prefetch ?
if ($node instanceof \OCA\DAV\Connector\Sabre\Directory && $propFind->getDepth() !== 0 && (!is_null($propFind->getStatus(self::TAGS_PROPERTYNAME)) || !is_null($propFind->getStatus(self::FAVORITE_PROPERTYNAME)))) {
// note: pre-fetching only supported for depth <= 1
$folderContent = $node->getChildren();
$fileIds[] = (int) $node->getId();
foreach ($folderContent as $info) {
$fileIds[] = (int) $info->getId();
}
$tags = $this->getTagger()->getTagsForObjects($fileIds);
if ($tags === false) {
// the tags API returns false on error...
$tags = array();
}
$this->cachedTags = $this->cachedTags + $tags;
$emptyFileIds = array_diff($fileIds, array_keys($tags));
// also cache the ones that were not found
foreach ($emptyFileIds as $fileId) {
$this->cachedTags[$fileId] = [];
}
}
$tags = null;
$isFav = null;
$propFind->handle(self::TAGS_PROPERTYNAME, function () use($tags, &$isFav, $node) {
list($tags, $isFav) = $this->getTagsAndFav($node->getId());
return new TagList($tags);
});
$propFind->handle(self::FAVORITE_PROPERTYNAME, function () use($isFav, $node) {
if (is_null($isFav)) {
list(, $isFav) = $this->getTagsAndFav($node->getId());
}
return $isFav;
});
}