-
Notifications
You must be signed in to change notification settings - Fork 635
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
Conditions + element source improvements #10075
Merged
brandonkelly
merged 247 commits into
4.0
from
feature/dev-75-condition-builder-framework
Nov 27, 2021
Merged
Conditions + element source improvements #10075
brandonkelly
merged 247 commits into
4.0
from
feature/dev-75-condition-builder-framework
Nov 27, 2021
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
# Conflicts: # composer.json # src/config/app.php # src/services/Structures.php # src/web/assets/cp/dist/css/_main.scss # src/web/assets/cp/dist/css/craft.css # src/web/assets/cp/dist/css/craft.css.map # src/web/assets/cp/dist/js/Craft.js # src/web/assets/cp/dist/js/Craft.min.js # src/web/assets/cp/dist/js/Craft.min.js.map # src/web/assets/cp/src/js/LivePreview.js # src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js # src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js.map # tests/unit/services/projectConfig/NoFixturesTest.php
- New condition builder asset - Hard-coded embed of condition builder on entry index page (to be removed) - `npm run serve` must be run on the condition builder directory to get the entry index page to render,
# Conflicts: # composer.json # src/config/app.php # src/web/assets/cp/dist/css/craft.css # src/web/assets/cp/dist/css/craft.css.map # src/web/assets/cp/dist/js/Craft.js # src/web/assets/cp/dist/js/Craft.min.js # src/web/assets/cp/dist/js/Craft.min.js.map # src/web/assets/cp/src/css/_main.scss # src/web/assets/cp/src/js/LivePreview.js # src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js # src/web/assets/matrixsettings/dist/MatrixConfigurator.min.js.map
…n-builder-framework
# Conflicts: # src/web/assets/cp/dist/css/craft.css.map # src/web/assets/cp/dist/js/Craft.min.js # src/web/assets/cp/dist/js/Craft.min.js.map
# Conflicts: # CHANGELOG.md
# Conflicts: # src/web/assets/cp/dist/css/craft.css.map
# Conflicts: # gulpfile.js # package.json # src/web/assets/cp/dist/css/craft.css # src/web/assets/cp/dist/css/craft.css.map # src/web/assets/cp/dist/js/Craft.min.js # src/web/assets/cp/dist/js/Craft.min.js.map
# Conflicts: # src/web/assets/cp/dist/js/Craft.min.js
# Conflicts: # package-lock.json # package.json # src/web/assets/cp/dist/css/cp.css # src/web/assets/cp/dist/js/Craft.min.js # src/web/assets/craftsupport/dist/CraftSupportWidget.js # src/web/assets/dashboard/dist/Dashboard.js # src/web/assets/deprecationerrors/dist/deprecator.js # src/web/assets/edituser/dist/AccountSettingsForm.js # src/web/assets/edituser/dist/profile.js # src/web/assets/generalsettings/dist/rebrand.js # src/web/assets/graphiql/dist/graphiql.js # src/web/assets/installer/dist/install.js # src/web/assets/login/dist/login.js # src/web/assets/plugins/dist/PluginManager.js # src/web/assets/pluginstoreoauth/dist/PluginStoreOauthCallback.js # src/web/assets/routes/dist/routes.js # src/web/assets/systemmessages/dist/system_messages.js # src/web/assets/updater/dist/Updater.js # src/web/assets/updates/dist/UpdatesUtility.js # src/web/assets/userpermissions/dist/UserPermissions.js
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This is a bit of a loaded PR. It does the following:
Creating conditions
Condition classes must implement
craft\conditions\ConditionInterface
. A generic base implementation is provided bycraft\conditions\BaseCondition
, as well as one tailored for modifying a database query:craft\conditions\BaseQueryCondition
.Condition rules must implement
craft\conditions\ConditionRuleInterface
; query condition rules must also implementcraft\conditions\QueryConditionRuleinterface
.A condition builder’s HTML can be generated via
$condition->getBuilderHtml()
, which supports a few builder-specific options:mainTag
– The container tag type (form
by default)id
– The container IDsortable
– Whether the rules should be user-sortable (true
by default)singleUseTypes
– Whether rules can only be used once within the conditionprojectConfigTypes
- Whether to limit the available rules to those which can be stored in the project config (needed for custom sources)Element query conditions
Element types can provide their own custom condition classes which extend
craft\conditions\elements\ElementQueryCondition
. Doing so will give them a chance to include additional element type-specific rules, by overridingconditionRuleTypes()
(seeEntryQueryCondition
for an example).The element type can return an instance of it from its static
createCondition()
method.Field condition rules
Field types can provide a rule type which implements
craft\conditions\elements\fields\FieldConditionRuleInterface
and usescraft\conditions\elements\fields\FieldConditionRuleTrait
.The field type can return its class name from its
getQueryConditionRuleType()
method.To-do