Issues (15)

app/Http/Action/HomeActionPayloadTwo copy.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace App\Http\Action;
6
7
// framework
8
use DarkMatter\Http\Response;
9
10
// StarDust
11
use StarDust\Action\HtmlAction;
0 ignored issues
show
The type StarDust\Action\HtmlAction was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
// application
14
use App\Domain\HomeDomainPayloadTwo;
15
use App\Http\PayloadResponder;
16
17
/**
18
 * Class HomeActionPayload
19
 *
20
 * This is an example of a HtmlAction. In every HtmlAction you have access to the HtmlResponder.
21
 *
22
 * @package DarkMatterApp\Actions
23
 */
24
class HomeActionPayloadTwo extends HtmlAction
25
{
26
    /**
27
     * Every Action needs to have a "__invoke" methods which is automatically executed by the application.
28
     * 1. The Action asks data from the Domain, which returns a Payload with the Payload Status
29
     * 2. This methods needs to return the response with the Payload which will than be send to the client.
30
     * 3. The Responder sets the Respomse
31
     * 
32
     * https://github.com/pmjones/adr-example/blob/master/src/Web/Blog/Read/BlogReadAction.php
33
     * PAYLOAD = domain result              // DOMAIN sets the payload and STATUS
34
     * retuns responder to                  // return $this->responder->__invoke($request, $payload);
35
     *
36
     * @param array $arguments Possible arguments from the URL.
37
     * @return Response
38
     */
39
    public function __invoke(array $arguments = []) : Response
40
    {
41
        // 0 get argument from request | route config: '/payloadtest/[{id:\d+}]', 
42
        // 1 new domain with route args
43
        // 2 get data from domain with route args
44
        // 3 call responder with payload from domain
45
46
        if (!isset($arguments['id'])) {
47
            $arguments['id'] = 42;
48
        }
49
50
        //
51
        $domain = new HomeDomainPayloadTwo($arguments);
52
        $payload = $domain->getWelcomePayload();
53
54
        // html responder
55
        // $responder = $this->responder->payload($payload);
56
57
        // Set Payload responder
58
        $this->setResponder(new PayloadResponder($this->config));
59
        $responder = $this->responder->__invoke($payload);
60
61
        return $responder;
62
    }
63
}
64