Skip to content
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

[ResourceBundle] add serialization for pimcore types #818

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/CoreShop/Bundle/ResourceBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ services:
tags:
- { name: jms_serializer.handler, type: pimcoreObject, direction: serialization, format: json, method: serializeRelation}

coreshop.jms_serializer.handler.pimcore_document:
class: CoreShop\Bundle\ResourceBundle\Serialization\PimcoreDocumentHandler
tags:
- { name: jms_serializer.handler, type: pimcoreDocument, direction: serialization, format: json, method: serializeRelation}

coreshop.jms_serializer.handler.pimcore_asset:
class: CoreShop\Bundle\ResourceBundle\Serialization\PimcoreAssetHandler
tags:
- { name: jms_serializer.handler, type: pimcoreAsset, direction: serialization, format: json, method: serializeRelation}

coreshop.jms_serializer.handler.pimcore_site:
class: CoreShop\Bundle\ResourceBundle\Serialization\PimcoreSiteHandler
tags:
- { name: jms_serializer.handler, type: pimcoreSite, direction: serialization, format: json, method: serializeRelation}

jms_serializer.object_constructor:
alias: jms_serializer.doctrine_object_constructor
public: false
Expand All @@ -53,4 +68,4 @@ services:
coreshop.doctrine.cache.pimcore:
class: CoreShop\Component\Resource\Doctrine\Cache\PimcoreCache
arguments:
- '@Pimcore\Cache\Core\CoreHandlerInterface'
- '@Pimcore\Cache\Core\CoreHandlerInterface'
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2019 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/

namespace CoreShop\Bundle\ResourceBundle\Serialization;

use JMS\Serializer\Context;
use JMS\Serializer\JsonSerializationVisitor;
use Pimcore\Model\Asset;

class PimcoreAssetHandler
{
public function serializeRelation(JsonSerializationVisitor $visitor, $relation, array $type, Context $context)
{
if ($relation instanceof Asset) {
return $relation->getId();
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2019 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/

namespace CoreShop\Bundle\ResourceBundle\Serialization;

use JMS\Serializer\Context;
use JMS\Serializer\JsonSerializationVisitor;
use Pimcore\Model\Document;

class PimcoreDocumentHandler
{
public function serializeRelation(JsonSerializationVisitor $visitor, $relation, array $type, Context $context)
{
if ($relation instanceof Document) {
return $relation->getId();
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2019 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/

namespace CoreShop\Bundle\ResourceBundle\Serialization;

use JMS\Serializer\Context;
use JMS\Serializer\JsonSerializationVisitor;
use Pimcore\Model\Site;

class PimcoreSiteHandler
{
public function serializeRelation(JsonSerializationVisitor $visitor, $relation, array $type, Context $context)
{
if ($relation instanceof Site) {
return $relation->getId();
}

return null;
}
}