Airship\Cabin\Bridge\Blueprint\CustomPages::getCabinForDirectory PHP Метод

getCabinForDirectory() публичный Метод

Get the cabin assigned to a particular directory
public getCabinForDirectory ( integer $directoryId ) : string
$directoryId integer
Результат string
    public function getCabinForDirectory(int $directoryId) : string
    {
        $cabin = $this->db->cell('SELECT cabin FROM airship_custom_dir WHERE directoryid = ?', $directoryId);
        if (empty($cabin)) {
            return '';
        }
        return $cabin;
    }

Usage Example

Пример #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);
 }