| @@ 8-50 (lines=43) @@ | ||
| 5 | use Broadway\Serializer\SerializableInterface; |
|
| 6 | use CultuurNet\UDB3\Language; |
|
| 7 | ||
| 8 | abstract class AbstractPropertyTranslatedEvent extends AbstractEvent implements SerializableInterface |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var Language |
|
| 12 | */ |
|
| 13 | protected $language; |
|
| 14 | ||
| 15 | public function __construct($itemId, Language $language) |
|
| 16 | { |
|
| 17 | $this->language = $language; |
|
| 18 | parent::__construct($itemId); |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @return Language |
|
| 23 | */ |
|
| 24 | public function getLanguage() |
|
| 25 | { |
|
| 26 | return $this->language; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * {@inheritdoc} |
|
| 31 | */ |
|
| 32 | public function serialize() |
|
| 33 | { |
|
| 34 | return parent::serialize() + array( |
|
| 35 | 'language' => (string)$this->language->getCode(), |
|
| 36 | ); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @param array $data |
|
| 41 | * @return mixed The object instance |
|
| 42 | */ |
|
| 43 | public static function deserialize(array $data) |
|
| 44 | { |
|
| 45 | return new static( |
|
| 46 | $data['item_id'], |
|
| 47 | new Language($data['language']) |
|
| 48 | ); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 12-60 (lines=49) @@ | ||
| 9 | * Abstract because it should be implemented in the namespace of each concrete |
|
| 10 | * offer implementation. (Place, Event, ...) |
|
| 11 | */ |
|
| 12 | abstract class AbstractImageEvent extends AbstractEvent |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var Image |
|
| 16 | */ |
|
| 17 | protected $image; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * {@inheritdoc} |
|
| 21 | * |
|
| 22 | * @param Image $image |
|
| 23 | * The image that is involved in the event. |
|
| 24 | */ |
|
| 25 | public function __construct($itemId, Image $image) |
|
| 26 | { |
|
| 27 | parent::__construct($itemId); |
|
| 28 | $this->image = $image; |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @return Image |
|
| 33 | */ |
|
| 34 | public function getImage() |
|
| 35 | { |
|
| 36 | return $this->image; |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @return array |
|
| 41 | */ |
|
| 42 | public function serialize() |
|
| 43 | { |
|
| 44 | return parent::serialize() + array( |
|
| 45 | 'image' => $this->image->serialize(), |
|
| 46 | ); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * @param array $data |
|
| 51 | * @return mixed The object instance |
|
| 52 | */ |
|
| 53 | public static function deserialize(array $data) |
|
| 54 | { |
|
| 55 | return new static( |
|
| 56 | $data['item_id'], |
|
| 57 | Image::deserialize($data['image']) |
|
| 58 | ); |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 8-51 (lines=44) @@ | ||
| 5 | use CultuurNet\UDB3\Role\ValueObjects\Permission; |
|
| 6 | use ValueObjects\Identity\UUID; |
|
| 7 | ||
| 8 | class AbstractPermissionEvent extends AbstractEvent |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var Permission |
|
| 12 | */ |
|
| 13 | private $permission; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * AbstractPermissionEvent constructor. |
|
| 17 | * @param UUID $uuid |
|
| 18 | * @param Permission $permission |
|
| 19 | */ |
|
| 20 | public function __construct(UUID $uuid, Permission $permission) |
|
| 21 | { |
|
| 22 | parent::__construct($uuid); |
|
| 23 | $this->permission = $permission; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @return Permission |
|
| 28 | */ |
|
| 29 | public function getPermission() |
|
| 30 | { |
|
| 31 | return $this->permission; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @inheritdoc |
|
| 36 | */ |
|
| 37 | public static function deserialize(array $data) |
|
| 38 | { |
|
| 39 | return new static(new UUID($data['uuid']), Permission::fromNative($data['permission'])); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @inheritdoc |
|
| 44 | */ |
|
| 45 | public function serialize() |
|
| 46 | { |
|
| 47 | return parent::serialize() + array( |
|
| 48 | 'permission' => $this->permission->toNative(), |
|
| 49 | ); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 7-54 (lines=48) @@ | ||
| 4 | ||
| 5 | use CultuurNet\UDB3\PriceInfo\PriceInfo; |
|
| 6 | ||
| 7 | abstract class AbstractPriceInfoUpdated extends AbstractEvent |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var PriceInfo |
|
| 11 | */ |
|
| 12 | protected $priceInfo; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * @param string $itemId |
|
| 16 | * @param PriceInfo $priceInfo |
|
| 17 | */ |
|
| 18 | public function __construct($itemId, PriceInfo $priceInfo) |
|
| 19 | { |
|
| 20 | parent::__construct($itemId); |
|
| 21 | $this->priceInfo = $priceInfo; |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @return PriceInfo |
|
| 26 | */ |
|
| 27 | public function getPriceInfo() |
|
| 28 | { |
|
| 29 | return $this->priceInfo; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @return array |
|
| 34 | */ |
|
| 35 | public function serialize() |
|
| 36 | { |
|
| 37 | return [ |
|
| 38 | 'item_id' => $this->itemId, |
|
| 39 | 'price_info' => $this->priceInfo->serialize(), |
|
| 40 | ]; |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @param array $data |
|
| 45 | * @return static |
|
| 46 | */ |
|
| 47 | public static function deserialize(array $data) |
|
| 48 | { |
|
| 49 | return new static( |
|
| 50 | $data['item_id'], |
|
| 51 | PriceInfo::deserialize($data['price_info']) |
|
| 52 | ); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 7-52 (lines=46) @@ | ||
| 4 | ||
| 5 | use CultuurNet\UDB3\Offer\Events\AbstractEvent; |
|
| 6 | ||
| 7 | abstract class AbstractPublished extends AbstractEvent |
|
| 8 | { |
|
| 9 | /** @var \DateTimeInterface */ |
|
| 10 | private $publicationDate; |
|
| 11 | ||
| 12 | /** |
|
| 13 | * AbstractPublish constructor. |
|
| 14 | * @param string $itemId |
|
| 15 | * @param \DateTimeInterface |
|
| 16 | */ |
|
| 17 | public function __construct($itemId, \DateTimeInterface $publicationDate) |
|
| 18 | { |
|
| 19 | parent::__construct($itemId); |
|
| 20 | ||
| 21 | $this->publicationDate = $publicationDate; |
|
| 22 | } |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @return \DateTimeInterface |
|
| 26 | */ |
|
| 27 | public function getPublicationDate() |
|
| 28 | { |
|
| 29 | return $this->publicationDate; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @inheritdoc |
|
| 34 | */ |
|
| 35 | public function serialize() |
|
| 36 | { |
|
| 37 | return parent::serialize() + [ |
|
| 38 | 'publication_date' => $this->publicationDate->format(\DateTime::ATOM) |
|
| 39 | ]; |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @inheritdoc |
|
| 44 | */ |
|
| 45 | public static function deserialize(array $data) |
|
| 46 | { |
|
| 47 | return new static( |
|
| 48 | $data['item_id'], |
|
| 49 | \DateTime::createFromFormat(\DateTime::ATOM, $data['publication_date']) |
|
| 50 | ); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 8-55 (lines=48) @@ | ||
| 5 | use CultuurNet\UDB3\Language; |
|
| 6 | use ValueObjects\StringLiteral\StringLiteral; |
|
| 7 | ||
| 8 | class AbstractDescriptionTranslated extends AbstractPropertyTranslatedEvent |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var string |
|
| 12 | */ |
|
| 13 | protected $description; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @param string $itemId |
|
| 17 | * @param Language $language |
|
| 18 | * @param StringLiteral $description |
|
| 19 | */ |
|
| 20 | public function __construct($itemId, Language $language, StringLiteral $description) |
|
| 21 | { |
|
| 22 | parent::__construct($itemId, $language); |
|
| 23 | $this->description = $description; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @return String |
|
| 28 | */ |
|
| 29 | public function getDescription() |
|
| 30 | { |
|
| 31 | return $this->description; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @return array |
|
| 36 | */ |
|
| 37 | public function serialize() |
|
| 38 | { |
|
| 39 | return parent::serialize() + array( |
|
| 40 | 'description' => $this->description->toNative(), |
|
| 41 | ); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * {@inheritdoc} |
|
| 46 | */ |
|
| 47 | public static function deserialize(array $data) |
|
| 48 | { |
|
| 49 | return new static( |
|
| 50 | $data['item_id'], |
|
| 51 | new Language($data['language']), |
|
| 52 | new StringLiteral($data['description']) |
|
| 53 | ); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| @@ 8-51 (lines=44) @@ | ||
| 5 | use ValueObjects\Identity\UUID; |
|
| 6 | use ValueObjects\StringLiteral\StringLiteral; |
|
| 7 | ||
| 8 | class AbstractConstraintEvent extends AbstractEvent |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var StringLiteral |
|
| 12 | */ |
|
| 13 | private $query; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * AbstractPermissionEvent constructor. |
|
| 17 | * @param UUID $uuid |
|
| 18 | * @param StringLiteral $query |
|
| 19 | */ |
|
| 20 | public function __construct(UUID $uuid, StringLiteral $query) |
|
| 21 | { |
|
| 22 | parent::__construct($uuid); |
|
| 23 | $this->query = $query; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @return StringLiteral |
|
| 28 | */ |
|
| 29 | public function getQuery() |
|
| 30 | { |
|
| 31 | return $this->query; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @inheritdoc |
|
| 36 | */ |
|
| 37 | public static function deserialize(array $data) |
|
| 38 | { |
|
| 39 | return new static(new UUID($data['uuid']), new StringLiteral($data['query'])); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @inheritdoc |
|
| 44 | */ |
|
| 45 | public function serialize() |
|
| 46 | { |
|
| 47 | return parent::serialize() + array( |
|
| 48 | 'query' => $this->query->toNative(), |
|
| 49 | ); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 8-54 (lines=47) @@ | ||
| 5 | use ValueObjects\Identity\UUID; |
|
| 6 | use ValueObjects\StringLiteral\StringLiteral; |
|
| 7 | ||
| 8 | class RoleCreated extends AbstractEvent |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var StringLiteral |
|
| 12 | */ |
|
| 13 | private $name; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * RoleCreated constructor. |
|
| 17 | * @param UUID $uuid |
|
| 18 | * @param StringLiteral $name |
|
| 19 | */ |
|
| 20 | public function __construct(UUID $uuid, StringLiteral $name) |
|
| 21 | { |
|
| 22 | parent::__construct($uuid); |
|
| 23 | $this->name = $name; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @return StringLiteral |
|
| 28 | */ |
|
| 29 | public function getName() |
|
| 30 | { |
|
| 31 | return $this->name; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @inheritdoc |
|
| 36 | */ |
|
| 37 | public static function deserialize(array $data) |
|
| 38 | { |
|
| 39 | return new static( |
|
| 40 | new UUID($data['uuid']), |
|
| 41 | new StringLiteral($data['name']) |
|
| 42 | ); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @inheritdoc |
|
| 47 | */ |
|
| 48 | public function serialize() |
|
| 49 | { |
|
| 50 | return parent::serialize() + [ |
|
| 51 | 'name' => $this->name->toNative() |
|
| 52 | ]; |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 8-54 (lines=47) @@ | ||
| 5 | use ValueObjects\Identity\UUID; |
|
| 6 | use ValueObjects\StringLiteral\StringLiteral; |
|
| 7 | ||
| 8 | class RoleRenamed extends AbstractEvent |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var StringLiteral |
|
| 12 | */ |
|
| 13 | private $name; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * RoleCreated constructor. |
|
| 17 | * @param UUID $uuid |
|
| 18 | * @param StringLiteral $name |
|
| 19 | */ |
|
| 20 | public function __construct(UUID $uuid, StringLiteral $name) |
|
| 21 | { |
|
| 22 | parent::__construct($uuid); |
|
| 23 | $this->name = $name; |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @return StringLiteral |
|
| 28 | */ |
|
| 29 | public function getName() |
|
| 30 | { |
|
| 31 | return $this->name; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @inheritdoc |
|
| 36 | */ |
|
| 37 | public static function deserialize(array $data) |
|
| 38 | { |
|
| 39 | return new static( |
|
| 40 | new UUID($data['uuid']), |
|
| 41 | new StringLiteral($data['name']) |
|
| 42 | ); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @inheritdoc |
|
| 47 | */ |
|
| 48 | public function serialize() |
|
| 49 | { |
|
| 50 | return parent::serialize() + [ |
|
| 51 | 'name' => $this->name->toNative() |
|
| 52 | ]; |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 7-56 (lines=50) @@ | ||
| 4 | ||
| 5 | use CultuurNet\UDB3\Title; |
|
| 6 | ||
| 7 | class TitleUpdated extends OrganizerEvent |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var Title |
|
| 11 | */ |
|
| 12 | private $title; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * TitleUpdated constructor. |
|
| 16 | * @param string $organizerId |
|
| 17 | * @param Title $title |
|
| 18 | */ |
|
| 19 | public function __construct( |
|
| 20 | $organizerId, |
|
| 21 | Title $title |
|
| 22 | ) { |
|
| 23 | parent::__construct($organizerId); |
|
| 24 | $this->title = $title; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @return Title |
|
| 29 | */ |
|
| 30 | public function getTitle() |
|
| 31 | { |
|
| 32 | return $this->title; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @return array |
|
| 37 | */ |
|
| 38 | public function serialize() |
|
| 39 | { |
|
| 40 | return parent::serialize() + [ |
|
| 41 | 'title' => $this->getTitle()->toNative() |
|
| 42 | ]; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @param array $data |
|
| 47 | * @return static |
|
| 48 | */ |
|
| 49 | public static function deserialize(array $data) |
|
| 50 | { |
|
| 51 | return new static( |
|
| 52 | $data['organizer_id'], |
|
| 53 | new Title($data['title']) |
|
| 54 | ); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| @@ 7-56 (lines=50) @@ | ||
| 4 | ||
| 5 | use ValueObjects\Web\Url; |
|
| 6 | ||
| 7 | class WebsiteUpdated extends OrganizerEvent |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * @var Url |
|
| 11 | */ |
|
| 12 | private $website; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * WebsiteUpdated constructor. |
|
| 16 | * @param string $organizerId |
|
| 17 | * @param Url $website |
|
| 18 | */ |
|
| 19 | public function __construct( |
|
| 20 | $organizerId, |
|
| 21 | Url $website |
|
| 22 | ) { |
|
| 23 | parent::__construct($organizerId); |
|
| 24 | $this->website = $website; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @return Url |
|
| 29 | */ |
|
| 30 | public function getWebsite() |
|
| 31 | { |
|
| 32 | return $this->website; |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @return array |
|
| 37 | */ |
|
| 38 | public function serialize() |
|
| 39 | { |
|
| 40 | return parent::serialize() + [ |
|
| 41 | 'website' => (string) $this->getWebsite() |
|
| 42 | ]; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @param array $data |
|
| 47 | * @return static |
|
| 48 | */ |
|
| 49 | public static function deserialize(array $data) |
|
| 50 | { |
|
| 51 | return new static( |
|
| 52 | $data['organizer_id'], |
|
| 53 | Url::fromNative($data['website']) |
|
| 54 | ); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| @@ 8-60 (lines=53) @@ | ||
| 5 | use CultuurNet\UDB3\Language; |
|
| 6 | use CultuurNet\UDB3\Title; |
|
| 7 | ||
| 8 | class TitleTranslated extends TitleUpdated |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var Language |
|
| 12 | */ |
|
| 13 | private $language; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * TitleTranslated constructor. |
|
| 17 | * @param string $organizerId |
|
| 18 | * @param Title $title |
|
| 19 | * @param Language $language |
|
| 20 | */ |
|
| 21 | public function __construct( |
|
| 22 | $organizerId, |
|
| 23 | Title $title, |
|
| 24 | Language $language |
|
| 25 | ) { |
|
| 26 | parent::__construct($organizerId, $title); |
|
| 27 | $this->language = $language; |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @return Language |
|
| 32 | */ |
|
| 33 | public function getLanguage() |
|
| 34 | { |
|
| 35 | return $this->language; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @return array |
|
| 40 | */ |
|
| 41 | public function serialize() |
|
| 42 | { |
|
| 43 | return parent::serialize() + [ |
|
| 44 | 'language' => $this->getLanguage()->getCode() |
|
| 45 | ]; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @param array $data |
|
| 50 | * @return static |
|
| 51 | */ |
|
| 52 | public static function deserialize(array $data) |
|
| 53 | { |
|
| 54 | return new static( |
|
| 55 | $data['organizer_id'], |
|
| 56 | new Title($data['title']), |
|
| 57 | new Language($data['language']) |
|
| 58 | ); |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||