moveDir() public méthode

Move/rename a directory
public moveDir ( integer $dirID, string $url = '', integer $parent, string $cabin = '' ) : boolean
$dirID integer
$url string
$parent integer
$cabin string
Résultat boolean
Exemple #1
0
 /**
  * Move/rename a directory.
  *
  * @param array $dirInfo
  * @param array $post
  * @param string $oldCabin
  * @param array $cabins
  * @return bool
  */
 protected function processMoveDir(array $dirInfo, array $post = [], string $oldCabin = '', array $cabins = []) : bool
 {
     $targetID = (int) $dirInfo['directoryid'];
     if (\is_numeric($post['move_destination'])) {
         $destination = (int) $post['move_destination'];
         $newCabin = $this->pg->getCabinForDirectory($destination);
         $newPieces = $this->pg->getDirectoryPieces($destination);
         \array_pop($newPieces);
         $newPieces[] = Util::charWhitelist($post['url'], Util::NON_DIRECTORY);
         $newPath = \implode('/', $newPieces);
     } elseif (!\in_array($post['move_destination'], $cabins)) {
         // Cabin doesn't exist!
         return false;
     } else {
         $newCabin = $post['move_destination'];
         $newPath = Util::charWhitelist($post['url'], Util::NON_DIRECTORY);
     }
     if (!empty($post['create_redirect'])) {
         $old = ['cabin' => $oldCabin, 'path' => \implode('/', $this->pg->getDirectoryPieces($targetID))];
         $new = ['cabin' => $newCabin, 'path' => $newPath];
         $this->pg->createRedirectsForMove($old, $new);
     }
     return $this->pg->moveDir($targetID, $post['url'], $destination ?? 0, $newCabin);
 }