Skip to content

Commit

Permalink
Merge pull request #20 from JoshuaMc1/feature/global-function
Browse files Browse the repository at this point in the history
global function successfully added
  • Loading branch information
JoshuaMc1 authored Apr 13, 2024
2 parents ba5b2d5 + 75c2c31 commit 59a88b2
Show file tree
Hide file tree
Showing 12 changed files with 1,509 additions and 872 deletions.
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
}
],
"scripts": {
"test": "./vendor/bin/phpunit test/"
"test": "./vendor/bin/phpunit test/",
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php console key:generate"
]
},
"support": {
"email": "joshua15mclean@gmail.com"
Expand All @@ -52,4 +58,4 @@
},
"minimum-stability": "stable",
"prefer-stable": true
}
}
4 changes: 2 additions & 2 deletions config/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/**
* Extensions for the view
*
* Default: ['.html.twig']
* Default: ['.html']
*/
'extensions' => ['.html.twig'],
'extensions' => ['.html'],
];
2 changes: 1 addition & 1 deletion console
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $finder->files()->in([

$container = new Container();
$dispatcher = new Dispatcher($container);
$application = new Application($container, $dispatcher, 'v2.2.2');
$application = new Application($container, $dispatcher, 'v2.2.3');

$namespaces = ['App\Console\Commands\\', 'Lib\Console\\'];

Expand Down
1 change: 1 addition & 0 deletions lib/Extensions/GlobalFunctionsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function getFunctions()
new TwigFunction('verify_bcrypt', 'verify_bcrypt'),
new TwigFunction('lang', 'lang'),
new TwigFunction('auth', 'auth'),
new TwigFunction('session', 'session'),
];
}
}
13 changes: 13 additions & 0 deletions lib/Global/Global.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ErrorHandler,
Request,
Response,
Session,
};
use Lib\Support\{
Config,
Expand Down Expand Up @@ -111,6 +112,18 @@ function dd(mixed $var): void
}
}

if (!function_exists('session')) {
/**
* The function `session` is a helper function in PHP that returns the value of a session key.
*
* @return Session
*/
function session(): Session
{
return new Session();
}
}

if (!function_exists('view')) {
/**
* The function `view` is a helper function in PHP that renders a view using the Twigs template
Expand Down
2 changes: 1 addition & 1 deletion lib/Http/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Session
*
* @throws \Throwable If an error occurs during session initialization.
*/
private function __construct()
public function __construct()
{
try {
if (session_status() !== PHP_SESSION_ACTIVE) {
Expand Down
Loading

0 comments on commit 59a88b2

Please sign in to comment.