2023-06-05 11:23:16 +00:00
|
|
|
<?php
|
2023-12-08 23:23:32 +00:00
|
|
|
/**
|
|
|
|
* File: CdnEngine.php
|
|
|
|
*
|
|
|
|
* @package W3TC
|
|
|
|
*/
|
|
|
|
|
2023-06-05 11:23:16 +00:00
|
|
|
namespace W3TC;
|
|
|
|
|
|
|
|
/**
|
2023-12-08 23:23:32 +00:00
|
|
|
* Class: CdnEngine
|
2023-06-05 11:23:16 +00:00
|
|
|
*/
|
|
|
|
class CdnEngine {
|
|
|
|
/**
|
2023-12-08 23:23:32 +00:00
|
|
|
* Returns CdnEngine_Base instance.
|
2023-06-05 11:23:16 +00:00
|
|
|
*
|
2023-12-08 23:23:32 +00:00
|
|
|
* @param string $engine CDN engine.
|
|
|
|
* @param array $config Configuration.
|
2023-06-05 11:23:16 +00:00
|
|
|
* @return CdnEngine_Base
|
|
|
|
*/
|
2023-12-08 23:23:32 +00:00
|
|
|
public static function instance( $engine, array $config = array() ) {
|
2023-06-05 11:23:16 +00:00
|
|
|
static $instances = array();
|
2023-12-08 23:23:32 +00:00
|
|
|
$instance_key = sprintf( '%s_%s', $engine, md5( serialize( $config ) ) );
|
2023-06-05 11:23:16 +00:00
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
if ( ! isset( $instances[ $instance_key ] ) ) {
|
2023-06-05 11:23:16 +00:00
|
|
|
switch ( $engine ) {
|
2023-12-08 23:23:32 +00:00
|
|
|
case 'akamai':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_Akamai( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'att':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_Att( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'azure':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Azure( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bunnycdn':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_BunnyCdn( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'cf':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_CloudFront( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'cf2':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_CloudFront( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'cotendo':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_Cotendo( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'edgecast':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_Edgecast( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'ftp':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Ftp( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'google_drive':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_GoogleDrive( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'highwinds':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_Highwinds( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'limelight':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_LimeLight( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'mirror':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'rackspace_cdn':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_RackSpaceCdn( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'rscf':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_RackSpaceCloudFiles( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's3':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_S3( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's3_compatible':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_S3_Compatible( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'stackpath':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_StackPath( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'stackpath2':
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Mirror_StackPath2( $config );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
empty( $engine ) || trigger_error( 'Incorrect CDN engine', E_USER_WARNING );
|
|
|
|
|
|
|
|
$instances[ $instance_key ] = new CdnEngine_Base();
|
|
|
|
break;
|
2023-06-05 11:23:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-08 23:23:32 +00:00
|
|
|
return $instances[ $instance_key ];
|
2023-06-05 11:23:16 +00:00
|
|
|
}
|
|
|
|
}
|