Skip to content

Commit 2ff98fd

Browse files
author
MrAnyx
committed
[feat] Added TwigFunction for options
1 parent edc5f71 commit 2ff98fd

File tree

6 files changed

+58
-28
lines changed

6 files changed

+58
-28
lines changed

App/Bundle/Twig/TwigFunction.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Bundle\Twig;
4+
5+
class TwigFunction {
6+
7+
public function test() {
8+
return "test";
9+
}
10+
11+
}

App/Bundle/Views/home.twig

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88
</ul> #}
99

1010
<h1>{{ message }}</h1>
11-
11+
{#
1212
<a href="{{ generate('connexion') }}">connexion</a>
1313
<a href="{{ generate('deconnexion') }}">deconnexion</a>
1414
1515
<input type="text" name="username" placeholder="Enter your username"/>
16-
<input type="hidden" name="token" value="{{ token }}"/>
16+
<input type="hidden" name="token" value="{{ token }}"/> #}
17+
1718

19+
{# <p>{{ session }}</p> #}
1820

19-
<p>{{ session }}</p>
21+
{{ test() }}
22+
{{ test2() }}
2023

21-
{# {{ test() }} #}
24+
{{ "bonjour"|shuffle }}
2225

2326
{% endblock %}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"require": {
2929
"php": "^7.4",
3030
"timephp/database": "^0.0.7",
31-
"timephp/timephp": "^0.0.9"
31+
"timephp/timephp": "^0.0.10"
3232
},
3333
"require-dev": {
3434
"symfony/var-dumper": "^5.1"

composer.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/options.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
11
<?php
22

3+
use App\Bundle\Twig\TwigFunction;
4+
35
return [
46
"types" => [
57
[
68
"id" => "s",
7-
"regex" => "[a-z0-9]+(?:-[a-z0-9]+)*"
8-
]
9+
"regex" => "[a-z0-9]+(?:-[a-z0-9]+)*",
910
],
11+
],
1012
"twig" => [
1113
[
1214
"name" => "test",
13-
"function" => function() {
14-
return "test";
15-
}
15+
"type" => "function",
16+
"class" => TwigFunction::class,
17+
"function" => "test",
18+
],
19+
[
20+
"name" => "test2",
21+
"type" => "function",
22+
"function" => function () {
23+
return "test2";
24+
},
25+
],
26+
[
27+
"name" => "shuffle",
28+
"type" => "filter",
29+
"function" => function ($string) {
30+
return str_shuffle($string);
31+
},
1632
]
17-
]
33+
],
1834
];

web/routes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
],
2020
[
2121
"method" => "get",
22-
"url" => "/function",
22+
"url" => "/function/[i:test]",
2323
"name" => "function",
24-
"function" => function() {
25-
echo "hello you !";
24+
"function" => function(int $test) {
25+
dd($test);
2626
}
2727
],
2828
[

0 commit comments

Comments
 (0)