1818 * consumes = {
1919 * "entity" = @ContextDefinition("entity",
2020 * label = @Translation("Entity")
21+ * ),
22+ * "rel" = @ContextDefinition("any",
23+ * label = @Translation("Relationship type"),
24+ * description = @Translation("The relationship type, e.g. canonical"),
25+ * required = FALSE
26+ * ),
27+ * "options" = @ContextDefinition("any",
28+ * label = @Translation("URL Options"),
29+ * description = @Translation("Options to pass to the toUrl call"),
30+ * required = FALSE
2131 * )
2232 * }
2333 * )
@@ -28,13 +38,18 @@ class EntityUrl extends DataProducerPluginBase {
2838 * Resolver.
2939 *
3040 * @param \Drupal\Core\Entity\EntityInterface $entity
41+ * The entity to create a canonical URL for.
42+ * @param string|null $rel
43+ * The link relationship type, for example: canonical or edit-form.
44+ * @param array|null $options
45+ * The options to provided to the URL generator.
3146 *
3247 * @return \Drupal\Core\Url
3348 *
3449 * @throws \Drupal\Core\Entity\EntityMalformedException
3550 */
36- public function resolve (EntityInterface $ entity ) {
37- return $ entity ->toUrl ();
51+ public function resolve (EntityInterface $ entity, ? string $ rel , ? array $ options ) {
52+ return $ entity ->toUrl ($ rel ?? ' canonical ' , $ options ?? [] );
3853 }
3954
4055}
0 commit comments