Skip to content

Commit e83fd40

Browse files
committed
Update
1 parent b7fee72 commit e83fd40

17 files changed

+55
-52
lines changed

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
composer.phar
22
/vendor/
3-
4-
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
5-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
6-
# composer.lock
3+
*.bak.php

composer.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "floatphp/kernel",
3-
"version" : "1.1.3",
3+
"version" : "1.2.0",
44
"type": "library",
55
"description": "FloatPHP Kernel Components",
66
"keywords": ["php","micro-framework","framework","PSR","ORM","jakiboy","composer"],
@@ -17,13 +17,13 @@
1717
"php": ">=8.2",
1818
"ext-curl": "*",
1919
"ext-intl": "*",
20-
"twig/twig": "^3.14.0",
20+
"twig/twig": "^3.14.2",
2121
"justinrainbow/json-schema": "^6.0.0",
22-
"floatphp/classes": "^1.1.0",
23-
"floatphp/helpers": "^1.1.0",
24-
"floatphp/interfaces": "^1.1.0",
25-
"floatphp/exceptions": "^1.1.0",
26-
"floatphp/cli": "^1.1.0"
22+
"floatphp/classes": "^1.2.0",
23+
"floatphp/helpers": "^1.2.0",
24+
"floatphp/interfaces": "^1.2.0",
25+
"floatphp/exceptions": "^1.2.0",
26+
"floatphp/cli": "^1.2.0"
2727
},
2828
"autoload": {
2929
"psr-4" : {

src/AbstractAuthController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/ApiController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/BackendController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/Base.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -93,9 +93,12 @@ protected function translate(string $string) : string
9393
}
9494

9595
$slug = $string;
96-
foreach ($this->matchEveryString('/([A-Z])/', $slug) as $upper) {
96+
$this->matchEveryString('/([A-Z])/', $slug, $matches, -1);
97+
98+
foreach ($matches as $upper) {
9799
$slug = $this->replaceString($upper, "{$upper}1-", $slug);
98100
}
101+
99102
$slug = $this->slugify($slug);
100103
$slug = $this->limitString($slug);
101104

src/BaseController.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -86,8 +86,8 @@ public function hasAccess() : bool
8686
protected function addJS(string $js, string $hook = 'add-js')
8787
{
8888
$this->addAction($hook, function() use($js) {
89-
$tpl = $this->applyFilter('view-js', 'system/js');
90-
$this->render(['js' => $js], $tpl);
89+
$file = $this->applyFilter('view-js', 'system/js');
90+
$this->render($file, ['js' => $js]);
9191
});
9292
}
9393

@@ -102,8 +102,8 @@ protected function addJS(string $js, string $hook = 'add-js')
102102
protected function addCSS(string $css, string $hook = 'add-css')
103103
{
104104
$this->addAction($hook, function() use($css){
105-
$tpl = $this->applyFilter('view-css', 'system/css');
106-
$this->render(['css' => $css], $tpl);
105+
$file = $this->applyFilter('view-css', 'system/css');
106+
$this->render($file, ['css' => $css]);
107107
});
108108
}
109109

src/Core.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/ErrorController.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -40,16 +40,16 @@ public function __construct($code = 404, $error = null, $render = true)
4040

4141
if ( $render ) {
4242

43-
$type = $this->applyFilter('error-response-type', 'text/html;charset=utf-8');
44-
$template = $this->applyFilter('error-template', '/system/error');
45-
$error = $this->applyFilter('error', $this->translate($error));
43+
$type = $this->applyFilter('error-response-type', 'text/html;charset=utf-8');
44+
$file = $this->applyFilter('error-template', '/system/error');
45+
$error = $this->applyFilter('error', $this->translate($error));
4646

4747
Response::setHttpHeaders($code, $type);
48-
$this->render([
48+
$this->render($file, [
4949
'status' => $message,
5050
'code' => $code,
5151
'error' => $error
52-
], $template);
52+
]);
5353

5454
die();
5555

src/FrontController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/Middleware.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -40,7 +40,7 @@ public function __construct(RouterInterface $router)
4040
$this->initConfig();
4141

4242
// Prepare router from config
43-
$router->setBasePath($this->getBaseRoute());
43+
$router->setBase($this->getBaseRoute());
4444

4545
// Set global router
4646
$router->addRoutes($this->getRoutes());
@@ -133,10 +133,10 @@ private function doCallable()
133133
private function doInstance()
134134
{
135135
// Parse
136-
$class = $this->parseClass();
136+
$class = $this->parseClass();
137137
$method = $this->parseMethod();
138-
$var = $this->parseVar();
139-
$role = $this->parsePermissions();
138+
$var = $this->parseVar();
139+
$role = $this->parsePermissions();
140140

141141
// Secure access
142142
$instance = new $class();

src/Model.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/Module.php

+15-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -34,11 +34,13 @@ public function __construct()
3434
}
3535

3636
/**
37+
* Check permission.
38+
*
3739
* @access public
38-
* @param mixed $role
40+
* @param string $role
3941
* @return bool
4042
*/
41-
public function hasPermissions($role = false) : bool
43+
public function hasPermissions(?string $role = null) : bool
4244
{
4345
if ( $this->isPermissions() ) {
4446
if ( $role ) {
@@ -74,31 +76,31 @@ public function getModulesRoutes()
7476
* Add module js.
7577
*
7678
* @access protected
77-
* @param string $js
79+
* @param string $path
7880
* @param string $hook
7981
* @return void
8082
*/
81-
protected function addJS($js, $hook = 'add-js')
83+
protected function addJS(string $path, string $hook = 'add-js')
8284
{
83-
$this->addAction($hook, function() use($js) {
84-
$tpl = $this->applyFilter('module-view-js', 'system/js');
85-
$this->render(['js' => "{$this->getModulesUrl()}/{$js}"], $tpl);
85+
$this->addAction($hook, function() use($path) {
86+
$file = $this->applyFilter('module-view-js', 'system/js');
87+
$this->render($file, ['js' => "{$this->getModulesUrl()}/{$path}"]);
8688
});
8789
}
8890

8991
/**
9092
* Add module css.
9193
*
9294
* @access protected
93-
* @param string $css
95+
* @param string $path
9496
* @param string $hook
9597
* @return void
9698
*/
97-
protected function addCSS($css, $hook = 'add-css')
99+
protected function addCSS(string $path, string $hook = 'add-css')
98100
{
99-
$this->addAction($hook, function() use($css){
100-
$tpl = $this->applyFilter('module-view-css', 'system/css');
101-
$this->render(['css' => "{$this->getModulesUrl()}/{$css}"], $tpl);
101+
$this->addAction($hook, function() use($path){
102+
$file = $this->applyFilter('module-view-css', 'system/css');
103+
$this->render($file, ['css' => "{$this->getModulesUrl()}/{$path}"]);
102104
});
103105
}
104106

src/Orm.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/TraitConfiguration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/TraitException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT

src/View.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author : Jakiboy
44
* @package : FloatPHP
55
* @subpackage : Kernel Component
6-
* @version : 1.1.0
6+
* @version : 1.2.x
77
* @copyright : (c) 2018 - 2024 Jihad Sinnaour <[email protected]>
88
* @link : https://floatphp.com
99
* @license : MIT
@@ -88,6 +88,7 @@ public function assign(string $file = 'default', array $content = []) : string
8888
// Return rendered view
8989
try {
9090
$view = $env->load("{$file}{$this->getViewExtension()}");
91+
$content = $this->mergeArray($this->content, $content);
9192
return $view->render($content);
9293

9394
} catch (\Exception | \RuntimeException $e) {

0 commit comments

Comments
 (0)