How to convert an existing dynamic/silverstripe-linkable DB records to gorricoe/silverstripe-link?

Silverstripe Version: 4.11

Question:
Hello all.

Does anyone know how to replace existing dynamic/silverstripe-linkable DB records with the gorricoe/silverstripe-link?

I removed the obsolete dynamic/silverstripe-linkable module and then added the gorricoe/silverstripe-link.

An existing pages already use a dynamic/silverstripe-linkable elements:
dynamic/silverstripe-elemental-baseobject uses dynamic/silverstripe-linkable methods in the code.

Problem:
In order to continue using pages that use dynamic/silverstripe-linkable and dynamic/silverstripe-linkfield I need to either switch to gorricoe/silverstripe-link and gorricoe/silverstripe-linkfield, OR just fork the obsolete dynamic/silverstripe-linkable and edit the version restrictions in order to use this with Silverstripe 4.11.

I’m trying to switch to gorricoe/silverstripe-linkfield because this is newer. But it’s LinkField::construct() method requires more params and throws an exception.

The Gorriecoe’s

LinkField::__construct($name, $title, $parent, $linkConfig = array())

requires 3 parameters but the dynamic/silverstripe-linkable’s __construct() method requires only 2 params.
Yes, I can just pass a null to 3rd param as parent but is this correct?

The dynamic/silverstripe-elemental-baseobject does not work with gorricoe/silverstripe-linkfield.

Upd3: OK, it seems that is worked, I passed the $this parameter as a 3rd argument to the Gorricoe’s LinkField __construct().

Am I really going the right way?

The docs for gorricoe/silverstripe-link refer to this migration module - have you given that a try?

@GuySartorelli Thank you! That’s what I was looking for.
I’ve forked a parent elemental-baseobject module and everything works but your approach is better I think.
Thank you!

1 Like