Exemple #1
0
 /**
  * @param string $mount
  * @throws Exception
  */
 private function createFileSystem($mount = '')
 {
     $_fs = xapp_get_option(self::FILE_SYSTEM);
     //file system class
     //VFS instance already included
     if (is_object($_fs)) {
         $this->_vfs = $_fs;
     } elseif (is_string($_fs)) {
         //class name of the VFS
         if (class_exists($_fs)) {
             /***
              * prepare file system options
              */
             $fsOptions = xapp_has_option(self::FILE_SYSTEM_CONF) ? xapp_get_option(self::FILE_SYSTEM_CONF) : array();
             if ($fsOptions && is_array($fsOptions)) {
                 //There is no mapping data in the VFS config, but we have a path to the mappings
                 if (!xapp_has_option(XApp_VFS_Base::RESOURCES_DATA, $fsOptions) && xapp_has_option(self::VFS_CONFIG_PATH)) {
                     $vfsMappingPath = xapp_get_option(self::VFS_CONFIG_PATH);
                     if (file_exists($vfsMappingPath)) {
                         $pass = null;
                         if (xapp_has_option(self::VFS_CONFIG_PASSWORD)) {
                             $pass = xapp_get_option(self::VFS_CONFIG_PASSWORD);
                         } else {
                         }
                         $vfsMappingData = (object) XApp_Utils_JSONUtils::read_json($vfsMappingPath, 'json', false, true, null, true, $pass);
                         if ($vfsMappingData) {
                             $fsOptions[XApp_VFS_Base::RESOURCES_DATA] = $vfsMappingData;
                         }
                     }
                 }
             }
             $remoteConfig = null;
             //switch to remove file system if needed
             if (strlen($mount) > 0) {
                 $remoteConfig = XApp_VFS_Local::isRemote($mount, $fsOptions[XApp_VFS_Base::RESOURCES_DATA]);
                 if ($remoteConfig != null) {
                     xapp_import('xapp.VFS.Remote');
                     $_fs = 'XApp_VFS_Remote';
                 } else {
                 }
             }
             $this->_vfs = $_fs::instance($fsOptions);
             $this->_vfs->{'remote'} = $remoteConfig != null;
             if ($remoteConfig) {
                 $this->_vfs->initWithResource($remoteConfig);
             }
         } else {
             throw new Exception('VFS Class doesnt exists : ' . $_fs);
         }
     }
 }