Esempio n. 1
0
    $success = false;
}
if ($success) {
    echo "Success! Identifier: {$ret->getIdentifier()}\n";
} else {
    echo "Failure...\n";
}
unset($ret);
echo "    Add To Folder Identity Path (data5, grandchild2) -- \n";
$success = true;
$granchild2 = null;
try {
    echo "        Instantiate grandchild2 -> ";
    $grandchild2 = new File\Folder('data5', 'grandchild2');
    echo "Success!\n";
    echo "        Add to Path (topFolder/childFolder2) -> ";
    File\Folder::addToFolderIdentityPath($top, 'topFolder/childFolder2', $grandchild2, $grandchild2->getIdentifier());
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success!\n\n";
} else {
    echo "Failure...\n\n";
}
$paths = File\Folder::getFolderIdentityPaths($top);
echo "Paths: \n";
foreach ($paths as $path) {
    echo "    {$path}\n";
}
echo "\n";
Esempio n. 2
0
 /**
  * Get Module Paths
  * 
  * This returns a list of all terminating paths
  * 
  * Ex:
  * 
  * [] Module1/Module2/Module3
  * [] Module1/Module4
  * [] Module1/Module5/Module6/Module7
  * 
  * @param Falcraft\Data\Components\File\Resource\DirectoryInterface $rootModule The Module to start at
  * @param $ModulePath A recursive function argument, don't use
  * 
  */
 public static function getModuleIdentityPaths(LoaderResource\ModuleInterface $rootModule, $modulePath = '')
 {
     return File\Folder::getFolderIdentityPaths($rootModule, $modulePath);
 }
Esempio n. 3
0
 /**
  * Get Folder Paths
  * 
  * This returns a list of all terminating paths
  * 
  * Ex:
  * 
  * [] CDirectory1/CDirectory2/CDirectory3
  * [] CDirectory1/CDirectory4
  * [] CDirectory1/CDirectory5/CDirectory6/CDirectory7
  * 
  * @param Falcraft\Data\Components\File\Resource\FolderInterface
  *              $root The CDirectory to start at
  * @param $path A recursive function argument, don't use
  * 
  */
 public static function getFolderIdentityPaths(FileResource\FolderInterface $root, $path = '')
 {
     static $paths;
     if ($path) {
         if (!$root->getFolders()) {
             $paths[] = $path;
             return true;
         }
         foreach ($root->getFolders() as $folderName => $folderValue) {
             if (Folder::getFolderIdentityPaths($folderValue, $path . '/' . $folderName)) {
                 return true;
             }
         }
         return false;
     } else {
         $paths = array();
         foreach ($root->getFolders() as $folderKey => $folderValue) {
             Folder::getFolderIdentityPaths($folderValue, $folderKey);
         }
         for ($a = 0; $a < count($paths); $a++) {
             $paths[$a] = $root->getIdentifier() . '/' . $paths[$a];
         }
         return $paths;
     }
 }