protected function EditLoadingTest::retrieveAttachments

Retrieves AJAX commands to load attachments for the given in-place editors.

Parameters

array $editors: An array of in-place editor ids.

Return value

string The response body.

1 call to EditLoadingTest::retrieveAttachments()

File

drupal/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php, line 200
Contains \Drupal\edit\Tests\EditLoadingTest.

Class

EditLoadingTest
Tests loading of Edit and lazy-loading of in-place editors.

Namespace

Drupal\edit\Tests

Code

protected function retrieveAttachments($editors) {

  // Build POST values.
  $post = array();
  for ($i = 0; $i < count($editors); $i++) {
    $post['editors[' . $i . ']'] = $editors[$i];
  }

  // Serialize POST values.
  foreach ($post as $key => $value) {

    // Encode according to application/x-www-form-urlencoded
    // Both names and values needs to be urlencoded, according to
    // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
    $post[$key] = urlencode($key) . '=' . urlencode($value);
  }
  $post = implode('&', $post);

  // Perform HTTP request.
  return $this
    ->curlExec(array(
    CURLOPT_URL => url('edit/attachments', array(
      'absolute' => TRUE,
    )),
    CURLOPT_POST => TRUE,
    CURLOPT_POSTFIELDS => $post . $this
      ->getAjaxPageStatePostData(),
    CURLOPT_HTTPHEADER => array(
      'Accept: application/vnd.drupal-ajax',
      'Content-Type: application/x-www-form-urlencoded',
    ),
  ));
}