Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

  • Cache
  • OutputHelper

Interfaces

  • IStorage
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Caching;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * Output caching helper.
15:  *
16:  * @author     David Grudl
17:  */
18: class OutputHelper extends Nette\Object
19: {
20:     /** @var array */
21:     public $dependencies;
22: 
23:     /** @var Cache */
24:     private $cache;
25: 
26:     /** @var string */
27:     private $key;
28: 
29: 
30:     public function __construct(Cache $cache, $key)
31:     {
32:         $this->cache = $cache;
33:         $this->key = $key;
34:         ob_start();
35:     }
36: 
37: 
38:     /**
39:      * Stops and saves the cache.
40:      * @param  array  dependencies
41:      * @return void
42:      */
43:     public function end(array $dependencies = NULL)
44:     {
45:         if ($this->cache === NULL) {
46:             throw new Nette\InvalidStateException('Output cache has already been saved.');
47:         }
48:         $this->cache->save($this->key, ob_get_flush(), (array) $dependencies + (array) $this->dependencies);
49:         $this->cache = NULL;
50:     }
51: 
52: }
53: 
Nette 2.0 API documentation generated by ApiGen 2.8.0