Skip to content

Commit 2829227

Browse files
authored
Merge pull request #2 from ABGEO07/develope
Develope
2 parents 04bb489 + e024c2f commit 2829227

File tree

8 files changed

+36
-18
lines changed

8 files changed

+36
-18
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Cherry-router
22

3+
## [v1.0.1](https://github.com/ABGEO07/cherry-router/releases/tag/v1.0.1 "v1.0.1") (2019-03-29)
4+
5+
- Change Namespace
6+
7+
Now you should use new namespace `Cherry\Routing\Router`
8+
9+
In controllers `Cherry\Controller`
10+
11+
- Validate code in PHP CodeSniffer
12+
13+
Code and comments has checked on [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
14+
15+
- Use call_user_func_array function in method calling
16+
17+
318
## [v1.0.0](https://github.com/ABGEO07/cherry-router/releases/tag/v1.0.0 "v1.0.0") (2019-03-07)
419
#### The first stable version
520

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Each route must have **path**, **method** and **action** keys. Homepage route ex
6060
"homepage": {
6161
"path": "/",
6262
"method": "GET",
63-
"action": "web2hw\\DefaultController::index"
63+
"action": "Cherry\\Controller\\DefaultController::index"
6464
}
6565
}
6666
```
@@ -93,16 +93,16 @@ Route example with placeholder:
9393
"homepage": {
9494
"path": "/hello/{name}",
9595
"method": "GET",
96-
"action": "Cherry\\DefaultController::sayHello"
96+
"action": "Cherry\\Controller\\DefaultController::sayHello"
9797
}
9898
}
9999
```
100100

101101
There we have placeholder called **{name}** and we can get this value in controller:
102102
```php
103-
public function sayHello($args)
103+
public function sayHello($name)
104104
{
105-
echo "Hello, {$args['name']}";
105+
echo "Hello, {$name}";
106106
}
107107
```
108108

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"minimum-stability": "dev",
1717
"require": {
1818
"php": ">=5.6.0",
19-
"cherry-project/request": "^1.0",
19+
"cherry-project/request": "v1.0.1",
2020
"ext-json": "*"
2121
},
2222
"autoload": {

composer.lock

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

examples/config/routes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"homepage": {
33
"path": "/",
44
"method": "GET",
5-
"action": "Cherry\\DefaultController::index"
5+
"action": "Cherry\\Controller\\DefaultController::index"
66
}
77
}

examples/controllers/DefaultController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Cherry;
3+
namespace Cherry\Controller;
44

55
class DefaultController
66
{

examples/test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
foreach ($config as $k => $v)
1616
define($k, __DIR__ . '/' . $v);
1717

18-
use Cherry\Router;
18+
use Cherry\Routing\Router;
1919

2020
$router = new Router();

src/Router.php renamed to src/Routing/Router.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
* @link https://github.com/ABGEO07/cherry-router
1212
*/
1313

14-
namespace Cherry;
14+
namespace Cherry\Routing;
15+
16+
use Cherry\HttpUtils\Request;
1517

1618
/**
1719
* Cherry project router class
@@ -122,7 +124,8 @@ private function _checkRoute()
122124

123125
$action = explode('::', $route['action']);
124126
$controller = explode('\\', $action[0]);
125-
$controllerFile = $controllersPath . '/' . $controller[1] . '.php';
127+
$controllerFile = $controllersPath . '/' .
128+
$controller[count($controller) - 1] . '.php';
126129

127130
//Include controller file
128131
if (file_exists($controllerFile)) {
@@ -145,7 +148,8 @@ private function _checkRoute()
145148
if (empty($match)) {
146149
$object->$objMethod();
147150
} else {
148-
$object->$objMethod($match);
151+
$match = array_unique($match, SORT_STRING);
152+
call_user_func_array(array($object, $objMethod), $match);
149153
}
150154
}
151155
}

0 commit comments

Comments
 (0)