Skip to content

Commit 126ec65

Browse files
authored
Merge pull request #5 from curiosity26/develop
Develop
2 parents 6612967 + 415ccf1 commit 126ec65

File tree

11 files changed

+177
-91
lines changed

11 files changed

+177
-91
lines changed

Entity/Entry.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
class Entry
1212
{
1313
private $id;
14-
private $classId;
15-
private $objectIdentityId;
16-
private $securityIdentityId;
14+
private $class;
15+
private $objectIdentity;
16+
private $securityIdentity;
1717
private $fieldName;
1818
private $aceOrder;
1919
private $mask;
@@ -41,49 +41,49 @@ public function setId($id)
4141
/**
4242
* @return mixed
4343
*/
44-
public function getClassId()
44+
public function getClass()
4545
{
46-
return $this->classId;
46+
return $this->class;
4747
}
4848

4949
/**
50-
* @param mixed $classId
50+
* @param mixed $class
5151
*/
52-
public function setClassId($classId)
52+
public function setClass(AclClass $class)
5353
{
54-
$this->classId = $classId;
54+
$this->class = $class;
5555
}
5656

5757
/**
5858
* @return mixed
5959
*/
60-
public function getObjectIdentityId()
60+
public function getObjectIdentity()
6161
{
62-
return $this->objectIdentityId;
62+
return $this->objectIdentity;
6363
}
6464

6565
/**
66-
* @param mixed $object_entity_id
66+
* @param ObjectIdentity $object_entity_id
6767
*/
68-
public function setObjectIdentityId($objectIdentityId)
68+
public function setObjectIdentity(ObjectIdentity $objectIdentity)
6969
{
70-
$this->objectIdentityId = $objectIdentityId;
70+
$this->objectIdentity = $objectIdentity;
7171
}
7272

7373
/**
7474
* @return mixed
7575
*/
76-
public function getSecurityIdentityId()
76+
public function getSecurityIdentity()
7777
{
78-
return $this->securityIdentityId;
78+
return $this->securityIdentity;
7979
}
8080

8181
/**
82-
* @param mixed $securityIdentityId
82+
* @param mixed $securityIdentity
8383
*/
84-
public function setSecurityIdentityId($securityIdentityId)
84+
public function setSecurityIdentity(SecurityIdentity $securityIdentity)
8585
{
86-
$this->securityIdentityId = $securityIdentityId;
86+
$this->securityIdentity = $securityIdentity;
8787
}
8888

8989
/**

Entity/ObjectIdentity.php

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
class ObjectIdentity
1212
{
1313
private $id;
14-
private $parentObjectIdentityId;
15-
private $classId;
14+
private $parentObjectIdentity;
15+
private $parent;
16+
private $ancestor;
17+
private $class;
1618
private $objectIdentifier;
1719
private $entriesInheriting;
1820

@@ -35,33 +37,33 @@ public function setId($id)
3537
/**
3638
* @return mixed
3739
*/
38-
public function getParentObjectIdentityId()
40+
public function getParentObjectIdentity()
3941
{
40-
return $this->parentObjectIdentityId;
42+
return $this->parentObjectIdentity;
4143
}
4244

4345
/**
44-
* @param mixed $parentObjectIdentityId
46+
* @param mixed $parentObjectIdentity
4547
*/
46-
public function setParentObjectIdentityId($parentObjectIdentityId)
48+
public function setParentObjectIdentity($parentObjectIdentity)
4749
{
48-
$this->parentObjectIdentityId = $parentObjectIdentityId;
50+
$this->parentObjectIdentity = $parentObjectIdentity;
4951
}
5052

5153
/**
5254
* @return mixed
5355
*/
54-
public function getClassId()
56+
public function getClass()
5557
{
56-
return $this->classId;
58+
return $this->class;
5759
}
5860

5961
/**
60-
* @param mixed $classId
62+
* @param mixed $class
6163
*/
62-
public function setClassId($classId)
64+
public function setClass($class)
6365
{
64-
$this->classId = $classId;
66+
$this->class = $class;
6567
}
6668

6769
/**
@@ -95,4 +97,44 @@ public function setEntriesInheriting($entriesInheriting)
9597
{
9698
$this->entriesInheriting = $entriesInheriting;
9799
}
100+
101+
/**
102+
* @return mixed
103+
*/
104+
public function getParent()
105+
{
106+
return $this->parent;
107+
}
108+
109+
/**
110+
* @param mixed $parent
111+
*
112+
* @return ObjectIdentity
113+
*/
114+
public function setParent(ObjectIdentity $parent)
115+
{
116+
$this->parent = $parent;
117+
118+
return $this;
119+
}
120+
121+
/**
122+
* @return mixed
123+
*/
124+
public function getAncestor()
125+
{
126+
return $this->ancestor;
127+
}
128+
129+
/**
130+
* @param mixed $ancestor
131+
*
132+
* @return ObjectIdentity
133+
*/
134+
public function setAncestor(ObjectIdentity $ancestor)
135+
{
136+
$this->ancestor = $ancestor;
137+
138+
return $this;
139+
}
98140
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: alex.boyce
5+
* Date: 11/28/18
6+
* Time: 10:13 AM
7+
*/
8+
9+
namespace Curiosity26\AclHelperBundle\EventListener;
10+
11+
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
12+
use Symfony\Component\Security\Acl\Dbal\Schema;
13+
14+
class AclSchemaListener
15+
{
16+
private $schema;
17+
18+
public function __construct(Schema $schema)
19+
{
20+
$this->schema = $schema;
21+
}
22+
23+
public function postGenerateSchema(GenerateSchemaEventArgs $args)
24+
{
25+
$schema = $args->getSchema();
26+
27+
foreach ($schema->getTableNames() as $tableName) {
28+
if (false != preg_match('/^acl_/', $tableName)) {
29+
$this->schema->addToSchema($schema);
30+
break;
31+
}
32+
}
33+
}
34+
}

Helper/AclHelperAgent.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,17 @@ public function findBy(
8989

9090
if (!empty($criteria)) {
9191
$predicates = $builder->expr()->andX();
92+
9293
foreach ($criteria as $field => $criterion) {
93-
$predicates->add(
94-
is_array($criterion)
95-
? $builder->expr()->in("e,$field", ":$field")
96-
: $builder->expr()->eq("e.$field", ":$field")
97-
);
98-
$builder->setParameter(":$field", $criterion);
94+
if (is_array($criterion)) {
95+
$predicates->add($builder->expr()->in("e.$field", ":$field"));
96+
$builder->setParameter(":$field", $criterion);
97+
} elseif (null !== $criterion) {
98+
$predicates->add($builder->expr()->eq("e.$field", ":$field"));
99+
$builder->setParameter(":$field", $criterion);
100+
} else {
101+
$predicates->add($builder->expr()->isNull("e.$field"));
102+
}
99103
}
100104

101105
$builder->where($predicates);

QueryBuilder/AclHelperQueryBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,18 @@ public function buildAclQuery($strategy = PermissionGrantingStrategy::ANY)
107107
->select('INT(acl_o.objectIdentifier)')
108108
->distinct()
109109
->from(ObjectIdentity::class, 'acl_o')
110-
->innerJoin(AclClass::class, 'acl_c', Join::WITH, 'acl_c.id = acl_o.classId')
110+
->innerJoin(AclClass::class, 'acl_c', Join::WITH, 'acl_c.id = acl_o.class')
111111
->leftJoin(
112112
Entry::class,
113113
'acl_e',
114114
Join::WITH,
115-
'acl_e.objectIdentityId = acl_o.id OR acl_e.objectIdentityId IS NULL'
115+
'acl_e.objectIdentity = acl_o.id OR acl_e.objectIdentity IS NULL'
116116
)
117117
->leftJoin(
118118
SecurityIdentity::class,
119119
'acl_s',
120120
Join::WITH,
121-
'acl_e.securityIdentityId = acl_s.id'
121+
'acl_e.securityIdentity = acl_s.id'
122122
)
123123
->where(
124124
$expr

Resources/config/doctrine/AclClass.orm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Curiosity26\AclHelperBundle\Entity\AclClass:
22
table: "acl_classes"
33
type: entity
4-
read-only: true
4+
readOnly: true
55
id:
66
id:
77
type: integer
Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
11
Curiosity26\AclHelperBundle\Entity\Entry:
22
table: "acl_entries"
33
type: entity
4-
read-only: true
4+
readOnly: true
55
id:
66
id:
77
type: integer
88
generator: { strategy: AUTO }
99
fields:
10-
classId:
11-
name: class_id
12-
type: integer
13-
options:
14-
unsigned: true
15-
objectIdentityId:
16-
name: object_identity_id
17-
type: integer
18-
options:
19-
unsigned: true
20-
securityIdentityId:
21-
name: security_identity_id
22-
type: integer
23-
options:
24-
unsigned: true
2510
fieldName:
26-
name: field_name
2711
type: string
2812
length: 50
13+
nullable: true
2914
aceOrder:
30-
name: ace_order
3115
type: smallint
16+
default: 0
3217
options:
3318
unsigned: true
3419
mask:
@@ -39,9 +24,20 @@ Curiosity26\AclHelperBundle\Entity\Entry:
3924
name: granting_strategy
4025
type: string
4126
length: 30
27+
default: 'all'
4228
auditSuccess:
4329
name: audit_success
4430
type: boolean
4531
auditFailure:
4632
name: audit_failure
47-
type: boolean
33+
type: boolean
34+
manyToOne:
35+
class:
36+
targetEntity: 'Curiosity26\AclHelperBundle\Entity\AclClass'
37+
cascade: ["persist"]
38+
objectIdentity:
39+
targetEntity: 'Curiosity26\AclHelperBundle\Entity\ObjectIdentity'
40+
casade: ['persist']
41+
securityIdentity:
42+
targetEntity: 'Curiosity26\AclHelperBundle\Entity\SecurityIdentity'
43+
cascade: ["persist"]
Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
Curiosity26\AclHelperBundle\Entity\ObjectIdentity:
22
table: "acl_object_identities"
33
type: entity
4-
read-only: true
4+
readOnly: true
55
id:
66
id:
77
type: integer
88
generator: { strategy: AUTO }
99
fields:
10-
parentObjectIdentityId:
11-
name: parent_object_identity_id
12-
type: integer
13-
options:
14-
unsigned: true
15-
classId:
16-
name: class_id
10+
parentObjectIdentity:
11+
column: parent_object_identity_id
1712
type: integer
13+
nullable: true
1814
options:
1915
unsigned: true
2016
objectIdentifier:
21-
name: object_identifier
2217
type: string
2318
length: 100
2419
entriesInheriting:
25-
name: entries_inheriting
26-
type: boolean
20+
type: boolean
21+
manyToOne:
22+
class:
23+
targetEntity: 'Curiosity26\AclHelperBundle\Entity\AclClass'
24+
cascade: ["persist"]
25+
manyToMany:
26+
parent:
27+
targetEntity: 'Curiosity26\AclHelperBundle\Entity\ObjectIdentity'
28+
mappedBy: ancestor
29+
ancestor:
30+
targetEntity: 'Curiosity26\AclHelperBundle\Entity\ObjectIdentity'
31+
inversedBy: parentObjectIdentity
32+
joinTable:
33+
name: acl_object_identity_ancestors
34+
inversedJoinColumns:
35+
object_identity_id:
36+
referencedColumnName: id
37+
joinColumns:
38+
ancestor_id:
39+
referencedColumnName: id
40+

Resources/config/doctrine/SecurityIdentity.orm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Curiosity26\AclHelperBundle\Entity\SecurityIdentity:
22
table: "acl_security_identities"
33
type: entity
4-
read_only: true
4+
readOnly: true
55
id:
66
id:
77
type: integer

0 commit comments

Comments
 (0)