setFragment() public method

Sets the fragment part of URI.
public setFragment ( $value ) : self
return self
Example #1
0
 /**
  * Send OAuth response
  * @param array|\Traversable $data
  * @param string|null $redirectUrl
  * @param int $code
  */
 public function oauthResponse($data, $redirectUrl = NULL, $code = 200)
 {
     if ($data instanceof \Traversable) {
         $data = iterator_to_array($data);
     }
     $data = (array) $data;
     // Redirect, if there is URL
     if ($redirectUrl !== NULL) {
         $url = new Url($redirectUrl);
         if ($this->getParameter('response_type') == 'token') {
             $url->setFragment(http_build_query($data));
         } else {
             $url->appendQuery($data);
         }
         $this->redirectUrl($url);
     }
     // else send JSON response
     foreach ($data as $key => $value) {
         $this->payload->{$key} = $value;
     }
     $this->getHttpResponse()->setCode($code);
     $this->sendResponse(new JsonResponse($this->payload));
 }