Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
...
Use the Groovy console to execute command business logic manually, in ad hoc fashion. This is a quick way to test a custom command before you compile it as a Java class.
...
Both of the two options below publish the page /travel/about/careers
. You can test it by making a small change on the careers page, executing the Groovy commands, and viewing the modified history page on the public instance.
Issue the following commands in the console:
Option A - Calling the info.magnolia.commands.CommandsManager.executeCommand()
:
Code Block | ||||
---|---|---|---|---|
| ||||
map = new java.util.LinkedHashMap<String, String>() map.put("path", "/travel/about/careers") map.put("repository", "website") cm = info.magnolia.commands.CommandsManager.getInstance() cm.executeCommand('default','publish',map) |
Option B - Passing a SimpleContextobject
to the execute()
method:
Code Block | ||||
---|---|---|---|---|
| ||||
cm = info.magnolia.commands.CommandsManager.getInstance() command = cm.getCommand('activate') |
...
command.setRepository('website') |
...
command.setPath('/travel/about/careers') |
...
command.setRecursive(true)
command.execute( |
...
This example activates the page /travel/about/careers
. You can test it by making a small change on the careers page, executing the Groovy commands, and viewing the modified history page on the public instance.
...
new info.magnolia.context.SimpleContext())
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
public class MyCommand extends BaseRepositoryCommand { public boolean execute(Context context) { // Your command logic goes here. } } |
See the commands in the info.magnolia.commands.impl
package for examples.