Code Duplication    Length = 51-51 lines in 2 locations

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

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

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

@@ 212-262 (lines=51) @@
209
  /**
210
   * {@inheritdoc}
211
   */
212
  public function validateDrupalSite() {
213
    if ('default' !== $this->uri) {
214
      // Fake the necessary HTTP headers that Drupal needs:
215
      $drupal_base_url = parse_url($this->uri);
216
      // If there's no url scheme set, add http:// and re-parse the url
217
      // so the host and path values are set accurately.
218
      if (!array_key_exists('scheme', $drupal_base_url)) {
219
        $drupal_base_url = parse_url($this->uri);
220
      }
221
      // Fill in defaults.
222
      $drupal_base_url += array(
223
        'path' => NULL,
224
        'host' => NULL,
225
        'port' => NULL,
226
      );
227
      $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
228
229
      if ($drupal_base_url['port']) {
230
        $_SERVER['HTTP_HOST'] .= ':' . $drupal_base_url['port'];
231
      }
232
      $_SERVER['SERVER_PORT'] = $drupal_base_url['port'];
233
234
      if (array_key_exists('path', $drupal_base_url)) {
235
        $_SERVER['PHP_SELF'] = $drupal_base_url['path'] . '/index.php';
236
      }
237
      else {
238
        $_SERVER['PHP_SELF'] = '/index.php';
239
      }
240
    }
241
    else {
242
      $_SERVER['HTTP_HOST'] = 'default';
243
      $_SERVER['PHP_SELF'] = '/index.php';
244
    }
245
246
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
247
    $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
248
    $_SERVER['REQUEST_METHOD']  = NULL;
249
250
    $_SERVER['SERVER_SOFTWARE'] = NULL;
251
    $_SERVER['HTTP_USER_AGENT'] = NULL;
252
253
    $conf_path = conf_path(TRUE, TRUE);
254
    $conf_file = $this->drupalRoot . "/$conf_path/settings.php";
255
    if (!file_exists($conf_file)) {
256
      throw new BootstrapException(sprintf('Could not find a Drupal settings.php file at "%s"', $conf_file));
257
    }
258
    $drushrc_file = $this->drupalRoot . "/$conf_path/drushrc.php";
259
    if (file_exists($drushrc_file)) {
260
      require_once $drushrc_file;
261
    }
262
  }
263
264
  /**
265
   * Expands properties on the given entity object to the expected structure.