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


PHP ExtensionDiscovery::setProfileDirectories方法代码示例

本文整理汇总了PHP中Drupal\Core\Extension\ExtensionDiscovery::setProfileDirectories方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtensionDiscovery::setProfileDirectories方法的具体用法?PHP ExtensionDiscovery::setProfileDirectories怎么用?PHP ExtensionDiscovery::setProfileDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Extension\ExtensionDiscovery的用法示例。


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

示例1: testDirectoryPrecedence

 /**
  * Tests that files in different directories take precedence as expected.
  */
 function testDirectoryPrecedence()
 {
     // Define the module files we will search for, and the directory precedence
     // we expect.
     $expected_directories = array('drupal_system_listing_compatible_test' => array('core/profiles/testing/modules', 'core/modules/system/tests/modules'));
     // This test relies on two versions of the same module existing in
     // different places in the filesystem. Without that, the test has no
     // meaning, so assert their presence first.
     foreach ($expected_directories as $module => $directories) {
         foreach ($directories as $directory) {
             $filename = "{$directory}/{$module}/{$module}.info.yml";
             $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename)));
         }
     }
     // Now scan the directories and check that the files take precedence as
     // expected.
     $listing = new ExtensionDiscovery(\Drupal::root());
     $listing->setProfileDirectories(array('core/profiles/testing'));
     $files = $listing->scan('module');
     foreach ($expected_directories as $module => $directories) {
         $expected_directory = array_shift($directories);
         $expected_uri = "{$expected_directory}/{$module}/{$module}.info.yml";
         $this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', array('@actual' => $files[$module]->getPathname(), '@expected' => $expected_uri)));
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:28,代码来源:SystemListingTest.php

示例2: testExtensionDiscoveryVfs

 /**
  * Tests extension discovery in a virtual filesystem with vfsStream.
  *
  * @covers ::scan
  */
 public function testExtensionDiscoveryVfs()
 {
     // Set up the file system.
     $filesystem = [];
     $files_by_type_and_name_expected = $this->populateFilesystemStructure($filesystem);
     $vfs = vfsStream::setup('root', NULL, $filesystem);
     $root = $vfs->url();
     $this->assertFileExists($root . '/core/modules/system/system.module');
     $this->assertFileExists($root . '/core/modules/system/system.info.yml');
     // Create an ExtensionDiscovery with $root.
     $extension_discovery = new ExtensionDiscovery($root, FALSE, NULL, 'sites/default');
     /** @var \Drupal\Core\Extension\Extension[][] $extensions_by_type */
     $extensions_by_type = [];
     $files_by_type_and_name = [];
     foreach (['profile', 'module', 'theme', 'theme_engine'] as $type) {
         $extensions_by_type[$type] = $extension_discovery->scan($type, FALSE);
         foreach ($extensions_by_type[$type] as $name => $extension) {
             $files_by_type_and_name[$type][$name] = $extension->getPathname();
         }
         if ($type === 'profile') {
             // Set profile directories for discovery of the other extension types.
             $extension_discovery->setProfileDirectories(['myprofile' => 'profiles/myprofile']);
         }
     }
     $this->assertEquals($files_by_type_and_name_expected, $files_by_type_and_name);
     $extension_expected = new Extension($root, 'module', 'core/modules/system/system.info.yml', 'system.module');
     $extension_expected->subpath = 'modules/system';
     $extension_expected->origin = 'core';
     $this->assertEquals($extension_expected, $extensions_by_type['module']['system'], 'system');
     $extension_expected = new Extension($root, 'theme_engine', 'core/themes/engines/twig/twig.info.yml', 'twig.engine');
     $extension_expected->subpath = 'themes/engines/twig';
     $extension_expected->origin = 'core';
     $this->assertEquals($extension_expected, $extensions_by_type['theme_engine']['twig'], 'twig');
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:39,代码来源:ExtensionDiscoveryTest.php

示例3: testInstaller

 /**
  * Ensures that the user page is available after installation.
  */
 public function testInstaller()
 {
     $this->assertUrl('user/1');
     $this->assertResponse(200);
     // Confirm that we are logged-in after installation.
     $this->assertText($this->rootUser->getUsername());
     // @todo hmmm this message is wrong!
     // Verify that the confirmation message appears.
     require_once \Drupal::root() . '/core/includes/install.inc';
     $this->assertRaw(t('Congratulations, you installed @drupal!', array('@drupal' => drupal_install_profile_distribution_name())));
     // Ensure that all modules, profile and themes have been installed and have
     // expected weights.
     $sync = \Drupal::service('config.storage.sync');
     $sync_core_extension = $sync->read('core.extension');
     $this->assertIdentical($sync_core_extension, \Drupal::config('core.extension')->get());
     // Ensure that the correct install profile has been written to settings.php.
     $listing = new ExtensionDiscovery(\Drupal::root());
     $listing->setProfileDirectories([]);
     $profiles = array_intersect_key($listing->scan('profile'), $sync_core_extension['module']);
     $current_profile = Settings::get('install_profile');
     $this->assertFalse(empty($current_profile), 'The $install_profile setting exists');
     $this->assertEqual($current_profile, key($profiles));
     // Test that any configuration entities in sync have been created.
     // @todo
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:28,代码来源:ConfigInstallerTestBase.php

示例4: getAllFolders

 /**
  * {@inheritdoc}
  */
 protected function getAllFolders()
 {
     if (!isset($this->folders)) {
         $this->folders = $this->getCoreNames();
         $listing = new ExtensionDiscovery(\Drupal::root());
         $listing->setProfileDirectories(array());
         $this->folders += $this->getComponentNames($listing->scan('profile'));
         $this->folders += $this->getComponentNames($listing->scan('module'));
         $this->folders += $this->getComponentNames($listing->scan('theme'));
     }
     return $this->folders;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:15,代码来源:TestInstallStorage.php

示例5: getAllFolders

 /**
  * {@inheritdoc}
  */
 protected function getAllFolders()
 {
     if (!isset($this->folders)) {
         $this->folders = $this->getComponentNames('core', array('core'));
         // @todo Refactor getComponentNames() to use the extension list directly.
         $listing = new ExtensionDiscovery(\Drupal::root());
         $listing->setProfileDirectories(array());
         $this->folders += $this->getComponentNames('profile', array_keys($listing->scan('profile')));
         $this->folders += $this->getComponentNames('module', array_keys($listing->scan('module')));
         $this->folders += $this->getComponentNames('theme', array_keys($listing->scan('theme')));
     }
     return $this->folders;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:16,代码来源:TestInstallStorage.php

示例6: testFileScanIgnoreDirectory

 /**
  * Tests that directories matching file_scan_ignore_directories are ignored
  */
 public function testFileScanIgnoreDirectory()
 {
     $listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
     $listing->setProfileDirectories(array('core/profiles/testing'));
     $files = $listing->scan('module');
     $this->assertArrayHasKey('drupal_system_listing_compatible_test', $files);
     // Reset the static to force a rescan of the directories.
     $reflected_class = new \ReflectionClass(ExtensionDiscovery::class);
     $reflected_property = $reflected_class->getProperty('files');
     $reflected_property->setAccessible(TRUE);
     $reflected_property->setValue($reflected_class, []);
     $this->setSetting('file_scan_ignore_directories', ['drupal_system_listing_compatible_test']);
     $listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
     $listing->setProfileDirectories(array('core/profiles/testing'));
     $files = $listing->scan('module');
     $this->assertArrayNotHasKey('drupal_system_listing_compatible_test', $files);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:20,代码来源:SystemListingTest.php

示例7: moduleData

 /**
  * Returns module data on the filesystem.
  *
  * @param $module
  *   The name of the module.
  *
  * @return \Drupal\Core\Extension\Extension|bool
  *   Returns an Extension object if the module is found, FALSE otherwise.
  */
 protected function moduleData($module)
 {
     if (!$this->moduleData) {
         // First, find profiles.
         $listing = new ExtensionDiscovery($this->root);
         $listing->setProfileDirectories(array());
         $all_profiles = $listing->scan('profile');
         $profiles = array_intersect_key($all_profiles, $this->moduleList);
         // If a module is within a profile directory but specifies another
         // profile for testing, it needs to be found in the parent profile.
         $settings = $this->getConfigStorage()->read('simpletest.settings');
         $parent_profile = !empty($settings['parent_profile']) ? $settings['parent_profile'] : NULL;
         if ($parent_profile && !isset($profiles[$parent_profile])) {
             // In case both profile directories contain the same extension, the
             // actual profile always has precedence.
             $profiles = array($parent_profile => $all_profiles[$parent_profile]) + $profiles;
         }
         $profile_directories = array_map(function ($profile) {
             return $profile->getPath();
         }, $profiles);
         $listing->setProfileDirectories($profile_directories);
         // Now find modules.
         $this->moduleData = $profiles + $listing->scan('module');
     }
     return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:DrupalKernel.php

示例8: getExtensions

 /**
  * Returns all available extensions.
  *
  * @return \Drupal\Core\Extension\Extension[]
  *   An array of Extension objects, keyed by extension name.
  */
 protected function getExtensions()
 {
     $listing = new ExtensionDiscovery(DRUPAL_ROOT);
     // Ensure that tests in all profiles are discovered.
     $listing->setProfileDirectories(array());
     $extensions = $listing->scan('module', TRUE);
     $extensions += $listing->scan('profile', TRUE);
     $extensions += $listing->scan('theme', TRUE);
     return $extensions;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:16,代码来源:TestDiscovery.php

示例9: getExtensionsForModules

 /**
  * Returns Extension objects for $modules to enable.
  *
  * @param string[] $modules
  *   The list of modules to enable.
  *
  * @return \Drupal\Core\Extension\Extension[]
  *   Extension objects for $modules, keyed by module name.
  *
  * @throws \PHPUnit_Framework_Exception
  *   If a module is not available.
  *
  * @see \Drupal\Tests\KernelTestBase::enableModules()
  * @see \Drupal\Core\Extension\ModuleHandler::add()
  */
 private function getExtensionsForModules(array $modules)
 {
     $extensions = array();
     $discovery = new ExtensionDiscovery($this->root);
     $discovery->setProfileDirectories(array());
     $list = $discovery->scan('module');
     foreach ($modules as $name) {
         if (!isset($list[$name])) {
             throw new \PHPUnit_Framework_Exception("Unavailable module: '{$name}'. If this module needs to be downloaded separately, annotate the test class with '@requires module {$name}'.");
         }
         $extensions[$name] = $list[$name];
     }
     return $extensions;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:29,代码来源:KernelTestBase.php

示例10: getAllModules

 /**
  * {@inheritdoc}
  */
 public function getAllModules(FeaturesBundleInterface $bundle = NULL)
 {
     // ModuleHandler::getModuleDirectories() returns data only for installed
     // modules. system_rebuild_module_data() includes only the site's install
     // profile directory, while we may need to include a custom profile.
     // @see _system_rebuild_module_data().
     $listing = new ExtensionDiscovery(\Drupal::root());
     $profile_directories = [];
     // Register the install profile.
     $installed_profile = drupal_get_profile();
     if ($installed_profile) {
         $profile_directories[] = drupal_get_path('profile', $installed_profile);
     }
     if (isset($bundle) && $bundle->isProfile()) {
         $profile_directory = 'profiles/' . $bundle->getProfileName();
         if ($bundle->getProfileName() != $installed_profile && is_dir($profile_directory)) {
             $profile_directories[] = $profile_directory;
         }
     }
     $listing->setProfileDirectories($profile_directories);
     // Find modules.
     $modules = $listing->scan('module');
     // Find installation profiles.
     $profiles = $listing->scan('profile');
     foreach ($profiles as $key => $profile) {
         $modules[$key] = $profile;
     }
     $return = array();
     // Detect modules by namespace.
     // If namespace is provided but is empty, then match all modules.
     foreach ($modules as $module_name => $extension) {
         if ($this->isFeatureModule($extension) && (!isset($bundle) || $bundle->isDefault() || $bundle->inBundle($module_name))) {
             $return[$module_name] = $extension;
         }
     }
     return $return;
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:40,代码来源:FeaturesManager.php

示例11: getAllFolders

 /**
  * Returns a map of all config object names and their folders.
  *
  * The list is based on installed 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.
  *
  * NOTE: This code is copied from ExtensionInstallStorage::getAllFolders() with
  * the following changes (Notes in CHANGED below)
  *   - Load all modules whether installed or not
  *
  * @return array
  *   An array mapping config object names with directories.
  */
 public 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());
         // CHANGED START: Add profile directories for any bundles that use a profile.
         $profile_directories = [];
         if ($profile) {
             $profile_directories[] = drupal_get_path('profile', $profile);
         }
         if ($this->includeProfile) {
             // Add any profiles used in bundles.
             /** @var \Drupal\features\FeaturesAssignerInterface $assigner */
             $assigner = \Drupal::service('features_assigner');
             $bundles = $assigner->getBundleList();
             foreach ($bundles as $bundle_name => $bundle) {
                 if ($bundle->isProfile()) {
                     // Register the profile directory.
                     $profile_directory = 'profiles/' . $bundle->getProfileName();
                     if (is_dir($profile_directory)) {
                         $profile_directories[] = $profile_directory;
                     }
                 }
             }
         }
         $listing->setProfileDirectories($profile_directories);
         // CHANGED END
         if (!empty($extensions['module'])) {
             // CHANGED START: Find ANY modules, not just installed ones.
             //$modules = $extensions['module'];
             $module_list_scan = $listing->scan('module');
             $modules = $module_list_scan;
             // CHANGED END
             // 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 = array();
             foreach (array_keys($module_list_scan) 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:robertfoleyjr,项目名称:robertfoleyjr-d8,代码行数:100,代码来源:FeaturesInstallStorage.php

示例12: getAllModules

 /**
  * {@inheritdoc}
  */
 public function getAllModules()
 {
     static $modules;
     if (!isset($modules)) {
         // ModuleHandler::getModuleDirectories() returns data only for installed
         // modules. system_rebuild_module_data() includes only the site's install
         // profile directory, while we may need to include a custom profile.
         // @see _system_rebuild_module_data().
         $listing = new ExtensionDiscovery(\Drupal::root());
         $profile_directories = [];
         // Register the install profile.
         $installed_profile = $this->drupalGetProfile();
         if ($installed_profile) {
             $profile_directories[] = drupal_get_path('profile', $installed_profile);
         }
         if (isset($bundle) && $bundle->isProfile()) {
             $profile_directory = 'profiles/' . $bundle->getProfileName();
             if ($bundle->getProfileName() != $installed_profile && is_dir($profile_directory)) {
                 $profile_directories[] = $profile_directory;
             }
         }
         $listing->setProfileDirectories($profile_directories);
         // Find modules.
         $modules = $listing->scan('module');
         // Find installation profiles.
         $profiles = $listing->scan('profile');
         foreach ($profiles as $key => $profile) {
             $modules[$key] = $profile;
         }
     }
     return $modules;
 }
开发者ID:curveagency,项目名称:intranet,代码行数:35,代码来源:FeaturesManager.php


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