/** * Gets the cache key to use for this object * * @return string cache key */ public function GetCacheKey() { return GitPHP_Tree::CacheKey($this->project->GetProject(), $this->hash); }
/** * Gets a tree * * @param string $hash tree hash * @return GitPHP_Tree tree object */ public function GetTree($hash) { if (empty($hash)) { return null; } if (preg_match('/^[0-9A-Fa-f]{4,39}$/', $hash) && !$this->compat) { $fullHash = $this->project->ExpandHash($hash); if ($fullHash == $hash) { throw new GitPHP_InvalidHashException($hash); } $hash = $fullHash; } if (!preg_match('/^[0-9A-Fa-f]{40}$/', $hash)) { return null; } $key = GitPHP_Tree::CacheKey($this->project->GetProject(), $hash); $tree = null; if ($this->memoryCache) { $tree = $this->memoryCache->Get($key); } if (!$tree) { if ($this->cache) { $tree = $this->cache->Get($key); } $strategy = null; if ($this->compat) { $strategy = new GitPHP_TreeLoad_Git($this->exe); } else { $strategy = new GitPHP_TreeLoad_Raw($this->objectLoader, $this->exe); } if ($tree) { $tree->SetProject($this->project); $tree->SetStrategy($strategy); } else { $tree = new GitPHP_Tree($this->project, $hash, $strategy); } $tree->AddObserver($this); if ($this->memoryCache) { $this->memoryCache->Set($key, $tree); } } return $tree; }