cancel
Showing results for 
Search instead for 
Did you mean: 

The direct use of ObjectManager error while submit extension on magento marketplace.

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

The direct use of ObjectManager error while submit extension on magento marketplace.

namespace Vendor\Module\Block\System\Config;

use Magento\Mtf\Client\BrowserInterface;

class CustomClass extends \Magento\Config\Block\System\Config\Form\Field
{
    const TEMPLATE = 'system/config/custom.phtml';
    private $objectManager;
    
    /**
     * @param \Magento\Framework\ObjectManagerInterface $objectmanager
     */
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Framework\ObjectManagerInterface $objectmanager,
        array $data = []
    ) {
       $this->objectManager    = $objectmanager;
       parent::__construct($context, $data);
    }
   
    public function checkClassData()
    {
        // This checks weather this "Module1" installed or not
        if ($this->moduleManager->isEnabled('Vendor1_Module1')) {
            // As "Module1" is installed so i want to use Helper of this module.
            $dataHelper = $this->objectManager->get("Vendor1\Module1\Helper\Data");
            $this->firstData      = $dataHelper->getFirstFunctionData();
        }
    }
}

This is example code of my requirements. I need to use ObjectManager to get Helper of another module if another module is installed.
This code is working fine and fulfill my requirements. But, when I submit my extension on Magento marketplace it throws exception error as follows:

 

2019-03-28_1826.png