forked from CakeDC/users
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsersUrl.php
More file actions
57 lines (50 loc) · 1.46 KB
/
Copy pathUsersUrl.php
File metadata and controls
57 lines (50 loc) · 1.46 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
<?php
/**
* Copyright 2010 - 2019, Cake Development Corporation (https://www.cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2018, Cake Development Corporation (https://www.cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace CakeDC\Users\Utility;
use Cake\Core\Configure;
use Cake\Http\ServerRequest;
class UsersUrl
{
/**
* Get an user action url
*
* @param string $action user action
* @param array $extra extra url attributes
*
* @return array
*/
public function actionUrl($action, $extra = [])
{
$prefix = false;
$controller = Configure::read('Users.controller', 'CakeDC/Users.Users');
list($plugin, $controller) = pluginSplit($controller);
$plugin = $plugin ? $plugin : false;
return compact('prefix', 'plugin', 'controller', 'action') + $extra;
}
/**
* Check if the action is the one from a request
*
* @param string $action users action
* @param Request $request the request
*
* @return bool
*/
public function checkActionOnRequest($action, ServerRequest $request)
{
$url = $this->actionUrl($action);
foreach ($url as $param => $value) {
if ($request->getParam($param) !== $value) {
return false;
}
}
return true;
}
}