funeralzone / valueobject-generator
此包的最新版本(3.1.1)没有可用的许可信息。
不可变值对象的生成器
3.1.1
2020-03-03 15:44 UTC
Requires
- php: >=7.1.0
- funeralzone/valueobjects: 0.4.*
- prettus/laravel-validation: 1.1.*
- symfony/yaml: 3.*
- twig/twig: 2.4.*
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ^6.2
- squizlabs/php_codesniffer: ^3.0
- dev-master
- 3.1.1
- 3.1.0
- 3.0.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.00
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-fix/add-rootnamespace-as-a-valid-property
- dev-feature/allow-root-namespace-to-be-overridden
- dev-feature/ensure-child-models-are-run-through-middleware
- dev-feature/add-implements-function
- dev-feature/refactor-to-allow-recursive-vos
- dev-feature/fix-erroneous-regeneration-of-models
- dev-feature/improve-hook-flexibility
This package is auto-updated.
Last update: 2024-08-29 04:25:49 UTC
README
V0 到 V1 的升级说明
一切都是模型
不再偏向事件源,因此已移除“事件”、“命令”、“查询”和“增量”的概念,并将实现这些概念的责任放在类型/模板库上。
此更改的实践影响如下
事件、命令、查询和增量
- 事件、命令、查询和增量的顶级项已被删除;每个模型都位于“模型”顶级项下
- 创建事件、命令、查询和增量时没有增量属性;必须定义实现增量行为的子模型
- 事件、命令、查询和增量现在是专门的类型 - 分别为 Event、Command、Query 和 Delta
从 Prooph 元数据中生成模型
事件、命令、查询和增量的类型包括一个 fromMetaDataKey 属性,允许您定义一个 Prooph 元数据键进行种子
- name: ExampleEvent type: Event children: - name: ExampleEventAggregateId type: Uuid propertyName: id fromMetaDataKey: _aggregateId
使用根有效负载生成增量
增量不能再自动接收命令/事件的根有效负载。
在 V0 中,您可以在定义中可选地提供 useRootData 标志,这意味着增量接收事件或命令的有效负载的整个有效负载,而不仅仅是其特定属性。这不再可行。
为了重新创建此行为,您可以在 Prooph 解析器中捆绑必要的属性,并在命令/事件的负载中添加一个虚构的数组属性。
集合不再接受子模型
在 V0 中,集合需要一个单独的子模型,该模型推断集合将接受的内容的类型。这不再可行。
在 V1 中,您必须通过设置 modelToEnforce 属性显式定义集合可以包含的模型类型。此属性必须引用一个有效的模型。
- name: OrganisationalUnitId type: Uuid - name: OrganisationalUnitIds type: Set modelToEnforce: OrganisationalUnitId
装饰器
装饰器已进行全面更新
- 现在每个模型可以有多个装饰器
- 您不需要定义它们的目标,即 nullDecorator、nonNUllDecorator 和 nullableDecerator 属性已失效
- 它们基于钩子,允许装饰器与模型中的不同动作相关联
可用的钩子
- 构造函数 - 在模型的构造函数期间执行,并接收用于实例化对象的所有参数
decorators: - path: Funeralzone\FAS\Common\ValueObjects\Decorators\DecoratorOne hooks: - type: constructor method: methodToCallOnConstructOne - path: Funeralzone\FAS\Common\ValueObjects\Decorators\DecoratorTwo hooks: - type: constructor method: methodToCallOnConstructTwo
示例定义
namespace: ValueObjects model: # External models # ========================== - name: EntityId type: String namespace: Funeralzone\FAS\DomainEntities testing: fromNative: "'1'" constructor: "'1'" # Data models # ========================== - name: TenantId type: Uuid - name: BereavedId type: Uuid - name: ContactId type: Uuid - name: DirectoryListingId type: Uuid - name: MediaId type: String decorators: - path: Funeralzone\FAS\Common\ValueObjects\Decorators\MediaIdDecoratorTrait hooks: - type: constructor method: decoratorConstruct - name: MediaUploadRequestId type: String - name: ProductId type: Uuid - name: ServiceId type: Uuid - name: StaffMemberId type: Uuid - name: PackageId type: Uuid # Telephones # -------------------------- - name: TelephoneNumber type: String - name: TelephoneCountryCode type: String - name: Telephone type: Telephone - name: TelephoneType type: Enum values: - WORK - HOME - MOBILE - FAX # Address # -------------------------- - name: AddressLine1 type: String - name: AddressLine2 type: String - name: Town type: String - name: County type: String - name: PostCode type: String - name: CountryCode type: ISOAlpha2CountryCode - name: GeoLocation type: Composite children: - name: AddressData type: String propertyName: data - name: Geometry type: Composite propertyName: geometry children: - name: Latitude type: Float propertyName: lat decorators: - path: Funeralzone\FAS\Common\ValueObjects\Decorators\LatitudeDecoratorTrait hooks: - type: constructor method: decoratorConstruct testing: fromNative: '50.9' constructor: '50.9' - name: Longitude type: Float propertyName: lng testing: fromNative: '50.9' constructor: '50.9' decorators: - path: Funeralzone\FAS\Common\ValueObjects\Decorators\LongitudeDecoratorTrait hooks: - type: constructor method: decoratorConstruct # Identity interface # -------------------------- - name: IdentityInterfacePolicyMembership type: String - name: IdentityInterfacePolicyScope type: String - name: IdentityInterface type: Composite children: - name: IdentityInterfaceType type: Enum propertyName: type values: - STAFF_MEMBER - DEVELOPER - name: IdentityInterfaceName type: String propertyName: name - name: IdentityInterfaceImage type: String propertyName: image - name: IdentityInterfaceEmail type: Email propertyName: email - name: IdentityInterfacePolicy type: Composite propertyName: policy children: - name: IdentityInterfacePolicyMemberships type: Set propertyName: memberships modelToEnforce: IdentityInterfacePolicyMembership - name: IdentityInterfacePolicyScopes type: Set propertyName: scopes modelToEnforce: IdentityInterfacePolicyScope # Other # -------------------------- - name: Note type: Entity children: - name: EntityId propertyName: id - name: NoteTimeCreated type: RFC3339 propertyName: timeCreated - name: NoteContent type: String propertyName: content - name: NoteAuthorId type: Uuid propertyName: authorId - name: Notes type: EntitySet modelToEnforce: Note - name: Name type: Composite children: - name: NameTitle type: String propertyName: title - name: GivenName type: String propertyName: givenName - name: FamilyName type: String propertyName: familyName - name: PersonPhone type: TelephoneContact typeValues: - WORK - HOME - MOBILE - FAX - name: PersonEmail type: Email - name: Person type: Composite children: - name: Name propertyName: name - name: PersonAddress type: Address propertyName: address - name: PersonPhones type: Set propertyName: phones modelToEnforce: PersonPhone - name: PersonEmails type: Set propertyName: emails modelToEnforce: PersonEmail - name: MediaId propertyName: image - name: DirectoryListingIds type: Set modelToEnforce: DirectoryListingId - name: OrganisationalUnitId type: Uuid - name: OrganisationalUnitIds type: Set modelToEnforce: OrganisationalUnitId - name: EstimateId type: Uuid - name: EstimateIds type: Set modelToEnforce: EstimateId - name: Tag type: String decorators: - path: Funeralzone\FAS\Common\ValueObjects\Decorators\TagDecoratorTrait hooks: - type: constructor method: decoratorConstruct - name: Tags type: Set decorators: - path: Funeralzone\FAS\Common\ValueObjects\Decorators\TagsDecoratorTrait modelToEnforce: Tag - name: PaginationInput type: Composite children: - name: PaginationInputPage type: Integer propertyName: page - name: PaginationInputNodesPerPage type: Integer propertyName: nodesPerPage - name: StaffRoleId type: Uuid - name: StaffRoleIds type: Set modelToEnforce: StaffRoleId - name: DeveloperId type: Uuid - name: DeveloperIds type: Set modelToEnforce: DeveloperId - name: PersonDelta type: Delta children: - name: Name propertyName: name - name: PersonAddress propertyName: address - name: PersonPhones propertyName: phones - name: PersonEmails propertyName: emails - name: MediaId propertyName: image