本文整理汇总了PHP中S3::listDistributions方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::listDistributions方法的具体用法?PHP S3::listDistributions怎么用?PHP S3::listDistributions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类S3
的用法示例。
在下文中一共展示了S3::listDistributions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_listDistributions
function test_listDistributions()
{
if (($dists = S3::listDistributions()) !== false) {
if (sizeof($dists) == 0) {
echo "listDistributions(): No distributions\n";
}
foreach ($dists as $dist) {
var_dump($dist);
}
} else {
echo "listDistributions(): Failed to get distribution list\n";
}
}
示例2: invalidateCloudfrontPosts
/**
* Invalidates all cloudfront paths stored in `$pathsToInvalidate`. Needs to
* invalidate everything in a single batch request otherwise cloudfront limits
* are hit (3 active invalidation requests per distribution)
*
* Called on each wp_redirect since that's the only way to capture multiple
* delete calls in a single request (i.e., through the bulk actions)
*
* @param integer $postId The original post ID
*/
function invalidateCloudfrontPosts($url)
{
if (empty($pathsToInvalidate)) {
return $url;
}
$s3Key = get_option('s3_access_key');
$s3KeySecret = get_option('s3_access_secret');
$S3 = new S3($s3Key, $s3KeySecret);
// invalidate cloudfront cache (if applicable)
$downloadDomain = get_option('s3_download');
if (!empty($downloadDomain)) {
$distributions = $S3->listDistributions();
// get matching distribution id
foreach ($distributions as $distributionId => $distributionDetails) {
if ($distributionDetails['domain'] === $downloadDomain) {
$S3->invalidateDistribution($distributionId, $this->pathsToInvalidate);
break;
}
}
}
return $url;
}