public function getOnPostSerializeData(Event $event)
 {
     $object = $event->getObject();
     $context = $event->getContext();
     $metadataStack = $context->getMetadataStack();
     $visitingStack = $context->getVisitingStack();
     $links = $this->linkFactory->createLinks($object);
     if ($this->deferredLinks->contains($object)) {
         // $object contains inlined objects that had links
         $links = array_merge($this->deferredLinks->offsetGet($object), $links ?: array());
         $this->deferredLinks->detach($object);
     }
     if (null === $links) {
         return;
     }
     $parentObjectInlining = $this->metadataHelper->getParentObjectInlining($object, $context);
     if (null !== $parentObjectInlining) {
         if ($this->deferredLinks->contains($parentObjectInlining)) {
             $links = array_merge($this->deferredLinks->offsetGet($parentObjectInlining), $links);
         }
         // We need to defer the links serialization to the $parentObject
         $this->deferredLinks->attach($parentObjectInlining, $links);
         return;
     }
     $visitor = $event->getVisitor();
     return $this->linkSerializationHelper->createGenericLinksData($links, $visitor);
 }
Esempio n. 2
0
 private function addLinks($classNameMatchesArr, Event $event)
 {
     if (method_exists($classNameMatchesArr[0][0], 'getLinks')) {
         $object = $event->getObject();
         $event->getVisitor()->addData('_links', $object->getLinks($this->container));
     }
 }
 public function onPostDeserialize(Event $event)
 {
     $context = $event->getContext();
     if ($context->getDepth() > 0) {
         return;
     }
     $validator = $this->validator;
     $context->attributes->get('validation_groups')->map(function (array $groups) use($event, $validator) {
         $list = $validator->validate($event->getObject(), $groups);
         if ($list->count() > 0) {
             throw new ValidationFailedException($list);
         }
     });
 }
 /**
  * @param AfterSerializeEvent
  */
 public function onPostSerialize(Event $event)
 {
     $notification = $event->getObject();
     $objetive = $notification->getObjetive();
     switch ($notification->getType()) {
         case 'NEW_COMMENT':
         case 'REPLY_TO_COMMENT':
             $objetive = $this->em->getRepository("juzzCommentsBundle:Comentarios")->find($objetive);
             break;
         default:
             break;
     }
     $visitor = $event->getVisitor();
     //$this->serializer->serialize($objetive,'json');
     $visitor->addData('objetive', 1);
 }
 /**
  * @param Event $event
  */
 public function onPostDeserialize(Event $event)
 {
     $context = $event->getContext();
     if ($context->getDepth() > 0) {
         return;
     }
     $certification = $event->getContext()->getVisitor()->getResult();
     foreach ($certification->getCategories() as $category) {
         $category->setCertification($certification);
         foreach ($category->getQuestions() as $question) {
             $question->setCategory($category);
             foreach ($question->getAnswers() as $answer) {
                 $answer->setQuestion($question);
             }
         }
     }
 }
 public function onPostSerialize(Event $event)
 {
     $author = $event->getObject();
     $event->getVisitor()->addData('_links', array('details' => 'http://foo.bar/details/' . $author->getName(), 'comments' => 'http://foo.bar/details/' . $author->getName() . '/comments'));
 }
 public function __construct(Context $context, $object, array $type)
 {
     parent::__construct($context, $type);
     $this->object = $object;
 }
Esempio n. 8
0
 public function __construct(DeserializationContext $context, $data, array $type)
 {
     parent::__construct($context, $type);
     $this->data = $data;
 }
 public function onPostSerialize(Event $event)
 {
     $event->getVisitor()->setData('full_name', 'new name');
 }
 protected function addRelationRelations(Event $event, $content, RelationMetadataInterface $relationMetadata)
 {
     $parameters = $this->parametersFactory->createParameters($event->getObject(), $relationMetadata->getParams());
     $this->relationsManager->addBasicRelations($content, $relationMetadata->getRoute(), $parameters);
 }