You are here

public function ImceFM::pageResponse in IMCE 8.2

Same name and namespace in other branches
  1. 8 src/ImceFM.php \Drupal\imce\ImceFM::pageResponse()

Returns a page response based on the current request.

File

src/ImceFM.php, line 695

Class

ImceFM
Imce File Manager.

Namespace

Drupal\imce

Code

public function pageResponse() {
  if ($request = $this->request) {

    // Json request.
    if ($request->request
      ->has('jsop')) {
      $this
        ->run();
      $data = $this
        ->getResponse();

      // Return html response if the flag is set.
      if ($request->request
        ->get('return_html')) {
        return new Response('<html><body><textarea>' . Json::encode($data) . '</textarea></body></html>');
      }
      return new JsonResponse($data);
    }

    // Build and render the main page.
    return new Response($this
      ->buildRenderPage());
  }
}