Code Duplication    Length = 51-51 lines in 2 locations

src/Drupal/Driver/Cores/Drupal6.php 1 location

@@ 259-309 (lines=51) @@
256
  /**
257
   * {@inheritdoc}
258
   */
259
  public function validateDrupalSite() {
260
    if ('default' !== $this->uri) {
261
      // Fake the necessary HTTP headers that Drupal needs:
262
      $drupal_base_url = parse_url($this->uri);
263
      // If there's no url scheme set, add http:// and re-parse the url
264
      // so the host and path values are set accurately.
265
      if (!array_key_exists('scheme', $drupal_base_url)) {
266
        $drupal_base_url = parse_url($this->uri);
267
      }
268
      // Fill in defaults.
269
      $drupal_base_url += array(
270
        'path' => NULL,
271
        'host' => NULL,
272
        'port' => NULL,
273
      );
274
      $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
275
276
      if ($drupal_base_url['port']) {
277
        $_SERVER['HTTP_HOST'] .= ':' . $drupal_base_url['port'];
278
      }
279
      $_SERVER['SERVER_PORT'] = $drupal_base_url['port'];
280
281
      if (array_key_exists('path', $drupal_base_url)) {
282
        $_SERVER['PHP_SELF'] = $drupal_base_url['path'] . '/index.php';
283
      }
284
      else {
285
        $_SERVER['PHP_SELF'] = '/index.php';
286
      }
287
    }
288
    else {
289
      $_SERVER['HTTP_HOST'] = 'default';
290
      $_SERVER['PHP_SELF'] = '/index.php';
291
    }
292
293
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
294
    $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
295
    $_SERVER['REQUEST_METHOD']  = NULL;
296
297
    $_SERVER['SERVER_SOFTWARE'] = NULL;
298
    $_SERVER['HTTP_USER_AGENT'] = NULL;
299
300
    $conf_path = conf_path(TRUE, TRUE);
301
    $conf_file = $this->drupalRoot . "/$conf_path/settings.php";
302
    if (!file_exists($conf_file)) {
303
      throw new BootstrapException(sprintf('Could not find a Drupal settings.php file at "%s"', $conf_file));
304
    }
305
    $drushrc_file = $this->drupalRoot . "/$conf_path/drushrc.php";
306
    if (file_exists($drushrc_file)) {
307
      require_once $drushrc_file;
308
    }
309
  }
310
311
  /**
312
   * Expands properties on the given entity object to the expected structure.

src/Drupal/Driver/Cores/Drupal7.php 1 location

@@ 293-343 (lines=51) @@
290
  /**
291
   * {@inheritdoc}
292
   */
293
  public function validateDrupalSite() {
294
    if ('default' !== $this->uri) {
295
      // Fake the necessary HTTP headers that Drupal needs:
296
      $drupal_base_url = parse_url($this->uri);
297
      // If there's no url scheme set, add http:// and re-parse the url
298
      // so the host and path values are set accurately.
299
      if (!array_key_exists('scheme', $drupal_base_url)) {
300
        $drupal_base_url = parse_url($this->uri);
301
      }
302
      // Fill in defaults.
303
      $drupal_base_url += array(
304
        'path' => NULL,
305
        'host' => NULL,
306
        'port' => NULL,
307
      );
308
      $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
309
310
      if ($drupal_base_url['port']) {
311
        $_SERVER['HTTP_HOST'] .= ':' . $drupal_base_url['port'];
312
      }
313
      $_SERVER['SERVER_PORT'] = $drupal_base_url['port'];
314
315
      if (array_key_exists('path', $drupal_base_url)) {
316
        $_SERVER['PHP_SELF'] = $drupal_base_url['path'] . '/index.php';
317
      }
318
      else {
319
        $_SERVER['PHP_SELF'] = '/index.php';
320
      }
321
    }
322
    else {
323
      $_SERVER['HTTP_HOST'] = 'default';
324
      $_SERVER['PHP_SELF'] = '/index.php';
325
    }
326
327
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
328
    $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
329
    $_SERVER['REQUEST_METHOD']  = NULL;
330
331
    $_SERVER['SERVER_SOFTWARE'] = NULL;
332
    $_SERVER['HTTP_USER_AGENT'] = NULL;
333
334
    $conf_path = conf_path(TRUE, TRUE);
335
    $conf_file = $this->drupalRoot . "/$conf_path/settings.php";
336
    if (!file_exists($conf_file)) {
337
      throw new BootstrapException(sprintf('Could not find a Drupal settings.php file at "%s"', $conf_file));
338
    }
339
    $drushrc_file = $this->drupalRoot . "/$conf_path/drushrc.php";
340
    if (file_exists($drushrc_file)) {
341
      require_once $drushrc_file;
342
    }
343
  }
344
345
  /**
346
   * Expands properties on the given entity object to the expected structure.