-
Notifications
You must be signed in to change notification settings - Fork 11
/
Tags.php
60 lines (56 loc) · 1.71 KB
/
Tags.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Fastly CDN for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Fastly CDN for Magento End User License Agreement
* that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Fastly CDN to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to http://www.magento.com for more information.
*
* @category Fastly
* @package Fastly_CDN
* @copyright Copyright (c) 2015 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/
class Fastly_CDN_Helper_Tags extends Mage_Core_Helper_Abstract
{
const SURROGATE_KEY_PRODUCT_PREFIX = 'PRD';
const SURROGATE_KEY_CATEGORY_PREFIX = 'CAT';
const SURROGATE_KEY_CMSPAGE_PREFIX = 'CMP';
const SURROGATE_KEY_CMSBLOCK_PREFIX = 'CMB';
const SURROGATE_KEY_STORE_PREFIX = 'STO';
const SURROGATE_KEY_HEADER_NAME = 'Surrogate-Key';
/**
* Return cache tag ids
*
* @param $cacheTags
* @param $name
* @return array
*/
public function extractTagIds($cacheTags, $name)
{
$idList = array();
// inspect all tags
foreach ($cacheTags as $cacheTag) {
// name found
if (strpos($cacheTag, $name) !== false) {
// tag is divided by _
$tagParts = explode('_', $cacheTag);
// id is the last part
$id = array_pop($tagParts);
// store id
if (is_numeric($id)) {
$idList[] = $id;
}
}
}
// return list of ids
return $idList;
}
}