According to the documentation, Mautic Factory is being phased out.
As I’m new to Mautic & this style of coding, I’m not sure how to tell if the Plugin I’m using needs to be updated. (I am using 2.1.1 but I’m not seeing any deprecation errors for Mautic Factory)
In reports (the native app):
Code:
$form = $model->createForm($entity, $this->get('form.factory'), $action);
-- is this "Mautic Factory"?
From a plugin:
Code:
use MauticCoreBundleFactoryMauticFactory;
Certainly, this is "Mautic Factory"
My question is, what should be used in place MauticFactory?
Do I need to replace only instances of MauticCoreBundleFactoryMauticFactory or does every instance of $this->factory need changing, too?
According to the documentation, Mautic Factory is being phased out.
As I’m new to Mautic & this style of coding, I’m not sure how to tell if the Plugin I’m using needs to be updated. (I am using 2.1.1 but I’m not seeing any deprecation errors for Mautic Factory)
In reports (the native app):
$form = $model->createForm($entity, $this->get('form.factory'), $action);
– is this “Mautic Factory”?
From a plugin:
use MauticCoreBundleFactoryMauticFactory;
Certainly, this is “Mautic Factory”
My question is, what should be used in place MauticFactory?
Do I need to replace only instances of MauticCoreBundleFactoryMauticFactory or does every instance of $this->factory need changing, too?
Hi!
$this->get('form.factory')
is not MauticFactory so that’s safe.
If you’re using $this->factory
in your controllers, then you’ll should replace the calls with obtaining the service directly from the container. For example, $this->factory->getSession()
should be $this->get('session')
.
If you’re using $this->factory
in an AbstractIntegration class, you’re safe for now - we haven’t converted that class yet - although we will in a future release of Mautic but provide BC.
Thank you for the clarification, Alan.
I’m not sure how to check if it’s in an AbstractIntegration class; but changing over to $this->get(‘session’) will serve the same functionality, irregardless; correct? And this will work on all calls of $this->factory, like $this->factory->getModel('something')
(so that would be: $this->get->getModel('something')
) ?
Can you clarify what “but provide BC” means?
And lastly, what to do about the use MauticCoreBundleFactoryMauticFactory;
namespace?