-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCommon.php
63 lines (55 loc) · 1.51 KB
/
Common.php
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
<?php
/**
* The goal of this file is to allow developers a location
* where they can overwrite core procedural functions and
* replace them with their own. This file is loaded during
* the bootstrap process and is called during the framework's
* execution.
*
* This can be looked at as a `master helper` file that is
* loaded early on, and may also contain additional functions
* that you'd like to use throughout your entire application
*
* @see: https://codeigniter4.github.io/CodeIgniter4/
*/
use App\Libraries\Theme;
use CodeIgniter\Config\Factories;
if (! function_exists('policy')) {
/**
* A convenience method for accessing the Policy service.
*/
function policy(string $permission, mixed ...$arguments): bool
{
return service('policy')->can($permission, ...$arguments);
}
}
/**
* Generates the URLs to the vite resources.
*/
function vite(string|array $path): string
{
$vite = service('vite');
if (! is_array($path)) {
$path = [$path];
}
return $vite->links($path);
}
if (! function_exists('manager')) {
/**
* More simple way of getting manager instances from Factories
*/
function manager(string $name, bool $getShared = true): mixed
{
return Factories::managers($name, ['getShared' => $getShared]);
}
}
if (! function_exists('theme')) {
/**
* A convenience method for accessing the Theme service.
* Especially useful for views.
*/
function theme(): Theme
{
return service('theme');
}
}