当前位置: 首页>>代码示例>>PHP>>正文


PHP File::getContext方法代码示例

本文整理汇总了PHP中Pimcore\File::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP File::getContext方法的具体用法?PHP File::getContext怎么用?PHP File::getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\File的用法示例。


在下文中一共展示了File::getContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * @return mixed|void
  * @throws DAV\Exception\Forbidden
  */
 public function get()
 {
     if ($this->asset->isAllowed("view")) {
         return fopen($this->asset->getFileSystemPath(), "r", false, FileHelper::getContext());
     } else {
         throw new DAV\Exception\Forbidden();
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:12,代码来源:File.php

示例2: loadData

 /**
  * Object
  *
  * @return mixed
  */
 public function loadData()
 {
     $data = null;
     $zipped = false;
     // check both the legacy file path and the new structure
     foreach ([$this->getFilePath(), $this->getLegacyFilePath()] as $path) {
         if (file_exists($path)) {
             $filePath = $path;
             break;
         }
         if (file_exists($path . ".gz")) {
             $filePath = $path . ".gz";
             $zipped = true;
             break;
         }
     }
     if ($zipped && is_file($filePath) && is_readable($filePath)) {
         $data = gzdecode(file_get_contents($filePath));
     } elseif (is_file($filePath) && is_readable($filePath)) {
         $data = file_get_contents($filePath);
     }
     if (!$data) {
         \Logger::err("Version: cannot read version data from file system.");
         $this->delete();
         return;
     }
     if ($this->getSerialized()) {
         $data = Serialize::unserialize($data);
     }
     if ($data instanceof Asset && file_exists($this->getBinaryFilePath())) {
         $binaryHandle = fopen($this->getBinaryFilePath(), "r+", false, File::getContext());
         $data->setStream($binaryHandle);
     } elseif ($data instanceof Asset && $data->data) {
         // this is for backward compatibility
         $data->setData($data->data);
     }
     $data = Element\Service::renewReferences($data);
     $this->setData($data);
     return $data;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:45,代码来源:Version.php

示例3: mysqlData

 /**
  * @param $name
  * @param $type
  * @return array
  */
 public function mysqlData($name, $type)
 {
     $db = Db::reset();
     $dumpData = "\n\n";
     $name = $db->quoteTableAs($name);
     if ($type != "VIEW") {
         // backup tables
         $tableData = $db->fetchAll("SELECT * FROM " . $name);
         foreach ($tableData as $row) {
             $cells = [];
             foreach ($row as $cell) {
                 if (is_string($cell)) {
                     $cell = $db->quote($cell);
                 } elseif ($cell === null) {
                     $cell = "NULL";
                 }
                 $cells[] = $cell;
             }
             $dumpData .= "INSERT INTO " . $name . " VALUES (" . implode(",", $cells) . ");";
             $dumpData .= "\n";
         }
     } else {
         // dump view structure
         $dumpData .= "\n\n";
         $dumpData .= "DROP VIEW IF EXISTS " . $name . ";";
         $dumpData .= "\n";
         try {
             $viewData = $db->fetchRow("SHOW CREATE VIEW " . $name);
             $dumpData .= $viewData["Create View"] . ";";
         } catch (\Exception $e) {
             Logger::error($e);
         }
     }
     $dumpData .= "\n\n";
     $h = fopen(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/backup-dump.sql", "a+", false, File::getContext());
     fwrite($h, $dumpData);
     fclose($h);
     return ["success" => true];
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:44,代码来源:Backup.php

示例4: getTemporaryFile

 /**
  * returns the path to a temp file
  * @return string
  */
 public function getTemporaryFile()
 {
     $destinationPath = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/asset-temporary/asset_" . $this->getId() . "_" . md5(microtime()) . "__" . $this->getFilename();
     if (!is_dir(dirname($destinationPath))) {
         File::mkdir(dirname($destinationPath));
     }
     $src = $this->getStream();
     $dest = fopen($destinationPath, "w+", false, File::getContext());
     stream_copy_to_stream($src, $dest);
     fclose($dest);
     @chmod($destinationPath, File::getDefaultMode());
     return $destinationPath;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:17,代码来源:Asset.php

示例5: restoreChilds

 /**
  * @param Element\ElementInterface $element
  */
 public function restoreChilds(Element\ElementInterface $element)
 {
     $restoreBinaryData = function ($element, $scope) {
         // assets are kinda special because they can contain massive amount of binary data which isn't serialized, we create separate files for them
         if ($element instanceof Asset) {
             $binFile = $scope->getStorageFileBinary($element);
             if (file_exists($binFile)) {
                 $binaryHandle = fopen($binFile, "r", false, File::getContext());
                 $element->setStream($binaryHandle);
             }
         }
     };
     $restoreBinaryData($element, $this);
     $element->save();
     if (method_exists($element, "getChilds")) {
         if ($element instanceof Object\AbstractObject) {
             // don't use the getter because this will return an empty array (variants are excluded by default)
             $childs = $element->o_childs;
         } else {
             $childs = $element->getChilds();
         }
         foreach ($childs as $child) {
             $this->restoreChilds($child);
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:29,代码来源:Item.php


注:本文中的Pimcore\File::getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。