當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。