You are here

private function FileCacheReader::saveCacheFile in Plug 7

Saves the cache file.

Parameters

string $path:

mixed $data:

Return value

void

3 calls to FileCacheReader::saveCacheFile()
FileCacheReader::getClassAnnotations in lib/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php
Gets the annotations applied to a class.
FileCacheReader::getMethodAnnotations in lib/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php
Gets the annotations applied to a method.
FileCacheReader::getPropertyAnnotations in lib/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php
Gets the annotations applied to a property.

File

lib/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php, line 191

Class

FileCacheReader
File cache reader for annotations.

Namespace

Doctrine\Common\Annotations

Code

private function saveCacheFile($path, $data) {
  if (!is_writable($this->dir)) {
    throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $this->dir));
  }
  $tempfile = tempnam($this->dir, uniqid('', true));
  if (false === $tempfile) {
    throw new \RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
  }
  $written = file_put_contents($tempfile, '<?php return unserialize(' . var_export(serialize($data), true) . ');');
  if (false === $written) {
    throw new \RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
  }
  if (false === rename($tempfile, $path)) {
    @unlink($tempfile);
    throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
  }
  @chmod($path, 0666 & ~umask());
}