Example #1
0
 /**
  * Creates a Symfony response object to simplify using the API in Symfony or frameworks that use the
  * HttpFoundation component
  *
  * @param \AppShed\Remote\HTML\Settings $settings
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getSymfonyResponse($settings = null)
 {
     $headers = static::getCORSResponseHeaders();
     if (static::isOptionsRequest()) {
         return new \Symfony\Component\HttpFoundation\Response('', 200, $headers);
     }
     if (!$settings) {
         $settings = $this->getSettings();
     }
     $data = $this->getResponseObject($settings);
     $data['remote'] = ['url' => $settings->getFetchUrl(), 'refreshAfter' => $this->refreshAfter];
     $data['remote'][$settings->getFetchUrl()] = $data['settings']['main'];
     $response = new \Symfony\Component\HttpFoundation\JsonResponse($data, 200, $headers);
     if ($callback = $this->getCallback()) {
         $response->setCallback($callback);
     }
     return $response;
 }