获取指定的文件存储
@param $id
@return mixed
@throws \yii\base\InvalidParamException
485481
public function get($id)
    {
        if (!$this->has($id)) {
            throw new InvalidParamException("Unknown file system '{$id}'.");
        }
        if (!is_object($this->_fileSystems[$id]) || is_callable($this->_fileSystems[$id])) {
            $this->_fileSystems[$id] = $this->create($id, $this->_fileSystems[$id]);
        }
        return $this->_fileSystems[$id];
    }
1098218
public function getSourceUrlById($id) {
        $image = instance(new Model_Image)->fetchById($id);
        if (!$image) {
            throw new InvalidArgumentException(self::ERROR_IMAGE_NOT_FOUND);
        }
        return $this->getSourceUrl($image['filename']);
    }
668747
protected function getFileName($id)
    {
        $directory = $this->getDirectory($id);
        $hash      = sha1($id, false);
        $file      = $directory . DIRECTORY_SEPARATOR . $hash . '.cache';
        return $file;
    }
753934
public function id_to_url($id){
    if ( $file = $this->id_to_real($id) ){
      return $this->real_to_url($file);
    }
    return false;
  }
925952
private function getEnumById($id)
    {
        if (!$enum = SchemaStore::getEnumById($id, true)) {
            throw new \InvalidArgumentException(sprintf(
                'Cannot find an enum with id "%s"',
                $id
            ));
        }

        return $enum;
    }
517410
public function getChannel($id){
        if(!isset($this->channels[$id])){
            throw new InvalidParamException("Unknown channel '{$id}'.");
        }

        if (!is_object($this->channels[$id])) {
            $this->channels[$id] = $this->createChannel($id, $this->channels[$id]);
        }

        return $this->channels[$id];
    }
985632
public function read($id)
    {
        // Reset data
        $data         = '';
        $this->exists = false;

        // Check if session file exists but (unlike native sessions) do
        // not create new session file on disk if session does not exist
        $file = $this->getPathForSessionId($id);
        if (file_exists($file)) {
            $data         = (string)file_get_contents($file);
            $this->exists = true;
        }

        return $data;
    }
1207821
public function findInResById($id)
    {
        $id = Lib::toInteger($id);
        $this->ensureIdIsInteger($id);

        // Sestaveni URL
        $url = $this->wrapUrl(sprintf(self::URL_RES, $id));

        $cachedFileName = $id.'_'.date($this->cacheStrategy).'.php';
        $cachedFile = $this->cacheDir.'/res_'.$cachedFileName;
        $cachedRawFile = $this->cacheDir.'/res_raw_'.$cachedFileName;

        if (is_file($cachedFile)) {
            return unserialize(file_get_contents($cachedFile));
        }

        try {
            $aresRequest = file_get_contents($url, null, stream_context_create($this->contextOptions));
            if ($this->debug) {
                file_put_contents($cachedRawFile, $aresRequest);
            }
            $aresResponse = simplexml_load_string($aresRequest);

            if ($aresResponse) {
                $ns = $aresResponse->getDocNamespaces();
                $data = $aresResponse->children($ns['are']);
                $elements = $data->children($ns['D'])->Vypis_RES;

                if (strval($elements->ZAU->ICO) === $id) {
                    $record = new AresRecord();
                    $record->setCompanyId(strval($id));
                    $record->setTaxId($this->findVatById($id));
                    $record->setCompanyName(strval($elements->ZAU->OF));
                    $record->setStreet(strval($elements->SI->NU));
                    $record->setStreetHouseNumber(strval($elements->SI->CD));
                    $record->setStreetOrientationNumber(strval($elements->SI->CO));
                    $record->setTown(strval($elements->SI->N));
                    $record->setZip(strval($elements->SI->PSC));
                } else {
                    throw new AresException('IČ firmy nebylo nalezeno.');
                }
            } else {
                throw new AresException('Databáze ARES není dostupná.');
            }
        } catch (\Exception $e) {
            throw new AresException($e->getMessage());
        }
        file_put_contents($cachedFile, serialize($record));

        return $record;
    }
1225853
public function actionDelete($id)
    {
        if (\Yii::$app->user->can('delete')) {
            $model = $this->findModel($id);
            foreach($model->files as $file)
                $file->delete();

            $model->delete();

            return $this->redirect(['index']);
        } else
            throw new ForbiddenHttpException(Module::t('core', 'Access denied.'));
    }
132432
public function getCacheFile($id)
    {
        assert('is_string($id)');

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

        return $cacheFile;
    }
230543
protected function deleteFilesAndImages($id)
    {
        $data = $this->model->with($this->getRelations())
            ->findOrFail($id)->toArray();

        $this->builder->fields()->filter(function ($field) {
            return $field instanceof Field\File;
        })->each(function (File $file) use ($data) {
            $file->setOriginal($data);

            $file->destroy();
        });
    }
214417
public function fetchById($id)
    {
        $data = [];
        foreach ($this->globDataFile($id) as $filename) {
            $data = array_merge($data, $this->fetchFileData($id, $filename));
        }
        return $this->resultAsModel($data);
    }
952750
public function getById($id)
    {
        $modelResult = $this->getRequest()->request(
            'GET',
            $this->getRequestUrl(sprintf('models/%s', $id))
        );

        return $this->getModelFromResult($modelResult);
    }
175131
public function getFile(string $id): ?FileResponse
	{
		$log = $this->getLog($id);
		if ($log) {
			$file = $log->name;
			if (Strings::endsWith($file, '.html')) {
				$contentType = 'text/html';
			} else {
				$contentType = 'text/plain';
			}
			return new FileResponse($this->path . $file, $file, $contentType, false);
		}
		return null;
	}
1080720
public function actionImage($id)
    {
        $model = StorageImage::find()->where(['id' => $id])->with(['file'])->one();

        if (!$model) {
            throw new NotFoundHttpException("Unable to find the given storage image.");
        }

        return $model;
    }
408206
public function store($id)
    {
        $file = $this->getFile($id);
        if (!empty($file)) {
            $this->authorize('create', $file);
            $this->authorize('update', $file);
            $input       = $this->validator->validate('create');
            $translation = $this->repository->createTranslation($file, $input);
            return $this->respondWithSuccess($translation, new FileTranslationTransformer);
        }
        return $this->respondNotFound();
    }
714330
public function getPathForDocument($id)
    {
        if(!$this->validateId($id)) {
            throw new \Exception(sprintf('`%s` is not a valid document ID.', $id));
        }

        return $this->path . DIRECTORY_SEPARATOR . $this->getFilename($id);
    }