Object/provider/FileSystemCache.php
public function save(CacheCollection $collection)
    {
        $directory = $this->cacheDir . $this->prefix;
        $dir = is_dir($directory);
        $read = is_readable($directory);
        $write = is_writable($directory);
        
        if ($dir && $read && $write) {
            if ($this->exist($collection->getId()) && ! $this->accessible($collection->getId())) {
                
                $read = $this->readable($collection->getId());
                $write = $this->writable($collection->getId());
                
                if ($read && ! $write) {
                    throw new AccessDeniedException(sprintf("The file %s is on read only state", $this->getPath($collection->getId())), 403);
                } else if (! $read && ! $write) {
                    throw new AccessDeniedException(sprintf("The file %s cannot be read or write", $this->getPath($collection->getId())), 403);
                }
            }
            
            $collection->setTimestampOffset($this->timestamp);
            $data = $collection->serialize();
            $result = file_put_contents($this->getPath($collection->getId()), $data);
            
            if ($result === false) {
                throw new FileException(sprintf("A failure occured during writing file %s", $this->getPath($collection->getId())), 500);
            } else if ($result !== strlen($data)) {
                throw new FileException(sprintf("An error occured during writing file %s. Writed %d bytes, expect %d", $this->getPath($collection->getId()), $result, strlen($data)), 500);
            }
        } else {
            if (! $dir) {
                
                if (! mkdir($directory, 0775, true)) {
                    throw new DirectoryException(sprintf("The %s directory does not exist", $directory), 500);
                } else {
                    
                    if (!chmod($directory, 0775)) {
                        throw new DirectoryException(sprintf("The %s directory present permission error", $directory), 500);
                    }
                    
                    $this->save($collection);
                }
            } else if ($read && ! $write) {
                throw new AccessDeniedException(sprintf("The directory %s is on read only state", $directory), 403);
            } else if (! $read && ! $write) {
                throw new AccessDeniedException(sprintf("The directory %s cannot be read or write", $directory), 403);
            } else {
                throw new AccessDeniedException(sprintf("The directory %s cannot be read", $directory), 403);
            }
        }
    }
public function save(CacheCollection $collection)
    {
        $directory = $this->cacheDir . $this->prefix;
        $dir = is_dir($directory);
        $read = is_readable($directory);
        $write = is_writable($directory);
        
        if ($dir && $read && $write) {
            if ($this->exist($collection->getId()) && ! $this->accessible($collection->getId())) {
                
                $read = $this->readable($collection->getId());
                $write = $this->writable($collection->getId());
                
                if ($read && ! $write) {
                    throw new AccessDeniedException(sprintf("The file %s is on read only state", $this->getPath($collection->getId())), 403);
                } else if (! $read && ! $write) {
                    throw new AccessDeniedException(sprintf("The file %s cannot be read or write", $this->getPath($collection->getId())), 403);
                }
            }
            
            $collection->setTimestampOffset($this->timestamp);
            $data = $collection->serialize();
            $result = file_put_contents($this->getPath($collection->getId()), $data);
            
            if ($result === false) {
                throw new FileException(sprintf("A failure occured during writing file %s", $this->getPath($collection->getId())), 500);
            } else if ($result !== strlen($data)) {
                throw new FileException(sprintf("An error occured during writing file %s. Writed %d bytes, expect %d", $this->getPath($collection->getId()), $result, strlen($data)), 500);
            }
        } else {
            if (! $dir) {
                
                if (! mkdir($directory, 0775, true)) {
                    throw new DirectoryException(sprintf("The %s directory does not exist", $directory), 500);
                } else {
                    
                    if (!chmod($directory, 0775)) {
                        throw new DirectoryException(sprintf("The %s directory present permission error", $directory), 500);
                    }
                    
                    $this->save($collection);
                }
            } else if ($read && ! $write) {
                throw new AccessDeniedException(sprintf("The directory %s is on read only state", $directory), 403);
            } else if (! $read && ! $write) {
                throw new AccessDeniedException(sprintf("The directory %s cannot be read or write", $directory), 403);
            } else {
                throw new AccessDeniedException(sprintf("The directory %s cannot be read", $directory), 403);
            }
        }
    }
Save

Save a cache collection

@param CacheCollection $collection - the cache collection to save

@return CacheProviderInterface

@see \Cscfa\Bundle\CacheSystemBundle\Object\provider\CacheProviderInterface::save()