Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class DefaultTransformationManager implements TransformationManager
public void performTransformations(Block block, TransformationContext context) throws TransformationException
{
Map<String, String> transformationsInError = null;
for (Transformation transformation : getTransformations()) {
for (Transformation transformation : getTransformations(context)) {
try {
((MutableRenderingContext) this.renderingContext).transformInContext(transformation, context, block);
} catch (Exception e) {
Expand All @@ -106,6 +106,18 @@ public void performTransformations(Block block, TransformationContext context) t
}
}

private List<Transformation> getTransformations(TransformationContext context)
{
List<String> transformationNames = context.getTransformationNames();
if (transformationNames == null || transformationNames.isEmpty()) {
// Execute the transformations specified in the configuration.
return getTransformations();
} else {
// Execute the transformations specified on the transformation context.
return getTransformations(transformationNames);
}
}

/**
* @return the ordered list of Transformations to execute
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package org.xwiki.rendering.transformation;

import java.util.List;

import org.xwiki.rendering.block.XDOM;
import org.xwiki.rendering.syntax.Syntax;

Expand Down Expand Up @@ -55,6 +57,12 @@ public class TransformationContext implements Cloneable
*/
private Syntax targetSyntax;

/**
* @see #getTransformationNames()
* @since 18.1.0RC1
*/
private List<String> transformationNames;

/**
* Default constructor that doesn't set the XDOM or the Syntax. This is because setting the XDOM and the Syntax is
* optional and only required by some Macros to behave as expected.
Expand Down Expand Up @@ -166,6 +174,29 @@ public Syntax getTargetSyntax()
return this.targetSyntax;
}

/**
* @return the list of transformations to execute; if not set or empty, the configured list of transformations will
* be executed
* @see org.xwiki.rendering.configuration.RenderingConfiguration#getTransformationNames()
* @since 18.1.0RC1
*/
Comment thread
mflorea marked this conversation as resolved.
public List<String> getTransformationNames()
Comment thread
mflorea marked this conversation as resolved.
Outdated
{
return this.transformationNames;
}

/**
* Set the list of transformations to execute. Use this to override the configured list of transformations.
*
* @param transformationNames the list of transformations to execute
* @see org.xwiki.rendering.configuration.RenderingConfiguration#getTransformationNames()
* @since 18.1.0RC1
*/
Comment thread
mflorea marked this conversation as resolved.
public void setTransformationNames(List<String> transformationNames)
{
this.transformationNames = transformationNames;
}

/**
* @param targetSyntax the syntax of the renderer
*/
Expand Down