| @@ 26-82 (lines=57) @@ | ||
| 23 | use Surfnet\Stepup\Identity\Value\IdentityId; |
|
| 24 | use Surfnet\Stepup\Identity\Value\Institution; |
|
| 25 | ||
| 26 | class AccreditedInstitutionsAddedToIdentityEvent extends IdentityEvent |
|
| 27 | { |
|
| 28 | /** |
|
| 29 | * @var IdentityId |
|
| 30 | */ |
|
| 31 | private $identityId; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @var InstitutionCollection |
|
| 35 | */ |
|
| 36 | public $institutions; |
|
| 37 | ||
| 38 | public function __construct(IdentityId $identityId, Institution $identityInstitution, InstitutionCollection $institutions) |
|
| 39 | { |
|
| 40 | parent::__construct($identityId, $identityInstitution); |
|
| 41 | ||
| 42 | $this->institutions = $institutions; |
|
| 43 | $this->identityId = $identityId; |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @param array $data |
|
| 48 | * @return AccreditedInstitutionsAddedToIdentityEvent |
|
| 49 | */ |
|
| 50 | public static function deserialize(array $data) |
|
| 51 | { |
|
| 52 | return new self( |
|
| 53 | new IdentityId($data['identity_id']), |
|
| 54 | new Institution($data['institution']), |
|
| 55 | InstitutionCollection::deserialize($data['institutions']) |
|
| 56 | ); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @return array |
|
| 61 | */ |
|
| 62 | public function serialize() |
|
| 63 | { |
|
| 64 | return [ |
|
| 65 | 'identity_id' => (string) $this->identityId, |
|
| 66 | 'institution' => (string) $this->identityInstitution, |
|
| 67 | 'institutions' => $this->institutions->serialize() |
|
| 68 | ]; |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @return \Surfnet\Stepup\Identity\AuditLog\Metadata |
|
| 73 | */ |
|
| 74 | public function getAuditLogMetadata() |
|
| 75 | { |
|
| 76 | $metadata = new Metadata(); |
|
| 77 | $metadata->identityId = $this->identityId; |
|
| 78 | $metadata->identityInstitution = $this->identityInstitution; |
|
| 79 | ||
| 80 | return $metadata; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||
| @@ 26-75 (lines=50) @@ | ||
| 23 | use Surfnet\Stepup\Identity\Value\Institution; |
|
| 24 | use Surfnet\Stepup\Identity\Value\Locale; |
|
| 25 | ||
| 26 | class LocalePreferenceExpressedEvent extends IdentityEvent |
|
| 27 | { |
|
| 28 | /** |
|
| 29 | * @var Locale |
|
| 30 | */ |
|
| 31 | public $preferredLocale; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param IdentityId $id |
|
| 35 | * @param Institution $institution |
|
| 36 | * @param Locale $preferredLocale |
|
| 37 | */ |
|
| 38 | public function __construct(IdentityId $id, Institution $institution, Locale $preferredLocale) |
|
| 39 | { |
|
| 40 | parent::__construct($id, $institution); |
|
| 41 | ||
| 42 | $this->preferredLocale = $preferredLocale; |
|
| 43 | } |
|
| 44 | ||
| 45 | public function getAuditLogMetadata() |
|
| 46 | { |
|
| 47 | $metadata = new Metadata(); |
|
| 48 | $metadata->identityId = $this->identityId; |
|
| 49 | $metadata->identityInstitution = $this->identityInstitution; |
|
| 50 | ||
| 51 | return $metadata; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @param array $data |
|
| 56 | * @return IdentityRenamedEvent The object instance |
|
| 57 | */ |
|
| 58 | public static function deserialize(array $data) |
|
| 59 | { |
|
| 60 | return new self( |
|
| 61 | new IdentityId($data['id']), |
|
| 62 | new Institution($data['institution']), |
|
| 63 | new Locale($data['preferred_locale']) |
|
| 64 | ); |
|
| 65 | } |
|
| 66 | ||
| 67 | public function serialize() |
|
| 68 | { |
|
| 69 | return [ |
|
| 70 | 'id' => (string) $this->identityId, |
|
| 71 | 'institution' => (string) $this->identityInstitution, |
|
| 72 | 'preferred_locale' => (string) $this->preferredLocale, |
|
| 73 | ]; |
|
| 74 | } |
|
| 75 | } |
|
| 76 | ||