Skip to content

Commit f900caa

Browse files
committed
Add RobotstxtJson View
1 parent 8f0cba0 commit f900caa

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/Views/Core/RobotstxtJson.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace BNETDocs\Views\Core;
4+
5+
class RobotstxtJson extends \BNETDocs\Views\Base\Json
6+
{
7+
public static function invoke(\BNETDocs\Interfaces\Model $model): void
8+
{
9+
if (!$model instanceof \BNETDocs\Models\Core\Robotstxt)
10+
{
11+
throw new \BNETDocs\Exceptions\InvalidModelException($model);
12+
}
13+
14+
echo \json_encode($model, self::jsonFlags());
15+
$model->_responseHeaders['Content-Type'] = self::mimeType();
16+
}
17+
}

src/Views/Core/Robotstxt.php renamed to src/Views/Core/RobotstxtPlain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace BNETDocs\Views\Core;
44

5-
class Robotstxt extends \BNETDocs\Views\Base\Plain
5+
class RobotstxtPlain extends \BNETDocs\Views\Base\Plain
66
{
77
public static function invoke(\BNETDocs\Interfaces\Model $model): void
88
{

src/main.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public static function main(int $argc, array $argv): int
106106
['#^/packet/index\.vb$#', 'Packet\\Index', ['Packet\\IndexVb'], true],
107107
['#^/phpinfo/?$#', 'Core\\PhpInfo', ['Core\\PhpInfoHtml']],
108108
['#^/privacy(?:/|\.html?)?$#', 'Community\\PrivacyPolicy', ['Community\\PrivacyPolicyHtml']],
109-
['#^/robots\.txt$#', 'Core\\Robotstxt', ['Core\\Robotstxt']],
109+
['#^/robots\.json$#', 'Core\\Robotstxt', ['Core\\RobotstxtJson']],
110+
['#^/robots\.txt$#', 'Core\\Robotstxt', ['Core\\RobotstxtPlain']],
110111
['#^/server/(\d+)/?.*\.html?$#', 'Server\\View', ['Server\\ViewHtml']],
111112
['#^/server/(\d+)/?.*\.json$#', 'Server\\View', ['Server\\ViewJson']],
112113
['#^/server/(\d+)/?.*\.txt$#', 'Server\\View', ['Server\\ViewPlain']],

0 commit comments

Comments
 (0)