Автор: Kévin Dunglas (dunglas@gmail.com)
Наследование: extends Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer, implements Symfony\Component\Serializer\Normalizer\NormalizerInterface, implements Symfony\Component\Serializer\Normalizer\DenormalizerInterface
Пример #1
0
 /**
  * Sets the {@link ClassMetadataFactoryInterface} to use.
  *
  * @param ContextBuilder                $contextBuilder
  * @param ResourceCollectionInterface   $resourceCollection
  * @param PropertyAccessorInterface     $propertyAccessor
  * @param ObjectManager                 $objectManager
  * @param ClassMetadataFactoryInterface $classMetadataFactory
  * @param NameConverterInterface        $nameConverter
  *
  * @internal param ClassMetadataFactoryInterface|null $classMetadataFactory
  * @internal param NameConverterInterface|null $nameConverter
  */
 public function __construct(ContextBuilder $contextBuilder, ResourceCollectionInterface $resourceCollection, PropertyAccessorInterface $propertyAccessor, ObjectManager $objectManager, ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null)
 {
     parent::__construct($classMetadataFactory, $nameConverter);
     $this->resourceCollection = $resourceCollection;
     $this->contextBuilder = $contextBuilder;
     $this->propertyAccessor = $propertyAccessor;
     $this->objectManager = $objectManager;
     $this->apiClassMetadataFactory = $classMetadataFactory;
 }
Пример #2
0
 public function __construct(ResourceCollectionInterface $resourceCollection, IriConverterInterface $iriConverter, ClassMetadataFactoryInterface $apiClassMetadataFactory, ContextBuilder $contextBuilder, PropertyAccessorInterface $propertyAccessor, NameConverterInterface $nameConverter = null)
 {
     parent::__construct(null, $nameConverter);
     $this->resourceCollection = $resourceCollection;
     $this->iriConverter = $iriConverter;
     $this->apiClassMetadataFactory = $apiClassMetadataFactory;
     $this->contextBuilder = $contextBuilder;
     $this->propertyAccessor = $propertyAccessor;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 protected function renderOne(array $data)
 {
     $path = $data['methodePath'];
     $markdown = sprintf("### `%s` %s ###\n", $data['method'], $data['uri']);
     if (isset($data['deprecated']) && false !== $data['deprecated']) {
         $markdown .= "### This method is deprecated ###";
         $markdown .= "\n\n";
     }
     if (isset($data['description'])) {
         $markdown .= sprintf("\n_%s_", $data['description']);
     }
     $markdown .= "\n\n";
     if (isset($data['documentation']) && !empty($data['documentation'])) {
         if (isset($data['description']) && 0 === strcmp($data['description'], $data['documentation'])) {
             $markdown .= $data['documentation'];
             $markdown .= "\n\n";
         }
     }
     if (isset($data['requirements']) && !empty($data['requirements']) && !$this->fs->exists($path . '/requirements.html')) {
         $dataFilters = $this->engine->render('ElibertyApiBundle:nelmio:requirements.html.twig', ['data' => $data]);
         $this->fs->dumpFile($path . '/requirements.html', $dataFilters);
     }
     if (isset($data['filters']) && !$this->fs->exists($path . '/filters.html')) {
         $dataFilters = $this->engine->render('ElibertyApiBundle:nelmio:filters.html.twig', ['data' => $data]);
         $this->fs->dumpFile($path . '/filters.html', $dataFilters);
     }
     if (isset($data['parameters']) && !$this->fs->exists($path . '/parameters.html')) {
         $dataFilters = $this->engine->render('ElibertyApiBundle:nelmio:parameters.html.twig', ['data' => $data]);
         $this->fs->dumpFile($path . '/parameters.html', $dataFilters);
     }
     if (isset($data['statusCodes']) && !$this->fs->exists($path . '/statusCodes.html')) {
         $dataFilters = $this->engine->render('ElibertyApiBundle:nelmio:statusCodes.html.twig', ['data' => $data]);
         $this->fs->dumpFile($path . '/statusCodes.html', $dataFilters);
     }
     if (isset($data['response'])) {
         if (!$this->fs->exists($path . '/responses.html')) {
             $dataFilters = $this->engine->render('ElibertyApiBundle:nelmio:responses.html.twig', ['data' => $data, 'enums' => $this->enums, 'entityName' => strtolower($this->apiResource->getShortName())]);
             $this->fs->dumpFile($path . '/responses.html', $dataFilters);
         }
         $dataToSerialize = $this->dataProvider->getCollection($this->apiResource, new Request());
         if (!isset($data['tags']['collection']) && $dataToSerialize instanceof Paginator) {
             $dataToSerialize = $dataToSerialize->getIterator()->current();
         }
         if (!$this->fs->exists($path . '/json/responses.json')) {
             try {
                 if (isset($data['tags']['embed']) && in_array(strtolower($this->apiResource->getShortName()), ['option', 'orderitem'])) {
                     $this->setEmbed($data, $dataToSerialize);
                 }
                 $dataJson = $this->normalizer->normalize($dataToSerialize, 'json-ld', $this->apiResource->getNormalizationContext(), false);
                 $this->fs->dumpFile($path . '/json/responses.json', json_encode($dataJson, JSON_PRETTY_PRINT));
             } catch (\Exception $ex) {
                 return $markdown;
             }
         }
     }
     return $markdown;
 }
 public function __construct(ResourceCollectionInterface $resourceCollection, IriConverterInterface $iriConverter, ClassMetadataFactoryInterface $apiClassMetadataFactory, ContextBuilder $contextBuilder, PropertyAccessorInterface $propertyAccessor, NameConverterInterface $nameConverter = null)
 {
     parent::__construct(null, $nameConverter);
     $this->resourceCollection = $resourceCollection;
     $this->iriConverter = $iriConverter;
     $this->apiClassMetadataFactory = $apiClassMetadataFactory;
     $this->contextBuilder = $contextBuilder;
     $this->propertyAccessor = $propertyAccessor;
     $this->setCircularReferenceHandler(function ($object) {
         return $this->iriConverter->getIriFromItem($object);
     });
 }
Пример #5
0
 public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyTypeExtractorInterface $propertyTypeExtractor = null)
 {
     parent::__construct($classMetadataFactory, $nameConverter);
     $this->propertyTypeExtractor = $propertyTypeExtractor;
 }
Пример #6
0
 public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null, PropertyAccessorInterface $propertyAccessor = null)
 {
     parent::__construct($classMetadataFactory, $nameConverter);
     $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
 }
 public function __construct(ClassMetadataFactoryInterface $classMetadataFactory = null, NameConverterInterface $nameConverter = null)
 {
     parent::__construct($classMetadataFactory, $nameConverter);
 }
 /**
  * {@inheritdoc}
  */
 public function getAllowedAttributes($classOrObject, array $context, $attributesAsString = false)
 {
     return parent::getAllowedAttributes($classOrObject, $context, $attributesAsString);
 }
 /**
  * {@inheritdoc}
  */
 public function setIgnoredAttributes(array $ignoredAttributes)
 {
     parent::setIgnoredAttributes($ignoredAttributes);
     $this->propertyNormalizer->setIgnoredAttributes($ignoredAttributes);
     return $this;
 }