示例#1
0
 public function beforeCreateFile($uri, $data)
 {
     list($dir, $name) = \Sabre\DAV\URLUtil::splitPath($uri);
     $currentNode = null;
     foreach (explode('/', trim($dir, '/')) as $pathPart) {
         $parentNode = $currentNode;
         $currentNode = \SiteCollection::getByHandle($pathPart, $parentNode ? $parentNode->ID : null);
         if (!$currentNode) {
             $currentNode = \SiteCollection::create($pathPart, $parentNode);
         }
     }
 }
 public static function getCollectionLayers($path, $localOnly = false)
 {
     // split path into array
     if (is_string($path)) {
         $path = Site::splitPath($path);
     }
     // resolve local and remote collections
     $rootHandle = array_shift($path);
     $localCollection = SiteCollection::getByHandle($rootHandle, null, false);
     if (!$localOnly) {
         $remoteCollection = SiteCollection::getByHandle($rootHandle, null, true);
     }
     while ($handle = array_shift($path)) {
         if ($localCollection) {
             $localCollection = SiteCollection::getByHandle($handle, $localCollection->ID, false);
         }
         if ($remoteCollection) {
             $remoteCollection = SiteCollection::getByHandle($handle, $remoteCollection->ID, true);
         }
     }
     return array_filter(array('remote' => $remoteCollection, 'local' => $localCollection));
 }