# Factory deprecation

**URL:** <https://forum.mautic.org/t/factory-deprecation/5143>\
**Category:** Development\
**Created:** [September 1, 2016, 4:04am UTC](https://forum.mautic.org/t/factory-deprecation/5143 "2016-09-01T04:04:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![floorbeads](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@floorbeads](https://forum.mautic.org/u/floorbeads)\
**Post date:** [September 1, 2016, 4:04am UTC](https://forum.mautic.org/t/factory-deprecation/5143/1 "2016-09-01T04:04:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![floorbeads](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@floorbeads](https://forum.mautic.org/u/floorbeads)\
**Post date:** [September 1, 2016, 4:04am UTC](https://forum.mautic.org/t/factory-deprecation/5143/2 "2016-09-01T04:04:56Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![gmillard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gmillard/32/5_2.png) [@gmillard](https://forum.mautic.org/u/gmillard)\
**Post date:** [September 1, 2016, 1:41pm UTC](https://forum.mautic.org/t/factory-deprecation/5143/3 "2016-09-01T13:41:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![floorbeads](https://avatars.discourse-cdn.com/v4/letter/f/3d9bf3/32.png) [@floorbeads](https://forum.mautic.org/u/floorbeads)\
**Post date:** [September 1, 2016, 5:55pm UTC](https://forum.mautic.org/t/factory-deprecation/5143/4 "2016-09-01T17:55:51Z")

</div>

Thank you for the clarification, Alan.

> [@](#):
>
> 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.

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?
