mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
add accessKey to entity workflow step
This commit is contained in:
parent
b56d8c2956
commit
08f9819453
@ -82,7 +82,10 @@ class WorkflowController extends AbstractController
|
|||||||
$entityWorkflow
|
$entityWorkflow
|
||||||
->setRelatedEntityClass($request->query->get('entityClass'))
|
->setRelatedEntityClass($request->query->get('entityClass'))
|
||||||
->setRelatedEntityId($request->query->getInt('entityId'))
|
->setRelatedEntityId($request->query->getInt('entityId'))
|
||||||
->setWorkflowName($request->query->get('workflow'));
|
->setWorkflowName($request->query->get('workflow'))
|
||||||
|
->addSubscriberToStep($this->getUser())
|
||||||
|
->addSubscriberToFinal($this->getUser())
|
||||||
|
;
|
||||||
|
|
||||||
$errors = $this->validator->validate($entityWorkflow, null, ['creation']);
|
$errors = $this->validator->validate($entityWorkflow, null, ['creation']);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class EntityWorkflowStep
|
|||||||
private ?string $transitionAfter = null;
|
private ?string $transitionAfter = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime_immutable")
|
* @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
|
||||||
*/
|
*/
|
||||||
private ?DateTimeImmutable $transitionAt = null;
|
private ?DateTimeImmutable $transitionAt = null;
|
||||||
|
|
||||||
@ -101,9 +101,15 @@ class EntityWorkflowStep
|
|||||||
*/
|
*/
|
||||||
private ?string $transitionByEmail = null;
|
private ?string $transitionByEmail = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="text", nullable=false)
|
||||||
|
*/
|
||||||
|
private string $accessKey;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->destUser = new ArrayCollection();
|
$this->destUser = new ArrayCollection();
|
||||||
|
$this->accessKey = bin2hex(openssl_random_pseudo_bytes(32));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addDestEmail(string $email): self
|
public function addDestEmail(string $email): self
|
||||||
@ -119,6 +125,9 @@ class EntityWorkflowStep
|
|||||||
{
|
{
|
||||||
if (!$this->destUser->contains($user)) {
|
if (!$this->destUser->contains($user)) {
|
||||||
$this->destUser[] = $user;
|
$this->destUser[] = $user;
|
||||||
|
$this->getEntityWorkflow()
|
||||||
|
->addSubscriberToFinal($user)
|
||||||
|
->addSubscriberToStep($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Main;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20220223171457 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_main_workflow_entity_step ADD accessKey TEXT DEFAULT NULL');
|
||||||
|
$this->addSql('WITH randoms AS (select
|
||||||
|
cmwes.id,
|
||||||
|
string_agg(substr(characters, (random() * length(characters) + 0.5)::integer, 1), \'\') as random_word
|
||||||
|
from (values(\'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\')) as symbols(characters)
|
||||||
|
-- length of word
|
||||||
|
join generate_series(1, 32) on 1 = 1
|
||||||
|
JOIN chill_main_workflow_entity_step cmwes ON true
|
||||||
|
GROUP BY cmwes.id)
|
||||||
|
UPDATE chill_main_workflow_entity_step SET accessKey = randoms.random_word FROM randoms WHERE chill_main_workflow_entity_step.id = randoms.id');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_workflow_entity_step ALTER accessKey DROP DEFAULT ');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_workflow_entity_step ALTER accessKey SET NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_main_workflow_entity_step DROP accessKey');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user