Skip to content

Commit

Permalink
Set userId when using command
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrands02 committed Jun 28, 2024
1 parent e64e21d commit 1c15d75
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/ActionHandler/ConnectBesluittypeToZaaktypeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function getConfiguration(): array
return [
'$id' => 'https://development.zaaksysteem.nl/schemas/ZaakType.ActionHandler.schema.json',
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
'title' => 'ZGW ZaakType Action',
'title' => 'Connect BesluitType to ZaakType Action',
'description' => 'This handler customly maps xxllnc casetype to zgw zaaktype ',
'required' => ['zaakTypeEntityId'],
'properties' => [
Expand Down
33 changes: 26 additions & 7 deletions src/Command/ZaakCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

use App\Entity\Action;
use CommonGateway\XxllncZGWBundle\Service\ZaakService;
use Doctrine\ORM\EntityManagerInterface;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class ZaakCommand extends Command
{
Expand All @@ -44,18 +45,28 @@ class ZaakCommand extends Command
*/
private EntityManagerInterface $entityManager;

/**
* @var SessionInterface
*/
private SessionInterface $session;

/**
* Class constructor.
*
* @param ZaakService $zaakService The case service
* @param ZaakTypeService $zaakTypeService The case type service
* @param EntityManagerInterface $entityManager
* @param SessionInterface $session
*/
public function __construct(ZaakService $zaakService, EntityManagerInterface $entityManager)
{
$this->zaakService = $zaakService;
$this->entityManager = $entityManager;
public function __construct(
ZaakTypeService $zaakTypeService,
EntityManagerInterface $entityManager,
SessionInterface $session
) {
$this->zaakTypeService = $zaakTypeService;
$this->entityManager = $entityManager;
$this->session = $session;
parent::__construct();

}//end __construct()


Expand Down Expand Up @@ -99,6 +110,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::FAILURE;
}

$this->session->remove('currentActionUserId');
if ($action->getUserId() !== null && Uuid::isValid($action->getUserId()) === true) {
$user = $this->entityManager->getRepository('App:User')->find($action->getUserId());
if ($user instanceof User === true) {
$this->session->set('currentActionUserId', $action->getUserId());
}
}

if (isset($zaakId) === true
&& Uuid::isValid($zaakId) === true
) {
Expand Down
43 changes: 39 additions & 4 deletions src/Command/ZaakTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@

namespace CommonGateway\XxllncZGWBundle\Command;

use App\Entity\Action;
use CommonGateway\XxllncZGWBundle\Service\ZaakTypeService;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

class ZaakTypeCommand extends Command
{
Expand All @@ -37,19 +40,35 @@ class ZaakTypeCommand extends Command
*/
private ZaakTypeService $zaakTypeService;

/**
* @var EntityManagerInterface
*/
private EntityManagerInterface $entityManager;

/**
* @var SessionInterface
*/
private SessionInterface $session;

/**
* Class constructor.
*
* @param ZaakTypeService $zaakTypeService The case type service
* @param ZaakTypeService $zaakTypeService The case type service
* @param EntityManagerInterface $entityManager
* @param SessionInterface $session
*/
public function __construct(ZaakTypeService $zaakTypeService)
{
public function __construct(
ZaakTypeService $zaakTypeService,
EntityManagerInterface $entityManager,
SessionInterface $session
) {
$this->zaakTypeService = $zaakTypeService;
$this->entityManager = $entityManager;
$this->session = $session;
parent::__construct();

}//end __construct()


/**
* Configures this command.
Expand Down Expand Up @@ -88,6 +107,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// ObjectType could be a BesluitType or ZaakType.
$objectTypeId = $input->getArgument('id');

$actionRef = 'https://development.zaaksysteem.nl/action/xxllnc.ZaakType.action.json';
$action = $this->entityManager->getRepository('App:Action')->findOneBy(['reference' => $actionRef]);

Check warning on line 111 in src/Command/ZaakTypeCommand.php

View workflow job for this annotation

GitHub Actions / build

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

Check warning on line 111 in src/Command/ZaakTypeCommand.php

View workflow job for this annotation

GitHub Actions / build

Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
if ($action instanceof Action === false) {
$style->error("Action with reference $actionRef not found");

return Command::FAILURE;
}

$this->session->remove('currentActionUserId');
if ($action->getUserId() !== null && Uuid::isValid($action->getUserId()) === true) {
$user = $this->entityManager->getRepository('App:User')->find($action->getUserId());
if ($user instanceof User === true) {
$this->session->set('currentActionUserId', $action->getUserId());
}
}

if (isset($objectTypeId) === true
&& Uuid::isValid($objectTypeId) === true
) {
Expand Down

0 comments on commit 1c15d75

Please sign in to comment.