-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
255 additions
and
118 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,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<serializer xmlns="http://symfony.com/schema/dic/serializer-mapping"> | ||
<class name="Sonata\PageBundle\Model\Block"> | ||
<attribute name="id" serialized-name="id"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="name" serialized-name="name"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="enabled" serialized-name="enabled"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="position" serialized-name="position"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="settings" serialized-name="settings"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="type" serialized-name="type"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="createdAt" serialized-name="created_at"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="updatedAt" serialized-name="updated_at"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="children" serialized-name="blocks"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="parents" ignore="true"/> | ||
<attribute name="page" ignore="true"/> | ||
<attribute name="parent" ignore="true"/> | ||
<attribute name="ttl" ignore="true"/> | ||
</class> | ||
</serializer> |
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,55 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<serializer xmlns="http://symfony.com/schema/dic/serializer-mapping"> | ||
<class name="Sonata\PageBundle\Model\Page"> | ||
<attribute name="id" serialized-name="id"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="name" serialized-name="name"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="javascript" serialized-name="javascript"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="stylesheet" serialized-name="stylesheet"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="rawHeaders" serialized-name="raw_headers"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="title" serialized-name="title"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="metaDescription" serialized-name="meta_description"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="metaKeyword" serialized-name="meta_keyword"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="templateCode" serialized-name="template_code"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="requestMethod" serialized-name="request_method"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="createdAt" serialized-name="created_at"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="updatedAt" serialized-name="updated_at"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="slug" serialized-name="slug"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="parent" serialized-name="parent_id"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="blocks" serialized-name="blocks"> | ||
<group>page_transformer</group> | ||
</attribute> | ||
<attribute name="routeName" ignore="true"/> | ||
<attribute name="pageAlias" ignore="true"/> | ||
<attribute name="customUrl" ignore="true"/> | ||
<attribute name="site" ignore="true"/> | ||
<attribute name="edited" ignore="true"/> | ||
</class> | ||
</serializer> |
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,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\PageBundle\Serializer; | ||
|
||
use Symfony\Component\Serializer\Exception\BadMethodCallException; | ||
use Symfony\Component\Serializer\Exception\InvalidArgumentException; | ||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface; | ||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; | ||
use Symfony\Component\Serializer\SerializerAwareInterface; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
class InterfaceDenormalizer implements ContextAwareDenormalizerInterface, SerializerAwareInterface | ||
{ | ||
public const SUPPORTED_INTERFACES_KEY = 'supported_interfaces'; | ||
|
||
/** | ||
* @var SerializerInterface|DenormalizerInterface | ||
*/ | ||
private $serializer; | ||
|
||
public function denormalize($data, $type, $format = null, array $context = []) | ||
{ | ||
if (null === $this->serializer) { | ||
throw new BadMethodCallException('Please set a serializer before calling denormalize()!'); | ||
} | ||
|
||
if (!isset($context[self::SUPPORTED_INTERFACES_KEY][$type])) { | ||
throw new InvalidArgumentException('Unsupported class: '.$type); | ||
} | ||
|
||
return $this->serializer->denormalize($data, $context[self::SUPPORTED_INTERFACES_KEY][$type], $format, $context); | ||
} | ||
|
||
public function supportsDenormalization($data, $type, $format = null, array $context = []): bool | ||
{ | ||
if (!interface_exists($type, false)) { | ||
return false; | ||
} | ||
|
||
if (!isset($context[self::SUPPORTED_INTERFACES_KEY][$type])) { | ||
return false; | ||
} | ||
|
||
return $this->serializer->supportsDenormalization($data, $context[self::SUPPORTED_INTERFACES_KEY][$type], $format, $context); | ||
} | ||
|
||
public function setSerializer(SerializerInterface $serializer) | ||
{ | ||
$this->serializer = $serializer; | ||
} | ||
} |
Oops, something went wrong.