public function movePagesToDir(int $parent, int $destinationDir = 0, bool $createRedirect = false, string $oldCabin = '', string $newCabin = '', array $pieces = []) : bool
{
$this->log('Moving pages to a new directroy', LogLevel::DEBUG, ['from' => $parent, 'to' => $destinationDir, 'redirect' => $createRedirect, 'oldCabin' => $oldCabin, 'newCabin' => $newCabin, 'pieces' => $pieces]);
$old = ['cabin' => $oldCabin, 'path' => \implode('/', $this->getDirectoryPieces($parent))];
$new = ['cabin' => $newCabin, 'path' => \implode('/', $pieces)];
if ($createRedirect) {
$this->createDirRedirect($old, $new);
}
foreach ($this->listCustomPagesByDirectoryID($parent) as $page) {
$this->movePage((int) $page['pageid'], $page['url'], $destinationDir);
}
$this->db->beginTransaction();
if ($destinationDir > 0) {
$update = ['parent' => null, 'cabin' => $newCabin];
} else {
$update = ['parent' => $destinationDir];
}
$this->db->update('airship_custom_dir', $update, ['parent' => $parent]);
return $this->db->commit();
}