Ejemplo n.º 1
0
 /**
  * Save file to storage
  *
  * @param  array $result
  * @return $this
  */
 protected function _afterSave($result)
 {
     if (empty($result['path']) || empty($result['file'])) {
         return $this;
     }
     if ($this->_coreFileStorage->isInternalStorage() || $this->skipDbProcessing()) {
         return $this;
     }
     $this->_result['file'] = $this->_coreFileStorageDb->saveUploadedFile($result);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Retrieve storage model
  * If storage not defined - retrieve current storage
  *
  * params = array(
  *  connection  => string,  - define connection for model if needed
  *  init        => bool     - force initialization process for storage model
  * )
  *
  * @param  int|null $storage
  * @param  array $params
  * @return AbstractModel|bool
  */
 public function getStorageModel($storage = null, $params = [])
 {
     if (is_null($storage)) {
         $storage = $this->_coreFileStorage->getCurrentStorageCode();
     }
     switch ($storage) {
         case self::STORAGE_MEDIA_FILE_SYSTEM:
             $model = $this->_fileFactory->create();
             break;
         case self::STORAGE_MEDIA_DATABASE:
             $connection = isset($params['connection']) ? $params['connection'] : null;
             $model = $this->_databaseFactory->create(['connectionName' => $connection]);
             break;
         default:
             return false;
     }
     if (isset($params['init']) && $params['init']) {
         $model->init();
     }
     return $model;
 }