Skip to content

Commit

Permalink
Add a paragraph in 1.7.5 changes page about the _legacy_link
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Dec 11, 2018
1 parent c24e520 commit f0f7220
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/content/1.7/modules/core_updates/1.7.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@ public function hookdisplayFooterProduct($params)
}
```

## About getAdminLink and _legacy_link

The 1.7.5 version offers a conversion from legacy links to new migrated Symfony pages. Meaning if you use the `Link::getAdminLink`
method somewhere in your modules to access a page that has been migrated, PrestaShop automatically converts it to the new Symfony
migrated url.

This prevents module developer to update their links each time a page has been migrated. However in many places the method is not
used with the url parameters as arguments. Parameters are concatenated after the getAdminLink call. This can result in wrong conversion
use cases, so you might need to refactor the way you use this method.

Example:

```php
//You shouldn't write
$link->getAdminLink('AdminOrders') . '&id_order={$order->id|intval}&vieworder';

//But rather
$link->getAdminLink('AdminOrders', true, [], ['id_customer' => $customer->id|intval, 'viewcustomer' => 1]);
```

Although this won't be a problem for legacy controllers, but as they will get migrated getAdminLink won't work any more
if it is not used properly, so we advice you to refactor your getAdminLink beforehand.

You can find more details about this new feature in the [Controller and Routing][controller-routing] page.

**Links:**

* [Related issue on module Google Ananlytics (GitHub)](https://github.com/PrestaShop/ps_googleanalytics/pull/14/files)

[controller-routing]: {{< relref "1.7/development/architecture/migration-guide/controller-routing.md#more-about-the-legacy-link-property" >}}

0 comments on commit f0f7220

Please sign in to comment.