本文整理汇总了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;
}