Fetch content folder and save in target directory.

@param int $id
Content identifier
@param string $target
Where the content folder will be saved
502176
public function exportContent($id, $target) {
    $source = "{$this->path}/content/{$id}";
    if (file_exists($source)) {
      // Copy content folder if it exists
      self::copyFileTree($source, $target);
    }
    else {
      // No contnet folder, create emty dir for content.json
      self::dirReady($target);
    }
  }
1257448
public function downloadAction(Request $request, $id)
    {
        try {
            if (ob_get_length()) {
                ob_end_clean();
            }

            $version = $request->get('v', null);
            $noCount = $request->get('no-count', false);

            $fileVersion = $this->getFileVersion($id, $version);

            if (!$fileVersion) {
                return new Response(null, 404);
            }

            if ($request->query->has('inline')) {
                $forceInline = (bool) $request->get('inline', false);
                $dispositionType = $forceInline ? ResponseHeaderBag::DISPOSITION_INLINE : ResponseHeaderBag::DISPOSITION_ATTACHMENT;
            } else {
                $dispositionType = $this->get('sulu_media.disposition_type.resolver')
                    ->getByMimeType($fileVersion->getMimeType());
            }

            if (!$noCount) {
                $this->getMediaManager()->increaseDownloadCounter($fileVersion->getId());
            }

            $response = $this->getFileResponse($fileVersion, $request->getLocale(), $dispositionType);

            return $response;
        } catch (MediaException $e) {
            throw $this->createNotFoundException('File not found: ' . $e->getCode() . ' ' . $e->getMessage());
        }
    }
988427
public function loadTemplate($id, $extension = 'proc')
    {
        $path = $this->locator->locate(sprintf('%s.%s', $id, $extension));

        return $this->loadFile($path);
    }
57119
public function update($id, $content)
    {
        $content['id'] = $id;

        $result =  $this->request(
            'POST',
            $this->getCore(). '/update/json',
            [],
            [
                'add' => [
                    'doc' => $content
                ]
            ]
        );

        if ($this->isAutoCommit()) {
            $this->commit();
        }

        return $result;
    }
1209157
public function download_file($id, $path) {
        $url = self::API."/${id}/content";
        // Microsoft live redirects to the real download location..
        $this->setopt(array('CURLOPT_FOLLOWLOCATION' => true, 'CURLOPT_MAXREDIRS' => 3));
        $content = $this->get($url);
        file_put_contents($path, $content);
        return array('path'=>$path, 'url'=>$url);
    }
279328
public function getAction(Request $request, $id)
    {
        // If a json request, let parent handle it
        if (in_array('application/json', $request->getAcceptableContentTypes())) {
            return parent::getAction($request, $id);
        }

        /** @var File $file */
        $file = $this->getModel()->find($id);

        /** @var Response $response */
        return $this->fileManager->buildGetContentResponse(
            $this->getResponse(),
            $file
        );
    }
1014566
public function cloneContent($id, $newId) {
    $path = $this->path . '/content/';
    if (file_exists($path . $id)) {
      self::copyFileTree($path . $id, $path . $newId);
    }
  }
670689
public static function saveToCache($id, $value)
    {
        $arrayCache = Configuration::getArrayCache();
        $cacheDriver = Configuration::getCacheDriver();

        $arrayCache->save($id, $value);
        if ($cacheDriver !== null) {
            $cacheDriver->save($id, $value);
        }
    }
615749
public function getFileLink($fileId, $target)
    {
        $file = Yii::$app->storage->getFile($fileId);
        if ($file) {
            $file->setTarget($target);
        }
        return $file;
    }
132432
public function getCacheFile($id)
    {
        assert('is_string($id)');

        $cacheFile = strval($this->cacheDirectory).'/'.$id;
        if (!file_exists($cacheFile)) {
            return null;
        }

        return $cacheFile;
    }
143714
public function saveById($id, $data)
    {
        $this->getRequest()->putContents($this->getKey(), $id, $data);
        return $id;
    }
364819
public function copyDirs($source, $target, $dirs)
    {
        foreach ($dirs as $dir) {
            $this->copyDir($source, $target, $dir);
        }
    }
1157813
public function fetch( $id ) {

		if ( $this->contains( $id ) ) {
			$this->cacheHits++;
			return $this->cache->getItem( $id );
		}

		$this->cacheMisses++;
		return false;
	}
1256191
public function hasDirectory(string $id): bool
    {
        if (isset($this->directories[$id])) {
            return true;
        }

        $path = $this->getDirectoryPath($id);

        if ($this->filesystem->has($path)) {
            $info = $this->filesystem->getMetadata($path);

            return $info['type'] === 'dir';
        }

        return false;
    }
350837
protected function storeUploadedFile( $target, $contents )
    {
        $dir = self::tempDirectory() . '/' . md5( microtime() . '-' . $target );
        $filePath = $dir . '/' . basename( $target );

        if ( !file_exists( $dir ) )
        {
            eZDir::mkdir( $dir, false, true );
        }

        $result = file_put_contents( $filePath, $contents );
        if ( !$result )
        {
            $result = file_exists( $filePath );
        }

        if ( $result )
        {
            return $filePath;
        }
        return false;
    }
798672
public function copy_content_from_storedfile(stored_file $file, $target) {
        $source = $this->get_local_path_from_storedfile($file, true);
        return copy($source, $target);
    }
413144
public function putAction(Request $request, $id)
    {
        $jsonData = $request->getContent();
        $data = json_decode($jsonData, true);

        // Id should be taken of request uri.
        $data['id'] = $id;

        $targetGroup = $this->deserializeData(json_encode($data));
        $targetGroup = $this->getTargetGroupRepository()->save($targetGroup);
        $this->getEntityManager()->flush();

        return $this->handleView($this->view($targetGroup));
    }