Last active
January 24, 2017 21:10
-
-
Save mike-potter/7f3ae5137bf2cf1c88f419d84cd1e053 to your computer and use it in GitHub Desktop.
Config Actions Templates
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
# this contains any global variables that are available to any template | |
tokens: | |
field_name: myproject_image | |
replace: | |
"example_image": [field_name] | |
# Here are some sample actions | |
actions: | |
# ***** | |
# Example of "template" plugin | |
# ***** | |
# Replace any tokens in a template to create a new config item | |
field.storage.node.image: | |
plugin: template | |
template: field.storage.node.image | |
# template is name of yml file in config/templates folder | |
dest: "field.storage.node.[field_name]" | |
field.field.node.image: | |
plugin: template | |
template: field.field.node.image | |
dest: "field.field.node.[bundle].[field_name]" | |
tokens: | |
bundle: article | |
# combine actions using nested "subactions" | |
field_templates: | |
plugin: template | |
actions: | |
field_storage: | |
template: field.storage.node.image | |
dest: "field.storage.node.[field_name]" | |
field_instances: | |
template: field.field.node.image | |
dest: "field.field.node.[bundle].[field_name]" | |
actions: | |
acticle_field: | |
tokens: | |
bundle: article | |
blog_field: | |
tokens: | |
bundle: blog | |
# ***** | |
# Example of "include" plugin | |
# ***** | |
field.storage.myproject_image: | |
# the above is the ID of the new configuration item to be created by the template | |
plugin: include | |
module: example_template | |
template: field.storage.node.image | |
# template references field_name which is taken from our global variable at the top | |
# This means: Parse the "template" located in the "module" and create the new config "id" | |
# but using our new variables and replacement values | |
# next, the field instance | |
field.field.node.myproject_article.image: | |
plugin: include | |
module: example_template | |
template: field.field.node.image | |
tokens: | |
bundle: myproject_article | |
# template references field_name which is taken from our global variable at the top | |
# and also references bundle which is specified within the action | |
# add the same image field to another bundle | |
field.field.node.myproject_blog.image: | |
plugin: include | |
module: example_template | |
template: field.field.node.image | |
tokens: | |
bundle: myproject_blog | |
# reusing a single template for multiple content types | |
# Could also combine the above three actions using nested "subactions" | |
myproject_image: | |
plugin: include | |
module: example_template | |
actions: | |
field.storage.myproject_image: | |
template: field.storage.node.image | |
myproject_image_instances: | |
template: field.field.node.image | |
actions: | |
field.field.node.myproject_article.image: | |
tokens: | |
bundle: myproject_article | |
field.field.node.myproject_blog.image: | |
tokens: | |
bundle: myproject_blog | |
# ***** | |
# Example of "change" plugin | |
# ***** | |
# Override some of the config properties | |
myproject_image.config: | |
plugin: change | |
id: field.field.node.myproject_article.myproject_image | |
# default "path" is the top level of the config data | |
value: | |
description: "This is the image field for myproject_article" | |
settings: | |
file_extensions: 'png gif jpg jpeg tiff pdf' | |
# If you just wanted to change the file_extensions directly: | |
myproject_image.file_extensions: | |
plugin: change | |
id: field.field.node.myproject_article.myproject_image | |
path: [ "settings" ] | |
value: | |
file_extensions: 'png gif jpg jpeg tiff pdf' | |
# Or, can do it like this: | |
myproject_image.file_extensions: | |
plugin: change | |
id: field.field.node.myproject_article.myproject_image | |
path: [ "settings", "file_extensions" ] | |
value: 'png gif jpg jpeg tiff pdf' | |
# override some existing core config | |
node.type.article: | |
plugin: change | |
value: | |
help: "This is a basic article" | |
# alternate way using path | |
node.type.article: | |
plugin: change | |
path: [ "help" ] | |
value: "This is a basic article" | |
# combine the above three changes using nested actions | |
overrides: | |
plugin: change | |
actions: | |
field.field.node.myproject_article.myproject_image: | |
value: | |
description: "This is the image field for myproject_article" | |
settings: | |
file_extensions: 'png gif jpg jpeg tiff pdf' | |
node.type.acticle: | |
value: | |
help: "This is a basic article" | |
# ***** | |
# Example of "delete" plugin | |
# ***** | |
# remove Source button in wysiwyg editor | |
editor_override: | |
plugin: delete | |
id: editor.editor.full_html | |
# path to Source button in wysiwyg | |
path: [ "settings", "toolbar", "rows", 0, 5, "items", 1 ] | |
# obviously config that has numeric sequences isn't ideal, but this is a | |
# real-world example we would want to support | |
# Use the "current-value" option to ensure "path" is pointing to the desired value | |
# If "current-path" is not specified, the "path" is used | |
current-value: "Source" | |
# alternative method using "by-value" searches entire sub-tree | |
editor_override2: | |
plugin: delete | |
id: editor.editor.full_html | |
path: [ "settings", "toolbar" ] | |
by-value: "Source" | |
# ***** | |
# Example of "add" plugin | |
# ***** | |
# add a button to the wysiwyg | |
editor_add_button: | |
plugin: add | |
id: editor.editor.full_html | |
# path to Formatting group | |
path: [ "settings", "toolbar", "rows", 0, 0, "items" ] | |
value: | |
- Underline | |
# combine the above actions using nested subactions | |
editor.editor.full_html: | |
actions: | |
remove_source_button: | |
plugin: delete | |
path: [ "settings", "toolbar" ] | |
by-value: "Source" | |
add_underline_button: | |
plugin: add | |
path: [ "settings", "toolbar", "rows", 0, 0, "items" ] | |
value: | |
- Underline | |
# execute an action only if a previous action has already executed | |
editor_dependency_override: | |
dependency: editor_add_button | |
plugin: delete | |
id: editor.editor.full_html | |
path: [ "settings", "toolbar" ] | |
by-value: "Underline" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment