-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Admin prehledy mazani #938
Changes from 4 commits
c6863ab
031c68a
24d5fc5
a27325a
983fae0
bf0d5bb
b732055
4cd3b54
1d6c1d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{control patrolsGrid} | ||
{control groupsGrid} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Model\User\Commands; | ||
|
||
class DeletePatrol | ||
{ | ||
public function __construct( | ||
public int $id, | ||
) { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Model\User\Commands; | ||
|
||
class DeleteTroop | ||
{ | ||
public function __construct( | ||
public int $id, | ||
) { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Model\User\Commands\Handlers; | ||
|
||
use App\Model\User\Commands\DeletePatrol; | ||
use App\Model\User\Queries\PatrolByIdQuery; | ||
use App\Model\User\Repositories\PatrolRepository; | ||
use App\Model\User\Repositories\UserGroupRoleRepository; | ||
use App\Model\User\Repositories\UserRepository; | ||
use App\Services\QueryBus; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\Messenger\Handler\MessageHandlerInterface; | ||
|
||
class DeletePatrolHandler implements MessageHandlerInterface | ||
{ | ||
public function __construct( | ||
private QueryBus $queryBus, | ||
private EntityManagerInterface $em, | ||
private PatrolRepository $patrolRepository, | ||
private UserGroupRoleRepository $userGroupRoleRepository, | ||
private UserRepository $userRepository | ||
) { | ||
} | ||
|
||
public function __invoke(DeletePatrol $command): void | ||
{ | ||
$this->em->wrapInTransaction(function () use ($command): void { | ||
$patrol = $this->queryBus->handle(new PatrolByIdQuery($command->id)); | ||
foreach ($patrol->getUsersRoles() as $usersRole) { | ||
$this->userGroupRoleRepository->remove($usersRole); | ||
$u = $usersRole->getUser(); | ||
// $r = $u->getRoles(); | ||
if ($u->getRolesText() == '') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tohle není moc hezké, co getRoles() empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pozor, že se tu míchají 2 typy rolí - skupinové a uživatelské. Smazat by se měl jen uživatel, který nemá ani jednu (není ve skupině, ani se nepřihlásil přes skautIS) |
||
$this->userRepository->remove($u); | ||
} | ||
} | ||
|
||
$this->patrolRepository->remove($patrol); | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Model\User\Commands\Handlers; | ||
|
||
use App\Model\User\Commands\DeletePatrol; | ||
use App\Model\User\Commands\DeleteTroop; | ||
use App\Model\User\Queries\TroopByIdQuery; | ||
use App\Model\User\Repositories\TroopRepository; | ||
use App\Model\User\Repositories\UserGroupRoleRepository; | ||
use App\Model\User\Repositories\UserRepository; | ||
use App\Services\CommandBus; | ||
use App\Services\QueryBus; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\Messenger\Handler\MessageHandlerInterface; | ||
|
||
class DeleteTroopHandler implements MessageHandlerInterface | ||
{ | ||
public function __construct( | ||
private QueryBus $queryBus, | ||
private CommandBus $commandBus, | ||
private EntityManagerInterface $em, | ||
private TroopRepository $troopRepository, | ||
private UserGroupRoleRepository $userGroupRoleRepository, | ||
private UserRepository $userRepository | ||
) { | ||
} | ||
|
||
public function __invoke(DeleteTroop $command): void | ||
{ | ||
$this->em->wrapInTransaction(function () use ($command): void { | ||
$troop = $this->queryBus->handle(new TroopByIdQuery($command->id)); | ||
foreach ($troop->getPatrols() as $patrol) { | ||
$this->commandBus->handle(new DeletePatrol($patrol->getId())); | ||
} | ||
|
||
foreach ($troop->getUsersRoles() as $usersRole) { | ||
$this->userGroupRoleRepository->remove($usersRole); | ||
$u = $usersRole->getUser(); | ||
|
||
if ($u->getRolesText() == '') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. viz mazání družiny |
||
$this->userRepository->remove($usersRole->getUser()); | ||
} | ||
} | ||
|
||
$this->troopRepository->remove($troop); | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nechal bych pojmenování Patrol a Troop, ať to odpovídá našim db objektům