Code Duplication    Length = 51-51 lines in 2 locations

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

@@ 238-288 (lines=51) @@
235
  /**
236
   * {@inheritdoc}
237
   */
238
  public function validateDrupalSite() {
239
    if ('default' !== $this->uri) {
240
      // Fake the necessary HTTP headers that Drupal needs:
241
      $drupal_base_url = parse_url($this->uri);
242
      // If there's no url scheme set, add http:// and re-parse the url
243
      // so the host and path values are set accurately.
244
      if (!array_key_exists('scheme', $drupal_base_url)) {
245
        $drupal_base_url = parse_url($this->uri);
246
      }
247
      // Fill in defaults.
248
      $drupal_base_url += array(
249
        'path' => NULL,
250
        'host' => NULL,
251
        'port' => NULL,
252
      );
253
      $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
254
255
      if ($drupal_base_url['port']) {
256
        $_SERVER['HTTP_HOST'] .= ':' . $drupal_base_url['port'];
257
      }
258
      $_SERVER['SERVER_PORT'] = $drupal_base_url['port'];
259
260
      if (array_key_exists('path', $drupal_base_url)) {
261
        $_SERVER['PHP_SELF'] = $drupal_base_url['path'] . '/index.php';
262
      }
263
      else {
264
        $_SERVER['PHP_SELF'] = '/index.php';
265
      }
266
    }
267
    else {
268
      $_SERVER['HTTP_HOST'] = 'default';
269
      $_SERVER['PHP_SELF'] = '/index.php';
270
    }
271
272
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
273
    $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
274
    $_SERVER['REQUEST_METHOD']  = NULL;
275
276
    $_SERVER['SERVER_SOFTWARE'] = NULL;
277
    $_SERVER['HTTP_USER_AGENT'] = NULL;
278
279
    $conf_path = conf_path(TRUE, TRUE);
280
    $conf_file = $this->drupalRoot . "/$conf_path/settings.php";
281
    if (!file_exists($conf_file)) {
282
      throw new BootstrapException(sprintf('Could not find a Drupal settings.php file at "%s"', $conf_file));
283
    }
284
    $drushrc_file = $this->drupalRoot . "/$conf_path/drushrc.php";
285
    if (file_exists($drushrc_file)) {
286
      require_once $drushrc_file;
287
    }
288
  }
289
290
  /**
291
   * Expands properties on the given entity object to the expected structure.

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

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