Skip to content

Commit 8cde8d7

Browse files
committed
Rename RedirectSoft to Redirect
1 parent d9bd505 commit 8cde8d7

File tree

8 files changed

+41
-38
lines changed

8 files changed

+41
-38
lines changed

src/Controllers/Core/Redirect.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace BNETDocs\Controllers\Core;
4+
5+
class Redirect extends \BNETDocs\Controllers\Base
6+
{
7+
/**
8+
* Constructs a Controller, typically to initialize properties.
9+
*/
10+
public function __construct()
11+
{
12+
$this->model = new \BNETDocs\Models\Core\Redirect();
13+
}
14+
15+
/**
16+
* Invoked by the Router class to handle the request.
17+
*
18+
* @param array|null $args The optional route arguments and any captured URI arguments.
19+
* @return boolean Whether the Router should invoke the configured View.
20+
*/
21+
public function invoke(?array $args): bool
22+
{
23+
$this->model->location = \BNETDocs\Libraries\Core\UrlFormatter::format(
24+
!empty($args) && \is_string($args[0]) ? \array_shift($args) : null
25+
);
26+
$this->model->_responseCode = !empty($args) && \is_int($args[0]) ?
27+
\array_shift($args) : \BNETDocs\Libraries\Core\HttpCode::HTTP_FOUND;
28+
$this->model->_responseHeaders['Location'] = $this->model->location;
29+
return true;
30+
}
31+
}

src/Controllers/Core/RedirectSoft.php

-28
This file was deleted.

src/Models/Core/RedirectSoft.php renamed to src/Models/Core/Redirect.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace BNETDocs\Models\Core;
44

5-
class RedirectSoft extends \BNETDocs\Models\ActiveUser implements \JsonSerializable
5+
class Redirect extends \BNETDocs\Models\ActiveUser implements \JsonSerializable
66
{
77
public ?string $location = null;
88

src/Templates/Core/RedirectSoft.phtml renamed to src/Templates/Core/Redirect.phtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
22
namespace BNETDocs\Templates\Core;
3-
$title = 'Soft Redirect';
3+
$title = 'Redirect';
44
require('./Includes/header.inc.phtml'); ?>
55
<div class="container">
66
<h1><?=$title?></h1>

src/Views/Core/RedirectSoftHtml.php renamed to src/Views/Core/RedirectHtml.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
namespace BNETDocs\Views\Core;
44

5-
class RedirectSoftHtml extends \BNETDocs\Views\Base\Html
5+
class RedirectHtml extends \BNETDocs\Views\Base\Html
66
{
77
public static function invoke(\BNETDocs\Interfaces\Model $model): void
88
{
9-
if (!$model instanceof \BNETDocs\Models\Core\RedirectSoft)
9+
if (!$model instanceof \BNETDocs\Models\Core\Redirect)
1010
{
1111
throw new \BNETDocs\Exceptions\InvalidModelException($model);
1212
}
1313

14-
(new \BNETDocs\Libraries\Core\Template($model, 'Core/RedirectSoft'))->invoke();
14+
(new \BNETDocs\Libraries\Core\Template($model, 'Core/Redirect'))->invoke();
1515
$model->_responseHeaders['Content-Type'] = self::mimeType();
1616
}
1717
}

src/Views/Core/RedirectSoftJson.php renamed to src/Views/Core/RedirectJson.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace BNETDocs\Views\Core;
44

5-
class RedirectSoftJson extends \BNETDocs\Views\Base\Json
5+
class RedirectJson extends \BNETDocs\Views\Base\Json
66
{
77
public static function invoke(\BNETDocs\Interfaces\Model $model): void
88
{
9-
if (!$model instanceof \BNETDocs\Models\Core\RedirectSoft)
9+
if (!$model instanceof \BNETDocs\Models\Core\Redirect)
1010
{
1111
throw new \BNETDocs\Exceptions\InvalidModelException($model);
1212
}

src/Views/Core/RedirectSoftPlain.php renamed to src/Views/Core/RedirectPlain.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace BNETDocs\Views\Core;
44

5-
class RedirectSoftPlain extends \BNETDocs\Views\Base\Plain
5+
class RedirectPlain extends \BNETDocs\Views\Base\Plain
66
{
77
public static function invoke(\BNETDocs\Interfaces\Model $model): void
88
{
9-
if (!$model instanceof \BNETDocs\Models\Core\RedirectSoft)
9+
if (!$model instanceof \BNETDocs\Models\Core\Redirect)
1010
{
1111
throw new \BNETDocs\Exceptions\InvalidModelException($model);
1212
}

src/main.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function main(int $argc, array $argv): int
5656
else
5757
{
5858
Router::$routes = [
59-
['#^/\.well-known/change-password$#', 'Core\\RedirectSoft', ['Core\\RedirectSoftHtml', 'Core\\RedirectSoftJson', 'Core\\RedirectSoftPlain'], '/user/changepassword'],
59+
['#^/\.well-known/change-password$#', 'Core\\Redirect', ['Core\\RedirectHtml', 'Core\\RedirectJson', 'Core\\RedirectPlain'], '/user/changepassword'],
6060
['#^/$#', 'Core\\Legacy', ['Core\\LegacyHtml']],
6161
['#^/comment/create/?$#', 'Comment\\Create', ['Comment\\CreateJson']],
6262
['#^/comment/delete/?$#', 'Comment\\Delete', ['Comment\\DeleteHtml']],

0 commit comments

Comments
 (0)