Esempio n. 1
0
$ret = null;
try {
    $ret = File\Folder::dataBelongsTo('data2', $top);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success! Identifier: {$ret}\n";
} else {
    echo "Failure...\n";
}
echo "    Retrieve Using Data (data4) -> ";
$success = true;
$ret = null;
try {
    $ret = File\Folder::dataBelongsTo('data4', $top);
} catch (\Exception $e) {
    $success = false;
}
if ($success) {
    echo "Success! Identifier: {$ret}\n";
} else {
    echo "Failure...\n";
}
echo "    Get From Path (topFolder/childFolder2) -> ";
$success = true;
unset($ret);
$ret = null;
try {
    $ret = File\Folder::getFromFolderIdentityPath($top, 'topFolder/childFolder2');
} catch (\Exception $e) {
Esempio n. 2
0
 /**
  * Returns a Module path that contains the path
  * 
  * Okay, this returns a Module path to the Module that contains the associated path
  * 
  * @param $path The path to find (NOT Modulepath)
  * @param Falcraft\Data\Components\File\Resource\DirectoryInterface $rootModule - The root of the Module
  * @param string $ModuleKey Recursive function argument, don't use
  * @param Falcraft\Data\Components\File\Resource\DirectoryInterface $Module Recursive function argument, don't use
  * 
  */
 public static function pathBelongsTo($path, LoaderResource\ModuleInterface $rootModule, $moduleKey = '', $module = null)
 {
     return File\Folder::dataBelongsTo($path, $rootModule, $moduleKey, $module);
 }
Esempio n. 3
0
 /**
  * Returns a folder path that contains the data
  * 
  * NOTE: Only returns the first instance it finds
  * 
  * Okay, this returns a folder path to the folder that contains the
  * associated data
  * 
  * @param $data The data to find (NOT CDirectorypath)
  * @param Falcraft\Data\Components\File\Resource\DirectoryInterface
  *              $root The root of the CDirectory
  * @param string $recurseKey Recursive function argument, don't use
  * @param Falcraft\Data\Components\File\Resource\FolderInterface
  *              $recurseFolder Recursive function argument, don't use
  * 
  */
 public static function dataBelongsTo($data, FileResource\FolderInterface $root, $recurseKey = '', $recurseFolder = null)
 {
     static $folderNames;
     if ($recurseFolder) {
         if ($recurseFolder->isData($data)) {
             $folderNames = $recurseKey;
             return true;
         }
         foreach ($recurseFolder->getFolders() as $folderName => $folderValue) {
             if (Folder::dataBelongsTo($data, $root, $folderName, $folderValue)) {
                 $folderNames = $recurseKey . '/' . $folderNames;
                 return true;
             }
         }
         return false;
     } else {
         $folderNames = '';
         foreach ($root->getFolders() as $folderKey => $folderValue) {
             Folder::dataBelongsTo($data, $root, $folderKey, $folderValue);
         }
         $folderNames = $root->getIdentifier() . '/' . $folderNames;
         return $folderNames;
     }
 }