I’m trying to figure out with Sylius routing, based on Symfony framework. I found that code
sylius_admin_channel:
resource: |
alias: sylius.channel
section: admin
templates: "@SyliusAdmin\\Crud"
except: ['show']
redirect: update
grid: sylius_admin_channel
permission: true
vars:
all:
subheader: sylius.ui.configure_channels_available_in_your_store
templates:
form: "@SyliusAdmin/Channel/_form.html.twig"
index:
icon: share alternate
type: sylius.resource
But I could not find any information what is it | for resource. Any help?
Thanks.
>Solution :
It’s the YAML syntax for a multi-line string (that preserves newlines).
So sylius_admin_channel is a mapping that has two keys (resource and type) whose values are both string types.
It can be confusing to see in this instance because the string happens to also be valid YAML.
If I didn’t know any better, I would have guessed that the | is there in error and resource should actually have a mapping type for its value. I edited your question to include syntax highlighting for YAML which makes this a little more obvious, visually.
If you remove the | then resource, then the same symbols within that string would still be valid YAML, but the value of resource would be a mapping, rather than a string.
With the | removed: (notice the difference in syntax highlighting, compared to the yaml in the question)
sylius_admin_channel:
resource:
alias: sylius.channel
section: admin
templates: "@SyliusAdmin\\Crud"
except: ['show']
redirect: update
grid: sylius_admin_channel
permission: true
vars:
all:
subheader: sylius.ui.configure_channels_available_in_your_store
templates:
form: "@SyliusAdmin/Channel/_form.html.twig"
index:
icon: share alternate
type: sylius.resource