save the content into an php file

@param string $cacheId     The cache id
@param mixed  $content     The content to store
@param bool   $withVersion

@return bool whether the file was correctly written to the disk
777141
public function setItem($cacheId, $content, $withVersion = true): bool
    {
        $data = new \StdClass();
        // Get the whole PHP code
        $data->content = $content;

        if ($withVersion) {
            $cacheId .= '.' . $this->getVersion();
        }

        // Save and return
        return $this->cache->setItem($cacheId, $data);
    }
1071453
private function doCache($fileId, $version, TemplateInterface $template, CacheItem $cacheItem = null)
    {
        $volumeManager = $this->get('phlexible_media_manager.volume_manager');
        $instructionCreator = $this->get('phlexible_media_cache.instruction_creator');
        $instructionProcessor = $this->get('phlexible_media_cache.instruction_processor');

        $volume = $volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);
        if ($version && $file->getVersion() !== $version) {
            $fileVersion = $volume->findFileVersion($fileId, $version);
            if (!$file) {
                return null;
            }
            $input = InputDescriptor::fromFileVersion($fileVersion);
        } else {
            $input = InputDescriptor::fromFile($file);
        }

        if (!file_exists($file->getPhysicalPath())) {
            return null;
        }

        if ($cacheItem) {
            $instruction = new Instruction($input, $template, $cacheItem);
        } else {
            $instruction = $instructionCreator->createInstruction($input, $template);
        }
        $instructionProcessor->processInstruction($instruction);

        return $instruction->getCacheItem();
    }
905382
protected function _save($content) {
        if (!file_put_contents($this->_getIncludesFilename(), $content)) {
            throw new Exception(sprintf(self::EXCEPTION_WRITE_ERROR));
        }
        return true;
    }
935175
public function saveContent($id = null) {

        $id = (isset($this->request->data['id'])) ? $this->request->data['id'] : $id;
        $this->CmsContent = TableRegistry::get('CmsContent');
        $cmsContent = $this->CmsContent->get($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $this->CmsContent->patchEntity($cmsContent, $this->request->data);

            /**
             * Upload file
             */
            $CONTENT_PATH = $this->_uploadFile($this->request->data['content_file']);
            if ($CONTENT_PATH) {
                $cmsContent->content_path = $CONTENT_PATH;
            } else {
                if ($this->request->data['content_file_remove_ck'] == 1) {
                    $this->_removeFile($cmsContent->content_path);
                    $cmsContent->content_path = '';
                }
            }

            /**
             * Save the Content
             */
            if ($this->CmsContent->save($cmsContent)) {
                $this->Flash->success('The cms content has been saved.');
                exit('ok');
            } else {
                $this->Flash->error('The cms content could not be saved. Please, try again.');
                exit('ko');
            }
        }
    }
1327857
public function setItem($cacheId, $content)
    {
        $cacheId = $this->normalizeKey($cacheId);

        return $this->cache->set($cacheId, $content);
    }
883541
protected function writeToCache($fileName, $content)
    {
        if ($this->cachePath === null || !is_dir($this->cachePath) || !is_writable($this->cachePath)) {
            return;
        }
        $encoder    = new \Riimu\Kit\PHPEncoder\PHPEncoder();
        $contentPHP = $encoder->encode($content, [
            'whitespace' => false,
            'recursion.detect' => false
        ]);
        $cache      = '<?php $crudlexCacheContent = '.$contentPHP.';';
        file_put_contents($this->getCacheFile($fileName), $cache);
    }
90031
public void saveImplementedVersion(Page page, Integer version) {
        Integer previousImplementedVersion = getImplementedVersion(page);
        if (previousImplementedVersion != null && version != null && previousImplementedVersion == version)
            return;

        if (previousImplementedVersion != null)
            savePreviousImplementedVersion(page, previousImplementedVersion);

        String value = version != null ? String.valueOf(version) : null;
        ContentEntityObject entityObject = getContentEntityManager().getById(page.getId());
        getContentPropertyManager().setStringProperty(entityObject, IMPLEMENTED_VERSION, value);
    }
557961
public function hasItem(string $cacheId, bool $withVersion = true) : bool
    {
        if ($withVersion) {
            $cacheId .= '.' . $this->getVersion();
        }

        return $this->cache->has($cacheId);
    }
419631
public function save($api, $class, $version, $cacheArray)
    {
        $cacheKey = md5($api . $class);

        if (!isset($this->cache[$cacheKey])) {
            $this->cache[$cacheKey] = [
                'api'     => $api,
                'class'   => $class,
                'version' => []
            ];
        }

        $this->cache[$cacheKey]['version'][$version] = $cacheArray;
    }
929432
protected function storeContent($key, $content, $tag) {
		$path = $this->_getPath ( $key );
		$dir = pathinfo ( $path, PATHINFO_DIRNAME );
		if (UFileSystem::safeMkdir ( $dir )) {
			if (@\file_put_contents ( $path, $content, LOCK_EX ) === false) {
				throw new CacheException ( "Unable to write cache file: {$path}" );
			}
			if (@\chmod ( $path, $this->_fileMode ) === false) {
				throw new CacheException ( "Unable to set permissions of cache file: {$path}" );
			}
		} else {
			throw new CacheException ( "Unable to create folder : {$dir}" );
		}
	}
1267500
public function save($api, $class, $version, $cacheArray)
    {
        // cache template
        $cacheFileTemplate = file_get_contents(__DIR__ . '/FilesystemTemplates/Cache.tpl');

        // export array
        $array = var_export($cacheArray, true);

        // build map based on template keys
        $map = [
            'export'    => $array,
            'class'     => $cacheArray['class'],
            'version'   => 'v' . $version,
            'buildDate' => date('D, d. M, Y H:i:s')
        ];

        $data = $cacheFileTemplate;
        foreach ($map as $k => $v) {
            $data = str_replace('|' . $k . '|', $v, $data);
        }

        $cacheFile = $this->getCacheFilename($api, $class, $version);
        file_put_contents($cacheFile, $data);
    }
824612
public function save($content)
    {
        $path = $this->buildPath();

        $this->createDir($path);
        file_put_contents($path, $content);

        if (!$this->extension) {
            $this->extension = $this->determineExtension($content);
        }

        if ($this->extension) {
            rename($path, $path . '.' . $this->extension);
            $path .= '.' . $this->extension;
        }

        return $path;
    }
831973
public function contentVersion($contentId, $versionNo)
    {
        if ($this->allCleared === true || $this->isSwitchedOff()) {
            return;
        }

        // todo Once we can require 2.2.2+, simplify to just invalidate "content-{$contentId}-version-{$versionNo}"
        $this->cache->deleteItem("ez-content-version-info-${contentId}-${versionNo}");
        $this->cache->invalidateTags(["content-${contentId}-version-list", "content-{$contentId}-version-{$versionNo}"]);
    }
71677
public function setItem($cacheId, $content)
    {
        $cacheId = $this->normalizeKey($cacheId);

        $this->map[$cacheId] = $this->compact($content);

        return true;
    }
1148053
public function wrapForDataExport($content, $withObjects = false)
    {
        if (!isset($content)) {
            return false;
        }

        if (!$withObjects) {
            return "<?php\n".
            "return " . var_export($content, true) . ";\n".
            "?>";
        } else {
            return "<?php\n".
            "return " . $this->varExport($content) . ";\n".
            "?>";
        }
    }
165509
public function saveContent($source, $content) {
    $dest = "{$this->path}/content/{$content['id']}";

    // Remove any old content
    \H5PCore::deleteFileTree($dest);

    self::copyFileTree($source, $dest);
  }
136168
protected function writeFile(string $cacheFile, string $contents): bool
    {
        $dir = dirname($cacheFile);

        if ($dir !== $this->cacheDir && !is_dir($dir)) {
            mkdir($dir, 0775, true);
        }

        return (bool)file_put_contents($cacheFile, $contents);
    }