本文整理匯總了PHP中FileUtils::createFolderRecursive方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileUtils::createFolderRecursive方法的具體用法?PHP FileUtils::createFolderRecursive怎麽用?PHP FileUtils::createFolderRecursive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FileUtils
的用法示例。
在下文中一共展示了FileUtils::createFolderRecursive方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ensureImageDirIsAvailable
public function ensureImageDirIsAvailable($row_id)
{
$image_dir = $this->getImageDir($row_id);
if ($image_dir !== false) {
if (!file_exists($image_dir)) {
FileUtils::createFolderRecursive($image_dir);
}
}
}
示例2: setData
public function setData($id, $data)
{
if ($data === null) {
return false;
}
$properties = $this->getProperties($id);
if ($properties === false) {
return false;
}
$folder = $this->getPageEditFolder($id, $properties);
$url = $this->getPageFilesEditUrl($id, $properties);
if (!is_dir($folder)) {
$published_folder = $this->getPagePublishedFolder($id, $properties);
if (is_dir($published_folder)) {
if (!FileUtils::copyFolder($published_folder, $folder)) {
return false;
}
} else {
if (!FileUtils::createFolderRecursive($folder)) {
return false;
}
}
}
$page_files_folder = $folder . self::PAGE_FILES_FOLDER_NAME;
$page_files_url = $url;
if (!file_exists($page_files_folder)) {
FileUtils::createFolderRecursive($page_files_folder);
}
$decoded_data = json_decode($data, true);
$parameters = array('pageId' => $id, 'pageFiles' => $page_files_folder . '/', 'pageFilesUrl' => $page_files_url . '/');
Plugins::call(Plugins::BEFORE_SAVE_PAGE_DATA_FIELDS, $parameters, $decoded_data);
$this->applyPluginsToDataFields(Plugins::SAVE_PAGE_DATA_FIELD, $parameters, $decoded_data, $properties);
Plugins::call(Plugins::AFTER_SAVE_PAGE_DATA_FIELDS, $parameters, $decoded_data);
$encoded_data = json_encode($decoded_data);
$file = $folder . self::DATA_FILE_NAME;
if (!FileUtils::createFile($file)) {
return false;
}
if (@file_put_contents($file, $encoded_data) === false) {
return false;
}
if ($properties['status'] == self::STATUS_PUBLISHED) {
$new_properties = array('status' => self::STATUS_EDIT);
$this->setProperties($id, $new_properties);
}
return true;
}