public function removeNode(Path $path) { $root = $this->rootNode; $mounted = false; $out = TraverseArray::remove($root, $path, true, function ($mounterClass, $relativePath, $path) use(&$mounted) { $mounted = true; return $this->router->query($mounterClass)->removeNode($relativePath); }); // it has altered the copy of root node if (!$mounted) { throw new NodeReadonlyException(); } return $out; }
/** * Removes a node. Returns true on success, false if the node doesn't even exist * @return True if the node has been removed, false if the node didn't exist. */ public function remove($path) { // normalize path $path = $this->path($path); // destroy pointers $this->destroyPointersUnder($path); // redirect query to the root mounter return $this->router->query(RootMounter::class)->removeNode($path); }