You are here

private function FileCacheReader::saveCacheFile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php \Doctrine\Common\Annotations\FileCacheReader::saveCacheFile()

Saves the cache file.

Parameters

string $path:

mixed $data:

Return value

void

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

File

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

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));
  }
  @chmod($tempfile, 0666 & ~$this->umask);
  if (false === rename($tempfile, $path)) {
    @unlink($tempfile);
    throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
  }
}