/**
  * Constructor for a storage object.
  *
  * @param Driver\DriverInterface $driver
  * @param array $storageRecord The storage record row from the database
  */
 public function __construct(Driver\DriverInterface $driver, array $storageRecord)
 {
     $this->storageRecord = $storageRecord;
     $this->configuration = ResourceFactory::getInstance()->convertFlexFormDataToConfigurationArray($storageRecord['configuration']);
     $this->capabilities = ($this->storageRecord['is_browsable'] ? self::CAPABILITY_BROWSABLE : 0) | ($this->storageRecord['is_public'] ? self::CAPABILITY_PUBLIC : 0) | ($this->storageRecord['is_writable'] ? self::CAPABILITY_WRITABLE : 0);
     $this->driver = $driver;
     $this->driver->setStorageUid($storageRecord['uid']);
     $this->driver->mergeConfigurationCapabilities($this->capabilities);
     try {
         $this->driver->processConfiguration();
     } catch (Exception\InvalidConfigurationException $e) {
         // configuration error
         // mark this storage as permanently unusable
         $this->markAsPermanentlyOffline();
     }
     $this->driver->initialize();
     $this->capabilities = $this->driver->getCapabilities();
     $this->isDefault = isset($storageRecord['is_default']) && $storageRecord['is_default'] == 1;
     $this->resetFileAndFolderNameFiltersToDefault();
 }
Esempio n. 2
0
 /**
  * Constructor for a storage object.
  *
  * @param Driver\DriverInterface $driver
  * @param array $storageRecord The storage record row from the database
  */
 public function __construct(Driver\DriverInterface $driver, array $storageRecord)
 {
     $this->storageRecord = $storageRecord;
     $this->configuration = ResourceFactory::getInstance()->convertFlexFormDataToConfigurationArray($storageRecord['configuration']);
     $this->capabilities = ($this->storageRecord['is_browsable'] ? self::CAPABILITY_BROWSABLE : 0) | ($this->storageRecord['is_public'] ? self::CAPABILITY_PUBLIC : 0) | ($this->storageRecord['is_writable'] ? self::CAPABILITY_WRITABLE : 0);
     $this->driver = $driver;
     $this->driver->setStorageUid($storageRecord['uid']);
     $this->driver->mergeConfigurationCapabilities($this->capabilities);
     try {
         $this->driver->processConfiguration();
     } catch (Exception\InvalidConfigurationException $e) {
         // Configuration error
         $this->isOnline = false;
         $message = sprintf('Failed initializing storage [%d] "%s", error: %s', $this->getUid(), $this->getName(), $e->getMessage());
         $this->getLogger()->error($message);
     }
     $this->driver->initialize();
     $this->capabilities = $this->driver->getCapabilities();
     $this->isDefault = isset($storageRecord['is_default']) && $storageRecord['is_default'] == 1;
     $this->resetFileAndFolderNameFiltersToDefault();
 }