- last update
over 1 year ago Patch Failed to Apply - Issue created by @meryem dibe
- Status changed to Needs work
over 1 year ago 9:34am 20 September 2023 - π¬π§United Kingdom james.williams
Nice idea! On reviewing this, my first thought is that it's a real shame that the additional query is needed at all, as it seems you can't add a condition for the path on the initial query.
Next, more actionable thoughts:
- Please use the injected database connection which is already available (
$this->database
) instead of\Drupal::database()
- The additional query could include a LIKE condition on the 'path' field so that it already matches the right path pattern, instead of using
preg_match()
to filter the results after querying. - The query is currently specific to nodes, but the linkit class is rightly written to be as generic as possible for any entity type. So instead, the link template for the target entity type could be used (rather than hardcoding '/node/'). The condition in the above point could then use this. (Tip:
$entity_type->getLinkTemplate('canonical')
can be used; it gets '/node/{node}' for nodes - so the '{node}' part would then need stripping out, but remember it would need to work for any/most entity type(s). Any entity that doesn't have a canonical link template probably can't be supported anyway.)
Final less actionable thought: wouldn't it be nice if Linkit could support querying on other fields too? Is there any work anywhere else for supporting that, e.g. in another issue?
- Please use the injected database connection which is already available (
- πΊπΈUnited States mark_fullmer Tucson
wouldn't it be nice if Linkit could support querying on other fields too? Is there any work anywhere else for supporting that, e.g. in another issue?
The active issue for this is at β¨ Search on non-title fields Needs review