I use third-party library in my module. I want to create a class object of this library using the factory class. But the problem is that constructor is this class takes 3 arguments string types.
namespace VendorName\ModuleName\Block\Adminhtml\System\Config\Form\Field;
class Shipping extends \Magento\Config\Block\System\Config\Form\Field
{
private $systemStore;
private $formFactory;
private $config;
private $shippingConfig;
public function __construct(
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Store\Model\System\Store $systemStore,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Shipping\Model\Config $shippingConfig,
\VendorName\ClassNameFactory $classNameFactory
) {
$this->systemStore = $systemStore;
$this->formFactory = $formFactory;
$this->config = $config;
$this->shippingConfig = $shippingConfig;
$var = $classNameFactory->create([
'param1' => 'value1',
'param2' => 'value2',
'param3' => 'value3'
]);
}
}
And when I try create object like this I get error
main.CRITICAL: Warning: Missing argument 2 for Vendor\Class::__construct(), called in vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93