本文整理汇总了PHP中file_unmanaged_delete函数的典型用法代码示例。如果您正苦于以下问题:PHP file_unmanaged_delete函数的具体用法?PHP file_unmanaged_delete怎么用?PHP file_unmanaged_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_unmanaged_delete函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: black_lagoon_settings_submit
/**
* Save settings data.
*/
function black_lagoon_settings_submit($form, &$form_state)
{
$settings = array();
// Update image field
foreach ($form_state['input']['images'] as $image) {
if (is_array($image)) {
$image = $image['image'];
if ($image['image_delete']) {
// Delete banner file
file_unmanaged_delete($image['image_path']);
// Delete banner thumbnail file
file_unmanaged_delete($image['image_thumb']);
} else {
// Update image
$settings[] = $image;
}
}
}
// Check for a new uploaded file, and use that if available.
if ($file = file_save_upload('image_upload')) {
$file->status = FILE_STATUS_PERMANENT;
if ($image = _black_lagoon_save_image($file)) {
// Put new image into settings
$settings[] = $image;
}
}
// Save settings
black_lagoon_set_banners($settings);
}
开发者ID:jcubed22,项目名称:Drupal_Space_Pirates,代码行数:32,代码来源:theme-settings.php
示例2: testFileRetrieving
/**
* Invokes system_retrieve_file() in several scenarios.
*/
function testFileRetrieving()
{
// Test 404 handling by trying to fetch a randomly named file.
drupal_mkdir($sourcedir = 'public://' . $this->randomMachineName());
$filename = 'Файл для тестирования ' . $this->randomMachineName();
$url = file_create_url($sourcedir . '/' . $filename);
$retrieved_file = system_retrieve_file($url);
$this->assertFalse($retrieved_file, 'Non-existent file not fetched.');
// Actually create that file, download it via HTTP and test the returned path.
file_put_contents($sourcedir . '/' . $filename, 'testing');
$retrieved_file = system_retrieve_file($url);
// URLs could not contains characters outside the ASCII set so $filename
// has to be encoded.
$encoded_filename = rawurlencode($filename);
$this->assertEqual($retrieved_file, 'public://' . $encoded_filename, 'Sane path for downloaded file returned (public:// scheme).');
$this->assertTrue(is_file($retrieved_file), 'Downloaded file does exist (public:// scheme).');
$this->assertEqual(filesize($retrieved_file), 7, 'File size of downloaded file is correct (public:// scheme).');
file_unmanaged_delete($retrieved_file);
// Test downloading file to a different location.
drupal_mkdir($targetdir = 'temporary://' . $this->randomMachineName());
$retrieved_file = system_retrieve_file($url, $targetdir);
$this->assertEqual($retrieved_file, "{$targetdir}/{$encoded_filename}", 'Sane path for downloaded file returned (temporary:// scheme).');
$this->assertTrue(is_file($retrieved_file), 'Downloaded file does exist (temporary:// scheme).');
$this->assertEqual(filesize($retrieved_file), 7, 'File size of downloaded file is correct (temporary:// scheme).');
file_unmanaged_delete($retrieved_file);
file_unmanaged_delete_recursive($sourcedir);
file_unmanaged_delete_recursive($targetdir);
}
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:RetrieveFileTest.php
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$messageHelper = $this->getHelperSet()->get('message');
$directory = $input->getArgument('directory');
if (!$directory) {
$config = $this->getConfigFactory()->get('system.file');
$directory = $config->get('path.temporary') ?: file_directory_temp();
$directory .= '/' . CONFIG_STAGING_DIRECTORY;
}
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
}
$config_export_file = $directory . '/config.tar.gz';
file_unmanaged_delete($config_export_file);
try {
$archiver = new ArchiveTar($config_export_file, 'gz');
$this->configManager = $this->getConfigManager();
// Get raw configuration data without overrides.
foreach ($this->configManager->getConfigFactory()->listAll() as $name) {
$archiver->addString("{$name}.yml", Yaml::encode($this->configManager->getConfigFactory()->get($name)->getRawData()));
}
$this->targetStorage = $this->getConfigStorage();
// Get all override data from the remaining collections.
foreach ($this->targetStorage->getAllCollectionNames() as $collection) {
$collection_storage = $this->targetStorage->createCollection($collection);
foreach ($collection_storage->listAll() as $name) {
$archiver->addString(str_replace('.', '/', $collection) . "/{$name}.yml", Yaml::encode($collection_storage->read($name)));
}
}
} catch (\Exception $e) {
$output->writeln('[+] <error>' . $e->getMessage() . '</error>');
return;
}
$messageHelper->addSuccessMessage(sprintf($this->trans('commands.config.export.messages.directory'), $config_export_file));
}
开发者ID:amira2r,项目名称:DrupalConsole,代码行数:38,代码来源:ConfigExportCommand.php
示例4: complete
/**
* Complete remote export.
*/
function complete()
{
// Download the export file.
$this->download();
// Remove the export file from the server.
file_unmanaged_delete($this->file_location);
}
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:10,代码来源:BackupDatabaseRemote.php
示例5: generate
/**
* {@inheritdoc}
*/
public function generate(array $packages = array(), FeaturesBundleInterface $bundle = NULL)
{
$filename = isset($bundle) && $bundle->isProfile() ? $bundle->getProfileName() : 'generated_features';
// If no packages were specified, get all packages.
if (empty($packages)) {
$packages = $this->featuresManager->getPackages();
} elseif (count($packages) == 1) {
// Single package export, so name tar archive by package name.
$filename = current($packages)['machine_name'];
}
$return = [];
$this->archiveName = $filename . '.tar.gz';
$archive_name = file_directory_temp() . '/' . $this->archiveName;
if (file_exists($archive_name)) {
file_unmanaged_delete($archive_name);
}
$archiver = new ArchiveTar($archive_name);
// Add package files.
foreach ($packages as $package) {
if (count($packages) == 1) {
// Single module export, so don't generate entire modules dir structure.
$package['directory'] = $package['machine_name'];
}
$this->generatePackage($return, $package, $archiver);
}
return $return;
}
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:30,代码来源:FeaturesGenerationArchive.php
示例6: testDirectory
/**
* Try deleting a directory.
*/
function testDirectory()
{
// A directory to operate on.
$directory = $this->createDirectory();
// Try to delete a directory
$this->assertFalse(file_unmanaged_delete($directory), 'Could not delete the delete directory.');
$this->assertTrue(file_exists($directory), 'Directory has not been deleted.');
}
开发者ID:alnutile,项目名称:drunatra,代码行数:11,代码来源:UnmanagedDeleteTest.php
示例7: downloadExport
/**
* Downloads a tarball of the site configuration.
*/
public function downloadExport()
{
file_unmanaged_delete(file_directory_temp() . '/config.tar.gz');
$archiver = new ArchiveTar(file_directory_temp() . '/config.tar.gz', 'gz');
// Get raw configuration data without overrides.
foreach ($this->configManager->getConfigFactory()->listAll() as $name) {
$archiver->addString("{$name}.yml", Yaml::encode($this->configManager->getConfigFactory()->get($name)->getRawData()));
}
// Get all override data from the remaining collections.
foreach ($this->targetStorage->getAllCollectionNames() as $collection) {
$collection_storage = $this->targetStorage->createCollection($collection);
foreach ($collection_storage->listAll() as $name) {
$archiver->addString(str_replace('.', '/', $collection) . "/{$name}.yml", Yaml::encode($collection_storage->read($name)));
}
}
$request = new Request(array('file' => 'config.tar.gz'));
return $this->fileDownloadController->download($request, 'temporary');
}
开发者ID:papillon-cendre,项目名称:d8,代码行数:21,代码来源:ConfigController.php
示例8: parallax_bg_region5_validate
function parallax_bg_region5_validate($element, &$form_state)
{
global $base_url;
$validateFile = array('file_validate_is_image' => array());
$UploadedFile = file_save_upload('parallax_bg_region5_image', $validateFile, "public://", FILE_EXISTS_REPLACE);
if ($form_state['values']['delete_parallax_bg_region5_image'] == TRUE) {
file_unmanaged_delete($form_state['values']['parallax_bg_region5_preview']);
$form_state['values']['parallax_bg_region5_preview'] = NULL;
}
if ($UploadedFile) {
$UploadedFile->status = FILE_STATUS_PERMANENT;
file_save($UploadedFile);
$file_url = file_create_url($UploadedFile->uri);
$file_url = str_ireplace($base_url, '', $file_url);
// set to form
$form_state['values']['parallax_bg_region5_preview'] = $file_url;
}
}
开发者ID:ApsGitAdmin,项目名称:APS,代码行数:18,代码来源:parallax-image-validate.php
示例9: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$configFile = $input->getOption('file');
$removeFiles = $input->getOption('remove-files');
$configSyncDir = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
if ($configFile) {
$archiveTar = new ArchiveTar($configFile, 'gz');
$io->simple($this->trans('commands.config.import.messages.config_files_imported'));
foreach ($archiveTar->listContent() as $file) {
$io->info('[-] ' . $file['filename']);
}
try {
$archiveTar->extract($configSyncDir . '/');
} catch (\Exception $e) {
$io->error($e->getMessage());
return;
}
}
$finder = new Finder();
$finder->in($configSyncDir);
$finder->name("*.yml");
foreach ($finder as $configFile) {
$configName = $configFile->getBasename('.yml');
$configFilePath = sprintf('%s/%s', $configSyncDir, $configFile->getBasename());
$config = $this->getConfigFactory()->getEditable($configName);
$parser = new Parser();
$configData = $parser->parse(file_get_contents($configFilePath));
$config->setData($configData);
if ($removeFiles) {
file_unmanaged_delete($configFilePath);
}
try {
$config->save();
} catch (\Exception $e) {
$io->error($e->getMessage());
return;
}
}
$io->success(sprintf($this->trans('commands.config.import.messages.imported'), CONFIG_SYNC_DIRECTORY));
}
开发者ID:larowlan,项目名称:DrupalConsole,代码行数:44,代码来源:ImportCommand.php
示例10: cleanup
/**
* Cleanup files created during download().
*
* It is expected that $files is returned from download(). Also, be aware that
* each parent directory in the hierarchy may be removed if there are no more
* files left in that directory.
*
* @param [] $files
* Array of files as returned from download() method.
*/
public static function cleanup(array $files)
{
foreach ($files as $file_path => $file_name) {
// Handle managed files.
if (count(file_load_multiple([], ['uri' => $file_path])) > 0) {
$file_obj = new \stdClass();
$file_obj->uri = $file_path;
file_delete($file_obj);
} else {
file_unmanaged_delete($file_path);
}
// Remove all directories in the tree if the file was the last one in this
// directory.
$file_dir = dirname($file_path);
while (count(file_scan_directory($file_dir, '/.*/')) === 0) {
if (!is_dir($file_dir)) {
break;
}
drupal_rmdir($file_dir);
$file_dir = dirname($file_dir);
}
}
}
开发者ID:alexdesignworks,项目名称:drupal_file_downloader,代码行数:33,代码来源:Downloader.php
示例11: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$directory = $input->getOption('directory');
if (!$directory) {
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
}
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
}
$configName = $input->getArgument('config-name');
$configExportFile = $directory . '/' . $configName . '.yml';
file_unmanaged_delete($configExportFile);
$config = $this->getConfigFactory()->getEditable($configName);
if ($config) {
$yaml = Yaml::encode($config->getRawData());
// Save release file
file_put_contents($configExportFile, $yaml);
$output->writeln('[+] <info>' . sprintf($this->trans('commands.config.export.single.messages.export'), $configExportFile) . '</info>');
} else {
$output->writeln('[+] <error>' . $this->trans('commands.config.export.single.messages.config-not-found') . '</error>');
}
}
开发者ID:legovaer,项目名称:DrupalConsole,代码行数:25,代码来源:ExportSingleCommand.php
示例12: site_bg_validate
function site_bg_validate($element, &$form_state)
{
global $base_url;
$validateFile = array('file_validate_is_image' => array());
$UploadedFile = file_save_upload('site_bg_image', $validateFile, "public://", FILE_EXISTS_REPLACE);
if ($form_state['values']['delete_site_bg_image'] == TRUE) {
// Delete layer file
file_unmanaged_delete($form_state['values']['site_bg_preview']);
$form_state['values']['site_bg_preview'] = NULL;
}
if ($UploadedFile) {
// change file's status from temporary to permanent and update file database
$UploadedFile->status = FILE_STATUS_PERMANENT;
file_save($UploadedFile);
$file_url = file_create_url($UploadedFile->uri);
$file_url = str_ireplace($base_url, '', $file_url);
// set to form
$form_state['values']['site_bg_preview'] = $file_url;
}
}
开发者ID:vfokov,项目名称:videosite,代码行数:20,代码来源:theme-settings.php
示例13: testJavaScriptTranslation
public function testJavaScriptTranslation()
{
$user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages'));
$this->drupalLogin($user);
$config = \Drupal::config('locale.settings');
$langcode = 'xx';
// The English name for the language. This will be translated.
$name = $this->randomMachineName(16);
// Add custom language.
$edit = array('predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => LanguageInterface::DIRECTION_LTR);
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->container->get('language_manager')->reset();
// Build the JavaScript translation file.
// Retrieve the source string of the first string available in the
// {locales_source} table and translate it.
$source = db_select('locales_source', 'l')->fields('l', array('source'))->condition('l.source', '%.js%', 'LIKE')->range(0, 1)->execute()->fetchField();
$search = array('string' => $source, 'langcode' => $langcode, 'translation' => 'all');
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name'];
$edit = array($lid => $this->randomMachineName());
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
// Trigger JavaScript translation parsing and building.
_locale_rebuild_js($langcode);
$locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
$js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js';
$this->assertTrue($result = file_exists($js_file), String::format('JavaScript file created: %file', array('%file' => $result ? $js_file : 'not found')));
// Test JavaScript translation rebuilding.
file_unmanaged_delete($js_file);
$this->assertTrue($result = !file_exists($js_file), String::format('JavaScript file deleted: %file', array('%file' => $result ? $js_file : 'found')));
_locale_rebuild_js($langcode);
$this->assertTrue($result = file_exists($js_file), String::format('JavaScript file rebuilt: %file', array('%file' => $result ? $js_file : 'not found')));
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:33,代码来源:LocaleTranslationUiTest.php
示例14: stability_settings_submit
/**
* Save settings data.
*/
function stability_settings_submit($form, &$form_state)
{
$settings = array();
if (isset($form_state['input']['sub_header_images'])) {
foreach ($form_state['input']['sub_header_images'] as $image) {
if (is_array($image)) {
$image = $image['image'];
if ($image['image_delete']) {
$image['fid'] && ($file = file_load($image['fid'])) ? file_delete($file) : file_unmanaged_delete($image['image_path']);
} else {
$settings[] = $image;
}
}
}
}
if ($file = file_save_upload('image_upload', array(), 'public://')) {
$file->status = 1;
file_save($file);
$settings[] = array('fid' => $file->fid, 'image_path' => $file->uri);
}
variable_set(variable_get('theme_default', 'none') . '_sub_headers', $settings);
}
开发者ID:harryboulderdash,项目名称:PlayGFC,代码行数:25,代码来源:theme-settings.php
示例15: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$messageHelper = $this->getMessageHelper();
$directory = $input->getArgument('directory');
if (!$directory) {
$config = $this->getConfigFactory()->get('system.file');
$directory = $config->get('path.temporary') ?: file_directory_temp();
$directory .= '/' . CONFIG_STAGING_DIRECTORY;
}
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
}
$config_name = $input->getArgument('config-name');
$config_export_file = $directory . '/' . $config_name . '.yml';
file_unmanaged_delete($config_export_file);
$config = $this->getConfigFactory()->getEditable($config_name);
if ($config) {
$yaml = Yaml::encode($config->getRawData());
// Save release file
file_put_contents($config_export_file, $yaml);
$output->writeln('[+] <info>' . sprintf($this->trans('commands.config.export.single.messages.export'), $config_export_file) . '</info>');
} else {
$output->writeln('[+] <error>' . $this->trans('commands.config.export.single.messages.config-not-found') . '</error>');
}
}
开发者ID:janstoeckler,项目名称:DrupalConsole,代码行数:28,代码来源:ConfigExportSingleCommand.php
示例16: foreach
$CSS .= $scss->compile($output);
}
// Preset Colours
foreach ($presets as $k => $preset) {
$maincolor = isset($preset->superhero_color_main) ? $preset->superhero_color_main : "false";
$textcolor = isset($preset->superhero_color_text) ? $preset->superhero_color_text : "false";
$linkcolor = isset($preset->superhero_color_link) ? $preset->superhero_color_link : "false";
$hovercolor = isset($preset->superhero_color_hover) ? $preset->superhero_color_hover : "false";
$headingcolor = isset($preset->superhero_color_heading) ? $preset->superhero_color_heading : "false";
$maincolor = empty($maincolor) ? "false" : $maincolor;
$output = <<<SCSS
\t\$maincolor: {$maincolor};
\t\$textcolor: {$textcolor};
\t\$linkcolor: {$linkcolor};
\t\$hovercolor: {$hovercolor};
\t\$headingcolor: {$headingcolor};
\t@import "global";
SCSS;
try {
$tmpCSS = $CSS . $scss->compile($output);
} catch (exception $e) {
drupal_set_message("fatal error: " . $e->getMessage(), 'error');
}
$theme_path = drupal_get_path('theme', $theme->theme);
$css_file = "public://" . $theme->theme . "-preset" . ($k + 1) . ".css";
//$css_file = $theme_path."/css/".$theme->theme."-preset".($k+1).".css";
file_unmanaged_save_data($tmpCSS, $css_file, FILE_EXISTS_REPLACE);
//Remove all custom scss
file_unmanaged_delete('public://' . $theme->theme . '-theme-preset' . ($k + 1) . '.css');
}
开发者ID:Kalamet,项目名称:poly_demo,代码行数:31,代码来源:scss.php
示例17: clear
/**
* {@inheritdoc}
*/
public function clear(FeedInterface $feed)
{
$feed_config = $feed->getConfigurationFor($this);
$url = $feed_config['source'];
\Drupal::cache()->delete('feeds_http_download:' . md5($url));
file_unmanaged_delete($this->prepareDirectory($url));
}
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:HttpFetcher.php
示例18: testFileRemovedFromDisk
/**
* Ensure a file entity can be saved when the file does not exist on disk.
*/
public function testFileRemovedFromDisk()
{
$this->drupalGet('file/test/1/0/1');
$test_file = $this->getTestFile('text');
$file_field_name = 'files[nested_file][]';
$edit = [$file_field_name => drupal_realpath($test_file->getFileUri())];
$this->drupalPostForm(NULL, $edit, t('Upload'));
$this->drupalPostForm(NULL, array(), t('Save'));
$fid = $this->getLastFileId();
/** @var $file \Drupal\file\FileInterface */
$file = $this->container->get('entity_type.manager')->getStorage('file')->load($fid);
$file->setPermanent();
$file->save();
$this->assertTrue(file_unmanaged_delete($file->getFileUri()));
$file->save();
$this->assertTrue($file->isPermanent());
$file->delete();
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:21,代码来源:FileManagedFileElementTest.php
示例19: surreal_settings_submit
/**
* Save settings data.
*/
function surreal_settings_submit(&$form, &$form_state)
{
$settings = array();
// Region parallax upload
for ($i = 1; $i <= 6; $i++) {
$fg = 'parallax_fg_region' . $i . '_image';
if ($file = file_load($form_state['values'][$fg])) {
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
file_usage_add($file, 'user', 'user', 1);
variable_set($fg, $file->fid);
}
$bg = 'parallax_bg_region' . $i . '_image';
if ($file = file_load($form_state['values'][$bg])) {
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
file_usage_add($file, 'user', 'user', 1);
variable_set($bg, $file->fid);
}
}
// Update image field
foreach ($form_state['input']['images'] as $image) {
if (is_array($image)) {
$image = $image['image'];
if ($image['image_delete']) {
// Delete banner file
file_unmanaged_delete($image['image_path']);
// Delete banner thumbnail file
file_unmanaged_delete($image['image_thumb']);
} else {
// Update image
$settings[] = $image;
}
}
}
// Check for a new uploaded file, and use that if available.
if ($file = file_save_upload('image_upload')) {
$file->status = FILE_STATUS_PERMANENT;
if ($image = _surreal_save_image($file)) {
// Put new image into settings
$settings[] = $image;
}
}
// Save settings
surreal_set_banners($settings);
}
开发者ID:ApsGitAdmin,项目名称:APS,代码行数:49,代码来源:theme-settings.php
示例20: saveManaged
/**
* Save downloaded managed files.
*
* @param [] $downloaded_files
* Array of downloaded files.
*/
protected function saveManaged(array $downloaded_files)
{
foreach ($downloaded_files as $file_path => $file_name) {
$local_file_loaded = file_get_contents($file_path);
$file = file_save_data($local_file_loaded, $file_path, FILE_EXISTS_REPLACE);
if ($file) {
if ($this->verbose) {
$this->messageSet(t('Saved file %filename as managed file with fid %fid', ['%filename' => $file_name, '%fid' => $file->fid]));
}
} else {
// Remove the file.
file_unmanaged_delete($file_path);
// Unset downloaded file if it was not saved as managed.
unset($downloaded_files[$file_path]);
if ($this->verbose) {
$this->messageSet(t('Unable to save file %filename as managed file', ['%filename' => $file_name]));
}
}
}
return $downloaded_files;
}
开发者ID:alexdesignworks,项目名称:drupal_file_downloader,代码行数:27,代码来源:DownloaderProvider.php
注:本文中的file_unmanaged_delete函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论