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

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