Skip to content

Commit 60281ab

Browse files
committed
Cache::start() renamed to capture()
1 parent 5ffe263 commit 60281ab

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/Caching/Cache.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function wrap(callable $function, array $dependencies = null): \Closure
303303
* Starts the output cache.
304304
* @param mixed $key
305305
*/
306-
public function start($key): ?OutputHelper
306+
public function capture($key): ?OutputHelper
307307
{
308308
$data = $this->load($key);
309309
if ($data === null) {
@@ -314,6 +314,15 @@ public function start($key): ?OutputHelper
314314
}
315315

316316

317+
/**
318+
* @deprecated use capture()
319+
*/
320+
public function start($key): ?OutputHelper
321+
{
322+
return $this->capture($key);
323+
}
324+
325+
317326
/**
318327
* Generates internal cache key.
319328
*/

tests/Storages/FileStorage.start.phpt renamed to tests/Storages/FileStorage.capture.phpt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* Test: Nette\Caching\Storages\FileStorage start().
4+
* Test: Nette\Caching\Storages\FileStorage capture().
55
*/
66

77
declare(strict_types=1);
@@ -18,27 +18,27 @@ $cache = new Cache(new FileStorage(getTempDir()));
1818

1919

2020
ob_start();
21-
$block = $cache->start('key');
22-
Assert::type(Nette\Caching\OutputHelper::class, $block);
21+
$capture = $cache->capture('key');
22+
Assert::type(Nette\Caching\OutputHelper::class, $capture);
2323
echo 'Hello';
24-
$block->end();
24+
$capture->end();
2525
Assert::same('Hello', ob_get_clean());
2626

2727

2828
Assert::same('Hello', $cache->load('key'));
2929

3030

3131
ob_start();
32-
Assert::null($cache->start('key'));
32+
Assert::null($cache->capture('key'));
3333
Assert::same('Hello', ob_get_clean());
3434

3535

3636

3737
ob_start();
38-
$block = $cache->start('key2');
39-
Assert::type(Nette\Caching\OutputHelper::class, $block);
38+
$capture = $cache->capture('key2');
39+
Assert::type(Nette\Caching\OutputHelper::class, $capture);
4040
echo 'Hello';
41-
$block->rollback();
41+
$capture->rollback();
4242
Assert::same('Hello', ob_get_clean());
4343

4444
Assert::same(null, $cache->load('key2'));

0 commit comments

Comments
 (0)