src/migrations/m190131_214300_cleanup_config.php
private function _convertVolumes()
    {
        $projectConfig = Craft::$app->getProjectConfig();

        $schemaVersion = $projectConfig->get('plugins.aws-s3.schemaVersion', true);
        $projectConfig->muteEvents = true;

        $volumes = $projectConfig->get(Volumes::CONFIG_VOLUME_KEY, true) ?? [];

        foreach ($volumes as $uid => &$volume) {
            if ($volume['type'] === Volume::class && !empty($volume['settings']) && is_array($volume['settings']) && array_key_exists('urlPrefix', $volume['settings'])) {
                $settings = $volume['settings'];

                $hasUrls = !empty($volume['hasUrls']);
                $url = ($hasUrls && !empty($settings['urlPrefix'])) ? $settings['urlPrefix'] : null;
                //$settings['region'] = $settings['location'];
                unset($settings['urlPrefix'], $settings['location'], $settings['storageClass']);

                $volume['url'] = $url;
                $volume['settings'] = $settings;

                $this->update('{{%volumes}}', [
                    'settings' => Json::encode($settings),
                    'url' => $url,
                ], ['uid' => $uid]);

                // If project config schema up to date, don't update project config
                if (!version_compare($schemaVersion, '1.1', '>=')) {
                    $projectConfig->set(Volumes::CONFIG_VOLUME_KEY . '.' . $uid, $volume);
                }
            }
        }

        $projectConfig->muteEvents = false;
    }
private function _convertVolumes()
    {
        $projectConfig = Craft::$app->getProjectConfig();

        $schemaVersion = $projectConfig->get('plugins.aws-s3.schemaVersion', true);
        $projectConfig->muteEvents = true;

        $volumes = $projectConfig->get(Volumes::CONFIG_VOLUME_KEY, true) ?? [];

        foreach ($volumes as $uid => &$volume) {
            if ($volume['type'] === Volume::class && !empty($volume['settings']) && is_array($volume['settings']) && array_key_exists('urlPrefix', $volume['settings'])) {
                $settings = $volume['settings'];

                $hasUrls = !empty($volume['hasUrls']);
                $url = ($hasUrls && !empty($settings['urlPrefix'])) ? $settings['urlPrefix'] : null;
                //$settings['region'] = $settings['location'];
                unset($settings['urlPrefix'], $settings['location'], $settings['storageClass']);

                $volume['url'] = $url;
                $volume['settings'] = $settings;

                $this->update('{{%volumes}}', [
                    'settings' => Json::encode($settings),
                    'url' => $url,
                ], ['uid' => $uid]);

                // If project config schema up to date, don't update project config
                if (!version_compare($schemaVersion, '1.1', '>=')) {
                    $projectConfig->set(Volumes::CONFIG_VOLUME_KEY . '.' . $uid, $volume);
                }
            }
        }

        $projectConfig->muteEvents = false;
    }
private function _convertVolumes ( ) { $ projectConfig = Craft :: $ app -> getProjectConfig ( ) ; $ schemaVersion = $ projectConfig -> get ( 'plugins.aws-s3.schemaVersion' , true ) ; $ projectConfig -> muteEvents = true ; $ volumes = $ projectConfig -> get ( Volumes :: CONFIG_VOLUME_KEY , true ) ?? [ ] ; foreach ( $ volumes as $ uid => & $ volume ) { if ( $ volume [ 'type' ] === Volume :: class && ! empty ( $ volume [ 'settings' ] ) && is_array ( $ volume [ 'settings' ] ) && array_key_exists ( 'urlPrefix' , $ volume [ 'settings' ] ) ) { $ settings = $ volume [ 'settings' ] ; $ hasUrls = ! empty ( $ volume [ 'hasUrls' ] ) ; $ url = ( $ hasUrls && ! empty ( $ settings [ 'urlPrefix' ] ) ) ? $ settings [ 'urlPrefix' ] : null ; //$settings['region'] = $settings['location']; unset ( $ settings [ 'urlPrefix' ] , $ settings [ 'location' ] , $ settings [ 'storageClass' ] ) ; $ volume [ 'url' ] = $ url ; $ volume [ 'settings' ] = $ settings ; $ this -> update ( '{{%volumes}}' , [ 'settings' => Json :: encode ( $ settings ) , 'url' => $ url , ] , [ 'uid' => $ uid ] ) ; // If project config schema up to date, don't update project config if ( ! version_compare ( $ schemaVersion , '1.1' , '>=' ) ) { $ projectConfig -> set ( Volumes :: CONFIG_VOLUME_KEY . '.' . $ uid , $ volume ) ; } } } $ projectConfig -> muteEvents = false ; }
Converts any old school S3 volumes to this one

@return void
Converts any old school S3 volumes to this one