Skip to content

Commit 1d9e56c

Browse files
committed
Properly set the subtype on the dispatcher as well as the standards tree.
Signed-off-by: Jason Lewis <[email protected]>
1 parent 58d07e8 commit 1d9e56c

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

src/Dispatcher.php

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,18 @@ class Dispatcher
122122
protected $persistAuthentication = true;
123123

124124
/**
125-
* API vendor.
125+
* API subtype.
126126
*
127127
* @var string
128128
*/
129-
protected $vendor;
129+
protected $subtype;
130+
131+
/**
132+
* API standards tree.
133+
*
134+
* @var string
135+
*/
136+
protected $standardsTree;
130137

131138
/**
132139
* API prefix.
@@ -486,7 +493,7 @@ protected function addPrefixToUri($uri)
486493
*/
487494
protected function getAcceptHeader()
488495
{
489-
return sprintf('application/vnd.%s.%s+%s', $this->getVendor(), $this->getVersion(), $this->getFormat());
496+
return sprintf('application/%s.%s.%s+%s', $this->getStandardsTree(), $this->getSubtype(), $this->getVersion(), $this->getFormat());
490497
}
491498

492499
/**
@@ -613,25 +620,47 @@ public function getFormat()
613620
}
614621

615622
/**
616-
* Get the vendor.
623+
* Get the subtype.
624+
*
625+
* @return string
626+
*/
627+
public function getSubtype()
628+
{
629+
return $this->subtype;
630+
}
631+
632+
/**
633+
* Set the subtype.
634+
*
635+
* @param string $subtype
636+
*
637+
* @return void
638+
*/
639+
public function setSubtype($subtype)
640+
{
641+
$this->subtype = $subtype;
642+
}
643+
644+
/**
645+
* Get the standards tree.
617646
*
618647
* @return string
619648
*/
620-
public function getVendor()
649+
public function getStandardsTree()
621650
{
622-
return $this->vendor;
651+
return $this->standardsTree;
623652
}
624653

625654
/**
626-
* Set the vendor.
655+
* Set the standards tree.
627656
*
628-
* @param string $vendor
657+
* @param string $standardsTree
629658
*
630659
* @return void
631660
*/
632-
public function setVendor($vendor)
661+
public function setStandardsTree($standardsTree)
633662
{
634-
$this->vendor = $vendor;
663+
$this->standardsTree = $standardsTree;
635664
}
636665

637666
/**

src/Provider/ApiServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public function registerDispatcher()
137137
$config = $app['config']['api'];
138138

139139
$dispatcher->setSubtype($config['subtype']);
140+
$dispatcher->setStandardsTree($config['standardsTree']);
140141
$dispatcher->setPrefix($config['prefix']);
141142
$dispatcher->setDefaultVersion($config['version']);
142143
$dispatcher->setDefaultDomain($config['domain']);

tests/DispatcherTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public function setUp()
3838
$this->auth = new Auth($this->router, $this->container, []);
3939
$this->dispatcher = new Dispatcher($this->container, new Filesystem, $this->router, $this->auth);
4040

41-
$this->dispatcher->setVendor('api');
41+
$this->dispatcher->setSubtype('api');
42+
$this->dispatcher->setStandardsTree('vnd');
4243
$this->dispatcher->setDefaultVersion('v1');
4344
$this->dispatcher->setDefaultFormat('json');
4445

0 commit comments

Comments
 (0)