Skip to content

Commit

Permalink
Merge pull request nette#607 from HosipLan/feature/cache-wrap-accepts…
Browse files Browse the repository at this point in the history
…-dps

Cache::wrap() accepts dependencies
  • Loading branch information
dg committed Mar 30, 2012
2 parents a94c8fc + c49fdee commit 4b9c9d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Nette/Caching/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,17 @@ public function call($function)
/**
* Caches results of function/method calls.
* @param mixed
* @param array dependencies
* @return Closure
*/
public function wrap($function)
public function wrap($function, array $dp = NULL)
{
$cache = $this;
return function() use ($cache, $function) {
return function() use ($cache, $function, $dp) {
$key = array($function, func_get_args());
$data = $cache->load($key);
if ($data === NULL) {
$data = $cache->save($key, callback($function)->invokeArgs($key[1]));
$data = $cache->save($key, callback($function)->invokeArgs($key[1]), $dp);
}
return $data;
};
Expand Down

0 comments on commit 4b9c9d7

Please sign in to comment.