Exemplo n.º 1
0
Arquivo: Model.php Projeto: ytnuk/orm
 public function __construct(array $configuration, Nextras\Orm\Model\IRepositoryLoader $repositoryLoader, Nextras\Orm\Model\MetadataStorage $metadataStorage, Nette\Caching\IStorage $cacheStorage)
 {
     parent::__construct($configuration, $repositoryLoader, $metadataStorage);
     $this->onFlush[] = function () use($cacheStorage) {
         $cacheStorage->clean([Nette\Caching\Cache::TAGS => $this->tags]);
         $this->tags = [];
     };
 }
Exemplo n.º 2
0
 public function success(Form $form)
 {
     $values = $form->getValues();
     if ($values['section'] === 'all') {
         $this->cacheStorage->clean(array(Cache::ALL => true));
         $this->session->destroy();
     } elseif ($values['section'] === 'cache') {
         $this->cacheStorage->clean(array(array(Cache::ALL => true)));
     } elseif ($values['section'] === 'sessions') {
         $this->session->destroy();
     }
 }
Exemplo n.º 3
0
 /**
  * Reads the specified item from the cache or generate it.
  *
  * @param  mixed key
  * @param  callable
  *
  * @return mixed|NULL
  */
 public function load($key, $fallback = null)
 {
     $data = $this->storage->read($this->generateKey($key));
     if ($data === null && $fallback) {
         return $this->save($key, new Nette\Callback($fallback));
     }
     return $data;
 }
Exemplo n.º 4
0
 /**
  * Removes items from the cache by conditions.
  * Conditions are:
  * - Cache::PRIORITY => (int) priority
  * - Cache::TAGS => (array) tags
  * - Cache::ALL => TRUE
  * @return void
  */
 public function clean(array $conditions = NULL)
 {
     $conditions = (array) $conditions;
     if (isset($conditions[self::TAGS])) {
         $conditions[self::TAGS] = array_values((array) $conditions[self::TAGS]);
     }
     $this->storage->clean($conditions);
 }
Exemplo n.º 5
0
 protected function createLatte()
 {
     $latte = new Latte\Engine();
     foreach ($this->helpers as $key => $callback) {
         $latte->addFilter($key, $callback);
     }
     foreach ($this->helperLoaders as $callback) {
         $latte->addFilter(NULL, function ($name) use($callback, $latte) {
             if ($res = call_user_func($callback, $name)) {
                 $latte->addFilter($name, $res);
             }
         });
     }
     if ($this->cacheStorage instanceof Nette\Caching\Storages\PhpFileStorage) {
         $latte->setTempDirectory($this->cacheStorage->getDir());
     }
     return $latte;
 }
Exemplo n.º 6
0
 /**
  * Removes items from the cache by conditions.
  * Conditions are:
  * - Cache::PRIORITY => (int) priority
  * - Cache::TAGS => (array) tags
  * - Cache::ALL => TRUE
  * @return void
  */
 public function clean(array $conditions = NULL)
 {
     $this->release();
     $this->storage->clean((array) $conditions);
 }
Exemplo n.º 7
0
 /**
  * Removes items from the cache by conditions.
  * Conditions are:
  * - Cache::PRIORITY => (int) priority
  * - Cache::TAGS => (array) tags
  * - Cache::ALL => TRUE
  * @return void
  */
 public function clean(array $conditions = NULL)
 {
     $this->key = $this->data = NULL;
     $this->storage->clean((array) $conditions);
 }
 /**
  * @param \l10n\Translator\Translator $translator
  */
 public function save(Translator $translator)
 {
     $language = $this->getLanguage();
     $this->storage->write($language->getIso639_1(), ['translated' => $translator->getTranslated(), 'untranslated' => $translator->getUntranslated()], []);
 }