/**
  * {@inheritdoc}
  */
 public static function setConfig($id, $config)
 {
     $rosConfig = OpenStackConfig::find($id);
     $pathConfig = FilePublicPath::find($id);
     $configPath = ['public_path' => ArrayUtils::get($config, 'public_path'), 'container' => ArrayUtils::get($config, 'container')];
     $configRos = ['service_id' => ArrayUtils::get($config, 'service_id'), 'username' => ArrayUtils::get($config, 'username'), 'password' => ArrayUtils::get($config, 'password'), 'tenant_name' => ArrayUtils::get($config, 'tenant_name'), 'api_key' => ArrayUtils::get($config, 'api_key'), 'url' => ArrayUtils::get($config, 'url'), 'region' => ArrayUtils::get($config, 'region'), 'storage_type' => ArrayUtils::get($config, 'storage_type')];
     ArrayUtils::removeNull($configRos);
     ArrayUtils::removeNull($configPath);
     if (!empty($rosConfig)) {
         $rosConfig->update($configRos);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configRos = array_reverse($configRos, true);
         $configRos['service_id'] = $id;
         $configRos = array_reverse($configRos, true);
         OpenStackConfig::create($configRos);
     }
     if (!empty($pathConfig)) {
         $pathConfig->update($configPath);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configPath = array_reverse($configPath, true);
         $configPath['service_id'] = $id;
         $configPath = array_reverse($configPath, true);
         FilePublicPath::create($configPath);
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public static function setConfig($id, $config)
 {
     $azureConfig = AzureConfig::find($id);
     $pathConfig = FilePublicPath::find($id);
     $configPath = ['public_path' => ArrayUtils::get($config, 'public_path'), 'container' => ArrayUtils::get($config, 'container')];
     $configAzure = ['service_id' => ArrayUtils::get($config, 'service_id'), 'account_name' => ArrayUtils::get($config, 'account_name'), 'account_key' => ArrayUtils::get($config, 'account_key'), 'protocol' => ArrayUtils::get($config, 'protocol')];
     ArrayUtils::removeNull($configAzure);
     ArrayUtils::removeNull($configPath);
     if (!empty($azureConfig)) {
         $azureConfig->update($configAzure);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configAzure = array_reverse($configAzure, true);
         $configAzure['service_id'] = $id;
         $configAzure = array_reverse($configAzure, true);
         AzureConfig::create($configAzure);
     }
     if (!empty($pathConfig)) {
         $pathConfig->update($configPath);
     } else {
         //Making sure service_id is the first item in the config.
         //This way service_id will be set first and is available
         //for use right away. This helps setting an auto-generated
         //field that may depend on parent data. See OAuthConfig->setAttribute.
         $configPath = array_reverse($configPath, true);
         $configPath['service_id'] = $id;
         $configPath = array_reverse($configPath, true);
         FilePublicPath::create($configPath);
     }
 }