コード例 #1
0
 public function terminate()
 {
     if ($this->booted) {
         $response = Response::create('');
         $this->kernel->terminate($this->request, $response);
     }
 }
コード例 #2
0
 /**
  * Tests the exception when container_yamls is not set.
  */
 public function testDiscoverServiceNoContainerYamls()
 {
     new Settings([]);
     $kernel = new DrupalKernel('prod', new \Composer\Autoload\ClassLoader());
     $kernel->discoverServiceProviders();
     $expect = ['app' => ['core' => 'core/core.services.yml'], 'site' => []];
     $this->assertAttributeSame($expect, 'serviceYamls', $kernel);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function discoverServiceProviders()
 {
     parent::discoverServiceProviders();
     // The test runner does not require an installed Drupal site to exist.
     // Therefore, its environment is identical to that of the early installer.
     $this->serviceProviderClasses['app']['Test'] = 'Drupal\\Core\\Installer\\InstallerServiceProvider';
 }
コード例 #4
0
ファイル: BaseUrl.php プロジェクト: AohRveTPV/security_review
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $settingsPath = DRUPAL_ROOT . '/' . DrupalKernel::findSitePath(Drupal::request()) . '/settings.php';
     $result = CheckResult::FAIL;
     $findings = array();
     if (file_exists($settingsPath)) {
         if ($this->settings()->get('method', 'token') === 'token') {
             $content = file_get_contents($settingsPath);
             $tokens = token_get_all($content);
             foreach ($tokens as $token) {
                 if (is_array($token) && $token[0] === T_VARIABLE && $token[1] == '$base_url') {
                     $result = CheckResult::SUCCESS;
                     break;
                 }
             }
         } else {
             include $settingsPath;
             if (isset($base_url)) {
                 $result = CheckResult::SUCCESS;
             }
         }
         global $base_url;
         if ($result === CheckResult::FAIL) {
             $findings[] = t('Your site is available at the following URL: !url.', array('!url' => $base_url));
             $findings[] = t("If your site should only be available at that URL it is recommended that you set it as the \$base_url variable in the settings.php file at !file", array('!file' => $settingsPath));
             $findings[] = t("Or, if you are using Drupal's multi-site functionality then you should set the \$base_url variable for the appropriate settings.php for your site.");
         }
         return $this->createResult($result, $findings);
     } else {
         return $this->createResult(CheckResult::INFO, array(t("Couldn't determine settings.php's path.")));
     }
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 protected function initializeContainer()
 {
     // Always force a container rebuild.
     $this->containerNeedsRebuild = TRUE;
     $container = parent::initializeContainer();
     return $container;
 }
コード例 #6
0
 /**
  * @covers ::validateHostname
  * @dataProvider providerTestValidateHostname
  */
 public function testValidateHostname($hostname, $message, $expected = FALSE)
 {
     $server = ['HTTP_HOST' => $hostname];
     $request = new Request([], [], [], [], [], $server);
     $validated_hostname = DrupalKernel::validateHostname($request);
     $this->assertSame($expected, $validated_hostname, $message);
 }
コード例 #7
0
 function setUp()
 {
     parent::setUp();
     // Add file_private_path setting.
     $request = Request::create('/');
     $site_path = DrupalKernel::findSitePath($request);
     $this->setSetting('file_private_path', $site_path . '/private');
 }
コード例 #8
0
ファイル: UpdateKernel.php プロジェクト: 318io/318-io
 /**
  * {@inheritdoc}
  */
 protected function initializeContainer()
 {
     // Always force a container rebuild, in order to be able to override some
     // services, see \Drupal\Core\Update\UpdateServiceProvider.
     $this->containerNeedsRebuild = TRUE;
     $container = parent::initializeContainer();
     return $container;
 }
コード例 #9
0
 /**
  * @inheritdoc
  */
 protected function getContainerBuilder()
 {
     $container = parent::getContainerBuilder();
     foreach ($this->serviceModifiers as $serviceModifier) {
         $serviceModifier->alter($container);
     }
     return $container;
 }
コード例 #10
0
ファイル: DrupalKernel.php プロジェクト: hanoii/drush
 /**
  * @inheritdoc
  */
 protected function getContainerBuilder()
 {
     drush_log(dt("get container builder"), LogLevel::DEBUG);
     $container = parent::getContainerBuilder();
     foreach ($this->serviceModifiers as $serviceModifier) {
         $serviceModifier->alter($container);
     }
     return $container;
 }
コード例 #11
0
ファイル: DrupalBoot8.php プロジェクト: nuwud/drush
 function bootstrap_drupal_configuration()
 {
     $this->request = Request::createFromGlobals();
     $classloader = drush_drupal_load_autoloader(DRUPAL_ROOT);
     $this->kernel = DrupalKernel::createFromRequest($this->request, $classloader, 'prod');
     // Unset drupal error handler and restore drush's one.
     restore_error_handler();
     parent::bootstrap_drupal_configuration();
 }
コード例 #12
0
 function setUp()
 {
     // Add file_private_path setting.
     $settings = Settings::getAll();
     $request = Request::create('/');
     $site_path = DrupalKernel::findSitePath($request);
     $settings['file_private_path'] = $site_path . '/private';
     new Settings($settings + Settings::getAll());
     parent::setUp();
 }
コード例 #13
0
ファイル: TestKernel.php プロジェクト: ddrozdik/dmaps
 /**
  * {@inheritdoc}
  */
 public function __construct($environment, $class_loader, $allow_dumping = TRUE)
 {
     // Include our bootstrap file.
     require_once __DIR__ . '/../../../../includes/bootstrap.inc';
     // Exit if we should be in a test environment but aren't.
     if (!drupal_valid_test_ua()) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
         exit;
     }
     parent::__construct($environment, $class_loader, $allow_dumping);
 }
コード例 #14
0
 /**
  * {@inheritdoc}
  */
 public static function createFromRequest(Request $request, ClassLoader $class_loader, $environment, $allow_dumping = TRUE)
 {
     // Include our bootstrap file.
     require_once __DIR__ . '/../../../../includes/bootstrap.inc';
     // Exit if we should be in a test environment but aren't.
     if (!drupal_valid_test_ua()) {
         header($request->server->get('SERVER_PROTOCOL') . ' 403 Forbidden');
         exit;
     }
     return parent::createFromRequest($request, $class_loader, $environment, $allow_dumping);
 }
コード例 #15
0
ファイル: Drupal8.php プロジェクト: philrennie/boris-loader
 public function initialize(\Boris\Boris $boris, $dir)
 {
     parent::initialize($boris, $dir);
     $classloader = (require_once $dir . '/core/vendor/autoload.php');
     $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
     $kernel = \Drupal\Core\DrupalKernel::createFromRequest($request, $classloader, 'dev');
     $kernel->boot();
     $kernel->prepareLegacyRequest($request);
     \Drupal::getContainer()->set('request', $request);
     $boris->onStart(function ($worker, $vars) use($kernel) {
         $worker->setLocal('kernel', $kernel);
         $worker->setLocal('container', $kernel->getContainer());
     });
 }
コード例 #16
0
 /**
  * {@inheritdoc}
  *
  * Configures a preexisting settings.php file without an install_profile
  * setting before invoking the interactive installer.
  */
 protected function setUp()
 {
     // Pre-configure hash salt.
     // Any string is valid, so simply use the class name of this test.
     $this->settings['settings']['hash_salt'] = (object) array('value' => __CLASS__, 'required' => TRUE);
     // Pre-configure database credentials.
     $connection_info = Database::getConnectionInfo();
     unset($connection_info['default']['pdo']);
     unset($connection_info['default']['init_commands']);
     $this->settings['databases']['default'] = (object) array('value' => $connection_info, 'required' => TRUE);
     // Pre-configure config directories.
     $this->settings['config_directories'] = array(CONFIG_SYNC_DIRECTORY => (object) array('value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync', 'required' => TRUE));
     mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
     parent::setUp();
 }
コード例 #17
0
 /**
  * Build a kernel for testings.
  *
  * Because the bootstrap is in DrupalKernel::boot and that involved loading
  * settings from the filesystem we need to go to extra lengths to build a kernel
  * for testing.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   A request object to use in booting the kernel.
  * @param array $modules_enabled
  *   A list of modules to enable on the kernel.
  * @param bool $read_only
  *   Build the kernel in a read only state.
  * @return DrupalKernel
  */
 protected function getTestKernel(Request $request, array $modules_enabled = NULL, $read_only = FALSE)
 {
     // Manually create kernel to avoid replacing settings.
     $kernel = DrupalKernel::createFromRequest($request, drupal_classloader(), 'testing');
     $this->settingsSet('hash_salt', $this->databasePrefix);
     if (isset($modules_enabled)) {
         $kernel->updateModules($modules_enabled);
     }
     $kernel->boot();
     if ($read_only) {
         $php_storage = Settings::get('php_storage');
         $php_storage['service_container']['class'] = 'Drupal\\Component\\PhpStorage\\FileReadOnlyStorage';
         $this->settingsSet('php_storage', $php_storage);
     }
     return $kernel;
 }
コード例 #18
0
ファイル: DrupalKernelTest.php プロジェクト: aWEBoLabs/taxi
        /**
         * Tests site path finding.
         *
         * This test is run in a separate process since it defines DRUPAL_ROOT. This
         * stops any possible pollution of other tests.
         *
         * @covers ::findSitePath
         * @runInSeparateProcess
         */
        public function testFindSitePath()
        {
            $vfs_root = vfsStream::setup('drupal_root');
            $sites_php = <<<'EOD'
<?php
$sites['8888.www.example.org'] = 'example';
EOD;
            // Create the expected directory structure.
            vfsStream::create(['sites' => ['sites.php' => $sites_php, 'example' => ['settings.php' => 'test']]]);
            define('DRUPAL_ROOT', $vfs_root->url('drupal_root'));
            $request = new Request();
            $request->server->set('SERVER_NAME', 'www.example.org');
            $request->server->set('SERVER_PORT', '8888');
            $request->server->set('SCRIPT_NAME', '/index.php');
            $this->assertEquals('sites/example', DrupalKernel::findSitePath($request));
        }
コード例 #19
0
ファイル: Drupal8.php プロジェクト: dliau/DrupalDriver
 /**
  * {@inheritdoc}
  */
 public function bootstrap()
 {
     // Validate, and prepare environment for Drupal bootstrap.
     if (!defined('DRUPAL_ROOT')) {
         define('DRUPAL_ROOT', $this->drupalRoot);
     }
     // Bootstrap Drupal.
     chdir(DRUPAL_ROOT);
     $autoloader = (require DRUPAL_ROOT . '/autoload.php');
     require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
     $this->validateDrupalSite();
     $request = Request::createFromGlobals();
     $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
     $kernel->boot();
     $kernel->prepareLegacyRequest($request);
     // Initialise an anonymous session. required for the bootstrap.
     \Drupal::service('session_manager')->start();
 }
コード例 #20
0
ファイル: Drupal.php プロジェクト: php-pm/php-pm-drupal
 /**
  * Create a Drupal application.
  */
 public function getApplication()
 {
     // Bootstrap Drupal.
     // Bootstrap code is modeled on a few examples in core/scripts, such as
     // db-tools.php.
     // Assume we're in DRUPAL_ROOT/vendor/php-pm/httpkernel-adapter/Bootstraps.
     // There may be a safer way to do this...
     $drupal_root = dirname(dirname(dirname(dirname(__DIR__))));
     // @todo: Is it necessary to call bootEnv()?  It's called automatically by createFromRequest().
     DrupalKernel::bootEnvironment();
     $request = Request::createFromGlobals();
     // @todo: Is it necessary to call initialize()? Is it called through createFromRequest()?
     $autoloader = (include $drupal_root . '/autoload.php');
     Settings::initialize($drupal_root, DrupalKernel::findSitePath($request), $autoloader);
     $app = DrupalKernel::createFromRequest($request, $autoloader, $this->appenv);
     $app->boot();
     return $app;
 }
コード例 #21
0
 /**
  * Overrides method.
  *
  * We have several forms to navigate through.
  */
 protected function setUpSite()
 {
     // Recreate the container so that we can simulate the submission of the
     // SyncConfigureForm after the full bootstrap has occurred. Without out this
     // drupal_realpath() does not work so uploading files through
     // WebTestBase::postForm() is impossible.
     $request = Request::createFromGlobals();
     $class_loader = (require $this->container->get('app.root') . '/vendor/autoload.php');
     Settings::initialize($this->container->get('app.root'), DrupalKernel::findSitePath($request), $class_loader);
     foreach ($GLOBALS['config_directories'] as $type => $path) {
         $this->configDirectories[$type] = $path;
     }
     $this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE);
     $this->kernel->prepareLegacyRequest($request);
     $this->container = $this->kernel->getContainer();
     $this->setUpSyncForm();
     $this->setUpInstallConfigureForm();
     // If we've got to this point the site is installed using the regular
     // installation workflow.
     $this->isInstalled = TRUE;
 }
コード例 #22
0
ファイル: UpdateTestBase.php プロジェクト: 318io/318-io
 protected function setUp()
 {
     parent::setUp();
     // Change the root path which Update Manager uses to install and update
     // projects to be inside the testing site directory. See
     // \Drupal\update\UpdateRootFactory::get() for equivalent changes to the
     // test child site.
     $request = \Drupal::request();
     $update_root = $this->container->get('update.root') . '/' . DrupalKernel::findSitePath($request);
     $this->container->set('update.root', $update_root);
     \Drupal::setContainer($this->container);
     // Create the directories within the root path within which the Update
     // Manager will install projects.
     foreach (drupal_get_updaters() as $updater_info) {
         $updater = $updater_info['class'];
         $install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath();
         if (!is_dir($install_directory)) {
             mkdir($install_directory);
         }
     }
 }
コード例 #23
0
 /**
  * {@inheritdoc}
  *
  * Fully configures a preexisting settings.php file before invoking the
  * interactive installer.
  */
 protected function setUp()
 {
     // Pre-configure hash salt.
     // Any string is valid, so simply use the class name of this test.
     $this->settings['settings']['hash_salt'] = (object) array('value' => __CLASS__, 'required' => TRUE);
     // During interactive install we'll change this to a different profile and
     // this test will ensure that the new value is written to settings.php.
     $this->settings['settings']['install_profile'] = (object) array('value' => 'minimal', 'required' => TRUE);
     // Pre-configure database credentials.
     $connection_info = Database::getConnectionInfo();
     unset($connection_info['default']['pdo']);
     unset($connection_info['default']['init_commands']);
     $this->settings['databases']['default'] = (object) array('value' => $connection_info, 'required' => TRUE);
     // Use the kernel to find the site path because the site.path service should
     // not be available at this point in the install process.
     $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
     // Pre-configure config directories.
     $this->settings['config_directories'] = array(CONFIG_SYNC_DIRECTORY => (object) array('value' => $site_path . '/files/config_sync', 'required' => TRUE));
     mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
     parent::setUp();
 }
コード例 #24
0
ファイル: Drupal8.php プロジェクト: lmakarov/DrupalDriver
 /**
  * {@inheritdoc}
  */
 public function validateDrupalSite()
 {
     if ('default' !== $this->uri) {
         // Fake the necessary HTTP headers that Drupal needs:
         $drupal_base_url = parse_url($this->uri);
         // If there's no url scheme set, add http:// and re-parse the url
         // so the host and path values are set accurately.
         if (!array_key_exists('scheme', $drupal_base_url)) {
             $drupal_base_url = parse_url($this->uri);
         }
         // Fill in defaults.
         $drupal_base_url += array('path' => NULL, 'host' => NULL, 'port' => NULL);
         $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
         if ($drupal_base_url['port']) {
             $_SERVER['HTTP_HOST'] .= ':' . $drupal_base_url['port'];
         }
         $_SERVER['SERVER_PORT'] = $drupal_base_url['port'];
         if (array_key_exists('path', $drupal_base_url)) {
             $_SERVER['PHP_SELF'] = $drupal_base_url['path'] . '/index.php';
         } else {
             $_SERVER['PHP_SELF'] = '/index.php';
         }
     } else {
         $_SERVER['HTTP_HOST'] = 'default';
         $_SERVER['PHP_SELF'] = '/index.php';
     }
     $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['REQUEST_METHOD'] = NULL;
     $_SERVER['SERVER_SOFTWARE'] = NULL;
     $_SERVER['HTTP_USER_AGENT'] = NULL;
     $conf_path = DrupalKernel::findSitePath(Request::createFromGlobals());
     $conf_file = $this->drupalRoot . "/{$conf_path}/settings.php";
     if (!file_exists($conf_file)) {
         throw new BootstrapException(sprintf('Could not find a Drupal settings.php file at "%s"', $conf_file));
     }
 }
コード例 #25
0
ファイル: WebTestBase.php プロジェクト: Wylbur/gj
 /**
  * Cleans up after testing.
  *
  * Deletes created files and temporary files directory, deletes the tables
  * created by setUp(), and resets the database prefix.
  */
 protected function tearDown()
 {
     // Destroy the testing kernel.
     if (isset($this->kernel)) {
         $this->kernel->shutdown();
     }
     parent::tearDown();
     // Ensure that the maximum meta refresh count is reset.
     $this->maximumMetaRefreshCount = NULL;
     // Ensure that internal logged in variable and cURL options are reset.
     $this->loggedInUser = FALSE;
     $this->additionalCurlOptions = array();
     // Close the CURL handler and reset the cookies array used for upgrade
     // testing so test classes containing multiple tests are not polluted.
     $this->curlClose();
     $this->curlCookies = array();
     $this->cookies = array();
 }
コード例 #26
0
 /**
  * Overrides WebTestBase::setUp().
  */
 protected function setUp()
 {
     $this->isInstalled = FALSE;
     // Define information about the user 1 account.
     $this->root_user = new UserSession(array('uid' => 1, 'name' => 'admin', 'mail' => '*****@*****.**', 'pass_raw' => $this->randomMachineName()));
     // If any $settings are defined for this test, copy and prepare an actual
     // settings.php, so as to resemble a regular installation.
     if (!empty($this->settings)) {
         // Not using File API; a potential error must trigger a PHP warning.
         copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php');
         $this->writeSettings($this->settings);
     }
     // Note that WebTestBase::installParameters() returns form input values
     // suitable for a programmed drupal_form_submit().
     // @see WebTestBase::translatePostValues()
     $this->parameters = $this->installParameters();
     // Set up a minimal container (required by WebTestBase).
     // @see install_begin_request()
     $request = Request::create($GLOBALS['base_url'] . '/core/install.php');
     $this->container = new ContainerBuilder();
     $request_stack = new RequestStack();
     $request_stack->push($request);
     $this->container->set('request_stack', $request_stack);
     $this->container->setParameter('language.default_values', Language::$defaultValues);
     $this->container->register('language.default', 'Drupal\\Core\\Language\\LanguageDefault')->addArgument('%language.default_values%');
     $this->container->register('language_manager', 'Drupal\\Core\\Language\\LanguageManager')->addArgument(new Reference('language.default'));
     $this->container->register('string_translation', 'Drupal\\Core\\StringTranslation\\TranslationManager')->addArgument(new Reference('language_manager'));
     \Drupal::setContainer($this->container);
     $this->drupalGet($GLOBALS['base_url'] . '/core/install.php');
     // Select language.
     $this->setUpLanguage();
     // Select profile.
     $this->setUpProfile();
     // Configure settings.
     $this->setUpSettings();
     // @todo Allow test classes based on this class to act on further installer
     //   screens.
     // Configure site.
     $this->setUpSite();
     // Import new settings.php written by the installer.
     $request = Request::createFromGlobals();
     $class_loader = (require DRUPAL_ROOT . '/core/vendor/autoload.php');
     Settings::initialize(DrupalKernel::findSitePath($request), $class_loader);
     foreach ($GLOBALS['config_directories'] as $type => $path) {
         $this->configDirectories[$type] = $path;
     }
     // After writing settings.php, the installer removes write permissions
     // from the site directory. To allow drupal_generate_test_ua() to write
     // a file containing the private key for drupal_valid_test_ua(), the site
     // directory has to be writable.
     // WebTestBase::tearDown() will delete the entire test site directory.
     // Not using File API; a potential error must trigger a PHP warning.
     chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777);
     $this->kernel = DrupalKernel::createFromRequest($request, $class_loader, 'prod', FALSE);
     $this->kernel->prepareLegacyRequest($request);
     $this->container = $this->kernel->getContainer();
     $config = $this->container->get('config.factory');
     // Manually configure the test mail collector implementation to prevent
     // tests from sending out e-mails and collect them in state instead.
     $config->get('system.mail')->set('interface.default', 'test_mail_collector')->save();
     // When running from run-tests.sh we don't get an empty current path which
     // would indicate we're on the home page.
     $path = current_path();
     if (empty($path)) {
         _current_path('run-tests');
     }
     $this->isInstalled = TRUE;
 }
コード例 #27
0
ファイル: BrowserTestBase.php プロジェクト: ddrozdik/dmaps
 /**
  * Rebuilds \Drupal::getContainer().
  *
  * Use this to build a new kernel and service container. For example, when the
  * list of enabled modules is changed via the Mink controlled browser, in
  * which case the test process still contains an old kernel and service
  * container with an old module list.
  *
  * @see BrowserTestBase::prepareEnvironment()
  * @see BrowserTestBase::restoreEnvironment()
  *
  * @todo Fix https://www.drupal.org/node/2021959 so that module enable/disable
  *   changes are immediately reflected in \Drupal::getContainer(). Until then,
  *   tests can invoke this workaround when requiring services from newly
  *   enabled modules to be immediately available in the same request.
  */
 protected function rebuildContainer()
 {
     // Rebuild the kernel and bring it back to a fully bootstrapped state.
     $this->container = $this->kernel->rebuildContainer();
     // Make sure the url generator has a request object, otherwise calls to
     // $this->drupalGet() will fail.
     $this->prepareRequestForGenerator();
 }
コード例 #28
0
ファイル: ExtensionDiscovery.php プロジェクト: ddrozdik/dmaps
 /**
  * Discovers available extensions of a given type.
  *
  * Finds all extensions (modules, themes, etc) that exist on the site. It
  * searches in several locations. For instance, to discover all available
  * modules:
  * @code
  * $listing = new ExtensionDiscovery(\Drupal::root());
  * $modules = $listing->scan('module');
  * @endcode
  *
  * The following directories will be searched (in the order stated):
  * - the core directory; i.e., /core
  * - the installation profile directory; e.g., /core/profiles/standard
  * - the legacy site-wide directory; i.e., /sites/all
  * - the site-wide directory; i.e., /
  * - the site-specific directory; e.g., /sites/example.com
  *
  * The information is returned in an associative array, keyed by the extension
  * name (without .info.yml extension). Extensions found later in the search
  * will take precedence over extensions found earlier - unless they are not
  * compatible with the current version of Drupal core.
  *
  * @param string $type
  *   The extension type to search for. One of 'profile', 'module', 'theme', or
  *   'theme_engine'.
  * @param bool $include_tests
  *   (optional) Whether to explicitly include or exclude test extensions. By
  *   default, test extensions are only discovered when in a test environment.
  *
  * @return \Drupal\Core\Extension\Extension[]
  *   An associative array of Extension objects, keyed by extension name.
  */
 public function scan($type, $include_tests = NULL)
 {
     // Determine the installation profile directories to scan for extensions,
     // unless explicit profile directories have been set. Exclude profiles as we
     // cannot have profiles within profiles.
     if (!isset($this->profileDirectories) && $type != 'profile') {
         $this->setProfileDirectoriesFromSettings();
     }
     // Search the core directory.
     $searchdirs[static::ORIGIN_CORE] = 'core';
     // Search the legacy sites/all directory.
     $searchdirs[static::ORIGIN_SITES_ALL] = 'sites/all';
     // Search for contributed and custom extensions in top-level directories.
     // The scan uses a whitelist to limit recursion to the expected extension
     // type specific directory names only.
     $searchdirs[static::ORIGIN_ROOT] = '';
     // Simpletest uses the regular built-in multi-site functionality of Drupal
     // for running web tests. As a consequence, extensions of the parent site
     // located in a different site-specific directory are not discovered in a
     // test site environment, because the site directories are not the same.
     // Therefore, add the site directory of the parent site to the search paths,
     // so that contained extensions are still discovered.
     // @see \Drupal\simpletest\WebTestBase::setUp()
     if ($parent_site = Settings::get('test_parent_site')) {
         $searchdirs[static::ORIGIN_PARENT_SITE] = $parent_site;
     }
     // Find the site-specific directory to search. Since we are using this
     // method to discover extensions including profiles, we might be doing this
     // at install time. Therefore Kernel service is not always available, but is
     // preferred.
     if (\Drupal::hasService('kernel')) {
         $searchdirs[static::ORIGIN_SITE] = \Drupal::service('site.path');
     } else {
         $searchdirs[static::ORIGIN_SITE] = $this->sitePath ?: DrupalKernel::findSitePath(Request::createFromGlobals());
     }
     // Unless an explicit value has been passed, manually check whether we are
     // in a test environment, in which case test extensions must be included.
     // Test extensions can also be included for debugging purposes by setting a
     // variable in settings.php.
     if (!isset($include_tests)) {
         $include_tests = Settings::get('extension_discovery_scan_tests') || drupal_valid_test_ua();
     }
     $files = array();
     foreach ($searchdirs as $dir) {
         // Discover all extensions in the directory, unless we did already.
         if (!isset(static::$files[$dir][$include_tests])) {
             static::$files[$dir][$include_tests] = $this->scanDirectory($dir, $include_tests);
         }
         // Only return extensions of the requested type.
         if (isset(static::$files[$dir][$include_tests][$type])) {
             $files += static::$files[$dir][$include_tests][$type];
         }
     }
     // If applicable, filter out extensions that do not belong to the current
     // installation profiles.
     $files = $this->filterByProfileDirectories($files);
     // Sort the discovered extensions by their originating directories.
     $origin_weights = array_flip($searchdirs);
     $files = $this->sort($files, $origin_weights);
     // Process and return the list of extensions keyed by extension name.
     return $this->process($files);
 }
コード例 #29
0
 /**
  * Returns the active configuration storage used during early install.
  *
  * This override changes the visibility so that the installer can access
  * config storage before the container is properly built.
  *
  * @return \Drupal\Core\Config\StorageInterface
  *   The config storage.
  */
 public function getConfigStorage()
 {
     return parent::getConfigStorage();
 }
コード例 #30
0
ファイル: index.php プロジェクト: favish/drupal-archetype
<?php

/**
 * @file
 * The PHP page that serves all page requests on a Drupal installation.
 *
 * All Drupal code is released under the GNU General Public License.
 * See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
 */
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
$autoloader = (require_once 'autoload.php');
$kernel = new DrupalKernel('prod', $autoloader);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);