Пример #1
0
 public function testTrimEmailNormalize()
 {
     $user = new User();
     $user->setEmail(' tester@devba.se ');
     $user->setPassword('password');
     $user->addExtension('favouriteStops', ['3390Y4', '3390Y3']);
     $data = $this->serializer->normalize($user);
     $this->assertEquals($this->getNormalized(), $data);
 }
Пример #2
0
 public function denormalize($data, $class, $format = null, array $context = [])
 {
     $user = new User();
     $user->setEmail($data['email']);
     $user->setPassword($data['password']);
     $user->setRoles($data['roles']);
     if (isset($data['confirm'])) {
         $user->setConfirm($data['confirm']);
     }
     if (isset($data['associations'])) {
         $user->setAssociations($data['associations']);
     }
     $user->setExtensions($this->serializer->denormalize($data, 'Base\\Core\\Extension\\ExtensionCollection', $format, $context));
     if ($format === 'mongo' && isset($data['_id'])) {
         $user->setId($data['_id']);
     }
     return $user;
 }