I'm attempting to port a custom plugin that was originally written for Craft 2. It has a fair bit of logic, controllers, services, records, models etc. The records and models which I admittedly don't have much experience with are the main area which I'm not fully understanding, but taking the challenge as a learning experience!
After porting the services classes to Craft 3 with namespaces and registering them in the plugin, I've hit the first major block.
The existing Craft 2 service logic seems to call methods that work in Craft 2 but don't seem to exist in Craft 3. Here's the example in Craft 2:
- MyPlugin_DataRecord::model()
- MyPlugin_DataModel::populateModel()
- MyPlugin_DataModel::populateModels()
Example in a service class, which is then used in other places.
protected function getModel()
{
return MyPlugin_DataRecord::model();
}
protected function newModel()
{
return new MyPlugin_DataModel();
}
protected function populateModel($record)
{
return MyPlugin_DataModel::populateModel($record);
}
protected function populateModels($records)
{
return MyPlugin_DataModel::populateModels($records, 'id');
}
These appear to be Craft 2 methods but do not seem to exist at all in Craft 3. Any pointers on how this should be replicated on Craft 3, given it doesn't look like there is any equivalent method in Craft 3 and it could be more of a case of refactor here.