Code Duplication    Length = 51-51 lines in 2 locations

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

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

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.