cancel
Showing results for 
Search instead for 
Did you mean: 

Course code example (from exercise guide) shows different arguments of "type".

Highlighted

Course code example (from exercise guide) shows different arguments of "type".

In the screenshot below you can see the code example in the exercise files use different "type"-attributes.

  • only "type"
  • or "xsi:type"
  • or no type at all

When do we need to use which argument?

question-types.jpg

1 REPLY 1
Highlighted

Re: Course code example (from exercise guide) shows different arguments of "type".

Hi @RickSnackers 

 

these are used for defining your argument type means an argument which you will pass what is the type of it..is it an 'string', 'boolean' ,'Integer' etc. 

 

You need to define here what kind of argument you are going to pass for exmple if you are passing an class then the type will be an object right.

 

Now next question is what they do why we need to define it here.. so answer is:

 

You can configure the class constructor arguments in your di.xml in the argument node. The object manager injects these arguments into the class during creation. The name of the argument configured in the XML file must correspond to the name of the parameter in the constructor in the configured class.

 

For reference please check Magento Dev Docs 

 

Hope it will help you. 

 

if above answer was helpful then please Accept as Solution & give Kudos
Shubham Khandelwal