当前位置: 首页>>代码示例>>PHP>>正文


PHP drupal_get_filename函数代码示例

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


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

示例1: testInstallerTranslationCache

 /**
  * Tests profile info caching in non-English languages.
  */
 function testInstallerTranslationCache()
 {
     require_once 'core/includes/install.inc';
     // Prime the drupal_get_filename() static cache with the location of the
     // testing profile as it is not the currently active profile and we don't
     // yet have any cached way to retrieve its location.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     drupal_get_filename('profile', 'testing', 'core/profiles/testing/testing.info.yml');
     $info_en = install_profile_info('testing', 'en');
     $info_nl = install_profile_info('testing', 'nl');
     $this->assertFalse(in_array('locale', $info_en['dependencies']), 'Locale is not set when installing in English.');
     $this->assertTrue(in_array('locale', $info_nl['dependencies']), 'Locale is set when installing in Dutch.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:16,代码来源:InstallerLanguageTest.php

示例2: tableDefinition

 /**
  * Returns the table definition for the URL alias fixtures.
  *
  * @return array
  *   Table definitions.
  */
 public function tableDefinition()
 {
     $tables = array();
     // Prime the drupal_get_filename() cache with the location of the system
     // module as its location is known and shouldn't change.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml');
     module_load_install('system');
     $schema = system_schema();
     $tables['url_alias'] = AliasStorage::schemaDefinition();
     $tables['key_value'] = $schema['key_value'];
     return $tables;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:19,代码来源:UrlAliasFixtures.php

示例3: _authcache_funcname

/**
 * Example custom function.
 *
 * This function will be called if the Authcache:ajax JSON object contains
 * { 'funcname' : 'var' } Use hook_authcache_ajax() in your Drupal module
 * to modify the Authcache:ajax JSON object for the cached page.
 *
 * @see modulename
 */
function _authcache_funcname($vars) {
  global $user; // current user

  // For core or contributed modules, it's best to try to include
  // the module file and call the required function. Example:
  include_once dirname(drupal_get_filename('module', 'module_name')) . '/module_name.module';
  return module_name_display_info();

  // You can return an array or a single value. This will be converted into
  // JSON and sent back to the browser. Create a JavaScript function called
  // _authcache_funcname(var) to handle the return value.  See authcache_example.module/.js

  return array(2, 3, 5, 7 => array(11, 17, 19));
}
开发者ID:ATouhou,项目名称:www.alim.org,代码行数:23,代码来源:authcache_custom.default.php

示例4: testSetUpWithMissingDependencies

  /**
   * Verifies that the exception message in the profile step is correct.
   */
  public function testSetUpWithMissingDependencies() {
    // Prime the drupal_get_filename() static cache with the location of the
    // testing profile as it is not the currently active profile and we don't
    // yet have any cached way to retrieve its location.
    // @todo Remove as part of https://www.drupal.org/node/2186491
    drupal_get_filename('profile', 'testing_missing_dependencies', 'core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml');

    $info = drupal_verify_profile([
      'parameters' => ['profile' => 'testing_missing_dependencies'],
      'profile_info' => install_profile_info('testing_missing_dependencies'),
    ]);

    $message = $info['required_modules']['description']->render();
    $this->assertContains('Missing_module1', $message);
    $this->assertContains('Missing_module2', $message);
  }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:19,代码来源:InstallerMissingDependenciesTest.php

示例5: getContainerDefinition

 /**
  * {@inheritdoc}
  */
 public function getContainerDefinition()
 {
     FileCacheFactory::setConfiguration(array('default' => array('class' => '\\Drupal\\Component\\FileCache\\NullFileCache')));
     $container_builder = new ContainerBuilder();
     $yaml_loader = new YamlFileLoader($container_builder);
     foreach (module_list() as $module) {
         $filename = drupal_get_filename('module', $module);
         $services = dirname($filename) . "/{$module}.services.yml";
         if (file_exists($services)) {
             $yaml_loader->load($services);
         }
     }
     // Disabled for now.
     // $container_builder->compile();
     $dumper = new PhpArrayDumper($container_builder);
     return $dumper->getArray();
 }
开发者ID:EarthTeam,项目名称:earthteam.net,代码行数:20,代码来源:ServiceContainerSymfonyServiceProvider.php

示例6: testDrupalGetFilename

 /**
  * Tests that drupal_get_filename() works when the file is not in database.
  */
 function testDrupalGetFilename()
 {
     // drupal_get_profile() is using obtaining the profile from state if the
     // install_state global is not set.
     global $install_state;
     $install_state['parameters']['profile'] = 'testing';
     // Assert that this test is meaningful.
     $this->assertNull($this->container);
     $this->assertNull(\Drupal::getContainer());
     // Retrieving the location of a module.
     $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml');
     // Retrieving the location of a theme.
     $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml');
     // Retrieving the location of a theme engine.
     $this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.info.yml');
     // Retrieving the location of a profile. Profiles are a special case with
     // a fixed location and naming.
     $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.info.yml');
     // Searching for an item that does not exist returns NULL.
     $this->assertNull(drupal_get_filename('module', uniqid("", TRUE)), 'Searching for an item that does not exist returns NULL.');
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:GetFilenameUnitTest.php

示例7: testDrupalGetFilename

 /**
  * Tests that drupal_get_filename() works when the file is not in database.
  */
 function testDrupalGetFilename()
 {
     // drupal_get_profile() is using obtaining the profile from state if the
     // install_state global is not set.
     global $install_state;
     $install_state['parameters']['profile'] = 'testing';
     // Rebuild system.module.files state data.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     drupal_static_reset('system_rebuild_module_data');
     system_rebuild_module_data();
     // Retrieving the location of a module.
     $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml');
     // Retrieving the location of a theme.
     \Drupal::service('theme_handler')->install(array('stark'));
     $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml');
     // Retrieving the location of a theme engine.
     $this->assertIdentical(drupal_get_filename('theme_engine', 'twig'), 'core/themes/engines/twig/twig.info.yml');
     // Retrieving the location of a profile. Profiles are a special case with
     // a fixed location and naming.
     $this->assertIdentical(drupal_get_filename('profile', 'testing'), 'core/profiles/testing/testing.info.yml');
     // Generate a non-existing module name.
     $non_existing_module = uniqid("", TRUE);
     // Set a custom error handler so we can ignore the file not found error.
     set_error_handler(function ($severity, $message, $file, $line) {
         // Skip error handling if this is a "file not found" error.
         if (strstr($message, 'is missing from the file system:')) {
             \Drupal::state()->set('get_filename_test_triggered_error', TRUE);
             return;
         }
         throw new \ErrorException($message, 0, $severity, $file, $line);
     });
     $this->assertNull(drupal_get_filename('module', $non_existing_module), 'Searching for an item that does not exist returns NULL.');
     $this->assertTrue(\Drupal::state()->get('get_filename_test_triggered_error'), 'Searching for an item that does not exist triggers an error.');
     // Restore the original error handler.
     restore_error_handler();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:39,代码来源:GetFilenameUnitTest.php

示例8: module_list

function module_list($refresh = FALSE, $sort = FALSE, $fixed_list = NULL)
{
    static $list, $sorted_list;
    if ($refresh || $fixed_list) {
        $list = array();
        $sorted_list = NULL;
        if ($fixed_list) {
            foreach ($fixed_list as $name => $module) {
                drupal_get_filename('module', $name, $module['filename']);
                $list[$name] = $name;
            }
        } else {
            $result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
            while ($module = db_fetch_object($result)) {
                if (file_exists($module->filename)) {
                    // Determine the current throttle status and see if the module should be
                    // loaded based on server load. We have to directly access the throttle
                    // variables, since throttle.module may not be loaded yet.
                    $throttle = $module->throttle && variable_get('throttle_level', 0) > 0;
                    if (!$throttle) {
                        drupal_get_filename('module', $module->name, $module->filename);
                        $list[$module->name] = $module->name;
                    }
                }
            }
        }
    }
    if ($sort) {
        if (!isset($sorted_list)) {
            $sorted_list = $list;
            ksort($sorted_list);
        }
        return $sorted_list;
    }
    return $list;
}
开发者ID:renatoinnocenti,项目名称:ModulosZend,代码行数:36,代码来源:lib.Modulos.php

示例9: testCompileDIC

 /**
  * Tests DIC compilation.
  */
 public function testCompileDIC()
 {
     // @todo: write a memory based storage backend for testing.
     $modules_enabled = array('system' => 'system', 'user' => 'user');
     $request = Request::createFromGlobals();
     $this->getTestKernel($request, $modules_enabled);
     // Instantiate it a second time and we should get the compiled Container
     // class.
     $kernel = $this->getTestKernel($request);
     $container = $kernel->getContainer();
     $refClass = new \ReflectionClass($container);
     $is_compiled_container = !$refClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $this->assertTrue($is_compiled_container);
     // Verify that the list of modules is the same for the initial and the
     // compiled container.
     $module_list = array_keys($container->get('module_handler')->getModuleList());
     $this->assertEqual(array_values($modules_enabled), $module_list);
     // Get the container another time, simulating a "production" environment.
     $container = $this->getTestKernel($request, NULL)->getContainer();
     $refClass = new \ReflectionClass($container);
     $is_compiled_container = !$refClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $this->assertTrue($is_compiled_container);
     // Verify that the list of modules is the same for the initial and the
     // compiled container.
     $module_list = array_keys($container->get('module_handler')->getModuleList());
     $this->assertEqual(array_values($modules_enabled), $module_list);
     // Test that our synthetic services are there.
     $class_loader = $container->get('class_loader');
     $refClass = new \ReflectionClass($class_loader);
     $this->assertTrue($refClass->hasMethod('loadClass'), 'Container has a class loader');
     // We make this assertion here purely to show that the new container below
     // is functioning correctly, i.e. we get a brand new ContainerBuilder
     // which has the required new services, after changing the list of enabled
     // modules.
     $this->assertFalse($container->has('service_provider_test_class'));
     // Add another module so that we can test that the new module's bundle is
     // registered to the new container.
     $modules_enabled['service_provider_test'] = 'service_provider_test';
     $this->getTestKernel($request, $modules_enabled);
     // Instantiate it a second time and we should not get a ContainerBuilder
     // class because we are loading the container definition from cache.
     $kernel = $this->getTestKernel($request, $modules_enabled);
     $container = $kernel->getContainer();
     $refClass = new \ReflectionClass($container);
     $is_container_builder = $refClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
     $this->assertFalse($is_container_builder, 'Container is not a builder');
     // Assert that the new module's bundle was registered to the new container.
     $this->assertTrue($container->has('service_provider_test_class'), 'Container has test service');
     // Test that our synthetic services are there.
     $class_loader = $container->get('class_loader');
     $refClass = new \ReflectionClass($class_loader);
     $this->assertTrue($refClass->hasMethod('loadClass'), 'Container has a class loader');
     // Check that the location of the new module is registered.
     $modules = $container->getParameter('container.modules');
     $this->assertEqual($modules['service_provider_test'], array('type' => 'module', 'pathname' => drupal_get_filename('module', 'service_provider_test'), 'filename' => NULL));
     // Check that the container itself is not among the persist IDs because it
     // does not make sense to persist the container itself.
     $persist_ids = $container->getParameter('persist_ids');
     $this->assertIdentical(FALSE, array_search('service_container', $persist_ids));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:63,代码来源:DrupalKernelTest.php

示例10: substr

$insecure_session_name = substr($sessname, 1);
if (isset($_COOKIE[$sessname]) || isset($_COOKIE[$insecure_session_name])) {
  // Avoid later warnings about session-start :
  // session_start(): Cannot send session cache limiter - headers already sent
  // by emptying the session cache headers to send
  // The problem is that DRUPAL_BOOTSRAP_CONFIGURATION does a:
  // ini_set('session.cache_limiter', 'none');
  // So we must do that after that this step is done
  session_cache_limiter(FALSE);
  // this include DRUPAL_BOOTSTRAP_VARIABLES
  drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
}

// Can't use module_load_include as it's not loaded yet, so fallback to
// drupal_get_filename to find our module.
$path = '/' . dirname(drupal_get_filename('module', 'mongodb'));
require_once  DRUPAL_ROOT . $path .'/mongodb.module';

// --> response is already sent, now back at work. Let's record everything
if (variable_get('mongodb_statistics_count_content_views', 0)) {
  // We are counting content views.
  
  // A node has been viewed, so update the node's counters.
  $collectionname = variable_get('mongodb_node_counter_collection_name', 'node_counter');
  $collection = mongodb_collection($collectionname);
  $nid = isset($_POST['nid']) ? (int) $_POST['nid'] : 0;
  $collection->update(
    array('_id' => $nid),
    array(
      '$inc' => array(
        'totalcount' => 1,
开发者ID:regilero,项目名称:drupal_mongodb_statistics,代码行数:31,代码来源:tracker.php

示例11: drupalGetFilename

 /**
  * {@inheritdoc}
  */
 function drupalGetFilename($type, $name)
 {
     return \Drupal::root() . '/' . drupal_get_filename($type, $name);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:7,代码来源:DrupalSystem.php

示例12: getAllFolders

 /**
  * Returns a map of all config object names and their folders.
  *
  * The list is based on enabled modules and themes. The active configuration
  * storage is used rather than \Drupal\Core\Extension\ModuleHandler and
  *  \Drupal\Core\Extension\ThemeHandler in order to resolve circular
  * dependencies between these services and \Drupal\Core\Config\ConfigInstaller
  * and \Drupal\Core\Config\TypedConfigManager.
  *
  * @return array
  *   An array mapping config object names with directories.
  */
 protected function getAllFolders()
 {
     if (!isset($this->folders)) {
         $this->folders = array();
         $this->folders += $this->getCoreNames();
         $install_profile = Settings::get('install_profile');
         $profile = drupal_get_profile();
         $extensions = $this->configStorage->read('core.extension');
         // @todo Remove this scan as part of https://www.drupal.org/node/2186491
         $listing = new ExtensionDiscovery(\Drupal::root());
         if (!empty($extensions['module'])) {
             $modules = $extensions['module'];
             // Remove the install profile as this is handled later.
             unset($modules[$install_profile]);
             $profile_list = $listing->scan('profile');
             if ($profile && isset($profile_list[$profile])) {
                 // Prime the drupal_get_filename() static cache with the profile info
                 // file location so we can use drupal_get_path() on the active profile
                 // during the module scan.
                 // @todo Remove as part of https://www.drupal.org/node/2186491
                 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname());
             }
             $module_list_scan = $listing->scan('module');
             $module_list = array();
             foreach (array_keys($modules) as $module) {
                 if (isset($module_list_scan[$module])) {
                     $module_list[$module] = $module_list_scan[$module];
                 }
             }
             $this->folders += $this->getComponentNames($module_list);
         }
         if (!empty($extensions['theme'])) {
             $theme_list_scan = $listing->scan('theme');
             foreach (array_keys($extensions['theme']) as $theme) {
                 if (isset($theme_list_scan[$theme])) {
                     $theme_list[$theme] = $theme_list_scan[$theme];
                 }
             }
             $this->folders += $this->getComponentNames($theme_list);
         }
         if ($this->includeProfile) {
             // The install profile can override module default configuration. We do
             // this by replacing the config file path from the module/theme with the
             // install profile version if there are any duplicates.
             if (isset($profile)) {
                 if (!isset($profile_list)) {
                     $profile_list = $listing->scan('profile');
                 }
                 if (isset($profile_list[$profile])) {
                     $profile_folders = $this->getComponentNames(array($profile_list[$profile]));
                     $this->folders = $profile_folders + $this->folders;
                 }
             }
         }
     }
     return $this->folders;
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:69,代码来源:ExtensionInstallStorage.php

示例13: drupalGetFilename

 /**
  * {@inheritdoc}
  */
 function drupalGetFilename($type, $name)
 {
     return DRUPAL_ROOT . '/' . drupal_get_filename($type, $name);
 }
开发者ID:isaenkov,项目名称:Dru.io,代码行数:7,代码来源:DrupalSystem.php

示例14: _authcache_authcache_example

/**
 * Example of customized block info being returned
 * @see authcache_example.module
 */
function _authcache_authcache_example($vars) {
  include_once './includes/common.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); // Use FULL if needed for additional functions

  include_once dirname(drupal_get_filename('module', 'authcache_example')) . '/authcache_example.module';
  return authcache_example_display_block_0();
}
开发者ID:ATouhou,项目名称:www.alim.org,代码行数:11,代码来源:authcache.php

示例15: listExtensionConfig

 /**
  * {@inheritdoc}
  */
 public function listExtensionConfig($extension) {
   // Convert to Component object if it is a string
   if (is_string($extension)) {
     $pathname = drupal_get_filename('module', $extension);
     $extension = new Extension(\Drupal::root(), 'module', $pathname);
   }
   return array_keys($this->extensionStorage->getComponentNames([
     $this->getExtensionName($extension) => $extension,
   ]));
 }
开发者ID:jeetendrasingh,项目名称:manage_profile,代码行数:13,代码来源:FeaturesManager.php


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