-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-59444: Create serializer interface and json class in framework
- Loading branch information
Joan He
committed
Oct 17, 2016
1 parent
3977f57
commit 363f1ca
Showing
6 changed files
with
62 additions
and
75 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\Serialize; | ||
|
||
class Json implements SerializerInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function serialize($data) | ||
{ | ||
return json_encode($data); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function unserialize($string) | ||
{ | ||
return json_decode($string, true); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
lib/internal/Magento/Framework/Serialize/SerializerInterface.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,26 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Framework\Serialize; | ||
|
||
interface SerializerInterface | ||
{ | ||
/** | ||
* Serialize data into string | ||
* | ||
* @param array|string $data | ||
* @return string|bool | ||
*/ | ||
public function serialize($data); | ||
|
||
/** | ||
* Unserialize the given string into array | ||
* | ||
* @param string $string | ||
* @param int $objectDecodeType | ||
* @return array | ||
*/ | ||
public function unserialize($string); | ||
} |
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