1

can somebody explain when I extend another Block what is the way to inject dependencies? For example my Block is extending ListProduct

1

In this example I inject into Some\Module\Model\SomeClass a new instance of CustomerMetadataInterface the key point to note is the type is set to object. Now in my class via the constructor I am able to obtain this class and use it as required:

class SomeClass 
{
    protected $metaDataInterface;

    public function __construct(\Magento\Customer\Api\CustomerMetadataInterface $metaInterface) {
        $this->metaDataInterface = $metaInterface;
    }
}

More reference here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.