Skip to main content
added 353 characters in body
Source Link
Kingshuk Deb
  • 1.2k
  • 2
  • 11
  • 31

If you go to Magento\Framework\Registry you can see a __destruct method specified there.

Register basically stores your data inside an array type object using key value pair.

As soon as you stop using that class it will automatically calls the __destruct method and that will unregister that variable.

Check this link to understand how it works.

And this is when destructor wont be called.

EDIT

Lets suppose you are using the registry class inside a controller. You can access the registry throughout the controller because you have instantiated that registry class in your constructor. But as soon as your execution goes to diff controller you cant access that registry variable. Because that would be destroyed by __destruct() automatically. You dont have to unregister it.

If you go to Magento\Framework\Registry you can see a __destruct method specified there.

Register basically stores your data inside an array type object using key value pair.

As soon as you stop using that class it will automatically calls the __destruct method and that will unregister that variable.

Check this link to understand how it works.

And this is when destructor wont be called.

If you go to Magento\Framework\Registry you can see a __destruct method specified there.

Register basically stores your data inside an array type object using key value pair.

As soon as you stop using that class it will automatically calls the __destruct method and that will unregister that variable.

Check this link to understand how it works.

And this is when destructor wont be called.

EDIT

Lets suppose you are using the registry class inside a controller. You can access the registry throughout the controller because you have instantiated that registry class in your constructor. But as soon as your execution goes to diff controller you cant access that registry variable. Because that would be destroyed by __destruct() automatically. You dont have to unregister it.

Source Link
Kingshuk Deb
  • 1.2k
  • 2
  • 11
  • 31

If you go to Magento\Framework\Registry you can see a __destruct method specified there.

Register basically stores your data inside an array type object using key value pair.

As soon as you stop using that class it will automatically calls the __destruct method and that will unregister that variable.

Check this link to understand how it works.

And this is when destructor wont be called.