Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
cooperatic-mlc
kohinos
Commits
43f00f57
Commit
43f00f57
authored
Jan 22, 2019
by
Julien Jorry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BO : empêcher la suppresion des groupes admin
parent
ff11addd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
32 deletions
+61
-32
composer.lock
composer.lock
+0
-0
sonata.yaml
config/packages/sonata.yaml
+5
-1
GroupCRUDController.php
src/Controller/CRUD/GroupCRUDController.php
+52
-0
IndexController.php
src/Controller/IndexController.php
+0
-28
User.php
src/Entity/User.php
+4
-3
No files found.
composer.lock
View file @
43f00f57
This diff is collapsed.
Click to expand it.
config/packages/sonata.yaml
View file @
43f00f57
...
...
@@ -9,8 +9,12 @@ sonata_user:
admin
:
# Admin Classes
user
:
class
:
App\Application\Sonata\UserBundle\Admin\UserAdmin
# controller: SonataAdminBundle:CRUD
controller
:
App\Controller\CRUD\CRUDController
translation
:
SonataUserBundle
group
:
class
:
Sonata\UserBundle\Admin\Entity\GroupAdmin
controller
:
App\Controller\CRUD\GroupCRUDController
translation
:
SonataUserBundle
impersonating
:
route
:
sonata_admin_dashboard
...
...
src/Controller/CRUD/GroupCRUDController.php
0 → 100644
View file @
43f00f57
<?php
namespace
App\Controller\CRUD
;
use
Sonata\AdminBundle\Controller\CRUDController
as
Controller
;
use
Sonata\AdminBundle\Datagrid\ProxyQueryInterface
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
class
GroupCRUDController
extends
Controller
{
public
function
deleteAction
(
$id
)
{
$request
=
$this
->
getRequest
();
$id
=
$request
->
get
(
$this
->
admin
->
getIdParameter
());
$object
=
$this
->
admin
->
getObject
(
$id
);
if
(
!
$object
)
{
throw
$this
->
createNotFoundException
(
sprintf
(
'unable to find the object with id: %s'
,
$id
));
}
if
(
$object
->
hasRole
(
'ROLE_ADMIN_SIEGE'
)
||
$object
->
hasRole
(
'ROLE_SUPER_ADMIN'
)
||
$object
->
hasRole
(
'ROLE_ADMIN'
))
{
$this
->
addFlash
(
'sonata_flash_error'
,
'Vous ne pouvez pas supprimer les groupe ayant les rôles ROLE_SUPER_ADMIN, ROLE_ADMIN et ROLE_ADMIN_SIEGE !'
);
return
$this
->
redirectTo
(
$object
);
}
return
parent
::
deleteAction
(
$id
);
}
public
function
batchActionDelete
(
ProxyQueryInterface
$query
)
{
$objects
=
$query
->
execute
();
foreach
(
$objects
as
$object
)
{
if
(
$object
->
hasRole
(
'ROLE_ADMIN_SIEGE'
)
||
$object
->
hasRole
(
'ROLE_SUPER_ADMIN'
)
||
$object
->
hasRole
(
'ROLE_ADMIN'
))
{
$this
->
addFlash
(
'sonata_flash_error'
,
'Vous ne pouvez pas supprimer les groupe ayant les rôles ROLE_SUPER_ADMIN, ROLE_ADMIN et ROLE_ADMIN_SIEGE !'
);
return
new
RedirectResponse
(
$this
->
admin
->
generateUrl
(
'list'
,
array
(
'filter'
=>
$this
->
admin
->
getFilterParameters
()))
);
}
}
return
parent
::
batchActionDelete
(
$query
);
}
}
src/Controller/IndexController.php
View file @
43f00f57
...
...
@@ -24,36 +24,8 @@ class IndexController extends AbstractController
// array('%name%' => $user->getName())
// );
// GEOCODING ADDRESS :
// $httpClient = new \Http\Adapter\Guzzle6\Client();
// $provider = Nominatim::withOpenStreetMapServer($httpClient, 'test');
// $geocoder = new \Geocoder\StatefulGeocoder($provider, 'fr');
// $result = $geocoder->geocodeQuery(GeocodeQuery::create("19300 Rosiers-d'Egletons"));
// dump($result);
// exit();
return
$this
->
render
(
'index.html.twig'
,
[
'news'
=>
array
(),
]);
}
/**
* @Route("/toto/{id}/{name}", name="toto")
*/
// public function index(TranslatorInterface $translator)
public
function
toto
(
$id
,
$name
)
{
// Exemple pour la traduction :
// $translated = $translator->trans('Symfony is great');
// $translator->transChoice(
// 'Hurry up %name%! There is one apple left.|There are %count% apples left.',
// 10,
// // no need to include %count% here; Symfony does that for you
// array('%name%' => $user->getName())
// );
return
$this
->
render
(
'index.html.twig'
,
[
'toto'
=>
'toto'
,
'id'
=>
$id
]);
}
}
src/Entity/User.php
View file @
43f00f57
...
...
@@ -212,9 +212,10 @@ class User extends BaseUser
*/
public
function
removeCotisation
(
Cotisation
$cotisation
)
{
if
(
$this
->
cotisations
->
contains
(
$cotisation
))
{
$this
->
cotisations
->
removeElement
(
$cotisation
);
}
throw
new
\LogicException
(
'User::removeCotisation : This code should not be reached!'
);
// if ($this->cotisations->contains($cotisation)) {
// $this->cotisations->removeElement($cotisation);
// }
return
$this
;
}
}
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