本文整理汇总了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();
}
}
示例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;
}
示例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];
}
示例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;
}
示例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);
}
}
}