protected function getHierarchyKey($key, &$pathKey = null)
{
if (!$this->isHierarchyKey($key)) {
return $key;
}
$key = $this->explodeKey($key);
$keyString = '';
// The comments below is for a $key = ["foo!tagHash", "bar!tagHash"]
foreach ($key as $name) {
// 1) $keyString = "foo!tagHash"
// 2) $keyString = "foo!tagHash![foo_index]!bar!tagHash"
$keyString .= $name;
$pathKey = sha1('path' . TaggablePoolInterface::TAG_SEPARATOR . $keyString);
if (isset($this->keyCache[$pathKey])) {
$index = $this->keyCache[$pathKey];
} else {
$index = $this->getValueFormStore($pathKey);
$this->keyCache[$pathKey] = $index;
}
// 1) $keyString = "foo!tagHash![foo_index]!"
// 2) $keyString = "foo!tagHash![foo_index]!bar!tagHash![bar_index]!"
$keyString .= TaggablePoolInterface::TAG_SEPARATOR . $index . TaggablePoolInterface::TAG_SEPARATOR;
}
// Assert: $pathKey = "path!foo!tagHash![foo_index]!bar!tagHash"
// Assert: $keyString = "foo!tagHash![foo_index]!bar!tagHash![bar_index]!"
// Make sure we do not get awfully long (>250 chars) keys
return sha1($keyString);
}