File tree Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of the Phalcon API.
5+ *
6+ * (c) Phalcon Team <[email protected] > 7+ *
8+ * For the full copyright and license information, please view
9+ * the LICENSE file that was distributed with this source code.
10+ */
11+
12+ declare (strict_types=1 );
13+
14+ namespace Phalcon \Api \Action \Hello ;
15+
16+ use Phalcon \Api \Domain \Hello \HelloService ;
17+ use Phalcon \Api \Responder \Hello \HelloTextResponder ;
18+ use Phalcon \Http \Response ;
19+
20+ final class GetAction
21+ {
22+ public function __construct (
23+ private readonly HelloService $ service ,
24+ private readonly HelloTextResponder $ responder
25+ ) {
26+ }
27+
28+ public function __invoke (): void
29+ {
30+ $ service = $ this ->service ;
31+ $ responder = $ this ->responder ;
32+
33+ $ serviceOutput = $ service ();
34+ $ outputResponse = $ responder ($ serviceOutput );
35+
36+ $ outputResponse ->send ();
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of the Phalcon API.
5+ *
6+ * (c) Phalcon Team <[email protected] > 7+ *
8+ * For the full copyright and license information, please view
9+ * the LICENSE file that was distributed with this source code.
10+ */
11+
12+ declare (strict_types=1 );
13+
14+ namespace Phalcon \Api \Domain \Hello ;
15+
16+ use function date ;
17+
18+ final class HelloService
19+ {
20+ public function __invoke (): string
21+ {
22+ return "Hello World!!! - " . date ("Y-m-d H:i:s " );
23+ }
24+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of the Phalcon API.
5+ *
6+ * (c) Phalcon Team <[email protected] > 7+ *
8+ * For the full copyright and license information, please view
9+ * the LICENSE file that was distributed with this source code.
10+ */
11+
12+ declare (strict_types=1 );
13+
14+ namespace Phalcon \Api \Responder \Hello ;
15+
16+ use Phalcon \Http \Response ;
17+
18+ final class HelloTextResponder
19+ {
20+ public function __construct (
21+ private Response $ response
22+ ) {
23+ }
24+
25+ public function __invoke (string $ payload ): Response
26+ {
27+ $ this ->response ->setContent ($ payload );
28+
29+ return $ this ->response ;
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments