Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CacheContext.php
Go to the documentation of this file.
1 <?php
7 
11 class CacheContext implements \Magento\Framework\DataObject\IdentityInterface
12 {
16  protected $entities = [];
17 
21  private $tags = [];
22 
30  public function registerEntities($cacheTag, $ids)
31  {
32  $this->entities[$cacheTag] = array_merge($this->getRegisteredEntity($cacheTag), $ids);
33  return $this;
34  }
35 
42  public function registerTags($cacheTags)
43  {
44  $this->tags = array_merge($this->tags, $cacheTags);
45  return $this;
46  }
47 
54  public function getRegisteredEntity($cacheTag)
55  {
56  if (empty($this->entities[$cacheTag])) {
57  return [];
58  } else {
59  return $this->entities[$cacheTag];
60  }
61  }
62 
68  public function getIdentities()
69  {
70  $identities = [];
71  foreach ($this->entities as $cacheTag => $ids) {
72  foreach ($ids as $id) {
73  $identities[] = $cacheTag . '_' . $id;
74  }
75  }
76  return array_merge($identities, array_unique($this->tags));
77  }
78 }
$id
Definition: fieldset.phtml:14