Example #1
0
 /**
  * {@inheritdoc}
  */
 public function checkHash(Request $request, $object, $identifier)
 {
     if (!$request->request->has($this->hashParameter) || $request->query->get('force', false) === 'true' || $request->request->get($this->hashParameter) == $this->hasher->hash($object)) {
         return true;
     }
     throw new InvalidHashException(get_class($object), $identifier);
 }
 /**
  * Adds the hash of the given object to its serialization.
  *
  * @param ObjectEvent $event
  */
 public function onPostSerialize(ObjectEvent $event)
 {
     $object = $event->getObject();
     // FIXME This can be removed, as soon as we've got rid of all ApiEntities.
     if ($object instanceof ApiWrapper) {
         $object = $object->getEntity();
     }
     if (!$object instanceof AuditableInterface && !$object instanceof LocalizedAuditableBehavior) {
         return;
     }
     if (!$event->getVisitor() instanceof GenericSerializationVisitor) {
         return;
     }
     $event->getVisitor()->addData('_hash', $this->hasher->hash($object));
 }