-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from dachcom-digital/version_reycle_fix
Allow Object Versioning and Recycling
- Loading branch information
Showing
11 changed files
with
377 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace JobsBundle\Normalizer; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use JobsBundle\Model\ConnectorContextItem; | ||
use JobsBundle\Model\ConnectorEngine; | ||
use JobsBundle\Model\ContextDefinition; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
|
||
class EntityNormalizer implements DenormalizerInterface | ||
{ | ||
/** | ||
* @var EntityManagerInterface | ||
*/ | ||
protected $entityManager; | ||
|
||
/** | ||
* @param EntityManagerInterface $entityManager | ||
*/ | ||
public function __construct(EntityManagerInterface $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function supportsDenormalization($data, $type, $format = null) | ||
{ | ||
return \is_a($type, ConnectorContextItem::class, true); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function denormalize($data, $class, $format = null, array $context = []) | ||
{ | ||
$connectorContextItem = null; | ||
|
||
if (is_numeric($data['id'])) { | ||
$connectorContextItem = $this->entityManager->find(ConnectorContextItem::class, $data['id']); | ||
} | ||
|
||
if (!$connectorContextItem instanceof ConnectorContextItem) { | ||
$connectorContextItem = new ConnectorContextItem(); | ||
} | ||
|
||
$connectorEngine = $this->entityManager->find(ConnectorEngine::class, $data['connectorEngine']['id']); | ||
if (!$connectorEngine instanceof ConnectorEngine) { | ||
return null; | ||
} | ||
|
||
$contextDefinition = $this->entityManager->find(ContextDefinition::class, $data['contextDefinition']['id']); | ||
if (!$contextDefinition instanceof ContextDefinition) { | ||
return null; | ||
} | ||
|
||
$connectorContextItem->setObjectId($data['objectId']); | ||
$connectorContextItem->setConnectorEngine($connectorEngine); | ||
$connectorContextItem->setContextDefinition($contextDefinition); | ||
|
||
return $connectorContextItem; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/JobsBundle/Resources/config/serialization/ConnectorContextItem.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
JobsBundle\Model\ConnectorContextItem: | ||
attributes: | ||
id: | ||
groups: [ Default, Version ] | ||
objectId: | ||
groups: [ Default, Version ] | ||
connectorEngine: | ||
groups: [ Default, Version ] | ||
contextDefinition: | ||
groups: [ Default, Version ] |
14 changes: 14 additions & 0 deletions
14
src/JobsBundle/Resources/config/serialization/ConnectorEngine.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
JobsBundle\Model\ConnectorEngine: | ||
attributes: | ||
id: | ||
groups: [ Default, Version ] | ||
name: | ||
groups: [ Default ] | ||
enabled: | ||
groups: [ Default ] | ||
token: | ||
groups: [ Default ] | ||
configuration: | ||
groups: [ Default ] | ||
feedIds: | ||
groups: [ Default ] |
8 changes: 8 additions & 0 deletions
8
src/JobsBundle/Resources/config/serialization/ContextDefinition.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
JobsBundle\Model\ContextDefinition: | ||
attributes: | ||
id: | ||
groups: [ Version ] | ||
host: | ||
groups: [ Default ] | ||
locale: | ||
groups: [ Default ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.