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


PHP Extension\ExtensionDiscovery类代码示例

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


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

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

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

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

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

示例5: getAllFolders

 /**
  * {@inheritdoc}
  */
 protected function getAllFolders()
 {
     if (!isset($this->folders)) {
         $listing = new ExtensionDiscovery(\Drupal::root());
         $modules = $listing->scan('module');
         $this->folders = $this->getComponentNames(array('behat_test' => $modules['behat_test']));
     }
     return $this->folders;
 }
开发者ID:alfonsojoven,项目名称:drupalextension,代码行数:12,代码来源:BehatTestExtensionInstallStorage.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     // Theme settings rely on System module's system.theme.global configuration.
     $this->installConfig(array('system'));
     if (!isset($this->availableThemes)) {
         $discovery = new ExtensionDiscovery(\Drupal::root());
         $this->availableThemes = $discovery->scan('theme');
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:10,代码来源:ThemeSettingsTest.php

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

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

示例9: getModules

 /**
  * [getModules description]
  * @param  boolean $core Return core modules
  * @return array list of modules
  */
 public function getModules($core = false)
 {
     if (null === $this->modules) {
         $this->modules = [];
         $extensionDiscover = new ExtensionDiscovery(\Drupal::root());
         $moduleList = $extensionDiscover->scan('module');
         foreach ($moduleList as $name => $filename) {
             if ($core) {
                 array_push($this->modules, $name);
             } elseif (!preg_match('/^core/', $filename->getPathname())) {
                 array_push($this->modules, $name);
             }
         }
     }
     return $this->modules;
 }
开发者ID:palantirnet,项目名称:DrupalConsole,代码行数:21,代码来源:ContainerAwareCommand.php

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

示例11: enableModules

 /**
  * Enables modules for this test.
  */
 protected function enableModules(array $modules)
 {
     // Perform an ExtensionDiscovery scan as this function may receive a
     // profile that is not the current profile, and we don't yet have a cached
     // way to receive inactive profile information.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     $listing = new ExtensionDiscovery(\Drupal::root());
     $module_list = $listing->scan('module');
     // In ModuleHandlerTest we pass in a profile as if it were a module.
     $module_list += $listing->scan('profile');
     // Set the list of modules in the extension handler.
     $module_handler = $this->container->get('module_handler');
     // Write directly to active storage to avoid early instantiation of
     // the event dispatcher which can prevent modules from registering events.
     $active_storage = $this->container->get('config.storage');
     $extension_config = $active_storage->read('core.extension');
     foreach ($modules as $module) {
         if ($module_handler->moduleExists($module)) {
             throw new \LogicException("{$module} module is already enabled.");
         }
         $module_handler->addModule($module, $module_list[$module]->getPath());
         // Maintain the list of enabled modules in configuration.
         $extension_config['module'][$module] = 0;
     }
     $active_storage->write('core.extension', $extension_config);
     // Update the kernel to make their services available.
     $extensions = $module_handler->getModuleList();
     $this->container->get('kernel')->updateModules($extensions, $extensions);
     // Ensure isLoaded() is TRUE in order to make
     // \Drupal\Core\Theme\ThemeManagerInterface::render() work.
     // Note that the kernel has rebuilt the container; this $module_handler is
     // no longer the $module_handler instance from above.
     $module_handler = $this->container->get('module_handler');
     $module_handler->reload();
     foreach ($modules as $module) {
         if (!$module_handler->moduleExists($module)) {
             throw new \RuntimeException("{$module} module is not enabled after enabling it.");
         }
     }
 }
开发者ID:Wylbur,项目名称:gj,代码行数:43,代码来源:SecureLoginTestBlock.php

示例12: setUp

 protected function setUp()
 {
     parent::setUp();
     // Install all available non-testing themes.
     $listing = new ExtensionDiscovery(\Drupal::root());
     $this->themes = $listing->scan('theme', FALSE);
     \Drupal::service('theme_handler')->install(array_keys($this->themes));
     // Create a test user.
     $this->user = $this->drupalCreateUser(array('access content', 'access user profiles'));
     $this->user->name = $this->xssLabel;
     $this->user->save();
     $this->drupalLogin($this->user);
     // Create a test term.
     $this->term = entity_create('taxonomy_term', array('name' => $this->xssLabel, 'vid' => 1));
     $this->term->save();
     // Add a comment field.
     $this->addDefaultCommentField('node', 'article', 'comment', CommentItemInterface::OPEN);
     // Create a test node tagged with the test term.
     $this->node = $this->drupalCreateNode(array('title' => $this->xssLabel, 'type' => 'article', 'promote' => NODE_PROMOTED, 'field_tags' => array(array('target_id' => $this->term->id()))));
     // Create a test comment on the test node.
     $this->comment = entity_create('comment', array('entity_id' => $this->node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, 'subject' => $this->xssLabel, 'comment_body' => array($this->randomMachineName())));
     $this->comment->save();
 }
开发者ID:papillon-cendre,项目名称:d8,代码行数:23,代码来源:EntityFilteringThemeTest.php

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

示例14: scanExtensionsAndLoadUpdateFiles

 /**
  * Scans all module + profile extensions and load the update files.
  */
 protected function scanExtensionsAndLoadUpdateFiles()
 {
     // Scan the module list.
     $extension_discovery = new ExtensionDiscovery($this->root, FALSE, [], $this->sitePath);
     $module_extensions = $extension_discovery->scan('module');
     $profile_extensions = $extension_discovery->scan('profile');
     $extensions = array_merge($module_extensions, $profile_extensions);
     $this->loadUpdateFiles($extensions);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:12,代码来源:UpdateRegistry.php

示例15: enableModules

 /**
  * Enables modules for this test.
  *
  * @param array $modules
  *   A list of modules to enable. Dependencies are not resolved; i.e.,
  *   multiple modules have to be specified with dependent modules first.
  *   The new modules are only added to the active module list and loaded.
  */
 protected function enableModules(array $modules)
 {
     // Perform an ExtensionDiscovery scan as this function may receive a
     // profile that is not the current profile, and we don't yet have a cached
     // way to receive inactive profile information.
     // @todo Remove as part of https://www.drupal.org/node/2186491
     $listing = new ExtensionDiscovery(\Drupal::root());
     $module_list = $listing->scan('module');
     // In ModuleHandlerTest we pass in a profile as if it were a module.
     $module_list += $listing->scan('profile');
     // Set the list of modules in the extension handler.
     $module_handler = $this->container->get('module_handler');
     // Write directly to active storage to avoid early instantiation of
     // the event dispatcher which can prevent modules from registering events.
     $active_storage = \Drupal::service('config.storage');
     $extensions = $active_storage->read('core.extension');
     foreach ($modules as $module) {
         $module_handler->addModule($module, $module_list[$module]->getPath());
         // Maintain the list of enabled modules in configuration.
         $extensions['module'][$module] = 0;
     }
     $active_storage->write('core.extension', $extensions);
     // Update the kernel to make their services available.
     $module_filenames = $module_handler->getModuleList();
     $this->kernel->updateModules($module_filenames, $module_filenames);
     // Ensure isLoaded() is TRUE in order to make _theme() work.
     // Note that the kernel has rebuilt the container; this $module_handler is
     // no longer the $module_handler instance from above.
     $this->container->get('module_handler')->reload();
     $this->pass(format_string('Enabled modules: %modules.', array('%modules' => implode(', ', $modules))));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:39,代码来源:KernelTestBase.php


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