/** * Fetches properties for a node. * * This event is called a bit later, so plugins have a chance first to * populate the result. * * @param PropFind $propFind * @param INode $node * @return void */ function propFindNode(PropFind $propFind, INode $node) { if ($node instanceof IProperties && ($propertyNames = $propFind->get404Properties())) { $nodeProperties = $node->getProperties($propertyNames); foreach ($nodeProperties as $propertyName => $value) { $propFind->set($propertyName, $value, 200); } } }
/** * 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(); } }
/** * Fetches properties for a node. * * This event is called a bit later, so plugins have a chance first to * populate the result. * * @param PropFind $propFind * @param INode $node * @return void */ function propFindNode(PropFind $propFind, INode $node) { if ($node instanceof IProperties && ($propertyNames = $propFind->get404Properties())) { $nodeProperties = $node->getProperties($propertyNames); foreach ($propertyNames as $propertyName) { if (array_key_exists($propertyName, $nodeProperties)) { $propFind->set($propertyName, $nodeProperties[$propertyName], 200); } } } }