forked from leafsphp/leafAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
90 lines (72 loc) · 1.88 KB
/
Copy pathfunctions.php
File metadata and controls
90 lines (72 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
function app() {
global $app;
return $app;
}
function d() {
return app()->date;
}
function dbRow($table, $row_id, $columns = "*") {
app()->db->auto_connect();
return app()->db->select($table, $columns)->where("id", $row_id)->fetchAll();
}
function fs() {
return app()->fs;
}
function email(array $email) {
$mail = new \Leaf\Mail;
if (getenv("MAIL_DRIVER") === "smtp") {
$mail->smtp_connect(
getenv("MAIL_HOST"),
getenv("MAIL_PORT"),
!getenv("MAIL_USERNAME") ? false : true,
getenv("MAIL_USERNAME") ?? null,
getenv("MAIL_PASSWORD") ?? null,
getenv("MAIL_ENCRYPTION") ?? "STARTTLS"
);
}
$mail->write($email)->send();
}
function markup($data) {
app()->response->renderMarkup($data);
}
function plural($value, $count = 2) {
return Leaf\Str::plural($value, $count);
}
function render(string $view, array $data = [], array $mergeData = []) {
markup(view($view, $data, $mergeData));
}
function requestBody() {
return app()->request->body();
}
function requestData($param) {
return app()->request->get($param);
}
function respond($data) {
app()->response->respond($data);
}
function respondWithCode($data, $code = 500) {
app()->response->respondWithCode($data, $code);
}
function Route($methods, $pattern, $fn) {
app()->match($methods, $pattern, $fn);
}
function sessionBody() {
return app()->session->body();
}
function sessionGet($param) {
return app()->session->get($param);
}
function sessionSet($data, $value = null) {
return app()->session->set($data, $value);
}
function singular($value) {
return Leaf\Str::singular($value);
}
function throwErr($error, int $code = 500, bool $use_message = false) {
app()->response->throwErr($error, $code, $use_message);
}
function view(string $view, array $data = [], array $mergeData = []) {
app()->blade->configure(views_path(), storage_path("framework/views"));
return app()->blade->render($view, $data, $mergeData);
}