Plugin Replacements and aliasing #306
-
I see the following method in the winter blog plugin where it has an array of classes to alias https://github.com/wintercms/wn-blog-plugin/blob/main/Plugin.php#L116-L139 Is this still needed on the latest versions of WinterCMS (v1.1.6)? I couldn't find any references to that plugin's method anywhere in Winter\Storm library or any of the winter modules and so I assume that is just a legacy method which was used in an earlier build of Winter CMS and everything should be handled pretty much automatically from now on as long as the replaces key is defined in the Plugin.php or plugin.yaml file? Just need to confirm as I am moving some of my plugins to a different namespace and want to make sure they will remain backwards compatible with the old namespace automatically. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
That's exactly right, Eric. |
Beta Was this translation helpful? Give feedback.
-
On a somewhat related note, I have several plugins which depend on each other and I am changing the namespace of all of them and I am trying to use the replacements feature so I can gradually move them over one by one but some of them have polymorphic relations between each other. What is the best way to deal with table names with something like a many-to-many polymorphic table. Currently I have a model which is something like this: <?php
// Model from plugin which depends on Acme.Links plugin Model
class AcmeModel extends Model {
public $morphToMany = [
'social_links' => [
\Acme\Links\Models\Link::class,
// 'table' => 'acme_links_linkables',
'name' => 'linkable',
'pivot' => ['order'],
'order' => ['order'],
],
];
} What's the best way to handle this situation where the tables are renamed to match the new plugin namespace on the Acme.Links plugin, because the problem is if you omit the table name from the relationship definition it doesn't reference the correct table in the DB. When omitted it tries to use the table linkables instead of adding the plugin namespace prefix automatically (acme_links_linkables). |
Beta Was this translation helpful? Give feedback.
-
Yeah, I've already looked at the winter plugins, but the problem is when
using polymorphic many to many relationship, the table name must be
provided unless you follow Laravel table naming conventions, but
unfortunately that isn't the case due to namespacing plugin tables. This is
kind of where I'm stuck on how to best proceed other than just making the
plugin only compatible with the new namespace set of plugins.
Luckily the plugins I'm doing this for are all internal, but it'd be nice
to be able to convert them over one by one instead of needing to update
them all to reference the new namespace straight away.
…On Mon, Sep 13, 2021, 7:40 PM Ben Thomson ***@***.***> wrote:
@ericp-mrel <https://github.com/ericp-mrel> You could take a look at what
we did with the Winter forks of the main RainLab plugins - such as the Blog
plugin:
https://github.com/wintercms/wn-blog-plugin/blob/main/updates/v2.0.0/rename_tables.php
As long as you are using models in all queries and defined relations, it
should be graceful, since the model defines the table used. I would
recommend doing the rename as an *important* update so people are fully
aware this is making a big change to the data structure.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#306 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APFXGHHRP5ES547OX47WSVDUB2KZDANCNFSM5DX6OOUA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
That's exactly right, Eric.