-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssertXPathMatch.php
More file actions
48 lines (37 loc) · 894 Bytes
/
AssertXPathMatch.php
File metadata and controls
48 lines (37 loc) · 894 Bytes
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
<?php
namespace BaseXMS;
use Zend\Permissions\Rbac\AssertionInterface;
use Zend\Permissions\Rbac\Rbac;
class AssertXPathMatch implements AssertionInterface
{
private $accessQuery;
private $contextDoc;
public function __construct( $accessQuery, $contextDoc )
{
$this->accessQuery = $accessQuery;
$this->contextDoc = $contextDoc;
}
public function assert( Rbac $rbac )
{
$return = false;
$role = $rbac->getRole( 'PermissionXML' );
$accessResult = $role->doc->query( $this->accessQuery );
if( $accessResult->length > 0 )
{
$limitationQuery = trim( $accessResult->item(0)->nodeValue );
if( $limitationQuery )
{
if( $this->contextDoc instanceof \BaseXMS\Stdlib\DOMDocument )
{
$return = $this->contextDoc->query( $limitationQuery )->length > 0;
}
}
else
{
$return = true;
}
}
return $return;
}
}
?>