-
Notifications
You must be signed in to change notification settings - Fork 271
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
Allow multiple send statement values for controllers #612
Conversation
There must be a way, without brackets or dashes, to support sub statements as we do something similar for model relationships. Even the very syntax in the draft file simply uses indents for statements. So there is some mechanism which should support: send:
ReviewNotification to:ticket.author with:ticket
ReviewNotification to:ticket.author with:ticket |
Relationships are not an array since they have keys in the form of |
I'm not completely against the array notation. However, it introduces a bit of rather dev syntax to an otherwise human YAML file. As such, I'm not ready to give up on something simpler. Two (quick) ideas:
Of the two, I prefer the first. But I am not sure the downstream implications of parsing/lexing it. |
I'll take a look at the first option, might have an idea how to solve it without requiring the numeric suffixes. Though option 2 looks nicer to me and also requires no special parsing. |
@jasonmccreary a possible approach would be the following code which takes all Code $sendLines = [];
if (preg_match_all('/\s*send: (.*)/', $content, $matches)) {
$sendLines = $matches[1];
}
if ($sendLines) {
$replacement = 'send:' . PHP_EOL;
foreach ($sendLines as $line) {
$replacement .= ' - ' . $line . PHP_EOL;
}
$content = preg_replace('/(send: .*(?:\r?\n\s*send: .*)*)/', trim($replacement), $content);
} Input controllers:
Ticket:
store:
validate: title, content
save: ticket
send: ReviewNotification to:ticket.author with:ticket
send: ReviewNotification to:ticket.author with:ticket
send: ReviewNotification to:ticket.author with:ticket
send: ReviewNotification to:ticket.author with:ticket
send: ReviewNotification to:ticket.author with:ticket
dispatch: SyncMedia with:ticket
fire: NewTicket with:ticket
flash: ticket.id
redirect: ticket.index Output controllers:
Ticket:
store:
validate: title, content
save: ticket
send:
- ReviewNotification to:ticket.author with:ticket
- ReviewNotification to:ticket.author with:ticket
- ReviewNotification to:ticket.author with:ticket
- ReviewNotification to:ticket.author with:ticket
- ReviewNotification to:ticket.author with:ticket
dispatch: SyncMedia with:ticket
fire: NewTicket with:ticket
flash: ticket.id
redirect: ticket.index |
Resolves #611 by making as little changes as possible in the form of using the
[]
syntax for arrays and usingArr::wrap
in various places to add support for handling thesend
array but this also means other properties can now use arrays as their statement value in the future and it should be handled in some places.Input
Output