Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
DomainControllerBase
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createViewActionResult
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 redirectPath
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace PeServer\App\Controllers;
6
7use PeServer\App\Models\AppConfiguration;
8use PeServer\App\Models\AppTemplateOptions;
9use PeServer\App\Models\AppUrl;
10use PeServer\App\Models\AppViewActionResult;
11use PeServer\Core\DI\Inject;
12use PeServer\Core\Mvc\ControllerArgument;
13use PeServer\Core\Mvc\ControllerBase;
14use PeServer\Core\Mvc\Result\RedirectActionResult;
15use PeServer\Core\Mvc\Result\ViewActionResult;
16use PeServer\Core\Mvc\Template\ITemplateFactory;
17use PeServer\Core\Mvc\Template\TemplateParameter;
18use PeServer\Core\ProgramContext;
19use PeServer\Core\Web\IUrlHelper;
20use PeServer\Core\Web\UrlPath;
21use PeServer\Core\Web\UrlQuery;
22use PeServer\Core\Web\WebSecurity;
23
24/**
25 * アプリケーションコントローラ基底処理。
26 */
27abstract class DomainControllerBase extends ControllerBase
28{
29    #region variable
30
31    #[Inject] //@phpstan-ignore-next-line [INJECT]
32    private AppUrl $appUrl;
33
34    #endregion
35
36    protected function __construct(ControllerArgument $argument)
37    {
38        parent::__construct($argument);
39    }
40
41    #region ControllerBase
42
43    protected function createViewActionResult(
44        string $templateBaseName,
45        string $actionName,
46        TemplateParameter $templateParameter,
47        array $headers,
48        ProgramContext $programContext,
49        ITemplateFactory $templateFactory,
50        IUrlHelper $urlHelper,
51        WebSecurity $webSecurity
52    ): ViewActionResult {
53        return new AppViewActionResult($templateBaseName, $actionName, $templateParameter, $headers, $programContext, $templateFactory, $urlHelper, $webSecurity);
54    }
55
56    protected function redirectPath(UrlPath|string $path, ?UrlQuery $query = null): RedirectActionResult
57    {
58        //NOTE: リダイレクトURLは設定から取得するためオーバーライドしている
59
60        if (is_string($path)) {
61            $path = new UrlPath($path);
62        }
63
64        $url = $this->appUrl->addPublicUrl($path, $query);
65
66        return parent::redirectUrl($url);
67    }
68
69    #endregion
70}