-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rootPath to AssetLinkDefinitionBuilder and InternalLinkDefinition…
…Builder
- Loading branch information
eschleb
committed
Jun 17, 2024
1 parent
adac0cb
commit 3b8eb87
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
15 changes: 14 additions & 1 deletion
15
...in/java/com/merkle/oss/magnolia/definition/builder/simple/AssetLinkDefinitionBuilder.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
package com.merkle.oss.magnolia.definition.builder.simple; | ||
|
||
import info.magnolia.dam.api.Item; | ||
import info.magnolia.dam.app.data.AssetDatasourceDefinition; | ||
import info.magnolia.dam.app.field.DamLinkFieldDefinition; | ||
import info.magnolia.ui.field.LinkFieldDefinition; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* builds a {@link LinkFieldDefinition} | ||
* @see <a href="https://docs.magnolia-cms.com/product-docs/6.2/Developing/Templating/Dialog-definition/Field-definition/List-of-fields/Link-field.html">magnolia Docs - Link field </a> | ||
* @author Merkle DACH | ||
*/ | ||
public class AssetLinkDefinitionBuilder extends AbstractLinkFieldDefinitionBuilder<Item, DamLinkFieldDefinition, AssetLinkDefinitionBuilder> { | ||
|
||
@Nullable | ||
private String rootPath; | ||
|
||
public AssetLinkDefinitionBuilder() {} | ||
public AssetLinkDefinitionBuilder(final DamLinkFieldDefinition definition) { | ||
super(definition); | ||
} | ||
|
||
public DamLinkFieldDefinition build(final String name) { | ||
final DamLinkFieldDefinition definition = new DamLinkFieldDefinition(); | ||
super.populate(definition, name, definition.getDatasource()); | ||
final AssetDatasourceDefinition datasource = (AssetDatasourceDefinition)definition.getDatasource(); | ||
datasource.setRootPath(rootPath); | ||
super.populate(definition, name, datasource); | ||
return definition; | ||
} | ||
|
||
public AssetLinkDefinitionBuilder rootPath(final String rootPath) { | ||
this.rootPath = rootPath; | ||
return self(); | ||
} | ||
} |
14 changes: 13 additions & 1 deletion
14
...java/com/merkle/oss/magnolia/definition/builder/simple/InternalLinkDefinitionBuilder.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
package com.merkle.oss.magnolia.definition.builder.simple; | ||
|
||
import info.magnolia.pages.app.field.PageLinkFieldDefinition; | ||
import info.magnolia.ui.datasource.jcr.JcrDatasourceDefinition; | ||
import info.magnolia.ui.field.LinkFieldDefinition; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.jcr.Node; | ||
|
||
public class InternalLinkDefinitionBuilder extends AbstractLinkFieldDefinitionBuilder<Node, LinkFieldDefinition<Node>, InternalLinkDefinitionBuilder> { | ||
|
||
@Nullable | ||
private String rootPath; | ||
|
||
public InternalLinkDefinitionBuilder() {} | ||
public InternalLinkDefinitionBuilder(final LinkFieldDefinition<Node> definition) { | ||
super(definition); | ||
} | ||
|
||
public LinkFieldDefinition<Node> build(final String name) { | ||
final PageLinkFieldDefinition definition = new PageLinkFieldDefinition(); | ||
super.populate(definition, name, definition.getDatasource()); | ||
final JcrDatasourceDefinition datasource = (JcrDatasourceDefinition)definition.getDatasource(); | ||
datasource.setRootPath(rootPath); | ||
super.populate(definition, name, datasource); | ||
return definition; | ||
} | ||
|
||
public InternalLinkDefinitionBuilder rootPath(final String rootPath) { | ||
this.rootPath = rootPath; | ||
return self(); | ||
} | ||
} |