From bdbbe5812801d4d84fa6d22a0f87b45044a661ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lavoie?= Date: Tue, 18 Jun 2013 17:56:09 -0400 Subject: [PATCH] [Security][Acl] Issue #5787 : Added MutableAclProvider::deleteSecurityIdentity Code style fix and documentation typo --- .../Security/Acl/Dbal/MutableAclProvider.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index 0ac4fa7218..f8f2aea41f 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -108,6 +108,18 @@ class MutableAclProvider extends AclProvider implements MutableAclProviderInterf } } + /** + * Deletes the security identity from the database. + * ACL entries have the CASCADE option on their foreign key so they will also get deleted + * + * @param SecurityIdentityInterface $sid + * @throws \InvalidArgumentException + */ + public function deleteSecurityIdentity(SecurityIdentityInterface $sid) + { + $this->connection->executeQuery($this->getDeleteSecurityIdentityIdSql($sid)); + } + /** * {@inheritDoc} */ @@ -595,6 +607,21 @@ QUERY; ); } + /** + * Constructs the SQL to delete a security identity. + * + * @param SecurityIdentityInterface $sid + * @throws \InvalidArgumentException + * @return string + */ + protected function getDeleteSecurityIdentityIdSql(SecurityIdentityInterface $sid) + { + $select = $this->getSelectSecurityIdentityIdSql($sid); + $delete = preg_replace('/^SELECT id FROM/', 'DELETE FROM', $select); + + return $delete; + } + /** * Constructs the SQL for updating an object identity. *