88
99namespace Curiosity26 \AclHelperBundle \Helper ;
1010
11+ use Symfony \Component \Security \Acl \Domain \Entry ;
1112use Symfony \Component \Security \Acl \Domain \ObjectIdentity ;
1213use Symfony \Component \Security \Acl \Exception \AclNotFoundException ;
1314use Symfony \Component \Security \Acl \Model \MutableAclInterface ;
1415use Symfony \Component \Security \Acl \Model \MutableAclProviderInterface ;
16+ use Symfony \Component \Security \Acl \Model \ObjectIdentityInterface ;
1517use Symfony \Component \Security \Acl \Model \SecurityIdentityInterface ;
1618
1719/**
@@ -48,7 +50,7 @@ public function __construct(MutableAclProviderInterface $provider)
4850 */
4951 public function aclFor ($ object )
5052 {
51- if (!$ object instanceof ObjectIdentity ) {
53+ if (!$ object instanceof ObjectIdentityInterface ) {
5254 $ object = ObjectIdentity::fromDomainObject ($ object );
5355 }
5456
@@ -333,6 +335,70 @@ public function save()
333335 return $ this ;
334336 }
335337
338+ /**
339+ * @return array|Entry[]
340+ */
341+ public function getClassAces (): array
342+ {
343+ if (null === $ this ->acl ) {
344+ throw new \RuntimeException ("Find or create an ACL using aclFor() first. " );
345+ }
346+
347+ return $ this ->acl ->getClassAces ();
348+ }
349+
350+ /**
351+ * @param string $field
352+ *
353+ * @return array|Entry[]
354+ */
355+ public function getClassFieldAces (\string $ field ): array
356+ {
357+ if (null === $ this ->acl ) {
358+ throw new \RuntimeException ("Find or create an ACL using aclFor() first. " );
359+ }
360+
361+ return $ this ->acl ->getClassFieldAces ($ field );
362+ }
363+
364+ /**
365+ * @return array|Entry[]
366+ */
367+ public function getObjectAces (): array
368+ {
369+ if (null === $ this ->acl ) {
370+ throw new \RuntimeException ("Find or create an ACL using aclFor() first. " );
371+ }
372+
373+ return $ this ->acl ->getObjectAces ();
374+ }
375+
376+ /**
377+ * @param string $field
378+ *
379+ * @return array|Entry[]
380+ */
381+ public function getObjectFieldAces (\string $ field ): array
382+ {
383+ if (null === $ this ->acl ) {
384+ throw new \RuntimeException ("Find or create an ACL using aclFor() first. " );
385+ }
386+
387+ return $ this ->acl ->getObjectFieldAces ($ field );
388+ }
389+
390+ /**
391+ * @return ObjectIdentityInterface
392+ */
393+ public function getObjectIdentity (): ObjectIdentityInterface
394+ {
395+ if (null === $ this ->acl ) {
396+ throw new \RuntimeException ("Find or create an ACL using aclFor() first. " );
397+ }
398+
399+ return $ this ->acl ->getObjectIdentity ();
400+ }
401+
336402 /**
337403 * @return null|MutableAclInterface
338404 */
@@ -344,4 +410,24 @@ public function getAcl(): ?MutableAclInterface
344410
345411 return $ this ->acl ;
346412 }
413+
414+ /**
415+ * Deletes the ACL
416+ *
417+ * @return $this
418+ */
419+ public function delete ()
420+ {
421+ if (null === $ this ->acl ) {
422+ throw new \RuntimeException ("Find or create an ACL using aclFor() first. " );
423+ }
424+
425+ $ identity = $ this ->getObjectIdentity ();
426+
427+ $ this ->aclProvider ->deleteAcl ($ identity );
428+
429+ $ this ->acl = null ;
430+
431+ return $ this ;
432+ }
347433}
0 commit comments