Skip to content

Commit

Permalink
Merge pull request #175 from tienvx/use-json-odm
Browse files Browse the repository at this point in the history
Use json odm
  • Loading branch information
tienvx authored Mar 9, 2019
2 parents 1a80f8d + ac68237 commit 66851b1
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 60 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"symfony/process": "^v4.2",
"symfony/serializer": "^4.2",
"doctrine/doctrine-bundle": "^1.10",
"doctrine/orm": "^2.6"
"doctrine/orm": "^2.6",
"dunglas/doctrine-json-odm": "^0.1.3"
},
"require-dev": {
"phpunit/phpunit": "^7.4",
Expand Down
4 changes: 1 addition & 3 deletions src/Command/ExecuteTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$path = new Path();
$path->add(null, null, [$workflow->getDefinition()->getInitialPlace()]);

$metaData = json_decode($task->getMetaData());

try {
foreach ($generator->getAvailableTransitions($workflow, $subject, $metaData) as $transitionName) {
foreach ($generator->getAvailableTransitions($workflow, $subject, $task->getMetaData()) as $transitionName) {
try {
if (!$generator->applyTransition($workflow, $subject, $transitionName)) {
throw new Exception(sprintf('Generator %s generated transition %s that can not be applied', $task->getGenerator(), $transitionName));
Expand Down
8 changes: 3 additions & 5 deletions src/Entity/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ class Task
private $takeScreenshots = false;

/**
* @ORM\Column(type="text")
* @Assert\NotBlank
* @MbtAssert\Json
* @ORM\Column(type="json_document", options={"jsonb": true}, nullable=true)
*/
private $metaData = '{}';
private $metaData;

/**
* @var \DateTime
Expand Down Expand Up @@ -215,7 +213,7 @@ public function getTakeScreenshots()
return $this->takeScreenshots;
}

public function setMetaData(string $metaData)
public function setMetaData($metaData)
{
$this->metaData = $metaData;
}
Expand Down
13 changes: 0 additions & 13 deletions src/Validator/Constraints/Json.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/Validator/Constraints/JsonValidator.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Message/ReplayTaskMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testConsumeMessage(string $model, string $generator, string $red
$task->setTitle('Test regression task');
$task->setModel($model);
$task->setGenerator($generator);
$task->setMetaData(json_encode(['bugId' => $bug->getId()]));
$task->setMetaData((object) ['bugId' => $bug->getId()]);
$task->setReducer($reducer);
$task->setTakeScreenshots(false);
$entityManager->persist($task);
Expand Down
2 changes: 2 additions & 0 deletions tests/app/src/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App;

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Dunglas\DoctrineJsonOdm\Bundle\DunglasDoctrineJsonOdmBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\MakerBundle\MakerBundle;
use Symfony\Bundle\MonologBundle\MonologBundle;
Expand All @@ -23,6 +24,7 @@ public function registerBundles()
new DoctrineBundle(),
new MonologBundle(),
new MakerBundle(),
new DunglasDoctrineJsonOdmBundle(),
new TienvxMbtBundle(),
);

Expand Down

0 comments on commit 66851b1

Please sign in to comment.