Merge remote-tracking branch 'origin/v10/dev' into v11/dev
This commit is contained in:
@@ -515,6 +515,15 @@ public class EntityController : UmbracoAuthorizedJsonController
|
||||
return Ok(returnUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity by a xpath query - OBSOLETE
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="nodeContextId"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This will be removed in Umbraco 13. Use GetByXPath instead")]
|
||||
public ActionResult<EntityBasic?>? GetByQuery(string query, int nodeContextId, UmbracoEntityTypes type) => GetByXPath(query, nodeContextId, null, type);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an entity by a xpath query
|
||||
@@ -522,19 +531,16 @@ public class EntityController : UmbracoAuthorizedJsonController
|
||||
/// <param name="query"></param>
|
||||
/// <param name="nodeContextId"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="parentId"></param>
|
||||
/// <returns></returns>
|
||||
public ActionResult<EntityBasic?>? GetByQuery(string query, int nodeContextId, UmbracoEntityTypes type)
|
||||
public ActionResult<EntityBasic?>? GetByXPath(string query, int nodeContextId, int? parentId, UmbracoEntityTypes type)
|
||||
{
|
||||
// TODO: Rename this!!! It's misleading, it should be GetByXPath
|
||||
|
||||
|
||||
if (type != UmbracoEntityTypes.Document)
|
||||
{
|
||||
throw new ArgumentException("Get by query is only compatible with entities of type Document");
|
||||
}
|
||||
|
||||
|
||||
var q = ParseXPathQuery(query, nodeContextId);
|
||||
var q = ParseXPathQuery(query, nodeContextId, parentId);
|
||||
IPublishedContent? node = _publishedContentQuery.ContentSingleAtXPath(q);
|
||||
|
||||
if (node == null)
|
||||
@@ -546,10 +552,11 @@ public class EntityController : UmbracoAuthorizedJsonController
|
||||
}
|
||||
|
||||
// PP: Work in progress on the query parser
|
||||
private string ParseXPathQuery(string query, int id) =>
|
||||
private string ParseXPathQuery(string query, int id, int? parentId) =>
|
||||
UmbracoXPathPathSyntaxParser.ParseXPathQuery(
|
||||
query,
|
||||
id,
|
||||
parentId,
|
||||
nodeid =>
|
||||
{
|
||||
IEntitySlim? ent = _entityService.Get(nodeid);
|
||||
|
||||
Reference in New Issue
Block a user