PHP code example of richcongress / normalizer-extension-bundle
1. Go to this page and download the library: Download richcongress/normalizer-extension-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
richcongress / normalizer-extension-bundle example snippets
use RichCongress\NormalizerExtensionBundle\Serializer\Normalizer\Extension\AbstractObjectNormalizerExtension;
class DummyEntityNormalizerExtension extends AbstractObjectNormalizerExtension
{
/**
* @var string
*/
public static $objectClass = DummyEntity::class;
/**
* Prefix to add before every context
*/
public static $contextPrefix = 'dummy_entity_';
/**
* ['serialization_group' => 'propertyName']
*
* @return array
*/
public static function getSupportedGroups(): array
{
return [
'is_beautiful_enough' => 'isBeautifulEnough',
'name' => 'wonderfulName',
];
}
public function isBeautifulEnought(): bool
{
return true;
}
public function getWonderfulName(): string
{
return 'DummyEntity is its name';
}
}
new RichCongress\NormalizerExtensionBundle\RichCongressNormalizerExtensionBundle::class => ['all' => true],