• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP file_unmanaged_delete_recursive函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中file_unmanaged_delete_recursive函数的典型用法代码示例。如果您正苦于以下问题:PHP file_unmanaged_delete_recursive函数的具体用法?PHP file_unmanaged_delete_recursive怎么用?PHP file_unmanaged_delete_recursive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了file_unmanaged_delete_recursive函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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


示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $id = $this->entity->id;
     $file_name = file_default_scheme() . "://js_injector/{$id}.js";
     file_unmanaged_delete_recursive($file_name);
     $this->entity->delete();
     drupal_set_message($this->t('Js Injector deleted @label.', ['@label' => $this->entity->label()]));
     $form_state->setRedirectUrl($this->getCancelUrl());
 }
开发者ID:pookmish,项目名称:js_injector,代码行数:12,代码来源:JsInjectorDeleteForm.php


示例3: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $js_injector = $this->entity;
     $status = $js_injector->save();
     switch ($status) {
         case SAVED_NEW:
             drupal_set_message($this->t('Created the %label Js Injector.', ['%label' => $js_injector->label()]));
             break;
         default:
             drupal_set_message($this->t('Saved the %label Js Injector.', ['%label' => $js_injector->label()]));
             $file_name = file_default_scheme() . '://js_injector/' . $js_injector->id . '.js';
             file_unmanaged_delete_recursive($file_name);
     }
     drupal_flush_all_caches();
     $form_state->setRedirectUrl($js_injector->urlInfo('collection'));
 }
开发者ID:pookmish,项目名称:js_injector,代码行数:19,代码来源:JsInjectorForm.php


示例4: testExportWrite

 public function testExportWrite()
 {
     $package = $this->featuresManager->getPackage(self::PACKAGE_NAME);
     // Find out where package will be exported
     list($full_name, $path) = $this->featuresManager->getExportInfo($package, $this->assigner->getBundle());
     $path = $path . '/' . $full_name;
     if (file_exists($path)) {
         file_unmanaged_delete_recursive($path);
     }
     $this->assertFalse(file_exists($path), 'Package directory already exists.');
     $this->generator->generatePackages('write', [self::PACKAGE_NAME], $this->assigner->getBundle());
     $this->assertTrue(file_exists($path), 'Package directory was not generated.');
     $this->assertTrue(file_exists($path . '/' . self::PACKAGE_NAME . '.info.yml'), 'Package info.yml not generated.');
     $this->assertTrue(file_exists($path . '/config/install'), 'Package config/install not generated.');
     $this->assertTrue(file_exists($path . '/config/install/system.site.yml'), 'Config.yml not exported.');
 }
开发者ID:selwynpolit,项目名称:d8_test2,代码行数:16,代码来源:FeaturesGenerateTest.php


示例5: testSubDirectory

 /**
  * Try deleting subdirectories with some files.
  */
 function testSubDirectory()
 {
     // A directory to operate on.
     $directory = $this->createDirectory();
     $subdirectory = $this->createDirectory($directory . '/sub');
     $filepathA = $directory . '/A';
     $filepathB = $subdirectory . '/B';
     file_put_contents($filepathA, '');
     file_put_contents($filepathB, '');
     // Delete the directory.
     $this->assertTrue(file_unmanaged_delete_recursive($directory), 'Function reported success.');
     $this->assertFalse(file_exists($filepathA), 'Test file A has been deleted.');
     $this->assertFalse(file_exists($filepathB), 'Test file B has been deleted.');
     $this->assertFalse(file_exists($subdirectory), 'Subdirectory has been deleted.');
     $this->assertFalse(file_exists($directory), 'Directory has been deleted.');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:19,代码来源:UnmanagedDeleteRecursiveTest.php


示例6: preparePackage

  /**
   * Reads and merges in existing files for a given package or profile.
   *
   * @param array &$package
   *   The package.
   * @param array $existing_packages
   *   An array of existing packages.
   * @param \Drupal\features\FeaturesBundleInterface $bundle
   *   The bundle the package belongs to.
   */
  protected function preparePackage(array &$package, array $existing_packages, FeaturesBundleInterface $bundle = NULL) {
    // If this package is already present, prepare files.
    if (isset($existing_packages[$package['machine_name']])) {
      $existing_directory = $existing_packages[$package['machine_name']];

      $package['directory'] = $existing_directory;

      // Merge in the info file.
      $info_file_uri = $existing_directory . '/' . $package['machine_name'] . '.info.yml';
      if (file_exists($info_file_uri)) {
        $package['files']['info']['string'] = $this->mergeInfoFile($package['files']['info']['string'], $info_file_uri);
      }

      // Remove the config directory, as it will be replaced.
      $config_directory = $existing_directory . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
      if (is_dir($config_directory)) {
        file_unmanaged_delete_recursive($config_directory);
      }
    }
  }
开发者ID:jeetendrasingh,项目名称:manage_profile,代码行数:30,代码来源:FeaturesGenerationWrite.php


示例7: preparePackage

 /**
  * Reads and merges in existing files for a given package or profile.
  *
  * @param array &$package
  *   The package.
  * @param array $existing_packages
  *   An array of existing packages.
  * @param \Drupal\features\FeaturesBundleInterface $bundle
  *   The bundle the package belongs to.
  */
 protected function preparePackage(array &$package, array $existing_packages, FeaturesBundleInterface $bundle = NULL)
 {
     // If this package is already present, prepare files.
     if (isset($existing_packages[$package['machine_name']])) {
         $existing_directory = $existing_packages[$package['machine_name']];
         $package['directory'] = $existing_directory;
         // Merge in the info file.
         $info_file_uri = $existing_directory . '/' . $package['machine_name'] . '.info.yml';
         if (file_exists($info_file_uri)) {
             $package['files']['info']['string'] = $this->mergeInfoFile($package['files']['info']['string'], $info_file_uri);
         }
         // Remove the config directories, as they will be replaced.
         foreach (array_keys($this->featuresManager->getExtensionStorages()->getExtensionStorages()) as $directory) {
             $config_directory = $existing_directory . '/' . $directory;
             if (is_dir($config_directory)) {
                 file_unmanaged_delete_recursive($config_directory);
             }
         }
     }
 }
开发者ID:selwynpolit,项目名称:d8_test2,代码行数:30,代码来源:FeaturesGenerationWrite.php


示例8: drupal_get_path

<?php

/**
 * @file
 * Adminimal Menu Update file 7100.
 */
// Define Adminimal Menu path.
$module_path = drupal_get_path('module', 'adminimal_admin_menu');
// Delete the "adminimal_admin_menu.js" file.
file_unmanaged_delete($module_path . '/adminimal_admin_menu.js');
// Empty the "slicknav" folder.
file_unmanaged_delete_recursive($module_path . '/slicknav');
// Delete the "slicknav" folder.
drupal_rmdir($module_path . '/slicknav');
开发者ID:blashbrook,项目名称:theming,代码行数:14,代码来源:update_7100.php


示例9: init

 /**
  * Fully initializes the git clone entity after it has been created or loaded.
  *
  * @param bool $force
  *   Toggle determining whether or not to force a reinitialization.
  *
  * @return GitClone
  *   The current GitClone entity instance.
  *
  * @see GitClone::save()
  * @see EntityController::load()
  *
  * @chainable
  */
 public function init($force = FALSE)
 {
     if (!$force && isset($this->initialized)) {
         return $this;
     }
     $this->initialized = TRUE;
     // Ensure a Gitonomy repository is instantiated.
     if (!$force && !isset($this->repository)) {
         $options = _git_clone_gitonomy_options();
         if (($path = $this->getPath(FALSE)) && !empty($this->url)) {
             $git_exists = file_exists("{$path}/.git");
             if (!$git_exists && in_array($this->refType, self::$allowedRefs)) {
                 try {
                     $this->repository = Admin::init($path, FALSE, $options);
                     $this->run('remote', array('add', 'origin', $this->url));
                 } catch (\Exception $e) {
                     drupal_set_message($e->getMessage(), 'error');
                 }
             } elseif ($git_exists && in_array($this->refType, self::$allowedRefs)) {
                 $this->repository = new Repository($path, $options);
             }
         } else {
             $temp_dir = 'temporary://git_clone-' . drupal_hash_base64(REQUEST_TIME);
             if (file_prepare_directory($temp_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
                 $temp_dir = drupal_realpath($temp_dir);
                 drupal_register_shutdown_function(function () use($temp_dir) {
                     if (file_exists($temp_dir)) {
                         file_unmanaged_delete_recursive($temp_dir);
                     }
                 });
                 try {
                     $this->repository = Admin::init($temp_dir, FALSE, $options);
                 } catch (\Exception $e) {
                     watchdog('git_clone', $e->getMessage(), WATCHDOG_ERROR);
                 }
             }
             if (!$this->repository) {
                 drupal_set_message(t('Unable to create temporary git clone repository: @directory. Please verify your system temporary directory is writable.', array('@directory' => $temp_dir)), 'error');
             }
         }
     }
     // Initialize the settings.
     $this->getSettings();
     // Initialize the refs.
     $this->getRefs($force);
     return $this;
 }
开发者ID:unicorn-fail,项目名称:drupal-bootstrap.org,代码行数:61,代码来源:GitClone.php


示例10: tearDown

 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $user, $language;
     // In case a fatal error occurred that was not in the test process read the
     // log to pick up any fatal errors.
     simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
     $emailCount = count(variable_get('drupal_test_email_collector', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
         $this->pass($message, t('E-mail'));
     }
     // Delete temporary files directory.
     file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
     // Remove all prefixed tables (all the tables in the schema).
     $schema = drupal_get_schema(NULL, TRUE);
     foreach ($schema as $name => $table) {
         db_drop_table($name);
     }
     // Get back to the original connection.
     Database::removeConnection('default');
     Database::renameConnection('simpletest_original_default', 'default');
     // Restore original shutdown callbacks array to prevent original
     // environment of calling handlers from test run.
     $callbacks =& drupal_register_shutdown_function();
     $callbacks = $this->originalShutdownCallbacks;
     // Return the user to the original one.
     $user = $this->originalUser;
     drupal_save_session(TRUE);
     // Ensure that internal logged in variable and cURL options are reset.
     $this->loggedInUser = FALSE;
     $this->additionalCurlOptions = array();
     // Reload module list and implementations to ensure that test module hooks
     // aren't called after tests.
     module_list(TRUE);
     module_implements('', FALSE, TRUE);
     // Reset the Field API.
     field_cache_clear();
     // Rebuild caches.
     $this->refreshVariables();
     // Reset language.
     $language = $this->originalLanguage;
     if ($this->originalLanguageDefault) {
         $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
     }
     // Close the CURL handler.
     $this->curlClose();
 }
开发者ID:rlugojr,项目名称:livereload-examples,代码行数:51,代码来源:drupal_web_test_case.php


示例11: hook_uninstall

/**
 * Remove any information that the module sets.
 *
 * The information that the module should remove includes:
 * - state that the module has set using \Drupal::state()
 * - modifications to existing tables
 *
 * The module should not remove its entry from the module configuration.
 * Database tables defined by hook_schema() will be removed automatically.
 *
 * The uninstall hook must be implemented in the module's .install file. It
 * will fire when the module gets uninstalled but before the module's database
 * tables are removed, allowing your module to query its own tables during
 * this routine.
 *
 * @see hook_install()
 * @see hook_schema()
 * @see hook_modules_uninstalled()
 */
function hook_uninstall()
{
    // Remove the styles directory and generated images.
    file_unmanaged_delete_recursive(file_default_scheme() . '://styles');
}
开发者ID:dev981,项目名称:gaptest,代码行数:24,代码来源:module.api.php


示例12: tearDown

 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user, $language;
     // In case a fatal error occured that was not in the test process read the
     // log to pick up any fatal errors.
     $db_prefix_temp = $db_prefix;
     $db_prefix = $this->originalPrefix;
     simpletest_log_read($this->testId, $db_prefix, get_class($this), TRUE);
     $db_prefix = $db_prefix_temp;
     $emailCount = count(variable_get('drupal_test_email_collector', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, t('!count e-mail was sent during this test.'), t('!count e-mails were sent during this test.'), array('!count' => $emailCount));
         $this->pass($message, t('E-mail'));
     }
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory.
         file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($db_prefix, 10));
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         drupal_save_session(TRUE);
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         module_implements('', FALSE, TRUE);
         // Reset the Field API.
         field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         // Reset language.
         $language = $this->originalLanguage;
         if ($this->originalLanguageDefault) {
             $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
         }
         // Close the CURL handler.
         $this->curlClose();
     }
 }
开发者ID:jacobSingh,项目名称:drupal,代码行数:52,代码来源:drupal_web_test_case.php


示例13: restoreEnvironment

 /**
  * Cleans up the test environment and restores the original environment.
  *
  * Deletes created files, database tables, and reverts environment changes.
  *
  * This method needs to be invoked for both unit and integration tests.
  *
  * @see TestBase::prepareDatabasePrefix()
  * @see TestBase::changeDatabasePrefix()
  * @see TestBase::prepareEnvironment()
  */
 private function restoreEnvironment()
 {
     // Destroy the session if one was started during the test-run.
     $_SESSION = array();
     if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_ACTIVE) {
         session_destroy();
         $params = session_get_cookie_params();
         setcookie(session_name(), '', REQUEST_TIME - 3600, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
     }
     session_name($this->originalSessionName);
     // Reset all static variables.
     // Unsetting static variables will potentially invoke destruct methods,
     // which might call into functions that prime statics and caches again.
     // In that case, all functions are still operating on the test environment,
     // which means they may need to access its filesystem and database.
     drupal_static_reset();
     if ($this->container && $this->container->has('state') && ($state = $this->container->get('state'))) {
         $captured_emails = $state->get('system.test_mail_collector') ?: array();
         $emailCount = count($captured_emails);
         if ($emailCount) {
             $message = $emailCount == 1 ? '1 email was sent during this test.' : $emailCount . ' emails were sent during this test.';
             $this->pass($message, 'Email');
         }
     }
     // Sleep for 50ms to allow shutdown functions and terminate events to
     // complete. Further information: https://www.drupal.org/node/2194357.
     usleep(50000);
     // Remove all prefixed tables.
     $original_connection_info = Database::getConnectionInfo('simpletest_original_default');
     $original_prefix = $original_connection_info['default']['prefix']['default'];
     $test_connection_info = Database::getConnectionInfo('default');
     $test_prefix = $test_connection_info['default']['prefix']['default'];
     if ($original_prefix != $test_prefix) {
         $tables = Database::getConnection()->schema()->findTables('%');
         foreach ($tables as $table) {
             if (Database::getConnection()->schema()->dropTable($table)) {
                 unset($tables[$table]);
             }
         }
     }
     // In case a fatal error occurred that was not in the test process read the
     // log to pick up any fatal errors.
     simpletest_log_read($this->testId, $this->databasePrefix, get_class($this));
     // Restore original dependency injection container.
     $this->container = $this->originalContainer;
     \Drupal::setContainer($this->originalContainer);
     // Delete test site directory.
     file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback'));
     // Restore original database connection.
     Database::removeConnection('default');
     Database::renameConnection('simpletest_original_default', 'default');
     // Reset all static variables.
     // All destructors of statically cached objects have been invoked above;
     // this second reset is guaranteed to reset everything to nothing.
     drupal_static_reset();
     // Restore original in-memory configuration.
     $GLOBALS['config'] = $this->originalConfig;
     $GLOBALS['conf'] = $this->originalConf;
     new Settings($this->originalSettings);
     // Restore original statics and globals.
     $GLOBALS['config_directories'] = $this->originalConfigDirectories;
     // Re-initialize original stream wrappers of the parent site.
     // This must happen after static variables have been reset and the original
     // container and $config_directories are restored, as simpletest_log_read()
     // uses the public stream wrapper to locate the error.log.
     $this->originalContainer->get('stream_wrapper_manager')->register();
     if (isset($this->originalPrefix)) {
         drupal_valid_test_ua($this->originalPrefix);
     } else {
         drupal_valid_test_ua(FALSE);
     }
     // Restore original shutdown callbacks.
     $callbacks =& drupal_register_shutdown_function();
     $callbacks = $this->originalShutdownCallbacks;
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:86,代码来源:TestBase.php


示例14: testExportWrite

 /**
  * @covers \Drupal\features\Plugin\FeaturesGeneration\FeaturesGenerationWrite
  */
 public function testExportWrite()
 {
     // Set a fake drupal root, so the testbot can also write into it.
     vfsStream::setup('drupal');
     \Drupal::getContainer()->set('app.root', 'vfs://drupal');
     $package = $this->featuresManager->getPackage(self::PACKAGE_NAME);
     // Find out where package will be exported
     list($full_name, $path) = $this->featuresManager->getExportInfo($package, $this->assigner->getBundle());
     $path = 'vfs://drupal/' . $path . '/' . $full_name;
     if (file_exists($path)) {
         file_unmanaged_delete_recursive($path);
     }
     $this->assertFalse(file_exists($path), 'Package directory already exists.');
     $this->generator->generatePackages('write', [self::PACKAGE_NAME], $this->assigner->getBundle());
     $this->assertTrue(file_exists($path), 'Package directory was not generated.');
     $this->assertTrue(file_exists($path . '/' . self::PACKAGE_NAME . '.info.yml'), 'Package info.yml not generated.');
     $this->assertTrue(file_exists($path . '/config/install'), 'Package config/install not generated.');
     $this->assertTrue(file_exists($path . '/config/install/system.site.yml'), 'Config.yml not exported.');
 }
开发者ID:gerbreown1,项目名称:calvaryfree,代码行数:22,代码来源:FeaturesGenerateTest.php


示例15: flush

 /**
  * {@inheritdoc}
  */
 public function flush($path = NULL)
 {
     // A specific image path has been provided. Flush only that derivative.
     if (isset($path)) {
         $derivative_uri = $this->buildUri($path);
         if (file_exists($derivative_uri)) {
             file_unmanaged_delete($derivative_uri);
         }
         return $this;
     }
     // Delete the style directory in each registered wrapper.
     $wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(StreamWrapperInterface::WRITE_VISIBLE);
     foreach ($wrappers as $wrapper => $wrapper_data) {
         if (file_exists($directory = $wrapper . '://styles/' . $this->id())) {
             file_unmanaged_delete_recursive($directory);
         }
     }
     // Let other modules update as necessary on flush.
     $module_handler = \Drupal::moduleHandler();
     $module_handler->invokeAll('image_style_flush', array($this));
     // Clear caches so that formatters may be added for this style.
     drupal_theme_rebuild();
     Cache::invalidateTags($this->getCacheTagsToInvalidate());
     return $this;
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:28,代码来源:ImageStyle.php


示例16: hoteldiamond_settings_submit

function hoteldiamond_settings_submit($form, &$form_state)
{
    if (!empty($form_state['values']['slider']['layers'])) {
        foreach ($form_state['values']['slider']['layers'] as $SlideId => &$Slide) {
            if (isset($Slide['background']) && is_object($Slide['background'])) {
                $UploadedFile = $Slide['background'];
                $Slide['background'] = file_unmanaged_copy($UploadedFile->uri, 'public://hoteldiamond/' . $UploadedFile->filename);
            }
            if (isset($Slide['sublayers'])) {
                foreach ($Slide['sublayers'] as $LayerId => &$sublayer) {
                    // If the user uploaded a new sublayer image, save it to a permanent location.
                    if (isset($sublayer['image']['file']) && is_object($sublayer['image']['file'])) {
                        $UploadedFile = $sublayer['image']['file'];
                        $sublayer['image']['path'] = file_unmanaged_copy($UploadedFile->uri, 'public://hoteldiamond/' . $UploadedFile->filename);
                        // Unset unnecessary data
                        unset($form_state['values']['slider']['layers'][$SlideId]['sublayers'][$LayerId]['image']['file']);
                        unset($form_state['values']['slider']['layers'][$SlideId]['sublayers'][$LayerId]['image']['upload']);
                    }
                }
            }
        }
        // If the user uploaded a new custom background, save it to a permanent location.
        if (isset($form_state['values']['style']['custom_bg']['file']) && is_object($form_state['values']['style']['custom_bg']['file'])) {
            $UploadedFile = $form_state['values']['style']['custom_bg']['file'];
            $form_state['values']['style']['custom_bg']['path'] = file_unmanaged_copy($UploadedFile->uri, 'public://hoteldiamond/' . $UploadedFile->filename);
            // Unset unnecessary data
            unset($form_state['values']['style']['custom_bg']['file']);
            unset($form_state['values']['style']['custom_bg']['upload']);
        }
        $BuildSettingTheme = $form_state['build_info']['args'][0];
        $path = variable_get('theme_' . $BuildSettingTheme . '_files_directory');
        @file_unmanaged_delete_recursive($path);
        // Prepare target location for generated files.
        $id = $BuildSettingTheme . '-' . substr(hash('sha256', serialize($BuildSettingTheme) . microtime()), 0, 8);
        $path = 'public://hoteldiamond/' . $id;
        file_prepare_directory($path, FILE_CREATE_DIRECTORY);
        variable_set('theme_' . $BuildSettingTheme . '_files_directory', $path);
    }
}
开发者ID:vfokov,项目名称:videosite,代码行数:39,代码来源:theme-settings.php


示例17: handleDirectoryDelete

 /**
  * Submit handler for directory deletion.
  *
  * @see file_unmanaged_delete_recursive()
  */
 public function handleDirectoryDelete(array &$form, FormStateInterface $form_state)
 {
     $form_values = $form_state->getValues();
     $directory = $form_values['directory_name'];
     $result = file_unmanaged_delete_recursive($directory);
     if (!$result) {
         drupal_set_message(t('Failed to delete %directory.', array('%directory' => $directory)), 'error');
     } else {
         drupal_set_message(t('Recursively deleted directory %directory.', array('%directory' => $directory)));
         $this->setDefaultDirectory($directory);
     }
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:17,代码来源:FileExampleReadWriteForm.php


示例18: testExportWrite

 /**
  * @covers \Drupal\features\Plugin\FeaturesGeneration\FeaturesGenerationWrite
  */
 public function testExportWrite()
 {
     // Set a fake drupal root, so the testbot can also write into it.
     vfsStream::setup('drupal');
     \Drupal::getContainer()->set('app.root', 'vfs://drupal');
     $this->featuresManager->setRoot('vfs://drupal');
     $package = $this->featuresManager->getPackage(self::PACKAGE_NAME);
     // Find out where package will be exported
     list($full_name, $path) = $this->featuresManager->getExportInfo($package, $this->assigner->getBundle());
     $path = 'vfs://drupal/' . $path . '/' . $full_name;
     if (file_exists($path)) {
         file_unmanaged_delete_recursive($path);
     }
     $this->assertFalse(file_exists($path), 'Package directory already exists.');
     $this->generator->generatePackages('write', $this->assigner->getBundle(), [self::PACKAGE_NAME]);
     $info_file_uri = $path . '/' . self::PACKAGE_NAME . '.info.yml';
     $this->assertTrue(file_exists($path), 'Package directory was not generated.');
     $this->assertTrue(file_exists($info_file_uri), 'Package info.yml not generated.');
     $this->assertTrue(file_exists($path . '/config/install'), 'Package config/install not generated.');
     $this->assertTrue(file_exists($path . '/config/install/system.site.yml'), 'Config.yml not exported.');
     $expected_info = ["name" => "My test package", "type" => "module", "core" => "8.x"];
     $info = Yaml::decode(file_get_contents($info_file_uri));
     $this->assertEquals($expected_info, $info, 'Incorrect info file generated');
     // Now, add stuff to the feature and re-export to ensure it is preserved
     // Add a dependency to the package itself to see that it gets exported.
     $package->setDependencies(['user']);
     $this->featuresManager->setPackage($package);
     // Add dependency and custom key to the info file to simulate manual edit.
     $info['dependencies'] = ['node'];
     $info['mykey'] = "test value";
     $info_contents = Yaml::encode($info);
     file_put_contents($info_file_uri, $info_contents);
     // Add an extra file that should be retained.
     $css_file = $path . '/' . self::PACKAGE_NAME . '.css';
     $file_contents = "This is a dummy file";
     file_put_contents($css_file, $file_contents);
     // Add a config file that should be removed since it's not part of the
     // feature.
     $config_file = $path . '/config/install/node.type.mytype.yml';
     file_put_contents($config_file, $file_contents);
     $this->generator->generatePackages('write', $this->assigner->getBundle(), [self::PACKAGE_NAME]);
     $this->assertTrue(file_exists($info_file_uri), 'Package info.yml not generated.');
     $expected_info = ["name" => "My test package", "type" => "module", "core" => "8.x", "dependencies" => ["node", "user"], "mykey" => "test value"];
     $info = Yaml::decode(file_get_contents($info_file_uri));
     $this->assertEquals($expected_info, $info, 'Incorrect info file generated');
     $this->assertTrue(file_exists($css_file), 'Extra file was not retained.');
     $this->assertFalse(file_exists($config_file), 'Config directory was not cleaned.');
     $this->assertEquals($file_contents, file_get_contents($css_file), 'Extra file contents not retained');
     // Next, test that generating an Archive picks up the extra files.
     $filename = file_directory_temp() . '/' . self::PACKAGE_NAME . '.tar.gz';
     if (file_exists($filename)) {
         unlink($filename);
     }
     $this->assertFalse(file_exists($filename), 'Archive file already exists.');
     $this->generator->generatePackages('archive', $this->assigner->getBundle(), [self::PACKAGE_NAME]);
     $this->assertTrue(file_exists($filename), 'Archive file was not generated.');
     $archive = new ArchiveTar($filename);
     $files = $archive->listContent();
     $this->assertEquals(4, count($files));
     $this->assertEquals(self::PACKAGE_NAME . '/' . self::PACKAGE_NAME . '.info.yml', $files[0]['filename']);
     $this->assertEquals(self::PACKAGE_NAME . '/' . self::PACKAGE_NAME . '.features.yml', $files[1]['filename']);
     $this->assertEquals(self::PACKAGE_NAME . '/config/install/system.site.yml', $files[2]['filename']);
     $this->assertEquals(self::PACKAGE_NAME . '/' . self::PACKAGE_NAME . '.css', $files[3]['filename']);
     $expected_info = ["name" => "My test package", "type" => "module", "core" => "8.x", "dependencies" => ["node", "user"], "mykey" => "test value"];
     $info = Yaml::decode($archive->extractInString(self::PACKAGE_NAME . '/' . self::PACKAGE_NAME . '.info.yml'));
     $this->assertEquals($expected_info, $info, 'Incorrect info file generated');
     $this->assertEquals($file_contents, $archive->extractInString(self::PACKAGE_NAME . '/' . self::PACKAGE_NAME . '.css'), 'Extra file contents not retained');
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:71,代码来源:FeaturesGenerateTest.php


示例19: tearDown

 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user;
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory and reset files directory path.
         file_unmanaged_delete_recursive(file_directory_path());
         variable_set('file_directory_path', $this->originalFileDirectory);
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         drupal_save_session(TRUE);
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
         // Reset the Field API.
         field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         // Close the CURL handler.
         $this->curlClose();
     }
 }
开发者ID:rolfington,项目名称:drupal,代码行数:37,代码来源:drupal_web_test_case.php


示例20: tearDown

 /**
  * Delete created files and temporary files directory, delete the tables created by setUp(),
  * and reset the database prefix.
  */
 protected function tearDown()
 {
     global $db_prefix, $user, $language;
     $emailCount = count(variable_get('simpletest_emails', array()));
     if ($emailCount) {
         $message = format_plural($emailCount, t('!count e-mail was sent during this test.'), t('!count e-mails were sent during this test.'), array('!count' => $emailCount));
         $this->pass($message, t('E-mail'));
     }
     if (preg_match('/simpletest\\d+/', $db_prefix)) {
         // Delete temporary files directory and reset files directory path.
         file_unmanaged_delete_recursive(file_directory_path());
         variable_set('file_directory_path', $this->originalFileDirectory);
         // Remove all prefixed tables (all the tables in the schema).
         $schema = drupal_get_schema(NULL, TRUE);
         $ret = array();
         foreach ($schema as $name => $table) {
             db_drop_table($ret, $name);
         }
         // Return the database prefix to the original.
         $db_prefix = $this->originalPrefix;
         // Return the user to the original one.
         $user = $this->originalUser;
         drupal_save_session(TRUE);
         // Ensure that internal logged in variable and cURL options are reset.
         $this->loggedInUser = FALSE;
         $this->additionalCurlOptions = array();
         // Reload module list and implementations to ensure that test module hooks
         // aren't called after tests.
         module_list(TRUE);
         module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
         // Reset the Field API.
         field_cache_clear();
         // Rebuild caches.
         $this->refreshVariables();
         // Reset language.
         $language = $this->originalLanguage;
         if ($this->originalLanguageDefault) {
             $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
         }
         // Close the CURL handler.
         $this->curlClose();
     }
 }
开发者ID:unicorn-fail,项目名称:drupal-bootstrap.org,代码行数:47,代码来源:dwtc.php



注:本文中的file_unmanaged_delete_recursive函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_unmanaged_move函数代码示例发布时间:2022-05-15
下一篇:
PHP file_unmanaged_delete函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap