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

PHP file_directory_temp函数代码示例

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

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



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

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


示例2: testExport

 /**
  * Tests export of configuration.
  */
 function testExport()
 {
     // Verify the export page with export submit button is available.
     $this->drupalGet('admin/config/development/configuration/full/export');
     $this->assertFieldById('edit-submit', t('Export'));
     // Submit the export form and verify response.
     $this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
     $this->assertResponse(200, 'User can access the download callback.');
     // Get the archived binary file provided to user for download.
     $archive_data = $this->drupalGetContent();
     // Temporarily save the archive file.
     $uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
     // Extract the archive and verify it's not empty.
     $file_path = file_directory_temp() . '/' . file_uri_target($uri);
     $archiver = new Tar($file_path);
     $archive_contents = $archiver->listContents();
     $this->assert(!empty($archive_contents), 'Downloaded archive file is not empty.');
     // Prepare the list of config files from active storage, see
     // \Drupal\config\Controller\ConfigController::downloadExport().
     $storage_active = $this->container->get('config.storage');
     $config_files = array();
     foreach ($storage_active->listAll() as $config_name) {
         $config_files[] = $config_name . '.yml';
     }
     // Assert that the downloaded archive file contents are the same as the test
     // site active store.
     $this->assertIdentical($archive_contents, $config_files);
     // Ensure the test configuration override is in effect but was not exported.
     $this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
     $archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
     $file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
     $exported = Yaml::decode($file_contents);
     $this->assertNotIdentical($exported['message'], 'Foo');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:37,代码来源:ConfigExportUITest.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: getHooksDirectorySetting

 /**
  * Set the hooks directory.
  */
 function getHooksDirectorySetting()
 {
     // Set the folder for the hooks. This contains a prepared file for the tests
     // to use.
     // By some magic this appears to be safe to use with DrupalUnitTestCase.
     $directory = file_directory_temp() . '/module_builder_hook_definitions/' . $this->major_version;
     $this->hooks_directory = $directory;
 }
开发者ID:verbruggenalex,项目名称:mediayoutubeupload,代码行数:11,代码来源:TestsTempLocation.php


示例5: testExportArchive

 public function testExportArchive()
 {
     $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', [self::PACKAGE_NAME], $this->assigner->getBundle());
     $this->assertTrue(file_exists($filename), 'Archive file was not generated.');
 }
开发者ID:selwynpolit,项目名称:d8_test2,代码行数:10,代码来源:FeaturesGenerateTest.php


示例6: nodeImportCreateFile

 /**
  * Create a file with the specified data.
  *
  * @param $data
  *   Twodimensional array.
  *
  * @param $file_options
  *   Array with record separator, etc.
  *
  * @return
  *   String. Path to file (in temporary directory).
  */
 public function nodeImportCreateFile($data, $file_options = array())
 {
     module_load_include('inc', 'node_import');
     $path = file_create_filename($this->randomName() . '.csv', file_directory_temp());
     $fp = fopen($path, 'w');
     foreach ($data as $row) {
         $s = node_import_write_to_string($row, $file_options);
         fputs($fp, $s);
     }
     fclose($fp);
     return $path;
 }
开发者ID:melsawy,项目名称:auc_grads,代码行数:24,代码来源:NodeImportTestCase.php


示例7: testExport

 /**
  * Tests export of configuration.
  */
 function testExport()
 {
     // Verify the export page with export submit button is available.
     $this->drupalGet('admin/config/development/configuration/full/export');
     $this->assertFieldById('edit-submit', t('Export'));
     // Submit the export form and verify response.
     $this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export'));
     $this->assertResponse(200, 'User can access the download callback.');
     // Test if header contains file name with hostname and timestamp.
     $request = \Drupal::request();
     $hostname = str_replace('.', '-', $request->getHttpHost());
     $header_content_disposition = $this->drupalGetHeader('content-disposition');
     $header_match = (bool) preg_match('/attachment; filename="config-' . preg_quote($hostname) . '-\\d{4}-\\d{2}-\\d{2}-\\d{2}-\\d{2}\\.tar\\.gz"/', $header_content_disposition);
     $this->assertTrue($header_match, "Header with filename matches the expected format.");
     // Get the archived binary file provided to user for download.
     $archive_data = $this->getRawContent();
     // Temporarily save the archive file.
     $uri = file_unmanaged_save_data($archive_data, 'temporary://config.tar.gz');
     // Extract the archive and verify it's not empty.
     $file_path = file_directory_temp() . '/' . file_uri_target($uri);
     $archiver = new Tar($file_path);
     $archive_contents = $archiver->listContents();
     $this->assert(!empty($archive_contents), 'Downloaded archive file is not empty.');
     // Prepare the list of config files from active storage, see
     // \Drupal\config\Controller\ConfigController::downloadExport().
     $storage_active = $this->container->get('config.storage');
     $config_files = array();
     foreach ($storage_active->listAll() as $config_name) {
         $config_files[] = $config_name . '.yml';
     }
     // Assert that the downloaded archive file contents are the same as the test
     // site active store.
     $this->assertIdentical($archive_contents, $config_files);
     // Ensure the test configuration override is in effect but was not exported.
     $this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo');
     $archiver->extract(file_directory_temp(), array('system.maintenance.yml'));
     $file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml');
     $exported = Yaml::decode($file_contents);
     $this->assertNotIdentical($exported['message'], 'Foo');
     // Check the single export form doesn't have "form-required" elements.
     $this->drupalGet('admin/config/development/configuration/single/export');
     $this->assertNoRaw('js-form-required form-required', 'No form required fields are found.');
     // Ensure the temporary file is not available to users without the
     // permission.
     $this->drupalLogout();
     $this->drupalGet('system/temporary', ['query' => ['file' => 'config.tar.gz']]);
     $this->assertResponse(403);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:51,代码来源:ConfigExportUITest.php


示例8: testGeneratorWithBundle

 /**
  * @covers \Drupal\features\FeaturesGenerator::setPackageBundleNames
  */
 public function testGeneratorWithBundle()
 {
     $filename = file_directory_temp() . '/giraffe_' . self::PACKAGE_NAME . '.tar.gz';
     if (file_exists($filename)) {
         unlink($filename);
     }
     $this->assertFalse(file_exists($filename), 'Archive file already exists.');
     $bundle = FeaturesBundle::create(['machine_name' => 'giraffe']);
     $this->generator->generatePackages('archive', [self::PACKAGE_NAME], $bundle);
     $package = $this->featuresManager->getPackage(self::PACKAGE_NAME);
     $this->assertNull($package);
     $package = $this->featuresManager->getPackage('giraffe_' . self::PACKAGE_NAME);
     $this->assertEquals('giraffe_' . self::PACKAGE_NAME, $package->getMachineName());
     $this->assertEquals('giraffe', $package->getBundle());
     $this->assertTrue(file_exists($filename), 'Archive file was not generated.');
 }
开发者ID:gerbreown1,项目名称:calvaryfree,代码行数:19,代码来源:FeaturesGenerateTest.php


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


示例10: _fetch

 /**
  * (non-PHPdoc)
  * @see Yamm_FileFetcher::_fetch()
  */
 public function _fetch($filepath)
 {
     $source_url = yamm_api_clean_url($this->_server->getUrl()) . $filepath;
     // Get file contents.
     if ($data = file_get_contents($source_url, FILE_BINARY)) {
         // Get a new temporary file name, for file creation.
         $tmp = file_directory_temp() . '/' . uniqid('yamm-');
         // If we go some content, return new file path as data.
         if (file_put_contents($tmp, $data) > 0) {
             // Free up some memory after copy.
             unset($data);
             return $tmp;
         } else {
             throw new Yamm_FileFetcher_CouldNotFetchException("Unable to save " . $source_url . " downloaded file as temporary file");
         }
     } else {
         throw new Yamm_FileFetcher_CouldNotFetchException("Unable to download file " . $source_url);
     }
 }
开发者ID:pounard,项目名称:yamm,代码行数:23,代码来源:Http.php


示例11: resizeimage_wrapper_filecache

function resizeimage_wrapper_filecache()
{
    global $bgcachexpire;
    $bgcacheid = 'bg_' . md5($_GET['imgp'] . $_GET['imgw'] . $_GET['imgh']);
    #echo $bgcacheid;
    #echo '. 0.... ';
    # Tested that both relative (eg sites/all/files/cache) and absolute (eg /home/data/tmp) tmp path settings work OK here.
    $cachetemp = variable_get('brilliant_gallery_pcache', file_directory_temp());
    #$cachedfile = file_directory_temp() .'/'. $bgcacheid;
    $cachedfile = $cachetemp . '/' . $bgcacheid;
    #$cachedfile = realpath(file_directory_temp() . '/' . $bgcacheid);
    #echo file_directory_temp()  . '/' . $bgcacheid;
    #echo " .... ";
    #echo $cachedfile;
    # See http://drupal.org/node/194923
    $lastchanged = file_exists($cachedfile) ? filemtime($cachedfile) : false;
    if ($lastchanged === false or time() - $lastchanged > $bgcachexpire) {
        #echo '. 1.... ';
        # Cache file does not exist or is too old.
        $my_data = resizeimage($_GET['imgp'], $_GET['imgw'], $_GET['imgh']);
        # Now put $my_data to cache!
        $fh = fopen($cachedfile, "w+");
        fwrite($fh, $my_data);
        fclose($fh);
        #test
        /*
        $my_data_t = unserialize( $my_data );
        $fh = fopen( $cachedfile . '_2', "w+" );
         fwrite( $fh, $my_data_t[1] );
         fclose( $fh ); 
        */
        $my_data = unserialize($my_data);
    } else {
        #echo '. 2.... ';
        # Cache file exists.
        $my_data = unserialize(file_get_contents($cachedfile));
    }
    return $my_data;
}
开发者ID:ndp,项目名称:aida-americas.org-src,代码行数:39,代码来源:image.php


示例12: downloadDocument

 /**
  * Downloads the translated document for the specified document and language.
  *
  * @param int $document_id
  *   The Lingotek document ID that should be downloaded.
  * @param string $language_lingotek
  *   A Lingotek language/locale code.
  *
  * @return mixed
  *   On success, a SimpleXMLElement object representing the translated document. FALSE on failure.
  *
  */
 public function downloadDocument($document_id, $language_lingotek)
 {
     $document = FALSE;
     $params = array('documentId' => $document_id, 'targetLanguage' => $language_lingotek);
     if ($results = $this->request('downloadDocument', $params)) {
         try {
             // TODO: This is borrowed from the now-deprecated LingotekSession::download()
             // and could use refactoring.
             $tmpFile = tempnam(file_directory_temp(), 'lingotek');
             $fp = fopen($tmpFile, 'w');
             fwrite($fp, $results);
             fclose($fp);
             $text = '';
             $file = FALSE;
             // downloadDocument returns zip-encoded data.
             $zip = new ZipArchive();
             $zip->open($tmpFile);
             $name = $zip->getNameIndex(0);
             $file = $zip->getStream($name);
             if ($file) {
                 while (!feof($file)) {
                     $text .= fread($file, 2);
                 }
                 fclose($file);
             }
             unlink($tmpFile);
             $document = new SimpleXMLElement($text);
         } catch (Exception $e) {
             LingotekLog::error('Unable to parse downloaded document. Error: @error. Text: !xml.', array('!xml' => $text, '@error' => $e->getMessage()));
         }
     }
     return $document;
 }
开发者ID:bunnywong,项目名称:isnatura.com.hk,代码行数:45,代码来源:LingotekApi.php


示例13: __get

 /**
  * BC: Automatically resolve former KernelTestBase class properties.
  *
  * Test authors should follow the provided instructions and adjust their tests
  * accordingly.
  *
  * @deprecated in Drupal 8.0.x, will be removed before Drupal 8.2.0.
  */
 public function __get($name)
 {
     if (in_array($name, array('public_files_directory', 'private_files_directory', 'temp_files_directory', 'translation_files_directory'))) {
         // @comment it in again.
         trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use the regular API method to retrieve it instead (e.g., Settings).", $name), E_USER_DEPRECATED);
         switch ($name) {
             case 'public_files_directory':
                 return Settings::get('file_public_path', \Drupal::service('site.path') . '/files');
             case 'private_files_directory':
                 return $this->container->get('config.factory')->get('system.file')->get('path.private');
             case 'temp_files_directory':
                 return file_directory_temp();
             case 'translation_files_directory':
                 return Settings::get('file_public_path', \Drupal::service('site.path') . '/translations');
         }
     }
     if ($name === 'configDirectories') {
         trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name), E_USER_DEPRECATED);
         return array(CONFIG_SYNC_DIRECTORY => config_get_config_directory(CONFIG_SYNC_DIRECTORY));
     }
     $denied = array('testId', 'timeLimit', 'results', 'assertions', 'skipClasses', 'verbose', 'verboseId', 'verboseClassName', 'verboseDirectory', 'verboseDirectoryUrl', 'dieOnFail', 'kernel', 'generatedTestFiles', 'keyValueFactory');
     if (in_array($name, $denied) || strpos($name, 'original') === 0) {
         throw new \RuntimeException(sprintf('TestBase::$%s property no longer exists', $name));
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:33,代码来源:KernelTestBase.php


示例14: hook_file_transfer_alter

/**
 * Make changes to a file before it is downloaded by the customer.
 *
 * Stores, either for customization, copy protection or other reasons, might want
 * to send customized downloads to customers. This hook will allow this to happen.
 * Before a file is opened to be transfered to a customer, this hook will be called
 * to make any altercations to the file that will be used to transfer the download
 * to the customer. This, in effect, will allow a developer to create a new,
 * personalized, file that will get transfered to a customer.
 *
 * @param $file_user
 *   The file_user object (i.e. an object containing a row from the uc_file_users
 *   table) that corresponds with the user download being accessed.
 * @param $ip
 *   The IP address from which the customer is downloading the file
 * @param $fid
 *   The file id of the file being transfered
 * @param $file
 *   The file path of the file to be transfered
 * @return
 *   The path of the new file to transfer to customer.
 */
function hook_file_transfer_alter($file_user, $ip, $fid, $file)
{
    $file_data = file_get_contents($file) . " [insert personalized data]";
    //for large files this might be too memory intensive
    $new_file = tempnam(file_directory_temp(), 'tmp');
    file_put_contents($new_file, $file_data);
    return $new_file;
}
开发者ID:patdunlavey,项目名称:Williamstown-Beat,代码行数:30,代码来源:hooks.php


示例15: install_main


//.........这里部分代码省略.........
    module_list(TRUE, FALSE, FALSE, $module_list);
    drupal_load('module', 'system');
    drupal_load('module', 'filter');
    // Load the cache infrastructure using a "fake" cache implementation that
    // does not attempt to write to the database. We need this during the initial
    // part of the installer because the database is not available yet. We
    // continue to use it even when the database does become available, in order
    // to preserve consistency between interactive and command-line installations
    // (the latter complete in one page request and therefore are forced to
    // continue using the cache implementation they started with) and also
    // because any data put in the cache during the installer is inherently
    // suspect, due to the fact that Drupal is not fully set up yet.
    require_once DRUPAL_ROOT . '/includes/cache-install.inc';
    $conf['cache_inc'] = './includes/cache-install.inc';
    // Install profile chosen, set the global immediately.
    // This needs to be done before the theme cache gets
    // initialized in drupal_maintenance_theme().
    if (!empty($_GET['profile'])) {
        $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
    }
    // Set up theme system for the maintenance page.
    drupal_maintenance_theme();
    // Check existing settings.php.
    $verify = install_verify_settings();
    if ($verify) {
        // Establish a connection to the database.
        require_once DRUPAL_ROOT . '/includes/database.inc';
        db_set_active();
        // Check if Drupal is installed.
        $task = install_verify_drupal();
        if ($task == 'done') {
            install_already_done_error();
        }
    } else {
        $task = NULL;
    }
    // No profile was passed in GET, ask the user.
    if (empty($_GET['profile'])) {
        if ($profile = install_select_profile()) {
            install_goto("install.php?profile={$profile}");
        } else {
            install_no_profile_error();
        }
    }
    // Load the profile.
    require_once DRUPAL_ROOT . "/profiles/{$profile}/{$profile}.profile";
    // Locale selection
    if (!empty($_GET['locale'])) {
        $install_locale = preg_replace('/[^a-zA-Z_0-9\\-]/', '', $_GET['locale']);
    } elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
        install_goto("install.php?profile={$profile}&locale={$install_locale}");
    }
    // Tasks come after the database is set up
    if (!$task) {
        global $db_url;
        if (!$verify && !empty($db_url)) {
            // Do not install over a configured settings.php.
            install_already_done_error();
        }
        // Check the installation requirements for Drupal and this profile.
        install_check_requirements($profile, $verify);
        // Verify existence of all required modules.
        $modules = drupal_verify_profile($profile, $install_locale);
        // If any error messages are set now, it means a requirement problem.
        $messages = drupal_set_message();
        if (!empty($messages['error'])) {
            install_task_list('requirements');
            drupal_set_title(st('Requirements problem'));
            print theme('install_page', '');
            exit;
        }
        // Change the settings.php information if verification failed earlier.
        // Note: will trigger a redirect if database credentials change.
        if (!$verify) {
            install_change_settings($profile, $install_locale);
        }
        // The default lock implementation uses a database table,
        // so we cannot use it for install, but we still need
        // the API functions available.
        require_once './includes/lock-install.inc';
        $conf['lock_inc'] = './includes/lock-install.inc';
        lock_init();
        // Install system.module.
        drupal_install_system();
        // Ensure that all of Drupal's standard directories have appropriate
        // .htaccess files. These directories will have already been created by
        // this point in the installer, since Drupal creates them during the
        // install_check_requirements() task. Note that we cannot create them any
        // earlier than this, since the code below relies on system.module in order
        // to work.
        file_create_htaccess(file_directory_path());
        file_create_htaccess(file_directory_temp());
        // Save the list of other modules to install for the 'profile-install'
        // task. variable_set() can be used now that system.module is installed
        // and drupal is bootstrapped.
        variable_set('install_profile_modules', array_diff($modules, array('system')));
    }
    // The database is set up, turn to further tasks.
    install_tasks($profile, $task);
}
开发者ID:rjbrown99,项目名称:6,代码行数:101,代码来源:install.php


示例16: getLogDir

 public function getLogDir()
 {
     require_once DRUPAL_ROOT . '/includes/file.inc';
     return file_directory_temp() . '/' . $this->getName() . '/logs';
 }
开发者ID:drufony,项目名称:drufony-module,代码行数:5,代码来源:DrupalKernel.php


示例17: getDirectoryPath

 /**
  * {@inheritdoc}
  */
 public function getDirectoryPath()
 {
     return file_directory_temp();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:7,代码来源:TemporaryStream.php


示例18: debug

 /**
  * {@inheritdoc}
  */
 public function debug($input, $name = NULL, $plugin_id = NULL)
 {
     $output = $this->createInstance($plugin_id)->export($input, $name) . "\n";
     // The temp directory does vary across multiple simpletest instances.
     $file = file_directory_temp() . '/drupal_debug.txt';
     if (file_put_contents($file, $output, FILE_APPEND) === FALSE && $this->hasAccessToDevelInformation()) {
         drupal_set_message(t('Devel was unable to write to %file.', ['%file' => $file]), 'error');
         return FALSE;
     }
 }
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:13,代码来源:DevelDumperManager.php


示例19: getProjectDir

 public static function getProjectDir($project_name)
 {
     return file_directory_temp() . "/" . $project_name;
 }
开发者ID:malcomio,项目名称:drupalytics,代码行数:4,代码来源:GitHandler.php


示例20: testExportImportCollections

 /**
  * Tests an export and import of collections.
  */
 public function testExportImportCollections()
 {
     /** @var \Drupal\Core\Config\StorageInterface $active_storage */
     $active_storage = \Drupal::service('config.storage');
     $test1_storage = $active_storage->createCollection('collection.test1');
     $test1_storage->write('config_test.create', array('foo' => 'bar'));
     $test1_storage->write('config_test.update', array('foo' => 'bar'));
     $test2_storage = $active_storage->createCollection('collection.test2');
     $test2_storage->write('config_test.another_create', array('foo' => 'bar'));
     $test2_storage->write('config_test.another_update', array('foo' => 'bar'));
     // Export the configuration.
     $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export');
     $this->tarball = $this->drupalGetContent();
     $filename = file_directory_temp() . '/' . $this->randomName();
     file_put_contents($filename, $this->tarball);
     // Set up the active storage collections to test import.
     $test1_storage->delete('config_test.create');
     $test1_storage->write('config_test.update', array('foo' => 'baz'));
     $test1_storage->write('config_test.delete', array('foo' => 'bar'));
     $test2_storage->delete('config_test.another_create');
     $test2_storage->write('config_test.another_update', array('foo' => 'baz'));
     $test2_storage->write('config_test.another_delete', array('foo' => 'bar'));
     // Create a snapshot.
     $snapshot_storage = \Drupal::service('config.storage.snapshot');
     \Drupal::service('config.manager')->createSnapshot($active_storage, $snapshot_storage);
     // Ensure that the snapshot has the expected collection data before import.
     $test1_snapshot = $snapshot_storage->createCollection('collection.test1');
     $data = $test1_snapshot->read('config_test.delete');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.delete in collection.test1 exists in the snapshot storage.');
     $data = $test1_snapshot->read('config_test.update');
     $this->assertEqual($data, array('foo' => 'baz'), 'The config_test.update in collection.test1 exists in the snapshot storage.');
     $this->assertFalse($test1_snapshot->read('config_test.create'), 'The config_test.create in collection.test1 does not exist in the snapshot storage.');
     $test2_snapshot = $snapshot_storage->createCollection('collection.test2');
     $data = $test2_snapshot->read('config_test.another_delete');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_delete in collection.test2 exists in the snapshot storage.');
     $data = $test2_snapshot->read('config_test.another_update');
     $this->assertEqual($data, array('foo' => 'baz'), 'The config_test.another_update in collection.test2 exists in the snapshot storage.');
     $this->assertFalse($test2_snapshot->read('config_test.another_create'), 'The config_test.another_create in collection.test2 does not exist in the snapshot storage.');
     // Create the tar contains the expected contect for the collections.
     $tar = new ArchiveTar($filename, 'gz');
     $content_list = $tar->listContent();
     // Convert the list of files into something easy to search.
     $files = array();
     foreach ($content_list as $file) {
         $files[] = $file['filename'];
     }
     $this->assertTrue(in_array('collection/test1/config_test.create.yml', $files), 'Config export contains collection/test1/config_test.create.yml.');
     $this->assertTrue(in_array('collection/test2/config_test.another_create.yml', $files), 'Config export contains collection/test2/config_test.another_create.yml.');
     $this->assertTrue(in_array('collection/test1/config_test.update.yml', $files), 'Config export contains collection/test1/config_test.update.yml.');
     $this->assertTrue(in_array('collection/test2/config_test.another_update.yml', $files), 'Config export contains collection/test2/config_test.another_update.yml.');
     $this->assertFalse(in_array('collection/test1/config_test.delete.yml', $files), 'Config export does not contain collection/test1/config_test.delete.yml.');
     $this->assertFalse(in_array('collection/test2/config_test.another_delete.yml', $files), 'Config export does not contain collection/test2/config_test.another_delete.yml.');
     $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload');
     // Verify that there are configuration differences to import.
     $this->drupalGet('admin/config/development/configuration');
     $this->assertNoText(t('There are no configuration changes.'));
     $this->assertText(t('!collection configuration collection', array('!collection' => 'collection.test1')));
     $this->assertText(t('!collection configuration collection', array('!collection' => 'collection.test2')));
     $this->assertText('config_test.create');
     $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create');
     $this->assertText('config_test.update');
     $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.update');
     $this->assertText('config_test.delete');
     $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.delete');
     $this->assertText('config_test.another_create');
     $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_create');
     $this->assertText('config_test.another_update');
     $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_update');
     $this->assertText('config_test.another_delete');
     $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_delete');
     $this->drupalPostForm(NULL, array(), 'Import all');
     $this->assertText(t('There are no configuration changes.'));
     // Test data in collections.
     $data = $test1_storage->read('config_test.create');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created.');
     $data = $test1_storage->read('config_test.update');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated.');
     $this->assertFalse($test1_storage->read('config_test.delete'), 'The config_test.delete in collection.test1 has been deleted.');
     $data = $test2_storage->read('config_test.another_create');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created.');
     $data = $test2_storage->read('config_test.another_update');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated.');
     $this->assertFalse($test2_storage->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 has been deleted.');
     // Ensure that the snapshot has been updated with the collection data.
     $snapshot_storage = \Drupal::service('config.storage.snapshot');
     $test1_snapshot = $snapshot_storage->createCollection('collection.test1');
     $data = $test1_snapshot->read('config_test.create');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created in the snapshot storage.');
     $data = $test1_snapshot->read('config_test.update');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated in the snapshot storage.');
     $this->assertFalse($test1_snapshot->read('config_test.delete'), 'The config_test.delete in collection.test1 does not exist in the snapshot storage.');
     $test2_snapshot = $snapshot_storage->createCollection('collection.test2');
     $data = $test2_snapshot->read('config_test.another_create');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created in the snapshot storage.');
     $data = $test2_snapshot->read('config_test.another_update');
     $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated in the snapshot storage.');
     $this->assertFalse($test2_snapshot->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 does not exist in the snapshot storage.');
//.........这里部分代码省略.........
开发者ID:alnutile,项目名称:drunatra,代码行数:101,代码来源:ConfigExportImportUITest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP file_down函数代码示例发布时间:2022-05-15
下一篇:
PHP file_directory_path函数代码示例发布时间: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