-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(REF) APIv4 FieldSpec - Extract various traits (Civi\Schema\Traits\*) #20875
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…Attrs, helpPre, helpPost)
…operators, sqlRenderer, sqlFilters)
…e, fkEntity) Also: Update `setSerialize()` to accept types a string. This is useful if the info comes from an annotation.
…onverting to/from array
(Standard links)
|
Jenkins re test this please |
This seems fine to me but will let @colemanw make a comment on it but I think this is a worth while thing and the unit test coverage should be pretty solid here |
seamuslee001
added
the
merge ready
PR will be merged after a few days if there are no objections
label
Jul 19, 2021
Agreed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
There are currently several different schemas floating around (e.g. for APIv3-fields, APIv4-fields, DAO-fields, and settings). These schemas have a mix of fields which are:
name
,title
,description
).table_name
andcolumn_name
; setting-fields havegroup_name
).help_text
vshelp_pre
/help_post
;html
vsinput_type
/input_attrs
).Since these mixable sets of fields, it makes sense to track/document/audit them as traits.
Before
Civi/Api4/Service/Spec/FieldSpec.php
has long list of metadata fields.After
A majority of the metadata fields have been split-off into separate traits (
Civi\Schema\Traits\*
). If you need to model a new schema, you can re-use these traits -- ensuring that the names/types/descriptions match-up. They are:BasicSpecTrait
- Basic identification for the field. (Name, title, description)DataTypeSpecTrait
- Describe the type of data stored in a field. (Data-type, serialize, fk-entity)OptionsSpecTrait
- Describe allowed options. (Options, options-callback)GuiSpecTrait
- Describe how to display the field in a user-facing GUI. (Label, input-type, input-attrs, help)SqlSpecTrait
- Describe how to the field maps into SQL. (Table-name, column-name, sql-operators, sql-filters)ArrayFormatTrait
- Translate the spec into an array-format. (eg$field->defaultValue
vs$field['default_value']
)Comments
This PR is a step toward introducing another schema for describing workflow message-template fields. However, that schema left as a separate issue.
Not sure there's a whole lot of QA'ing that makes sense beyond existing tests.
I did expand coverage a bit in
ConformanceTest
- this basically ensures that APIv4'sgetFields
and the class-model inFieldSpec
remain true to each other.