diff --git a/src/Caching/Cache.php b/src/Caching/Cache.php index 8566022b..1c58100e 100644 --- a/src/Caching/Cache.php +++ b/src/Caching/Cache.php @@ -303,7 +303,7 @@ public function wrap(callable $function, array $dependencies = null): \Closure * Starts the output cache. * @param mixed $key */ - public function start($key): ?OutputHelper + public function capture($key): ?OutputHelper { $data = $this->load($key); if ($data === null) { @@ -314,6 +314,15 @@ public function start($key): ?OutputHelper } + /** + * @deprecated use capture() + */ + public function start($key): ?OutputHelper + { + return $this->capture($key); + } + + /** * Generates internal cache key. */ diff --git a/tests/Storages/FileStorage.start.phpt b/tests/Storages/FileStorage.capture.phpt similarity index 60% rename from tests/Storages/FileStorage.start.phpt rename to tests/Storages/FileStorage.capture.phpt index 46a783cf..9f91d247 100644 --- a/tests/Storages/FileStorage.start.phpt +++ b/tests/Storages/FileStorage.capture.phpt @@ -1,7 +1,7 @@ start('key'); -Assert::type(Nette\Caching\OutputHelper::class, $block); +$capture = $cache->capture('key'); +Assert::type(Nette\Caching\OutputHelper::class, $capture); echo 'Hello'; -$block->end(); +$capture->end(); Assert::same('Hello', ob_get_clean()); @@ -29,16 +29,16 @@ Assert::same('Hello', $cache->load('key')); ob_start(); -Assert::null($cache->start('key')); +Assert::null($cache->capture('key')); Assert::same('Hello', ob_get_clean()); ob_start(); -$block = $cache->start('key2'); -Assert::type(Nette\Caching\OutputHelper::class, $block); +$capture = $cache->capture('key2'); +Assert::type(Nette\Caching\OutputHelper::class, $capture); echo 'Hello'; -$block->rollback(); +$capture->rollback(); Assert::same('Hello', ob_get_clean()); Assert::same(null, $cache->load('key2'));