PHP code example of wwwision / cr-graphql

1. Go to this page and download the library: Download wwwision/cr-graphql 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/ */

    

wwwision / cr-graphql example snippets



namespace Your\Package;

use Neos\Media\Domain\Model\Video;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;

final class AssetNormalizer implements NormalizerInterface
{

    public function supportsNormalization($data, string $format = null)
    {
        return $data instanceof Video;
    }

    /**
     * @param Video $video
     * @param string|null $format
     * @param array $context
     * @return array|\ArrayObject|bool|float|int|string|void|null
     */
    public function normalize($video, string $format = null, array $context = [])
    {
        return [
            'id' => $video->getIdentifier(),
            'title' => $video->getTitle(),
            'width' => $video->getWidth(),
            'height' => $video->getHeight(),
        ];
    }

}