protected function makeMasonResponse(Document $document, Request $request, array $routeParams = [], $status = 200, array $headers = [])
 {
     $url = static::getProfileUrl();
     $document->setMetaControl('profile', new Control($url));
     if (isset($headers['Link']) && !is_array($headers['Link'])) {
         $headers['Link'] = [$headers['Link']];
     }
     $headers['Link'][] = sprintf('<%s>; rel="profile"', $url);
     if (!isset($document->{'@controls'}->self)) {
         $document->setControl('self', static::class, $routeParams);
     }
     if (method_exists($this, 'addMasonNamespaces')) {
         $this->addMasonNamespaces($document);
     }
     return MasonResponse::create($document, $request, $status, $headers, JSON_UNESCAPED_SLASHES);
 }
Example #2
0
 public function testCanAddMetaControl()
 {
     $obj = new Document();
     $obj->setMetaControl('self', '/path');
     $this->assertEquals('/path', $obj->{'@meta'}->{'@controls'}->self->href);
 }