<td>
<a href="<?= $escaper->escapeUrl($block->getUrl('blog/manage/edit', ['id'=>$escaper->escapeHtml($blog->getId())]))?>">
<?= __('Edit') ?>
</a>
</td>
 
When we use the getUrl function, we pass an array as the second parameter. This array contains key-value pairs, like ['id' => $post->getEntityId()]. These key-value pairs are added to the URL as parameters when generating the link. For example, ?id=123 would be added to the URL if ['id' => 123] was passed in the array.
 
 
  • $escaper->escapeUrl() is used to escape the URL generated by $block->getUrl() method. It ensures that the URL is properly encoded and safe to use within an HTML attribute.

  • $block->getUrl('blog/manage/edit', ['id'=>$escaper->escapeHtml($blog->getId())]) is used to generate the URL for the "Edit" action of the "Blog" module. It constructs the URL based on the provided route and parameters. In this case, it generates the URL for editing a specific blog post by passing the blog post ID as a parameter.

  • $escaper->escapeHtml($blog->getId()) is used to escape the blog post ID to prevent any potential