-
-
Notifications
You must be signed in to change notification settings - Fork 158
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 #766 from dpfaffenbauer/jms-pimcore-object-serializer
[ResourceBundle] add JMS Serializer Handler for Pimcore Objects
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 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
29 changes: 29 additions & 0 deletions
29
src/CoreShop/Bundle/ResourceBundle/Serialization/PimcoreObjectHandler.php
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,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\DataObject\Concrete; | ||
|
||
class PimcoreObjectHandler | ||
{ | ||
public function serializeRelation(JsonSerializationVisitor $visitor, $relation, array $type, Context $context) | ||
{ | ||
if ($relation instanceof Concrete) { | ||
return $relation->getId(); | ||
} | ||
|
||
return null; | ||
} | ||
} |