Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
20f4c1e3
Commit
20f4c1e3
authored
Apr 04, 2024
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user admin: prevent deleting user if its adherent account has flux
parent
aca3a2c6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
CRUDController.php
src/Controller/CRUD/CRUDController.php
+24
-0
No files found.
src/Controller/CRUD/CRUDController.php
View file @
20f4c1e3
...
...
@@ -9,9 +9,20 @@ use Symfony\Component\Form\FormView;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\Security\Core\Exception\AccessDeniedException
;
use
App\Utils\CustomEntityManager
;
use
App\Entity\User
;
use
App\Entity\Flux
;
class
CRUDController
extends
Controller
{
protected
$em
;
public
function
__construct
(
CustomEntityManager
$em
)
{
$this
->
em
=
$em
;
}
/**
* Create action.
*
...
...
@@ -220,6 +231,19 @@ class CRUDController extends Controller
return
$this
->
redirectTo
(
$object
);
}
// Prevent deleting user if flux related to its Adherent account exist
if
(
$object
instanceof
User
&&
$object
->
getAdherent
())
{
$query
=
$this
->
em
->
getRepository
(
Flux
::
class
)
->
getQueryByAdherent
(
$object
->
getAdherent
());
if
(
null
!=
$query
&&
count
(
$query
->
getResult
())
>
0
)
{
$this
->
addFlash
(
'sonata_flash_error'
,
'Vous ne pouvez pas supprimer ce compte utilisateur car des flux en relation à son compte Adhérent existent.'
);
return
$this
->
redirectTo
(
$object
);
}
}
return
parent
::
deleteAction
(
$id
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment